summaryrefslogtreecommitdiff
path: root/plugin.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-07 09:18:03 -0500
committerJeff Carr <[email protected]>2023-04-07 09:18:03 -0500
commit820067cbff754cf9a5f96c425d8f31b5949d353c (patch)
tree70d0e9d9be1ca988078a0bffedc66b824d928cc3 /plugin.go
parentba35c2760687384055d2b7ae733e0f9ac814af4c (diff)
open gocui when DISPLAY=""
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'plugin.go')
-rw-r--r--plugin.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/plugin.go b/plugin.go
index 26667cf..051f9c7 100644
--- a/plugin.go
+++ b/plugin.go
@@ -47,8 +47,9 @@ type aplug struct {
var allPlugins []*aplug
// loads and initializes a toolkit (andlabs/ui, gocui, etc)
-func LoadToolkit(name string) bool {
- var newPlug aplug
+func LoadToolkit(name string) *aplug {
+ var newPlug *aplug
+ newPlug = new(aplug)
log(debugGui, "gui.LoadToolkit() START")
newPlug.LoadOk = false
@@ -57,44 +58,45 @@ func LoadToolkit(name string) bool {
log(debugGui, "gui.LoadToolkit() already loaded toolkit plugin =", aplug.name)
if (aplug.name == name) {
log(debugGui, "gui.LoadToolkit() SKIPPING")
- return true
+ return aplug
}
}
// locate the shared library file
filename := name + ".so"
- loadPlugin(&newPlug, filename)
+ loadPlugin(newPlug, filename)
if (newPlug.plug == nil) {
log(true, "attempt to find plugin", filename, "failed")
- return false
+ return nil
}
// newPlug.Ok = true
newPlug.name = name
// deprecate Init(?)
- newPlug.Init = loadFuncE(&newPlug, "Init")
+ newPlug.Init = loadFuncE(newPlug, "Init")
// should make a goroutine that never exits
- newPlug.Main = loadFuncF(&newPlug, "Main")
+ newPlug.Main = loadFuncF(newPlug, "Main")
// should send things to the goroutine above
// newPlug.Queue = loadFuncF(&newPlug, "Queue")
// unload the plugin and restore state
- newPlug.Quit = loadFuncE(&newPlug, "Quit")
+ newPlug.Quit = loadFuncE(newPlug, "Quit")
// Sends instructions like "Add", "Delete", "Disable", etc
// Sends a widget (button, checkbox, etc) and it's parent widget
- newPlug.Action = loadFuncA(&newPlug, "Action")
+ newPlug.Action = loadFuncA(newPlug, "Action")
- newPlug.Callback = loadCallback(&newPlug, "Callback")
+ newPlug.Callback = loadCallback(newPlug, "Callback")
- allPlugins = append(allPlugins, &newPlug)
+ allPlugins = append(allPlugins, newPlug)
log(debugPlugin, "gui.LoadToolkit() END", newPlug.name, filename)
newPlug.Init()
+ Config.rootNode.Redraw(newPlug)
newPlug.LoadOk = true
- return true
+ return newPlug
}
// TODO: All these functions need to be done a smarter way