summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-11-09 08:38:50 -0600
committerJeff Carr <[email protected]>2022-11-09 08:38:50 -0600
commited382bec55be25039e4dcf020d1512139855c9bb (patch)
treefb3a671fd07c03a75cedb8d56b2241108cd792ff /cmds
parentb410d0fd083ee89eed410cda2123a22cddcd3f44 (diff)
cleanup of the example commands. more plugin workv0.4.6
add a button in two plugins at the same time! added a button in andlabs/ui & gocui attempt a common widget struct between wit/gui & the plugins start handling missing plugins rename Makefile command examples remote examples used for testing filename improvements golang src code uses lowercase and _ in filenames fix crash when button click function == nil fix wrong name 'gocli' -> 'gocui' keep fighting with goreadme generated README.md Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'cmds')
-rw-r--r--cmds/buttonAsPlugin/Makefile14
-rw-r--r--cmds/buttonplugin/Makefile (renamed from cmds/console-hello-world/Makefile)5
-rw-r--r--cmds/buttonplugin/log.go (renamed from cmds/buttonAsPlugin/log.go)0
-rw-r--r--cmds/buttonplugin/main.go (renamed from cmds/buttonAsPlugin/main.go)21
-rw-r--r--cmds/console-ui-helloworld/Makefile (renamed from cmds/consolemouse/Makefile)3
-rw-r--r--cmds/console-ui-helloworld/keybindings.go (renamed from cmds/console-hello-world/keybindings.go)0
-rw-r--r--cmds/console-ui-helloworld/log.go (renamed from cmds/console-hello-world/log.go)0
-rw-r--r--cmds/console-ui-helloworld/main.go (renamed from cmds/console-hello-world/main.go)10
-rw-r--r--cmds/console-ui-helloworld/newJ.go (renamed from cmds/console-hello-world/newJ.go)0
-rw-r--r--cmds/console-ui-helloworld/views.go (renamed from cmds/console-hello-world/views.go)0
-rw-r--r--cmds/consolemouse/gocui.go51
-rw-r--r--cmds/consolemouse/main.go52
-rw-r--r--cmds/debug/Makefile (renamed from cmds/gui-demo/Makefile)2
-rw-r--r--cmds/debug/helloworld.go20
-rw-r--r--cmds/debug/main.go (renamed from cmds/gui-demo/main.go)8
-rw-r--r--cmds/gocli-as-plugin/Makefile14
-rw-r--r--cmds/gocli-as-plugin/log.go35
-rw-r--r--cmds/gocli-as-plugin/main.go59
18 files changed, 36 insertions, 258 deletions
diff --git a/cmds/buttonAsPlugin/Makefile b/cmds/buttonAsPlugin/Makefile
deleted file mode 100644
index d9a67bf..0000000
--- a/cmds/buttonAsPlugin/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-run: build
- ./buttonAsPlugin >/tmp/buttonAsPlugin.log 2>&1
-
-build-release:
- go get -v -u -x .
- go build
- ./buttonAsPlugin
-
-build:
- GO111MODULE="off" go get -v -x .
- GO111MODULE="off" go build
-
-update:
- GO111MODULE="off" go get -v -u -x .
diff --git a/cmds/console-hello-world/Makefile b/cmds/buttonplugin/Makefile
index 9c3540d..cf60369 100644
--- a/cmds/console-hello-world/Makefile
+++ b/cmds/buttonplugin/Makefile
@@ -1,11 +1,10 @@
run: build
- ./console-hello-world
- reset
- ldd ./console-hello-world
+ ./buttonplugin >/tmp/buttonplugin.log 2>&1
build-release:
go get -v -u -x .
go build
+ ./buttonplugin
build:
GO111MODULE="off" go get -v -x .
diff --git a/cmds/buttonAsPlugin/log.go b/cmds/buttonplugin/log.go
index 642ff7b..642ff7b 100644
--- a/cmds/buttonAsPlugin/log.go
+++ b/cmds/buttonplugin/log.go
diff --git a/cmds/buttonAsPlugin/main.go b/cmds/buttonplugin/main.go
index e26c75e..cd4d770 100644
--- a/cmds/buttonAsPlugin/main.go
+++ b/cmds/buttonplugin/main.go
@@ -3,19 +3,19 @@ package main
import (
"log"
+ "strconv"
"git.wit.org/wit/gui"
)
func main() {
- // go loadPlugin(plugHello, "../../toolkit/hello.so")
-
// this doesn't seem to work
captureSTDOUT()
- // go loadPlugin("../../toolkit/gocli.so")
gui.Main(buttonWindow)
}
+var counter int = 10
+
// This creates a window
func buttonWindow() {
var w, g *gui.Node
@@ -30,13 +30,6 @@ func buttonWindow() {
log.Println("world")
})
- /*
- g.NewButton("LoadPlugin()", func () {
- log.Println("world")
- gui.LoadPlugin("../../toolkit/gocli.so")
- })
- */
-
g.NewButton("RunGreet()", func () {
log.Println("world")
go gui.RunGreet()
@@ -47,8 +40,10 @@ func buttonWindow() {
gui.LookupJcarrButton()
})
- g.NewButton("gui.GocuiAddButton()", func () {
- log.Println("gui.GocuiAddButton()")
- gui.GocuiAddButton("new foobar")
+ 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)
})
}
diff --git a/cmds/consolemouse/Makefile b/cmds/console-ui-helloworld/Makefile
index 7061e7e..f63c8a9 100644
--- a/cmds/consolemouse/Makefile
+++ b/cmds/console-ui-helloworld/Makefile
@@ -1,6 +1,7 @@
run: build
- ./consolemouse
+ ./console-ui-helloworld
reset
+ ldd ./console-ui-helloworld
build-release:
go get -v -u -x .
diff --git a/cmds/console-hello-world/keybindings.go b/cmds/console-ui-helloworld/keybindings.go
index fdac1ff..fdac1ff 100644
--- a/cmds/console-hello-world/keybindings.go
+++ b/cmds/console-ui-helloworld/keybindings.go
diff --git a/cmds/console-hello-world/log.go b/cmds/console-ui-helloworld/log.go
index b05beaf..b05beaf 100644
--- a/cmds/console-hello-world/log.go
+++ b/cmds/console-ui-helloworld/log.go
diff --git a/cmds/console-hello-world/main.go b/cmds/console-ui-helloworld/main.go
index dd360d5..d16b805 100644
--- a/cmds/console-hello-world/main.go
+++ b/cmds/console-ui-helloworld/main.go
@@ -51,17 +51,9 @@ func main() {
}
addButton("hello")
- addButton("world")
- addButton("foo")
addGroup("blank")
- addButton("bar")
- addButton("bar none")
- addButton("bar going")
-
- addGroup("te")
- addButton("world 2")
- addButton("foo 2")
+ addButton("world")
if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) {
log.Panicln(err)
diff --git a/cmds/console-hello-world/newJ.go b/cmds/console-ui-helloworld/newJ.go
index 47c7439..47c7439 100644
--- a/cmds/console-hello-world/newJ.go
+++ b/cmds/console-ui-helloworld/newJ.go
diff --git a/cmds/console-hello-world/views.go b/cmds/console-ui-helloworld/views.go
index 50287c2..50287c2 100644
--- a/cmds/console-hello-world/views.go
+++ b/cmds/console-ui-helloworld/views.go
diff --git a/cmds/consolemouse/gocui.go b/cmds/consolemouse/gocui.go
deleted file mode 100644
index 7da888e..0000000
--- a/cmds/consolemouse/gocui.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// This creates a simple hello world window
-package main
-
-import (
- "log"
- "time"
- "git.wit.org/wit/gui"
-)
-
-import toolkit "git.wit.org/wit/gui/toolkit/gocui"
-
-func configureGogui() {
- toolkit.Init()
- toolkit.OnExit(mycallback)
-}
-
-func startGogui() {
- toolkit.StartConsoleMouse()
-}
-
-func mycallback(name string) {
- log.Println("run andlabs here? name =", name)
- if (name == "andlabs") {
- go gui.Main(initGUI)
- }
- if (name == "something") {
- log.Println("add something to do here")
- }
- if (name == "DemoToolkitWindow") {
- gui.Queue( func () {
- gui.DemoToolkitWindow()
- })
- }
- if (name == "addDemoTab") {
- gui.Queue( func () {
- addDemoTab(w, "A Tab from gocui")
- })
- }
- if (name == "DebugWindow") {
- log.Println("Opening a Debug Window via the gui.Queue()")
- gui.Config.Width = 800
- gui.Config.Height = 300
- gui.Config.Exit = myExit
- gui.Queue(gui.DebugWindow)
- time.Sleep(1 * time.Second)
- gui.Queue(gui.DebugTab)
- }
- if (name == "exit") {
- myExit(nil)
- }
-}
diff --git a/cmds/consolemouse/main.go b/cmds/consolemouse/main.go
deleted file mode 100644
index 3f4ce58..0000000
--- a/cmds/consolemouse/main.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// This creates a simple hello world window
-package main
-
-import (
- "os"
- "log"
-// "time"
- "git.wit.org/wit/gui"
-)
-
-import toolkit "git.wit.org/wit/gui/toolkit/gocui"
-
-var w *gui.Node
-
-func main() {
- go gui.Main(initGUI)
-
- configureGogui()
- startGogui()
-}
-
-// This initializes the first window
-func initGUI() {
- gui.Config.Title = "Hello World golang wit/gui Window"
- gui.Config.Width = 640
- gui.Config.Height = 480
- gui.Config.Exit = myExit
-
- w = gui.NewWindow()
- w.Dump()
- addDemoTab(w, "A Simple Tab Demo")
- addDemoTab(w, "A Second Tab")
-}
-
-func addDemoTab(w *gui.Node, title string) {
- var newNode, g *gui.Node
-
- newNode = w.NewTab(title)
-
- g = newNode.NewGroup("group 1")
-
- dd := g.NewDropdown("demoCombo2")
- dd.AddDropdown("more 1")
- dd.AddDropdown("less 2")
- dd.AddDropdown("foo 3")
-}
-
-func myExit(n *gui.Node) {
- log.Println("You can Do exit() things here")
- toolkit.Exit()
- os.Exit(0)
-}
diff --git a/cmds/gui-demo/Makefile b/cmds/debug/Makefile
index 41fdd10..25c994d 100644
--- a/cmds/gui-demo/Makefile
+++ b/cmds/debug/Makefile
@@ -1,5 +1,5 @@
run: build
- ./gui-demo
+ ./debug
build:
go build
diff --git a/cmds/debug/helloworld.go b/cmds/debug/helloworld.go
new file mode 100644
index 0000000..d0998bf
--- /dev/null
+++ b/cmds/debug/helloworld.go
@@ -0,0 +1,20 @@
+// A simple helloworld window
+package main
+
+import (
+ "log"
+ "git.wit.org/wit/gui"
+)
+
+// This creates a window
+func helloworld() {
+ var w *gui.Node
+ gui.Config.Title = "helloworld golang wit/gui window"
+ gui.Config.Width = 400
+ gui.Config.Height = 100
+
+ w = gui.NewWindow()
+ w.NewButton("hello", func () {
+ log.Println("world")
+ })
+}
diff --git a/cmds/gui-demo/main.go b/cmds/debug/main.go
index 54ad449..5e3a350 100644
--- a/cmds/gui-demo/main.go
+++ b/cmds/debug/main.go
@@ -17,16 +17,12 @@ import (
func main() {
log.Println("Starting my Control Panel")
- go gui.Main(initGUI)
+ go gui.Main(helloworld)
+// go gui.DemoToolkitWindow()
watchGUI()
}
-// This initializes the first window
-func initGUI() {
- gui.DemoToolkitWindow()
-}
-
// This demonstrates how to properly interact with the GUI
// You can not involke the GUI from external goroutines in most cases.
func watchGUI() {
diff --git a/cmds/gocli-as-plugin/Makefile b/cmds/gocli-as-plugin/Makefile
deleted file mode 100644
index 277d737..0000000
--- a/cmds/gocli-as-plugin/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-run: build
- ./gocli-as-plugin
- # ldd ./gocli-as-plugin
-
-build-release:
- go get -v -u -x .
- go build
-
-build:
- GO111MODULE="off" go get -v -x .
- GO111MODULE="off" go build
-
-update:
- GO111MODULE="off" go get -v -u -x .
diff --git a/cmds/gocli-as-plugin/log.go b/cmds/gocli-as-plugin/log.go
deleted file mode 100644
index b05beaf..0000000
--- a/cmds/gocli-as-plugin/log.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// This creates a simple hello world window
-package main
-
-import (
- "log"
- "fmt"
- "os"
- arg "github.com/alexflint/go-arg"
-)
-
-
-var args struct {
- Foo string
- Bar bool
- User string `arg:"env:USER"`
- Demo bool `help:"run a demo"`
-}
-
-var f *os.File
-var err error
-
-func init() {
- arg.MustParse(&args)
- fmt.Println(args.Foo, args.Bar, args.User)
-
- f, err = os.OpenFile("/tmp/guilogfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
- if err != nil {
- log.Fatalf("error opening file: %v", err)
- }
- // hmm. is there a trick here or must this be in main()
- // defer f.Close()
-
- log.SetOutput(f)
- log.Println("This is a test log entry")
-}
diff --git a/cmds/gocli-as-plugin/main.go b/cmds/gocli-as-plugin/main.go
deleted file mode 100644
index a9bd632..0000000
--- a/cmds/gocli-as-plugin/main.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2014 The gocui Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "log"
- "os"
-
- "plugin"
-// "github.com/awesome-gocui/gocui"
-)
-
-type Greeter interface {
- Greet()
-}
-
-var plugGocli *plugin.Plugin
-var plugHello *plugin.Plugin
-
-func main() {
- log.Println("attempt plugin")
-
- go loadPlugin(plugHello, "../../toolkit/hello.so")
- loadPlugin(plugGocli, "../../toolkit/gocli.so")
-}
-
-func loadPlugin(plug *plugin.Plugin, name string) {
- // load module
- // 1. open the so file to load the symbols
- plug, err = plugin.Open(name)
- if err != nil {
- log.Println(err)
- os.Exit(1)
- }
-
- // 2. look up a symbol (an exported function or variable)
- // in this case, variable Greeter
- symGreeter, err := plug.Lookup("Greeter")
- if err != nil {
- log.Println(err)
- os.Exit(1)
- }
-
- log.Println("symGreater", symGreeter)
-
- // 3. Assert that loaded symbol is of a desired type
- // in this case interface type Greeter (defined above)
- // var greeter Greeter
- greeter, ok := symGreeter.(Greeter)
- if !ok {
- log.Println("unexpected type from module symbol")
- os.Exit(1)
- }
-
- // 4. use the module
- greeter.Greet()
-}