diff options
| author | Jeff Carr <[email protected]> | 2024-01-17 21:31:49 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-17 21:31:49 -0600 |
| commit | 841e6252c95244f0ee7faf2c01d33f69a8ab483a (patch) | |
| tree | ef400228622b87611168db2227269ba7fd56625d /tree/init.go | |
| parent | ba95c13799740b5f55541fc5e8ab9f1d34f7e421 (diff) | |
common tree package for toolkitsv0.12.4
This update provides *lots* of toolkit updates. This will allow
the next step of debugging the gocui toolkit to make it work
again. There are new common routines for handling the plugin
channel communication
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'tree/init.go')
| -rw-r--r-- | tree/init.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tree/init.go b/tree/init.go new file mode 100644 index 0000000..cdbd62a --- /dev/null +++ b/tree/init.go @@ -0,0 +1,58 @@ +package tree + +import ( + "sync" + "errors" + + "go.wit.com/log" + "go.wit.com/gui/widget" +) + +var muAction sync.Mutex + +func (me *TreeInfo) toolkit(a widget.Action) { + if me.ActionFromChannel == nil { + log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType) + return + } + me.ActionFromChannel(a) +} + +func (me *TreeInfo) catchActionChannel() { + defer func() { + if r := recover(); r != nil { + log.Warn("nocui YAHOOOO Recovered in simpleStdin()", r) + me.DoToolkitPanic() + panic(-1) + } + }() + log.Info("catchActionChannel() START") + for { + log.Info("catchActionChannel() for loop") + select { + case a := <-me.pluginChan: + log.Info("catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName) + log.Warn("catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType) + if a.WidgetType == widget.Dropdown { + log.Warn("Found dropdown", a.WidgetId, a.ActionType, a.WidgetType) + for i, s := range a.State.Strings { + log.Warn("a.State.Strings =", i, s) + } + } + muAction.Lock() + me.toolkit(a) + muAction.Unlock() + log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType) + } + } +} + +func New() *TreeInfo { + me := new(TreeInfo) + me.pluginChan = make(chan widget.Action, 1) + + log.Info("Init() start channel reciever") + go me.catchActionChannel() + log.Info("Init() END") + return me +} |
