diff options
| author | Jeff Carr <[email protected]> | 2022-11-13 08:53:03 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-11-13 08:53:03 -0600 |
| commit | 207cf7ea16f1da8fa9f893504d77a2856298cc22 (patch) | |
| tree | 54d513b83ce797be75268f7d8867e0b01ab8f23e /cmds/buttonplugin/main.go | |
| parent | ed382bec55be25039e4dcf020d1512139855c9bb (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/buttonplugin/main.go')
| -rw-r--r-- | cmds/buttonplugin/main.go | 77 |
1 files changed, 63 insertions, 14 deletions
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") + }) }) } |
