From 207cf7ea16f1da8fa9f893504d77a2856298cc22 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 13 Nov 2022 08:53:03 -0600 Subject: Massive refactor to use go plugins. This is neat. update README.md set xterm title. make os.Exit() default on window close add a toolkit.Widget to the node structure remove 'Greeter' symbol mapping scheme removed the testing greeter code plugins: attempt to load plugins in a sensible order andlabs/ui: working andlabs/ui plugin (andlabs2) buttons work in andlabs plugin TODO: re-implement non-plugin version for Windows mswindows doesn't support go plugins yet gocui: put the gocui console so file in the binary does a full init of gocui plugin Button() and Group() working very well with gogui cleanly exit gocui technically you can load two toolkits at the same time kinda both working at the same time. esoteric two working plugins at the same time give up working on two gui's at the same time this is fun, but _not interesting wow. this actually works. NewButton() from both toolkits examples: all the examples run again remove early helloplugin example buttonplugin example cmd code buttonplugin runs and ldd is minimum Signed-off-by: Jeff Carr --- toolkit/andlabs2/plugin.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 toolkit/andlabs2/plugin.go (limited to 'toolkit/andlabs2/plugin.go') diff --git a/toolkit/andlabs2/plugin.go b/toolkit/andlabs2/plugin.go new file mode 100644 index 0000000..f78e95e --- /dev/null +++ b/toolkit/andlabs2/plugin.go @@ -0,0 +1,43 @@ +package main + +import ( + "log" + + "git.wit.org/wit/gui/toolkit" +) + +// This is a map between the widgets in wit/gui and the internal structures of gocui + +var mapWidgets map[*andlabsT]*toolkit.Widget +var mapToolkits map[*toolkit.Widget]*andlabsT + +// This lists out the know mappings +func listMap() { + log.Println("listMap() HERE") + log.Println("listMap() HERE") + log.Println("listMap() HERE mapWidgets()") + for t, w := range mapWidgets { + log.Println("andlabs =", t.Name, "widget =", w.Name) + } + log.Println("listMap() HERE mapToolkits()") + for w, t := range mapToolkits { + log.Println("andlabs =", t, "widget =", w.Name) + forceDump(t) + } +} + +func mapWidgetsToolkits(w *toolkit.Widget, t *andlabsT) { + if (mapToolkits[w] == nil) { + mapToolkits[w] = t + } else { + log.Println("WTF: mapToolkits already installed") + panic("WTF") + } + + if (mapWidgets[t] == nil) { + mapWidgets[t] = w + } else { + log.Println("WTF: mapWidgets already installed") + panic("WTF") + } +} -- cgit v1.2.3