summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-11-13 08:53:03 -0600
committerJeff Carr <[email protected]>2022-11-13 08:53:03 -0600
commit207cf7ea16f1da8fa9f893504d77a2856298cc22 (patch)
tree54d513b83ce797be75268f7d8867e0b01ab8f23e /cmds
parented382bec55be25039e4dcf020d1512139855c9bb (diff)
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 <[email protected]>
Diffstat (limited to 'cmds')
-rw-r--r--cmds/buttonplugin/Makefile9
-rw-r--r--cmds/buttonplugin/main.go77
-rw-r--r--cmds/console-ui-helloworld/keybindings.go2
-rw-r--r--cmds/debug/Makefile3
-rw-r--r--cmds/debug/main.go8
-rw-r--r--cmds/helloworld/main.go1
-rw-r--r--cmds/textbox/main.go24
7 files changed, 96 insertions, 28 deletions
diff --git a/cmds/buttonplugin/Makefile b/cmds/buttonplugin/Makefile
index cf60369..faa8882 100644
--- a/cmds/buttonplugin/Makefile
+++ b/cmds/buttonplugin/Makefile
@@ -1,5 +1,14 @@
+# with andlabs plugin loaded:
+# PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
+# 180006 jcarr 20 0 1918460 41688 31152 S 0.7 0.3 0:00.27 buttonplugin
+
+# with gocui plugin loaded:
+# 180365 jcarr 20 0 1392668 24364 12596 S 2.0 0.2 0:00.09 buttonplugin
+#
+
run: build
./buttonplugin >/tmp/buttonplugin.log 2>&1
+ # ./buttonplugin
build-release:
go get -v -u -x .
diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go
index cd4d770..c296280 100644
--- a/cmds/buttonplugin/main.go
+++ b/cmds/buttonplugin/main.go
@@ -2,48 +2,97 @@
package main
import (
+ "fmt"
"log"
+ "time"
"strconv"
"git.wit.org/wit/gui"
)
+var title string = "Demo Plugin Window"
+
func main() {
+ fmt.Println("\033]0;" + title + "\007")
+ // time.Sleep(5 * time.Second)
+ // var w *gui.Node
// this doesn't seem to work
captureSTDOUT()
- gui.Main(buttonWindow)
+ // gui.LoadToolkit("default")
+ // panic("WTF gocui not happening")
+ // gui.LoadToolkit("gocui")
+ gui.Init()
+
+ // buttonWindow()
+ go gui.Main(func () {
+ log.Println("START Main f()")
+ buttonWindow()
+ /*
+ log.Println("END NewWindow()")
+ log.Println("START NewGroup()")
+ g := w.NewGroup("new Group 22")
+ log.Println("END NewGroup()")
+ g.NewButton("asdjkl", func () {
+ log.Println("world")
+ })
+ */
+ log.Println("END Main f()")
+ // gui.StandardExit(nil)
+ })
+ log.Println("Main() END")
+ time.Sleep(1 * time.Second)
+ gui.Watchdog()
+ gui.StandardExit(nil)
}
-var counter int = 10
+var counter int = 5
// This creates a window
func buttonWindow() {
var w, g *gui.Node
- gui.Config.Title = "Demo Plugin Window"
+ gui.Config.Title = title
gui.Config.Width = 640
gui.Config.Height = 480
w = gui.NewWindow()
g = w.NewGroup("buttonGroup")
+ g.NewButton("NewButton()", func () {
+ log.Println("new foobar 2. Adding button 'foobar 3'")
+ name := "foobar " + strconv.Itoa(counter)
+ counter += 1
+ g.NewButton(name, func () {
+ log.Println("Got all the way to main() name =", name)
+ })
+ })
+
+ g.NewButton("NewGroup()", func () {
+ log.Println("new foobar 2. Adding button 'foobar 3'")
+ name := "neat " + strconv.Itoa(counter)
+ counter += 1
+ g.NewGroup(name)
+ })
+
g.NewButton("hello", func () {
log.Println("world")
})
- g.NewButton("RunGreet()", func () {
- log.Println("world")
- go gui.RunGreet()
+ g.NewButton("LoadToolkit(andlabs2)", func () {
+ gui.LoadToolkit("andlabs2")
})
- g.NewButton("gui.LookupJcarrButton()", func () {
- log.Println("gui.LookupJcarrButton()")
- gui.LookupJcarrButton()
+ g.NewButton("LoadToolkit(gocui)", func () {
+ gui.LoadToolkit("gocui")
})
- g.NewButton("new foobar 2", func () {
- log.Println("new foobar 2. Adding button 'foobar 3'")
- name := "foobar " + strconv.Itoa(counter)
- counter += 1
- g.NewButton(name, nil)
+ g.NewButton("Init()", func () {
+ gui.Init()
+ })
+
+ g.NewButton("Main()", func () {
+ go gui.Main(func () {
+ w := gui.NewWindow()
+ w.NewGroup("buttonGroup")
+ })
})
}
diff --git a/cmds/console-ui-helloworld/keybindings.go b/cmds/console-ui-helloworld/keybindings.go
index fdac1ff..8c4623b 100644
--- a/cmds/console-ui-helloworld/keybindings.go
+++ b/cmds/console-ui-helloworld/keybindings.go
@@ -115,7 +115,7 @@ func initKeybindings(g *gocui.Gui) error {
func(g *gocui.Gui, v *gocui.View) error {
log.Println("help", v.Name())
tmp, _ := g.SetViewOnTop("help")
- log.Println("help 2", tmp.Name(), "blah")
+ log.Println("help 2", tmp.Name())
// g.SetView("help", 2, 2, 30, 15, 0);
g.SetCurrentView("help")
// moveView(g, tmp, 0, -delta)
diff --git a/cmds/debug/Makefile b/cmds/debug/Makefile
index 25c994d..5f979cc 100644
--- a/cmds/debug/Makefile
+++ b/cmds/debug/Makefile
@@ -2,4 +2,5 @@ run: build
./debug
build:
- go build
+ # go build
+ GO111MODULE="off" go build
diff --git a/cmds/debug/main.go b/cmds/debug/main.go
index 5e3a350..c0df70b 100644
--- a/cmds/debug/main.go
+++ b/cmds/debug/main.go
@@ -17,7 +17,9 @@ import (
func main() {
log.Println("Starting my Control Panel")
- go gui.Main(helloworld)
+ gui.Init()
+// go gui.Main(helloworld)
+ go gui.Main(gui.DebugWindow)
// go gui.DemoToolkitWindow()
watchGUI()
@@ -36,9 +38,9 @@ func watchGUI() {
gui.Config.Width = 800
gui.Config.Height = 300
gui.Config.Exit = myExit
- gui.Queue(gui.DebugWindow)
+ // gui.DebugWindow()
time.Sleep(1 * time.Second)
- gui.Queue(gui.DebugTab)
+ // gui.DebugTab()
}
}
}
diff --git a/cmds/helloworld/main.go b/cmds/helloworld/main.go
index 552ecb5..43aa08c 100644
--- a/cmds/helloworld/main.go
+++ b/cmds/helloworld/main.go
@@ -7,6 +7,7 @@ import (
)
func main() {
+ gui.Init()
gui.Main(helloworld)
}
diff --git a/cmds/textbox/main.go b/cmds/textbox/main.go
index faf8b86..b545d08 100644
--- a/cmds/textbox/main.go
+++ b/cmds/textbox/main.go
@@ -21,7 +21,7 @@ var args struct {
Foo string
Bar bool
LogOptions
- gui.GuiOptions
+ gui.GuiDebug
}
@@ -29,11 +29,13 @@ func main() {
arg.MustParse(&args)
fmt.Println(args.Foo, args.Bar, args.User)
- gui.Config.Options.Debug = args.Debug
- gui.Config.Options.DebugChange = args.DebugChange
- gui.Config.Options.DebugDump = args.DebugDump
- gui.Config.Options.DebugNode = args.DebugNode
- gui.Config.Options.DebugTabs = args.DebugTabs
+ gui.Config.Debug.Debug = args.Debug
+ /*
+ gui.Config.Debug.Change = args.DebugChange
+ gui.Config.Debug.Dump = args.DebugDump
+ gui.Config.Debug.Node = args.DebugNode
+ gui.Config.Debug.Tabs = args.DebugTabs
+ */
/*
f, err := os.OpenFile("/tmp/guilogfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
@@ -46,6 +48,7 @@ func main() {
log.Println("This is a test log entry")
*/
+ gui.Init()
gui.Main(initGUI)
}
@@ -62,6 +65,8 @@ func initGUI() {
addDemoTab(w, "A Simple Tab Demo")
addDemoTab(w, "A Second Tab")
+ /*
+ TODO: add these back
if (args.GuiDemo) {
gui.DemoToolkitWindow()
}
@@ -69,6 +74,7 @@ func initGUI() {
if (args.GuiDebug) {
gui.DebugWindow()
}
+ */
}
func addDemoTab(window *gui.Node, title string) {
@@ -80,9 +86,9 @@ func addDemoTab(window *gui.Node, title string) {
g = newNode.NewGroup("group 1")
dd := g.NewDropdown("demoCombo2")
- dd.AddDropdown("more 1")
- dd.AddDropdown("more 2")
- dd.AddDropdown("more 3")
+ dd.AddDropdownName("more 1")
+ dd.AddDropdownName("more 2")
+ dd.AddDropdownName("more 3")
dd.OnChanged = func(*gui.Node) {
s := dd.GetText()
tb.SetText("hello world " + args.User + "\n" + s)