diff options
| -rw-r--r-- | README-goreadme.md | 4 | ||||
| -rw-r--r-- | main.go | 18 | ||||
| -rw-r--r-- | toolkit/gocui/main.go | 1 | ||||
| -rw-r--r-- | toolkit/gocui/plugin.go | 6 | ||||
| -rw-r--r-- | toolkit/widget.go | 5 |
5 files changed, 29 insertions, 5 deletions
diff --git a/README-goreadme.md b/README-goreadme.md index 9336c80..160264f 100644 --- a/README-goreadme.md +++ b/README-goreadme.md @@ -146,7 +146,7 @@ attempts to locate the .so file `func ShowDebugValues()` -### func [StandardExit](/main.go#L153) +### func [StandardExit](/main.go#L169) `func StandardExit()` @@ -187,7 +187,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 [New](/main.go#L126) +#### func [New](/main.go#L142) `func New() *Node` @@ -112,13 +112,29 @@ func (n *Node) doUserEvent(a toolkit.Action) { } func (n *Node) LoadToolkit(name string) *Node { - log(logInfo, "Start() Main(f) for name =", name) + log(logInfo, "LoadToolkit() for name =", name) if (FindPlugin(name) == nil) { return n } return n } +func (n *Node) CloseToolkit(name string) bool { + log(logInfo, "CloseToolkit() for name =", name) + for _, aplug := range allPlugins { + log(debugGui, "CloseToolkit() found", aplug.name) + if (aplug.name == name) { + log(debugNow, "CloseToolkit() sending close", name) + var a toolkit.Action + a.ActionType = toolkit.CloseToolkit + aplug.pluginChan <- a + sleep(.5) + return true + } + } + return false +} + // There should only be one of these per application // This is due to restrictions by being cross platform // some toolkit's on some operating systems don't support more than one diff --git a/toolkit/gocui/main.go b/toolkit/gocui/main.go index de35700..f0415f5 100644 --- a/toolkit/gocui/main.go +++ b/toolkit/gocui/main.go @@ -83,5 +83,6 @@ func main() { log("This is a test log entry") MouseMain() + log(true, "MouseMain() closed") me.baseGui.Close() } diff --git a/toolkit/gocui/plugin.go b/toolkit/gocui/plugin.go index ce47f20..f70ae96 100644 --- a/toolkit/gocui/plugin.go +++ b/toolkit/gocui/plugin.go @@ -1,6 +1,7 @@ package main import ( + "os" // if you include more than just this import // then your plugin might be doing something un-ideal (just a guess from 2023/02/27) "git.wit.org/wit/gui/toolkit" @@ -38,6 +39,11 @@ func action(a *toolkit.Action) { w.AddText(a.S) case toolkit.Move: log(logNow, "attempt to move() =", a.ActionType, a.WidgetType, a.Name) + case toolkit.CloseToolkit: + log(logNow, "attempting to close the plugin and release stdout and stderr") + me.baseGui.Close() + // defer outf.Close() + setOutput(os.Stdout) default: log(logError, "action() Unknown =", a.ActionType, a.WidgetType, a.Name) } diff --git a/toolkit/widget.go b/toolkit/widget.go index 769bf09..21f2f47 100644 --- a/toolkit/widget.go +++ b/toolkit/widget.go @@ -109,7 +109,6 @@ const ( const ( Add ActionType = iota - User // the user did something (mouse, keyboard, etc) Delete Get Set @@ -127,7 +126,9 @@ const ( Append Move Dump - Quit + User // the user did something (mouse, keyboard, etc) + InitToolkit // initializes the toolkit + CloseToolkit // closes the toolkit ) func (s WidgetType) String() string { |
