diff options
Diffstat (limited to 'gocui/plugin.go')
| -rw-r--r-- | gocui/plugin.go | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/gocui/plugin.go b/gocui/plugin.go index 2055529..f1834a1 100644 --- a/gocui/plugin.go +++ b/gocui/plugin.go @@ -8,7 +8,7 @@ import ( ) func action(a *widget.Action) { - log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name) + log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName) n := me.rootNode.findWidgetId(a.WidgetId) var w *guiWidget if (n != nil) { @@ -24,32 +24,32 @@ func action(a *widget.Action) { // this is done to protect the plugin being 'refreshed' with the // widget binary tree. TODO: find a way to keep them in sync log.Log(ERROR, "action() Add ignored for already defined widget", - a.WidgetId, a.ActionType, a.WidgetType, a.Name) + a.WidgetId, a.ActionType, a.WidgetType, a.ProgName) } case widget.Show: - if (a.B) { + if widget.GetBool(a.Value) { n.showView() } else { n.hideWidgets() } case widget.Set: if a.WidgetType == widget.Flag { - log.Log(NOW, "TODO: set flag here", a.ActionType, a.WidgetType, a.Name) - log.Log(NOW, "TODO: n.WidgetType =", n.WidgetType, "n.Name =", a.Name) + log.Log(NOW, "TODO: set flag here", a.ActionType, a.WidgetType, a.ProgName) + log.Log(NOW, "TODO: n.WidgetType =", n.WidgetType, "n.progname =", a.ProgName) } else { - if (a.A == nil) { - log.Log(ERROR, "TODO: Set here. a == nil id =", a.WidgetId, "type =", a.WidgetType, "Name =", a.Name) - log.Log(ERROR, "TODO: Set here. id =", a.WidgetId, "n.Name =", n.Name) + if (a.Value == nil) { + log.Log(ERROR, "TODO: Set here. a == nil id =", a.WidgetId, "type =", a.WidgetType, "Name =", a.ProgName) + log.Log(ERROR, "TODO: Set here. id =", a.WidgetId, "n.progname =", n.progname) } else { - n.Set(a.A) + n.Set(a.Value) } } case widget.SetText: - n.SetText(a.S) + n.SetText(widget.GetString(a.Value)) case widget.AddText: - n.AddText(a.S) + n.AddText(widget.GetString(a.Value)) case widget.Move: - log.Log(NOW, "attempt to move() =", a.ActionType, a.WidgetType, a.Name) + log.Log(NOW, "attempt to move() =", a.ActionType, a.WidgetType, a.ProgName) case widget.CloseToolkit: log.Log(NOW, "attempting to close the plugin and release stdout and stderr") standardExit() @@ -57,18 +57,18 @@ func action(a *widget.Action) { if n.Visible() { // widget was already shown } else { - log.Log(INFO, "Setting Visable to true", a.Name) + log.Log(INFO, "Setting Visable to true", a.ProgName) n.SetVisible(true) } case widget.Disable: if n.Visible() { - log.Log(INFO, "Setting Visable to false", a.Name) + log.Log(INFO, "Setting Visable to false", a.ProgName) n.SetVisible(false) } else { // widget was already hidden } default: - log.Log(ERROR, "action() ActionType =", a.ActionType, "WidgetType =", a.WidgetType, "Name =", a.Name) + log.Log(ERROR, "action() ActionType =", a.ActionType, "WidgetType =", a.WidgetType, "Name =", a.ProgName) } log.Log(INFO, "action() END") } @@ -80,7 +80,7 @@ func (n *node) AddText(text string) { } n.vals = append(n.vals, text) for i, s := range n.vals { - log.Log(NOW, "AddText()", n.Name, i, s) + log.Log(NOW, "AddText()", n.progname, i, s) } n.SetText(text) } @@ -91,12 +91,8 @@ func (n *node) SetText(text string) { log.Log(NOW, "widget is nil") return } - if (n.Text != text) { - n.Text = text - changed = true - } - if (n.S != text) { - n.S = text + if widget.GetString(n.value) != text { + n.value = text changed = true } if (! changed) { @@ -114,15 +110,8 @@ func (n *node) Set(val any) { // w := n.tk log.Log(INFO, "Set() value =", val) - switch v := val.(type) { - case bool: - n.B = val.(bool) - n.setCheckbox(val.(bool)) - case string: - n.SetText(val.(string)) - case int: - n.I = val.(int) - default: - log.Log(ERROR, "Set() unknown type =", val, v) + n.value = val + if (n.WidgetType != widget.Checkbox) { + n.setCheckbox(val) } } |
