gocui: keep deprecating non-gochannel code

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-08 08:40:31 -05:00
parent 9d315c3a00
commit d4b3283484
11 changed files with 66 additions and 30 deletions

View File

@ -203,7 +203,7 @@ var Config GuiConfig
The Node is a binary tree. This is how all GUI elements are stored
simply the name and the size of whatever GUI element exists
#### func [NewWindow](/window.go#L15)
#### func [NewWindow](/window.go#L13)
`func NewWindow() *Node`

View File

@ -28,6 +28,7 @@ func main() {
// gui.Init()
// buttonWindow()
gui.SetDebug(true)
myGui = gui.Start()
time.Sleep(1 * time.Second)
buttonWindow()
@ -42,11 +43,12 @@ func main() {
// This creates a window
func buttonWindow() {
var w, t, g, more, more2 *gui.Node
gui.Config.Title = title
gui.Config.Width = 640
gui.Config.Height = 480
w = gui.NewWindow()
log.Println("buttonWindow()")
log.Println("buttonWindow()")
log.Println("buttonWindow()")
w = myGui.NewWindow2(title)
t = w.NewTab("buttonTab")
g = t.NewGroup("buttonGroup")
g1 := t.NewGroup("buttonGroup 2")

View File

@ -203,8 +203,8 @@ func Main(f func()) {
if (os.Getenv("DISPLAY") == "") {
InitPlugins([]string{"gocui"})
} else {
InitPlugins([]string{"andlabs", "gocui"})
// InitPlugins([]string{"gocui", "andlabs"})
//InitPlugins([]string{"andlabs", "gocui"})
InitPlugins([]string{"gocui", "andlabs"})
}
for _, aplug := range allPlugins {

View File

@ -331,14 +331,14 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
for _, aplug := range allPlugins {
log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType)
if (aplug.Action == nil) {
log(debugPlugin, "Failed Action() == nil for", aplug.name)
continue
}
if (aplug.pluginChan == nil) {
log(debugNow, "Action() SEND old way", aplug.name)
log(debugNow, "Action() SEND old way", aplug.name)
log(debugNow, "Action() SEND old way", aplug.name)
if (aplug.Action == nil) {
log(debugPlugin, "Failed Action() == nil for", aplug.name)
continue
}
aplug.Action(a)
log(debugNow, "Action() SEND trying aplug.PluginChannel()", aplug.name)
aplug.pluginChan = aplug.PluginChannel()
@ -349,6 +349,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
log(debugNow, "Action() SEND pluginChan", aplug.name)
aplug.pluginChan <- *a
}
sleep(.5)
}
// increment where to put the next widget in a grid or table
if (where != nil) {

View File

@ -36,8 +36,8 @@ func (n *Node) Redraw(p *aplug) {
return
}
func (n *Node) redo(p *aplug) {
log(logNow, "redo()", p.name, n.id, n.WidgetType, n.Name)
func (n *Node) redo(plug *aplug) {
log(logNow, "redo()", plug.name, n.id, n.WidgetType, n.Name)
var a *toolkit.Action
a = new(toolkit.Action)
@ -72,5 +72,21 @@ func (n *Node) redo(p *aplug) {
a.ParentId = n.parent.id
}
p.Action(a)
plug.pluginChan = plug.PluginChannel()
// plug.Action(a)
if (plug.pluginChan == nil) {
log(debugNow, "Action() SEND old way", plug.name)
log(debugNow, "Action() SEND old way", plug.name)
log(debugNow, "Action() SEND old way", plug.name)
plug.Action(a)
log(debugNow, "Action() SEND trying plug.PluginChannel()", plug.name)
log(debugNow, "Action() SEND trying plug.PluginChannel()", plug.pluginChan)
} else {
log(debugNow, "Action() SEND pluginChan", plug.name)
log(debugNow, "Action() SEND pluginChan", plug.name)
log(debugNow, "Action() SEND pluginChan", plug.name)
plug.pluginChan <- *a
}
sleep(.5)
}

View File

@ -25,7 +25,7 @@ func (w *cuiWidget) setFake() {
fakeStartWidth += 20
}
w.setWH()
if (debugAction) {
if (logInfo) {
w.drawView()
}
}

View File

@ -7,7 +7,7 @@ import (
// "github.com/awesome-gocui/gocui"
)
var debugAction bool = false
// var debugAction bool = false
func actionDump(b bool, a *toolkit.Action) {
if (a == nil) {

View File

@ -8,9 +8,9 @@ import (
// various debugging flags
var logNow bool = true // useful for active development
var logError bool = true
var logWarn bool = false
var logInfo bool = false
var logVerbose bool = false
var logWarn bool = true
var logInfo bool = true
var logVerbose bool = true
func log(a ...any) {
witlog.Where = "wit/gocui"

View File

@ -49,7 +49,7 @@ func catchActionChannel() {
select {
case a := <-me.pluginChan:
log(logNow, "makeCallback() SELECT widget id =", a.WidgetId, a.Name)
Action(&a)
action(&a)
sleep(.1)
}
}

View File

@ -10,8 +10,8 @@ func Quit() {
me.baseGui.Close()
}
func Action(a *toolkit.Action) {
log(logInfo, "Action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
func action(a *toolkit.Action) {
log(logInfo, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
w := findWidget(a.WidgetId, me.rootNode)
switch a.ActionType {
case toolkit.Add:
@ -21,7 +21,7 @@ func Action(a *toolkit.Action) {
} else {
// this is done to protect the plugin being 'refreshed' with the
// widget binary tree. TODO: find a way to keep them in sync
log(logError, "Action() Add ignored for already defined widget",
log(logError, "action() Add ignored for already defined widget",
a.WidgetId, a.ActionType, a.WidgetType, a.Name)
}
case toolkit.Show:
@ -39,9 +39,9 @@ func Action(a *toolkit.Action) {
case toolkit.Move:
log(logNow, "attempt to move() =", a.ActionType, a.WidgetType, a.Name)
default:
log(logError, "Action() Unknown =", a.ActionType, a.WidgetType, a.Name)
log(logError, "action() Unknown =", a.ActionType, a.WidgetType, a.Name)
}
log(logInfo, "Action() END")
log(logInfo, "action() END")
}
func (w *cuiWidget) AddText(text string) {
@ -70,8 +70,6 @@ func (w *cuiWidget) SetText(text string) {
func (w *cuiWidget) Set(val any) {
log(logInfo, "Set() value =", val)
var a toolkit.Action
a.ActionType = toolkit.Set
switch v := val.(type) {
case bool:
@ -82,6 +80,6 @@ func (w *cuiWidget) Set(val any) {
case int:
w.i = val.(int)
default:
log(logError, "Set() unknown type =", v, "a =", a)
log(logError, "Set() unknown type =", val, v)
}
}

View File

@ -4,8 +4,6 @@ import (
"git.wit.org/wit/gui/toolkit"
)
//import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
// This routine creates a blank window with a Title and size (W x H)
//
// This routine can not have any arguements due to the nature of how
@ -48,3 +46,24 @@ func NewWindow() *Node {
return newNode
}
// This routine creates a blank window with a Title
//
func (n *Node) NewWindow2(title string) *Node {
var newNode *Node
// Windows are created off of the master node of the Binary Tree
newNode = n.New(Config.Title, toolkit.Window, StandardExit)
log(logInfo, "NewWindow()", Config.Title)
var a toolkit.Action
a.ActionType = toolkit.Add
a.Width = Config.Width
a.Height = Config.Height
a.Name = Config.Title
a.Text = Config.Title
newaction(&a, newNode, n)
return newNode
}