From 9d075afb1df62276dea06be4a188eaee8fc69420 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 3 Dec 2023 16:08:39 -0600 Subject: clean and rename examples fix syntax try new goreadme remove autogenerated go readme.md Signed-off-by: Jeff Carr --- .gitignore | 18 ++- Makefile | 57 ++++---- README-goreadme.md | 200 -------------------------- README.md | 141 ++++++++---------- cmds/buttonplugin/Makefile | 26 ---- cmds/buttonplugin/log.go | 78 ---------- cmds/buttonplugin/main.go | 104 -------------- cmds/cloudflare/Makefile | 18 --- cmds/cloudflare/argv.go | 30 ---- cmds/cloudflare/dns.go | 115 --------------- cmds/cloudflare/main.go | 122 ---------------- cmds/console-ui-helloworld/Makefile | 15 -- cmds/console-ui-helloworld/keybindings.go | 130 ----------------- cmds/console-ui-helloworld/log.go | 35 ----- cmds/console-ui-helloworld/main.go | 83 ----------- cmds/console-ui-helloworld/newJ.go | 46 ------ cmds/console-ui-helloworld/views.go | 114 --------------- cmds/debug/Makefile | 6 - cmds/debug/helloworld.go | 20 --- cmds/debug/main.go | 54 ------- cmds/helloworld/Makefile | 14 -- cmds/helloworld/main.go | 25 ---- cmds/plugin-consoleonly/Makefile | 14 -- cmds/plugin-consoleonly/args.go | 31 ---- cmds/plugin-consoleonly/main.go | 33 ----- cmds/textbox/Makefile | 14 -- cmds/textbox/main.go | 96 ------------- common.go | 2 +- debug.go | 2 +- doc.go | 40 +++--- example_test.go | 45 ------ examples/buttons/Makefile | 26 ++++ examples/buttons/buttonplugin | Bin 0 -> 6062120 bytes examples/buttons/buttons | Bin 0 -> 6062120 bytes examples/buttons/log.go | 78 ++++++++++ examples/buttons/main.go | 104 ++++++++++++++ examples/cloudflare/Makefile | 18 +++ examples/cloudflare/argv.go | 30 ++++ examples/cloudflare/dns.go | 132 +++++++++++++++++ examples/cloudflare/main.go | 84 +++++++++++ examples/console-ui-helloworld/Makefile | 15 ++ examples/console-ui-helloworld/keybindings.go | 130 +++++++++++++++++ examples/console-ui-helloworld/log.go | 35 +++++ examples/console-ui-helloworld/main.go | 83 +++++++++++ examples/console-ui-helloworld/newJ.go | 46 ++++++ examples/console-ui-helloworld/views.go | 114 +++++++++++++++ examples/example_test.go | 45 ++++++ examples/helloworld/Makefile | 14 ++ examples/helloworld/main.go | 23 +++ go.mod | 11 +- go.sum | 17 +-- plugin.go | 15 +- 52 files changed, 1129 insertions(+), 1619 deletions(-) delete mode 100644 README-goreadme.md delete mode 100644 cmds/buttonplugin/Makefile delete mode 100644 cmds/buttonplugin/log.go delete mode 100644 cmds/buttonplugin/main.go delete mode 100644 cmds/cloudflare/Makefile delete mode 100644 cmds/cloudflare/argv.go delete mode 100644 cmds/cloudflare/dns.go delete mode 100644 cmds/cloudflare/main.go delete mode 100644 cmds/console-ui-helloworld/Makefile delete mode 100644 cmds/console-ui-helloworld/keybindings.go delete mode 100644 cmds/console-ui-helloworld/log.go delete mode 100644 cmds/console-ui-helloworld/main.go delete mode 100644 cmds/console-ui-helloworld/newJ.go delete mode 100644 cmds/console-ui-helloworld/views.go delete mode 100644 cmds/debug/Makefile delete mode 100644 cmds/debug/helloworld.go delete mode 100644 cmds/debug/main.go delete mode 100644 cmds/helloworld/Makefile delete mode 100644 cmds/helloworld/main.go delete mode 100644 cmds/plugin-consoleonly/Makefile delete mode 100644 cmds/plugin-consoleonly/args.go delete mode 100644 cmds/plugin-consoleonly/main.go delete mode 100644 cmds/textbox/Makefile delete mode 100644 cmds/textbox/main.go delete mode 100644 example_test.go create mode 100644 examples/buttons/Makefile create mode 100755 examples/buttons/buttonplugin create mode 100755 examples/buttons/buttons create mode 100644 examples/buttons/log.go create mode 100644 examples/buttons/main.go create mode 100644 examples/cloudflare/Makefile create mode 100644 examples/cloudflare/argv.go create mode 100644 examples/cloudflare/dns.go create mode 100644 examples/cloudflare/main.go create mode 100644 examples/console-ui-helloworld/Makefile create mode 100644 examples/console-ui-helloworld/keybindings.go create mode 100644 examples/console-ui-helloworld/log.go create mode 100644 examples/console-ui-helloworld/main.go create mode 100644 examples/console-ui-helloworld/newJ.go create mode 100644 examples/console-ui-helloworld/views.go create mode 100644 examples/example_test.go create mode 100644 examples/helloworld/Makefile create mode 100644 examples/helloworld/main.go diff --git a/.gitignore b/.gitignore index 03137f9..135bf8c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,14 +3,18 @@ # ignore compiled plugins *.so -cmds/buttonplugin/buttonplugin -cmds/console-ui-helloworld/console-ui-helloworld -cmds/debug/debug -cmds/helloworld/helloworld -cmds/textbox/textbox -cmds/cloudflare/cloudflare -cmds/*/helloconsole +examples/buttonplugin/buttonplugin +examples/console-ui-helloworld/console-ui-helloworld +examples/debug/debug +examples/helloworld/helloworld +examples/textbox/textbox +examples/cloudflare/cloudflare +examples/*/helloconsole # temporary files when building debian packages /*.deb /files +/ + +# ignore the generated readme +/README-goreadme.md diff --git a/Makefile b/Makefile index 8e73c22..d0e7cfc 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,21 @@ -.PHONY: README.md log +.PHONY: README.md log examples all: README.md - reset + # reset @echo @echo "make examples # will run all the Example demos and commands" @echo "make update # full git update of all the dependencies" @echo + @echo This Requires working IPv6 + @echo + @sleep 1 +ifeq (,$(wildcard go.mod)) + go mod init gui + go mod tidy +endif make clean make plugins - make cmds-buttonplugin + make examples-buttons build-dep: apt install -f libgtk-3-dev @@ -25,30 +32,30 @@ deb: examples: \ all \ - cmds-helloworld \ - cmds-buttonplugin \ - cmds-console-ui-helloworld \ - cmds-textbox \ - cmds-debug + examples-helloworld \ + examples-buttons \ + examples-console-ui-helloworld \ + examples-textbox \ + examples-debug -cmds-buttonplugin: - make -C cmds/buttonplugin +examples-buttons: + make -C examples/buttons -cmds-console-ui-helloworld: - make -C cmds/console-ui-helloworld +examples-console-ui-helloworld: + make -C examples/console-ui-helloworld # this is the most basic one. This syntax should always work -cmds-helloworld: - make -C cmds/helloworld +examples-helloworld: + make -C examples/helloworld -cmds-debug: - -make -C cmds/debug +examples-debug: + -make -C examples/debug -cmds-textbox: - make -C cmds/textbox +examples-textbox: + make -C examples/textbox -cmds-helloconsole: - make -C cmds/plugin-consoleonly +examples-helloconsole: + make -C examples/plugin-consoleonly # sync repo to the github backup # git remote add github git@github.com:witorg/gui.git @@ -65,10 +72,10 @@ github: @echo doc: - GO111MODULE="off" godoc -v + godoc -v goget: - GO111MODULE="off" go get -v -t -u + go get -v -t -u make -C toolkit/gocui goget make -C toolkit/andlabs goget @@ -83,11 +90,11 @@ clean: plugins: plugins-gocui plugins-andlabs plugins-gocui: - GO111MODULE="off" go build -C toolkit/gocui -v -buildmode=plugin -o ../gocui.so - GO111MODULE="off" go build -C toolkit/nocui -v -buildmode=plugin -o ../nocui.so + go build -C toolkit/gocui -v -buildmode=plugin -o ../gocui.so + go build -C toolkit/nocui -v -buildmode=plugin -o ../nocui.so plugins-andlabs: - GO111MODULE="off" go build -C toolkit/andlabs -v -buildmode=plugin -o ../andlabs.so + go build -C toolkit/andlabs -v -buildmode=plugin -o ../andlabs.so objdump: objdump -t toolkit/andlabs.so |less diff --git a/README-goreadme.md b/README-goreadme.md deleted file mode 100644 index 454cfff..0000000 --- a/README-goreadme.md +++ /dev/null @@ -1,200 +0,0 @@ -# gui - -Package gui implements a abstraction layer for Go visual elements. - -Definitions: - -```go -* Toolkit: the underlying GUI library (MacOS gui, Windows gui, gtk, qt, etc) -* Node: A binary tree of all the underlying widgets -``` - -Principles: - -```go -* Make code using this package simple to use -* Hide complexity internally here -* Isolate the GUI toolkit -* Widget names should try to match [Wikipedia Graphical widget] -* When in doubt, search upward in the binary tree -* It's ok to guess. Try to do something sensible. -``` - -Quick Start - -```go -// This creates a simple hello world window -package main - -import ( - "log" - "git.wit.org/wit/gui" -) - -var window *gui.Node // This is the beginning of the binary tree of widgets - -// go will sit here until the window exits -func main() { - gui.Init() - gui.Main(helloworld) -} - -// This initializes the first window and 2 tabs -func helloworld() { - gui.Config.Title = "Hello World golang wit/gui Window" - gui.Config.Width = 640 - gui.Config.Height = 480 - - window := gui.NewWindow() - addTab(window, "A Simple Tab Demo") - addTab(window, "A Second Tab") -} - -func addTab(w *gui.Node, title string) { - tab := w.NewTab(title) - - group := tab.NewGroup("foo bar") - group.NewButton("hello", func() { - log.Println("world") - }) -} -``` - -## Debian Build - -This worked on debian sid on 2022/10/20 -I didn't record the dependances needed - -```go -GO111MODULE="off" go get -v -t -u git.wit.org/wit/gui -cd ~/go/src/git.wit.org/wit/gui/cmds/helloworld/ -GO111MODULE="off" go build -v -x -[./helloworld](./helloworld) -``` - -Toolkits - -```go -* andlabs - [https://github.com/andlabs/ui](https://github.com/andlabs/ui) -* gocui - [https://github.com/awesome-gocui/gocui](https://github.com/awesome-gocui/gocui) -``` - -The next step is to allow this to work against go-gtk and go-qt. - -TODO: Add Fyne, WASM, native macos & windows, android and -hopefully also things like libSDL, faiface/pixel, slint - -## Bugs - -"The author's idea of friendly may differ to that of many other people." - --- quote from the minimalistic window manager 'evilwm' - -## References - -Useful links and other -external things which might be useful - -[Wikipedia Graphical widget]: [https://en.wikipedia.org/wiki/Graphical_widget](https://en.wikipedia.org/wiki/Graphical_widget) -[Github mirror]: [https://github.com/witorg/gui](https://github.com/witorg/gui) -[Federated git pull]: [https://github.com/forgefed/forgefed](https://github.com/forgefed/forgefed) -[GO Style Guide]: [https://google.github.io/styleguide/go/index](https://google.github.io/styleguide/go/index) - -```go -* [Wikipedia Graphical widget] -* [Github mirror] -* [Federated git pull] -* [GO Style Guide] -``` - -## Functions - -### func [DebugWidgetWindow](/debugWidget.go#L52) - -`func DebugWidgetWindow(w *Node)` - -### func [DebugWindow](/debugWindow.go#L21) - -`func DebugWindow()` - -Creates a window helpful for debugging this package - -### func [ExampleCatcher](/chan.go#L37) - -`func ExampleCatcher(f func())` - -### func [Indent](/debug.go#L124) - -`func Indent(b bool, a ...interface{})` - -### func [SetDebug](/debug.go#L28) - -`func SetDebug(s bool)` - -### func [SetFlag](/debug.go#L50) - -`func SetFlag(s string, b bool)` - -### func [ShowDebugValues](/debug.go#L82) - -`func ShowDebugValues()` - -### func [StandardExit](/main.go#L153) - -`func StandardExit()` - -The window is destroyed and the application exits -TODO: properly exit the plugin since Quit() doesn't do it - -### func [Watchdog](/watchdog.go#L16) - -`func Watchdog()` - -This program sits here. -If you exit here, the whole thing will os.Exit() -TODO: use Ticker - -This goroutine can be used like a watchdog timer - -## Types - -### type [GuiArgs](/structs.go#L29) - -`type GuiArgs struct { ... }` - -This struct can be used with the go-arg package - -#### Variables - -```golang -var GuiArg GuiArgs -``` - -### type [Node](/structs.go#L59) - -`type Node struct { ... }` - -The Node is a binary tree. This is how all GUI elements are stored -simply the name and the size of whatever GUI element exists - -#### func [New](/main.go#L120) - -`func New() *Node` - -There should only be one of these per application -This is due to restrictions by being cross platform -some toolkit's on some operating systems don't support more than one -Keep things simple. Do the default expected thing whenever possible - -### type [Symbol](/plugin.go#L17) - -`type Symbol any` - -## Sub Packages - -* [log](./log) - -* [toolkit](./toolkit) - ---- -Readme created from Go doc with [goreadme](https://github.com/posener/goreadme) diff --git a/README.md b/README.md index 3ab8d30..775be32 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,33 @@ Package gui implements a abstraction layer for Go visual elements. Definitions: +```go * Toolkit: the underlying GUI library (MacOS gui, Windows gui, gtk, qt, etc) * Node: A binary tree of all the underlying widgets +``` Principles: +```go * Make code using this package simple to use * Hide complexity internally here * Isolate the GUI toolkit * Widget names should try to match [Wikipedia Graphical widget] * When in doubt, search upward in the binary tree * It's ok to guess. Try to do something sensible. +``` + +## Debian Build + +This worked on debian sid (mate-desktop) on 2023/12/03 +I didn't record the dependances needed (gtk-dev) + +```go +export GO111MODULE="off" +make +``` -Quick Start +Hello World Example ```go // This creates a simple hello world window @@ -56,22 +70,12 @@ func addTab(w *gui.Node, title string) { } ``` -## Debian Build - -This worked on debian sid on 2022/10/20 -I didn't record the dependances needed +External Toolkits ```go -GO111MODULE="off" go get -v -t -u git.wit.org/wit/gui -cd ~/go/src/git.wit.org/wit/gui/cmds/helloworld/ -GO111MODULE="off" go build -v -x -[./helloworld](./helloworld) -``` - -Toolkits - * andlabs - [https://github.com/andlabs/ui](https://github.com/andlabs/ui) * gocui - [https://github.com/awesome-gocui/gocui](https://github.com/awesome-gocui/gocui) +``` The next step is to allow this to work against go-gtk and go-qt. @@ -89,75 +93,56 @@ hopefully also things like libSDL, faiface/pixel, slint Useful links and other external things which might be useful -* [Wikipedia Graphical widget](https://en.wikipedia.org/wiki/Graphical_widget) -* [GO Style Guide](https://google.github.io/styleguide/go/index) Code this way -* [MS Windows Application Library Kit](https://github.com/lxn/walk) -* [Federated git pull](https://github.com/forgefed/forgefed) Hopefully this will work for me with gitea -* [Github mirror](https://github.com/wit-go/gui) This repo on mirror. Hopefully I won't have to use this. -* [WIT GO projects](https://go.wit.org/) Attempt to model go.uber.org - -## Functions - -### func [GetDebug](/structs.go#L25) - -`func GetDebug() bool` - -### func [GetDebugToolkit](/structs.go#L37) - -`func GetDebugToolkit() bool` - -### func [IndentPrintln](/structs.go#L188) +[Wikipedia Graphical widget]: [https://en.wikipedia.org/wiki/Graphical_widget](https://en.wikipedia.org/wiki/Graphical_widget) +[Github mirror]: [https://github.com/witorg/gui](https://github.com/witorg/gui) +[Federated git pull]: [https://github.com/forgefed/forgefed](https://github.com/forgefed/forgefed) +[GO Style Guide]: [https://google.github.io/styleguide/go/index](https://google.github.io/styleguide/go/index) -`func IndentPrintln(a ...interface{})` - -### func [Init](/main.go#L41) +```go +* [Wikipedia Graphical widget] +* [Github mirror] +* [Federated git pull] +* [GO Style Guide] +``` -`func Init()` +## Functions -### func [LoadToolkit](/plugin.go#L37) +### func [DebugWidgetWindow](/debugWidget.go#L52) -`func LoadToolkit(name string)` +`func DebugWidgetWindow(w *Node)` -loads and initializes a toolkit (andlabs/ui, gocui, etc) +### func [DebugWindow](/debugWindow.go#L21) -### func [Main](/main.go#L56) +`func DebugWindow()` -`func Main(f func())` +Creates a window helpful for debugging this package -### func [Queue](/main.go#L77) +### func [ExampleCatcher](/chan.go#L37) -`func Queue(f func())` +`func ExampleCatcher(f func())` -Other goroutines must use this to access the GUI +### func [Indent](/debug.go#L124) -You can not acess / process the GUI thread directly from -other goroutines. This is due to the nature of how -Linux, MacOS and Windows work (they all work differently. suprise. surprise.) -For example: gui.Queue(NewWindow()) +`func Indent(b bool, a ...interface{})` -### func [SetDebug](/structs.go#L29) +### func [SetDebug](/debug.go#L28) `func SetDebug(s bool)` -### func [SetDebugToolkit](/structs.go#L41) +### func [SetFlag](/debug.go#L50) -`func SetDebugToolkit(s bool)` +`func SetFlag(s string, b bool)` -### func [ShowDebugValues](/structs.go#L45) +### func [ShowDebugValues](/debug.go#L82) `func ShowDebugValues()` -### func [StandardClose](/main.go#L83) +### func [StandardExit](/main.go#L153) -`func StandardClose(n *Node)` +`func StandardExit()` -The window is destroyed but the application does not quit - -### func [StandardExit](/main.go#L90) - -`func StandardExit(n *Node)` - -The window is destroyed but the application does not quit +The window is destroyed and the application exits +TODO: properly exit the plugin since Quit() doesn't do it ### func [Watchdog](/watchdog.go#L16) @@ -165,43 +150,39 @@ The window is destroyed but the application does not quit This program sits here. If you exit here, the whole thing will os.Exit() +TODO: use Ticker This goroutine can be used like a watchdog timer ## Types -### type [GuiConfig](/structs.go#L68) +### type [GuiArgs](/structs.go#L29) -`type GuiConfig struct { ... }` +`type GuiArgs struct { ... }` + +This struct can be used with the go-arg package #### Variables ```golang -var Config GuiConfig +var GuiArg GuiArgs ``` -### type [GuiOptions](/structs.go#L56) - -`type GuiOptions struct { ... }` - -This struct can be used with go-arg - -### type [Node](/structs.go#L87) +### type [Node](/structs.go#L59) `type Node struct { ... }` -The Node is simply the name and the size of whatever GUI element exists +The Node is a binary tree. This is how all GUI elements are stored +simply the name and the size of whatever GUI element exists -#### func [NewWindow](/window.go#L15) +#### func [New](/main.go#L120) -`func NewWindow() *Node` +`func New() *Node` -This routine creates a blank window with a Title and size (W x H) - -This routine can not have any arguements due to the nature of how -it can be passed via the 'andlabs/ui' queue which, because it is -cross platform, must pass UI changes into the OS threads (that is -my guess). +There should only be one of these per application +This is due to restrictions by being cross platform +some toolkit's on some operating systems don't support more than one +Keep things simple. Do the default expected thing whenever possible ### type [Symbol](/plugin.go#L17) @@ -209,6 +190,8 @@ my guess). ## Sub Packages +* [log](./log) + * [toolkit](./toolkit) --- diff --git a/cmds/buttonplugin/Makefile b/cmds/buttonplugin/Makefile deleted file mode 100644 index 74486e5..0000000 --- a/cmds/buttonplugin/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# 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 --gui gocui >/tmp/witgui.log.stderr 2>&1 - -build-release: - go get -v -u -x . - go build - ./buttonplugin - -build: - GO111MODULE="off" go get -v -x . - GO111MODULE="off" go build - -update: - GO111MODULE="off" go get -v -u -x . - -log: - reset - tail -f /tmp/witgui.* /tmp/guilogfile diff --git a/cmds/buttonplugin/log.go b/cmds/buttonplugin/log.go deleted file mode 100644 index 7d65d05..0000000 --- a/cmds/buttonplugin/log.go +++ /dev/null @@ -1,78 +0,0 @@ -// This creates a simple hello world window -package main - -import ( - "fmt" - arg "github.com/alexflint/go-arg" - "git.wit.org/wit/gui" - log "git.wit.org/wit/gui/log" -) - - -var args struct { - Foo string - Bar bool - User string `arg:"env:USER"` - Demo bool `help:"run a demo"` - gui.GuiArgs - log.LogArgs -} - -/* -var f1 *os.File -var f2 *os.File -var err error -*/ - -func init() { - arg.MustParse(&args) - fmt.Println(args.Foo, args.Bar, args.User) - - if (args.Gui != "") { - gui.GuiArg.Gui = args.Gui - } - log.Log(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui) - -/* - log.Println() - log.Println("STDOUT is now at /tmp/guilogfile") - log.Println("STDOUT is now at /tmp/guilogfile") - log.Println() - f1, err = os.OpenFile(outfile, 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(f1) - log.Println("This is a test log entry") -*/ -} - -/* -func captureSTDOUT() { - f2, _ = os.OpenFile("/tmp/my.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664) - multiWriter := io.MultiWriter(os.Stderr, f2) - rd, wr, err := os.Pipe() - if err != nil { - os.Exit(1) - } - - // overwrite os.Stdout - os.Stderr = wr - - go func() { - scanner := bufio.NewScanner(rd) - for scanner.Scan() { - stdoutLine := scanner.Text() - multiWriter.Write([]byte(stdoutLine + "\n")) - } - }() - - fmt.Println("foobar") - - // hacky sleep to ensure the go routine can write before program exits - time.Sleep(time.Second) -} -*/ diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go deleted file mode 100644 index 3200e9e..0000000 --- a/cmds/buttonplugin/main.go +++ /dev/null @@ -1,104 +0,0 @@ -// This is a simple example -package main - -import ( - "fmt" - "log" - "strconv" - "git.wit.org/wit/gui" -) - -var title string = "Demo Plugin Window" -var outfile string = "/tmp/guilogfile" -var myGui *gui.Node - -var buttonCounter int = 5 -var gridW int = 5 -var gridH int = 3 - -func main() { - // This will turn on all debugging - // gui.SetDebug(true) - - myGui = gui.New().Default() - buttonWindow() - - // This is just a optional goroutine to watch that things are alive - gui.Watchdog() - gui.StandardExit() -} - -// This creates a window -func buttonWindow() { - var w, t, g, more, more2 *gui.Node - - log.Println("buttonWindow() START") - - w = myGui.NewWindow(title).SetText("Nueva Ventana de Botones") - t = w.NewTab("buttonTab is this thing") - g = t.NewGroup("buttonGroup") - g1 := t.NewGroup("buttonGroup 2") - more = g1.NewGroup("more") - g1.NewButton("hello2", func () { - log.Println("world2") - }) - more2 = g1.NewGrid("gridnuts", gridW, gridH) - - more2.NewLabel("more2") - - g.NewButton("this app is useful for plugin debuggin", func () { - }) - g.NewLabel("STDOUT is set to: " + outfile) - - g.NewButton("hello", func () { - log.Println("world") - }) - - g.NewButton("Load 'gocui'", func () { - // this set the xterm and mate-terminal window title. maybe works generally? - fmt.Println("\033]0;" + title + "blah \007") - myGui.LoadToolkit("gocui") - }) - - g.NewButton("Load 'andlabs'", func () { - myGui.LoadToolkit("andlabs") - }) - - g.NewButton("NewButton(more)", func () { - name := "foobar " + strconv.Itoa(buttonCounter) - log.Println("NewButton(more) Adding button", name) - buttonCounter += 1 - more.NewButton(name, func () { - log.Println("Got all the way to main() name =", name) - }) - }) - - g.NewButton("NewButton(more2)", func () { - name := "foobar " + strconv.Itoa(buttonCounter) - log.Println("NewButton(more2) Adding button", name) - buttonCounter += 1 - more2.NewButton(name, func () { - log.Println("Got all the way to main() name =", name) - }) - }) - - g.NewButton("NewButton(more2 d)", func () { - name := "d" + strconv.Itoa(buttonCounter) - log.Println("NewButton(more2 d) Adding button", name) - buttonCounter += 1 - more2.NewButton(name, func () { - log.Println("Got all the way to main() name =", name) - }) - }) - - g.NewButton("NewGroup()", func () { - name := "neat " + strconv.Itoa(buttonCounter) - log.Println("NewGroup() Adding button", name) - buttonCounter += 1 - more.NewGroup(name) - }) - - g.NewButton("gui.DebugWindow()", func () { - gui.DebugWindow() - }) -} diff --git a/cmds/cloudflare/Makefile b/cmds/cloudflare/Makefile deleted file mode 100644 index bcd88c6..0000000 --- a/cmds/cloudflare/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -run: build - ./cloudflare - -build-release: - go get -v -u -x . - go build - ./cloudflare - -build: - GO111MODULE="off" go get -v -x . - GO111MODULE="off" go build - -update: - GO111MODULE="off" go get -v -u -x . - -log: - reset - tail -f /tmp/witgui.* /tmp/guilogfile diff --git a/cmds/cloudflare/argv.go b/cmds/cloudflare/argv.go deleted file mode 100644 index 38579c7..0000000 --- a/cmds/cloudflare/argv.go +++ /dev/null @@ -1,30 +0,0 @@ -// This creates a simple hello world window -package main - -import ( - "fmt" - arg "github.com/alexflint/go-arg" - "git.wit.org/wit/gui" - log "git.wit.org/wit/gui/log" -) - - -var args struct { - Foo string - Bar bool - User string `arg:"env:USER"` - Demo bool `help:"run a demo"` - gui.GuiArgs - log.LogArgs -} - -func init() { - arg.MustParse(&args) - fmt.Println(args.Foo, args.Bar, args.User) - - if (args.Gui != "") { - gui.GuiArg.Gui = args.Gui - } - log.Log(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui) - -} diff --git a/cmds/cloudflare/dns.go b/cmds/cloudflare/dns.go deleted file mode 100644 index 6626843..0000000 --- a/cmds/cloudflare/dns.go +++ /dev/null @@ -1,115 +0,0 @@ -// This is a simple example -package main - -import ( - "os" - "log" - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "strconv" -) - -// Define a struct to match the JSON structure of the response. -// This structure should be adjusted based on the actual format of the response. -type DNSRecords struct { - Result []struct { - ID string `json:"id"` - Type string `json:"type"` - Name string `json:"name"` - Content string `json:"content"` - Proxied bool `json:"proxied"` - Proxiable bool `json:"proxiable"` - TTL int `json:"ttl"` - } `json:"result"` -} - -// var domain string = "wit.org" -// var os.Getenv("CLOUDFLARE_DOMAIN") - -func loadDNS(hostname string) { - log.Println("adding DNS record") - - // more2.NewButton(name, func () { - // log.Println(name, "ip =", ip) - // }) - - newt := mainWindow.NewTab(hostname) - newg := newt.NewGroup("more") - more2 := newg.NewGrid("gridnuts", 5, gridH) - - records := getRecords() - for _, record := range records.Result { - more2.NewLabel(record.Type) - more2.NewLabel(record.Name) - if (record.Proxied) { - more2.NewLabel("Proxied") - } else { - more2.NewLabel("DNS") - } - var ttl, short string - if (record.TTL == 1) { - ttl = "Auto" - } else { - ttl = strconv.Itoa(record.TTL) - } - more2.NewLabel(ttl) - // short = fmt.Sprintf("%80s", record.Content) - short = record.Content - if len(short) > 40 { - short = short[:40] // Slice the first 20 characters - } - more2.NewLabel(short) - - fmt.Printf("ID: %s, Type: %s, Name: %s, short Content: %s\n", record.ID, record.Type, record.Name, short) - fmt.Printf("\tproxied: %b, %b, string TTL: %i\n", record.Proxied, record.Proxiable, ttl) - } -} - - -func getRecords() *DNSRecords { - var url string = os.Getenv("CLOUDFLARE_URL") - req, err := http.NewRequest("GET", url, nil) - if err != nil { - fmt.Println(err) - return nil - } - - var authKey string = os.Getenv("CLOUDFLARE_AUTHKEY") - var email string = os.Getenv("CLOUDFLARE_EMAIL") - - // Set headers - req.Header.Set("X-Auth-Key", authKey) - req.Header.Set("X-Auth-Email", email) - - client := &http.Client{} - resp, err := client.Do(req) - if err != nil { - fmt.Println(err) - return nil - } - defer resp.Body.Close() - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - fmt.Println(err) - return nil - } - - var records DNSRecords - if err := json.Unmarshal(body, &records); err != nil { - fmt.Println(err) - return nil - } - - // Process the records as needed - /* - for _, record := range records.Result { - fmt.Printf("ID: %s, Type: %s, Name: %s, Content: %s\n", record.ID, record.Type, record.Name, record.Content) - fmt.Printf("\tproxied: %b, %b, TTL: %i\n", record.Proxied, record.Proxiable, record.TTL) - } - */ - - return &records -} diff --git a/cmds/cloudflare/main.go b/cmds/cloudflare/main.go deleted file mode 100644 index 75ba448..0000000 --- a/cmds/cloudflare/main.go +++ /dev/null @@ -1,122 +0,0 @@ -// This is a simple example -package main - -import ( - "os" - "fmt" - "log" - "strconv" - "git.wit.org/wit/gui" -) - -var title string = "Cloudflare DNS Control Panel" -var outfile string = "/tmp/guilogfile" -var myGui *gui.Node - -var buttonCounter int = 5 -var gridW int = 5 -var gridH int = 3 - -var mainWindow, more, more2 *gui.Node - -func main() { - myGui = gui.New().Default() - buttonWindow() - - // This is just a optional goroutine to watch that things are alive - gui.Watchdog() - gui.StandardExit() -} - -// This creates a window -func buttonWindow() { - var t, g *gui.Node - - log.Println("buttonWindow() START") - - mainWindow = myGui.NewWindow(title).SetText(title) - t = mainWindow.NewTab("Cloudflare") - g = t.NewGroup("buttons") - g1 := t.NewGroup("buttonGroup 2") - - more = g1.NewGroup("more") - showCloudflareCredentials(more) - - g1.NewButton("hello", func () { - log.Println("world") - }) - more2 = g1.NewGrid("gridnuts", gridW, gridH) - - var domain string = os.Getenv("CLOUDFLARE_DOMAIN") - if (domain == "") { - domain = "example.org" - } - - g.NewButton("Load " + domain + " DNS", func () { - loadDNS(domain) - }) - - g.NewButton("Load 'gocui'", func () { - // this set the xterm and mate-terminal window title. maybe works generally? - fmt.Println("\033]0;" + title + "blah \007") - myGui.LoadToolkit("gocui") - }) - - g.NewButton("Load 'andlabs'", func () { - myGui.LoadToolkit("andlabs") - }) - - g.NewButton("NewButton(more)", func () { - name := "foobar " + strconv.Itoa(buttonCounter) - log.Println("NewButton(more) Adding button", name) - buttonCounter += 1 - more.NewButton(name, func () { - log.Println("Got all the way to main() name =", name) - }) - }) - - g.NewButton("NewButton(more2)", func () { - name := "foobar " + strconv.Itoa(buttonCounter) - log.Println("NewButton(more2) Adding button", name) - buttonCounter += 1 - more2.NewButton(name, func () { - log.Println("Got all the way to main() name =", name) - }) - }) - - g.NewButton("NewButton(more2 d)", func () { - name := "d" + strconv.Itoa(buttonCounter) - log.Println("NewButton(more2 d) Adding button", name) - buttonCounter += 1 - more2.NewButton(name, func () { - log.Println("Got all the way to main() name =", name) - }) - }) - - g.NewButton("NewGroup()", func () { - name := "neat " + strconv.Itoa(buttonCounter) - log.Println("NewGroup() Adding button", name) - buttonCounter += 1 - more.NewGroup(name) - }) - - g.NewButton("gui.DebugWindow()", func () { - gui.DebugWindow() - }) -} - -func showCloudflareCredentials(box *gui.Node) { - grid := box.NewGrid("credsGrid", 2, 4) // width = 2 - - grid.NewLabel("Domain") - grid.NewLabel(os.Getenv("CLOUDFLARE_DOMAIN")) - - grid.NewLabel("Auth Key") - grid.NewLabel(os.Getenv("CLOUDFLARE_AUTHKEY")) - - grid.NewLabel("Email") - grid.NewLabel(os.Getenv("CLOUDFLARE_EMAIL")) - - grid.NewLabel("URL") - grid.NewLabel(os.Getenv("CLOUDFLARE_URL")) -} diff --git a/cmds/console-ui-helloworld/Makefile b/cmds/console-ui-helloworld/Makefile deleted file mode 100644 index f63c8a9..0000000 --- a/cmds/console-ui-helloworld/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -run: build - ./console-ui-helloworld - reset - ldd ./console-ui-helloworld - -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/console-ui-helloworld/keybindings.go b/cmds/console-ui-helloworld/keybindings.go deleted file mode 100644 index 8c4623b..0000000 --- a/cmds/console-ui-helloworld/keybindings.go +++ /dev/null @@ -1,130 +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 ( -// "errors" -// "fmt" - "log" -// "strings" - - "github.com/awesome-gocui/gocui" -) - -func initKeybindings(g *gocui.Gui) error { - log.Println("got to initKeybindings") - if err := g.SetKeybinding("", 'q', gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return gocui.ErrQuit - }); err != nil { - return err - } - if err := g.SetKeybinding("", 'Q', gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return gocui.ErrQuit - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return gocui.ErrQuit - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeySpace, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return newView(g) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyBackspace, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return delView(g) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyBackspace2, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return delView(g) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - log.Println("tab", v.Name()) - return nextView(g, true) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyArrowLeft, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return moveView(g, v, -delta, 0) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyArrowRight, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return moveView(g, v, delta, 0) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyArrowDown, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - log.Println("down", v.Name()) - return moveView(g, v, 0, delta) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - log.Println("up", v.Name()) - return moveView(g, v, 0, -delta) - }); err != nil { - return err - } - if err := g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - log.Println("enter", v.Name()) - return nil - }); err != nil { - return err - } - if err := g.SetKeybinding("", 't', gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - _, err := g.SetViewOnTop(views[curView]) - return err - }); err != nil { - return err - } - if err := g.SetKeybinding("", 'b', gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - _, err := g.SetViewOnBottom(views[curView]) - return err - }); err != nil { - return err - } - if err := g.SetKeybinding("", 'j', gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - return newJ(g) - }); err != nil { - return err - } - if err := g.SetKeybinding("", 'h', gocui.ModNone, - func(g *gocui.Gui, v *gocui.View) error { - log.Println("help", v.Name()) - tmp, _ := g.SetViewOnTop("help") - log.Println("help 2", tmp.Name()) -// g.SetView("help", 2, 2, 30, 15, 0); - g.SetCurrentView("help") -// moveView(g, tmp, 0, -delta) - if err := g.DeleteView("help"); err != nil { - panic(err) - } - return nil - }); err != nil { - return err - } - return nil -} diff --git a/cmds/console-ui-helloworld/log.go b/cmds/console-ui-helloworld/log.go deleted file mode 100644 index b05beaf..0000000 --- a/cmds/console-ui-helloworld/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/console-ui-helloworld/main.go b/cmds/console-ui-helloworld/main.go deleted file mode 100644 index d16b805..0000000 --- a/cmds/console-ui-helloworld/main.go +++ /dev/null @@ -1,83 +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 ( - "errors" - "fmt" - "log" - - "github.com/awesome-gocui/gocui" -) - -const delta = 1 - -var ( - views = []string{} - curView = -1 - idxView = 0 - currentX = 5 - currentY = 2 - groupSize = 0 - baseGui *gocui.Gui -) - -var helpLabel *gocui.View - -func main() { - // setup log to write to a file -// logInit() - - g, err := gocui.NewGui(gocui.OutputNormal, true) - baseGui = g - if err != nil { - log.Panicln(err) - } - defer g.Close() - - g.Highlight = true - g.SelFgColor = gocui.ColorRed - g.SelFrameColor = gocui.ColorRed - - g.SetManagerFunc(layout) - - if err := initKeybindings(g); err != nil { - log.Panicln(err) - } - if err := newView(g); err != nil { - log.Panicln(err) - } - - addButton("hello") - - addGroup("blank") - addButton("world") - - if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) { - log.Panicln(err) - } -} - -func layout(g *gocui.Gui) error { - var err error - maxX, _ := g.Size() - helpLabel, err = g.SetView("help", maxX-32, 0, maxX-1, 11, 0) - if err != nil { - if !errors.Is(err, gocui.ErrUnknownView) { - return err - } - fmt.Fprintln(helpLabel, "KEYBINDINGS") - fmt.Fprintln(helpLabel, "Enter: Click Button") - fmt.Fprintln(helpLabel, "Tab/Space: Switch Buttons") - fmt.Fprintln(helpLabel, "") - fmt.Fprintln(helpLabel, "h: Help") - fmt.Fprintln(helpLabel, "Backspace: Delete Button") - fmt.Fprintln(helpLabel, "Arrow keys: Move Button") - fmt.Fprintln(helpLabel, "t: Move Button to the top") - fmt.Fprintln(helpLabel, "b: Move Button to the button") - fmt.Fprintln(helpLabel, "Ctrl-C or Q: Exit") - } - return nil -} diff --git a/cmds/console-ui-helloworld/newJ.go b/cmds/console-ui-helloworld/newJ.go deleted file mode 100644 index 47c7439..0000000 --- a/cmds/console-ui-helloworld/newJ.go +++ /dev/null @@ -1,46 +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 ( - "errors" - "fmt" - "log" - "strings" - - "github.com/awesome-gocui/gocui" -) - -var topX int = 2 -var bottomX int = 20 -var topY int = 2 -var bottomY int = 7 - -func newJ(g *gocui.Gui) error { - // maxX, maxY := g.Size() - name := fmt.Sprintf("jcarr %v test ", idxView) - v, err := g.SetView(name, topX, topY, bottomX, bottomY, 0) - if err == nil { - return err - } - if !errors.Is(err, gocui.ErrUnknownView) { - return err - } - - v.Wrap = true - fmt.Fprintln(v, name) - fmt.Fprintln(v, strings.Repeat("foo\n", 2)) - // fmt.Fprintln(v, strings.Repeat(name+" ", 30)) - log.Println("newJ added a new view", v.Name()) - - if _, err := g.SetCurrentView(name); err != nil { - return err - } - - views = append(views, name) - curView = len(views) - 1 - idxView += 1 - return nil -} diff --git a/cmds/console-ui-helloworld/views.go b/cmds/console-ui-helloworld/views.go deleted file mode 100644 index 50287c2..0000000 --- a/cmds/console-ui-helloworld/views.go +++ /dev/null @@ -1,114 +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 ( - "errors" - "fmt" - "log" - "strings" - - "github.com/awesome-gocui/gocui" -) - -func addGroup(name string) { - log.Println("addGroup()", name) - currentY = 2 - currentX += groupSize + 6 -} - -func addButton(name string) error { - t := len(name) - v, err := baseGui.SetView(name, currentX, currentY, currentX+t+3, currentY+2, 0) - if err == nil { - return err - } - if !errors.Is(err, gocui.ErrUnknownView) { - return err - } - - v.Wrap = true - fmt.Fprintln(v, " " + name) - fmt.Fprintln(v, strings.Repeat("foo\n", 2)) - - if _, err := baseGui.SetCurrentView(name); err != nil { - return err - } - - views = append(views, name) - curView = len(views) - 1 - idxView += 1 - currentY += 3 - if (groupSize < len(views)) { - groupSize = len(views) - } - return nil -} - -func newView(g *gocui.Gui) error { - maxX, maxY := g.Size() - name := fmt.Sprintf("v%v", idxView) - v, err := g.SetView(name, maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5, 0) - if err == nil { - return err - } - if !errors.Is(err, gocui.ErrUnknownView) { - return err - } - - v.Wrap = true - fmt.Fprintln(v, strings.Repeat(name+" ", 30)) - - if _, err := g.SetCurrentView(name); err != nil { - return err - } - - views = append(views, name) - curView = len(views) - 1 - idxView += 1 - return nil -} - -func delView(g *gocui.Gui) error { - if len(views) <= 1 { - return nil - } - - if err := g.DeleteView(views[curView]); err != nil { - return err - } - views = append(views[:curView], views[curView+1:]...) - - return nextView(g, false) -} - -func nextView(g *gocui.Gui, disableCurrent bool) error { - next := curView + 1 - if next > len(views)-1 { - next = 0 - } - - if _, err := g.SetCurrentView(views[next]); err != nil { - return err - } - - curView = next - return nil -} - -func moveView(g *gocui.Gui, v *gocui.View, dx, dy int) error { - name := v.Name() - x0, y0, x1, y1, err := g.ViewPosition(name) - if err != nil { - return err - } - log.Println(x0, y0, x1, y1) - if _, err := g.SetView(name, x0+dx, y0+dy, x1+dx, y1+dy, 0); err != nil { - return err - } - x0, y0, x1, y1, err = g.ViewPosition(name) - log.Println(x0, y0, x1, y1) - return nil -} diff --git a/cmds/debug/Makefile b/cmds/debug/Makefile deleted file mode 100644 index 5f979cc..0000000 --- a/cmds/debug/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -run: build - ./debug - -build: - # go build - GO111MODULE="off" go build diff --git a/cmds/debug/helloworld.go b/cmds/debug/helloworld.go deleted file mode 100644 index d0998bf..0000000 --- a/cmds/debug/helloworld.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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/debug/main.go b/cmds/debug/main.go deleted file mode 100644 index 375ccae..0000000 --- a/cmds/debug/main.go +++ /dev/null @@ -1,54 +0,0 @@ -package main - -import ( - "log" - "os" - "time" - - "git.wit.org/wit/gui" -) - -// This initializes the first window -// -// BUG: THIS PROGRAM DOESN'T EXIT PROPERLY (NOT REALLY A BUG) -// -// Then starts a goroutine to demonstrate how to -// inject things into the GUI -func main() { - log.Println("Starting my Control Panel") - -// gui.Init() -// go gui.Main(helloworld) - go gui.Main(gui.DebugWindow) -// go gui.DemoToolkitWindow() - - watchGUI() -} - -// This demonstrates how to properly interact with the GUI -// You can not involke the GUI from external goroutines in most cases. -func watchGUI() { - var i = 1 - for { - log.Println("Waiting", i, "seconds") - i += 1 - time.Sleep(1 * time.Second) - if i == 2 { - log.Println("Opening a Debug Window via the gui.Queue()") - gui.Config.Width = 800 - gui.Config.Height = 300 - gui.Config.Exit = myExit - // gui.DebugWindow() - time.Sleep(1 * time.Second) - // gui.DebugTab() - } - } -} - -// TODO: myExit isn't getting used anymore -func myExit(n *gui.Node) { - log.Println() - log.Println("Entered myExit() on node.Name =", n.Name) - log.Println() - os.Exit(0) -} diff --git a/cmds/helloworld/Makefile b/cmds/helloworld/Makefile deleted file mode 100644 index 961ed8c..0000000 --- a/cmds/helloworld/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -run: build - ./helloworld - -build-release: - go get -v -u -x . - go build - ./helloworld - -build: - GO111MODULE="off" go get -v -x . - GO111MODULE="off" go build - -update: - GO111MODULE="off" go get -v -u -x . diff --git a/cmds/helloworld/main.go b/cmds/helloworld/main.go deleted file mode 100644 index 5516340..0000000 --- a/cmds/helloworld/main.go +++ /dev/null @@ -1,25 +0,0 @@ -// This is a simple example -package main - -import ( - "log" - "git.wit.org/wit/gui" -) - -func main() { - // gui.Init() - gui.Main(helloworld) -} - -// This creates a window -func helloworld() { - var w *gui.Node - gui.Config.Title = "helloworld golang wit/gui window" - gui.Config.Width = 640 - gui.Config.Height = 480 - - w = gui.NewWindow() - w.NewButton("hello", func () { - log.Println("world") - }) -} diff --git a/cmds/plugin-consoleonly/Makefile b/cmds/plugin-consoleonly/Makefile deleted file mode 100644 index a8279f6..0000000 --- a/cmds/plugin-consoleonly/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -run: build - ./helloconsole - -build-release: - go get -v -u -x . - go install -v -o helloconsole - helloconsole - -build: - GO111MODULE="off" go get -v -x . - GO111MODULE="off" go build -v -o helloconsole - -update: - GO111MODULE="off" go get -v -u -x . diff --git a/cmds/plugin-consoleonly/args.go b/cmds/plugin-consoleonly/args.go deleted file mode 100644 index dc4a322..0000000 --- a/cmds/plugin-consoleonly/args.go +++ /dev/null @@ -1,31 +0,0 @@ -// This creates a simple hello world window -package main - -import ( - "log" - "git.wit.org/wit/gui" - arg "github.com/alexflint/go-arg" -) - -type LogOptions struct { - LogFile string - Verbose bool - User string `arg:"env:USER"` -} - -var args struct { - LogOptions - gui.GuiArgs -} - -func init() { - arg.MustParse(&args) - log.Println("Toolkit = ", args.Toolkit) - - if (args.GuiDebug) { - gui.DebugWindow() - } - if (args.GuiVerbose) { - gui.SetDebug(true) - } -} diff --git a/cmds/plugin-consoleonly/main.go b/cmds/plugin-consoleonly/main.go deleted file mode 100644 index fa428d6..0000000 --- a/cmds/plugin-consoleonly/main.go +++ /dev/null @@ -1,33 +0,0 @@ -// This is a simple example -package main - -import ( - "log" - "git.wit.org/wit/gui" -) - -func main() { - gui.InitPlugins([]string{"gocui"}) - gui.Main(helloworld) -} - -// This creates a window -func helloworld() { - var w *gui.Node - gui.Config.Title = "helloworld golang wit/gui window" - gui.Config.Width = 640 - gui.Config.Height = 480 - - w = gui.NewWindow() - w.NewButton("hello", func () { - log.Println("world") - }) - w.NewButton("Flags", func () { - log.Println("the debugging flags window") - w.DebugFlags(false) - }) - w.NewButton("Widgets", func () { - w.DebugWidgets(false) - log.Println("debug the widgets window") - }) -} diff --git a/cmds/textbox/Makefile b/cmds/textbox/Makefile deleted file mode 100644 index 5785c10..0000000 --- a/cmds/textbox/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -run: build - # GOTRACEBACK=all ./textbox --gui-debug - GOTRACEBACK=all ./textbox --gui-debug >/tmp/witgui.log.stderr 2>&1 - -build-release: - go get -v -u -x . - go build - -build: - GO111MODULE="off" go get -v -x . - GO111MODULE="off" GOTRACEBACK=all go build - -update: - GO111MODULE="off" go get -v -u -x . diff --git a/cmds/textbox/main.go b/cmds/textbox/main.go deleted file mode 100644 index e02ff4a..0000000 --- a/cmds/textbox/main.go +++ /dev/null @@ -1,96 +0,0 @@ -// This creates a simple hello world window -package main - -import ( - "os" - "log" - "git.wit.org/wit/gui" - arg "github.com/alexflint/go-arg" -) - -type LogOptions struct { - LogFile string - Verbose bool - User string `arg:"env:USER"` -} - -var args struct { - LogOptions - gui.GuiArgs -} - -func main() { - // this implements ./cmd --gui-debug --gui-toolkit, etc - arg.MustParse(&args) - log.Println("Toolkit = ", args.Toolkit) - - // gui.SetDebug(true) - // gui.InitPlugins([]string{"gocui"}) - gui.Main(initGUI) -} - -// This initializes the first window -func initGUI() { - var w *gui.Node - gui.Config.Title = "Hello World" - gui.Config.Width = 642 - gui.Config.Height = 481 - gui.Config.Exit = myDefaultExit - - w = gui.NewWindow() - w.Custom = func () { - log.Println("myDefaultExit(w)") - myDefaultExit(w) - } - addDemoTab(w, "A Simple Tab Demo") - addDemoTab(w, "A Second Tab") - - if (args.GuiDebug) { - gui.DebugWindow() - } - if (args.GuiVerbose) { - gui.SetDebug(true) - } -} - -func addDemoTab(window *gui.Node, title string) { - var newNode, g *gui.Node - - newNode = window.NewTab(title) - log.Println("addDemoTab() newNode START") - // newNode.Dump(true) - - g = newNode.NewGroup("group 1") - - g1 := g.NewGrid("grid 1", 2, 2) - g1.NewLabel("less") - dd := g1.NewDropdown("more") - dd.AddDropdownName("more 1") - dd.AddDropdownName("more 2") - dd.AddDropdownName("more 3") - - // g.SetNext(3,1) - // g1.NewLabel("label (3,1)") - // g.SetNext(3,2) - // g1.NewLabel("label (3,2)") - - g2 := newNode.NewGroup("group 2") - tb := g2.NewTextbox("tb") - log.Println("tb =", tb.GetText()) - tb.Custom = func() { - s := tb.GetText() - log.Println("text =", s) - } - - dd.Custom = func() { - s := dd.GetText() - log.Println("hello world " + args.User + "\n" + s + "\n") - tb.SetText("hello world " + args.User + "\n" + s + "\n") - } -} - -func myDefaultExit(n *gui.Node) { - log.Println("You can Do exit() things here") - os.Exit(0) -} - diff --git a/common.go b/common.go index f9884d0..6f42ce4 100644 --- a/common.go +++ b/common.go @@ -187,7 +187,7 @@ func (n *Node) Standard() *Node { return n } -func (n *Node) DoMargin() *Node { +func (n *Node) SetMargin() *Node { log(debugError, "DoMargin() not implemented yet") return n } diff --git a/debug.go b/debug.go index 955a246..acc249d 100644 --- a/debug.go +++ b/debug.go @@ -134,7 +134,7 @@ func (n *Node) dumpWidget(b bool) string { } info = n.WidgetType.String() - d = strconv.Itoa(n.id) + " " + info + d = strconv.Itoa(n.id) + " " + info + " " + n.Name var tabs string for i := 0; i < listChildrenDepth; i++ { diff --git a/doc.go b/doc.go index 29f36db..14cb2f3 100644 --- a/doc.go +++ b/doc.go @@ -16,7 +16,16 @@ Principles: * When in doubt, search upward in the binary tree * It's ok to guess. Try to do something sensible. -Quick Start +Debian Build + +This worked on debian sid (mate-desktop) on 2023/12/03 +I didn't record the dependances needed (gtk-dev) + + export GO111MODULE="off" + make + + +Hello World Example // This creates a simple hello world window package main @@ -54,18 +63,7 @@ Quick Start }) } - -Debian Build - -This worked on debian sid on 2022/10/20 -I didn't record the dependances needed - - GO111MODULE="off" go get -v -t -u git.wit.org/wit/gui - cd ~/go/src/git.wit.org/wit/gui/cmds/helloworld/ - GO111MODULE="off" go build -v -x - ./helloworld - -Toolkits +External Toolkits * andlabs - https://github.com/andlabs/ui * gocui - https://github.com/awesome-gocui/gocui @@ -86,16 +84,12 @@ References Useful links and other external things which might be useful -[Wikipedia Graphical widget]: https://en.wikipedia.org/wiki/Graphical_widget -[Github mirror]: https://github.com/witorg/gui -[Federated git pull]: https://github.com/forgefed/forgefed -[GO Style Guide]: https://google.github.io/styleguide/go/index - - * [Wikipedia Graphical widget] - * [Github mirror] - * [Federated git pull] - * [GO Style Guide] - +* [Wikipedia Graphical widget](https://en.wikipedia.org/wiki/Graphical_widget) +* [GO Style Guide](https://google.github.io/styleguide/go/index) Code this way +* [MS Windows Application Library Kit](https://github.com/lxn/walk) +* [Federated git pull](https://github.com/forgefed/forgefed) Hopefully this will work for me with gitea +* [Github mirror](https://github.com/wit-go/gui) This repo on mirror. Hopefully I won't have to use this. +* [WIT GO projects](https://go.wit.org/) Attempt to model go.uber.org */ package gui diff --git a/example_test.go b/example_test.go deleted file mode 100644 index f65cad1..0000000 --- a/example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package gui_test - -import ( - "git.wit.org/wit/gui" -) - -// This example demonstrates how to create a NewWindow() -// -// Interacting with a GUI in a cross platform fashion adds some -// unusual problems. To obvuscate those, andlabs/ui starts a -// goroutine that interacts with the native gui toolkits -// on the Linux, MacOS, Windows, etc. -// -// Because of this oddity, to initialize a new window, the -// function is not passed any arguements and instead passes -// the information via the Config type. -// -func ExampleNewWindow() { - // Define the name and size - gui.Config.Title = "WIT GUI Window 1" - gui.Config.Width = 640 - gui.Config.Height = 480 - - // Create the Window - gui.NewWindow() - - // Output: - // You get a window -} diff --git a/examples/buttons/Makefile b/examples/buttons/Makefile new file mode 100644 index 0000000..74b7728 --- /dev/null +++ b/examples/buttons/Makefile @@ -0,0 +1,26 @@ +# 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 + ./buttons --gui andlabs + +build-release: + go get -v -u -x . + go build + ./buttons + +build: + GO111MODULE="off" go get -v -x . + GO111MODULE="off" go build + +update: + GO111MODULE="off" go get -v -u -x . + +log: + reset + tail -f /tmp/witgui.* /tmp/guilogfile diff --git a/examples/buttons/buttonplugin b/examples/buttons/buttonplugin new file mode 100755 index 0000000..3f4dee3 Binary files /dev/null and b/examples/buttons/buttonplugin differ diff --git a/examples/buttons/buttons b/examples/buttons/buttons new file mode 100755 index 0000000..01ea9aa Binary files /dev/null and b/examples/buttons/buttons differ diff --git a/examples/buttons/log.go b/examples/buttons/log.go new file mode 100644 index 0000000..7d65d05 --- /dev/null +++ b/examples/buttons/log.go @@ -0,0 +1,78 @@ +// This creates a simple hello world window +package main + +import ( + "fmt" + arg "github.com/alexflint/go-arg" + "git.wit.org/wit/gui" + log "git.wit.org/wit/gui/log" +) + + +var args struct { + Foo string + Bar bool + User string `arg:"env:USER"` + Demo bool `help:"run a demo"` + gui.GuiArgs + log.LogArgs +} + +/* +var f1 *os.File +var f2 *os.File +var err error +*/ + +func init() { + arg.MustParse(&args) + fmt.Println(args.Foo, args.Bar, args.User) + + if (args.Gui != "") { + gui.GuiArg.Gui = args.Gui + } + log.Log(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui) + +/* + log.Println() + log.Println("STDOUT is now at /tmp/guilogfile") + log.Println("STDOUT is now at /tmp/guilogfile") + log.Println() + f1, err = os.OpenFile(outfile, 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(f1) + log.Println("This is a test log entry") +*/ +} + +/* +func captureSTDOUT() { + f2, _ = os.OpenFile("/tmp/my.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664) + multiWriter := io.MultiWriter(os.Stderr, f2) + rd, wr, err := os.Pipe() + if err != nil { + os.Exit(1) + } + + // overwrite os.Stdout + os.Stderr = wr + + go func() { + scanner := bufio.NewScanner(rd) + for scanner.Scan() { + stdoutLine := scanner.Text() + multiWriter.Write([]byte(stdoutLine + "\n")) + } + }() + + fmt.Println("foobar") + + // hacky sleep to ensure the go routine can write before program exits + time.Sleep(time.Second) +} +*/ diff --git a/examples/buttons/main.go b/examples/buttons/main.go new file mode 100644 index 0000000..3200e9e --- /dev/null +++ b/examples/buttons/main.go @@ -0,0 +1,104 @@ +// This is a simple example +package main + +import ( + "fmt" + "log" + "strconv" + "git.wit.org/wit/gui" +) + +var title string = "Demo Plugin Window" +var outfile string = "/tmp/guilogfile" +var myGui *gui.Node + +var buttonCounter int = 5 +var gridW int = 5 +var gridH int = 3 + +func main() { + // This will turn on all debugging + // gui.SetDebug(true) + + myGui = gui.New().Default() + buttonWindow() + + // This is just a optional goroutine to watch that things are alive + gui.Watchdog() + gui.StandardExit() +} + +// This creates a window +func buttonWindow() { + var w, t, g, more, more2 *gui.Node + + log.Println("buttonWindow() START") + + w = myGui.NewWindow(title).SetText("Nueva Ventana de Botones") + t = w.NewTab("buttonTab is this thing") + g = t.NewGroup("buttonGroup") + g1 := t.NewGroup("buttonGroup 2") + more = g1.NewGroup("more") + g1.NewButton("hello2", func () { + log.Println("world2") + }) + more2 = g1.NewGrid("gridnuts", gridW, gridH) + + more2.NewLabel("more2") + + g.NewButton("this app is useful for plugin debuggin", func () { + }) + g.NewLabel("STDOUT is set to: " + outfile) + + g.NewButton("hello", func () { + log.Println("world") + }) + + g.NewButton("Load 'gocui'", func () { + // this set the xterm and mate-terminal window title. maybe works generally? + fmt.Println("\033]0;" + title + "blah \007") + myGui.LoadToolkit("gocui") + }) + + g.NewButton("Load 'andlabs'", func () { + myGui.LoadToolkit("andlabs") + }) + + g.NewButton("NewButton(more)", func () { + name := "foobar " + strconv.Itoa(buttonCounter) + log.Println("NewButton(more) Adding button", name) + buttonCounter += 1 + more.NewButton(name, func () { + log.Println("Got all the way to main() name =", name) + }) + }) + + g.NewButton("NewButton(more2)", func () { + name := "foobar " + strconv.Itoa(buttonCounter) + log.Println("NewButton(more2) Adding button", name) + buttonCounter += 1 + more2.NewButton(name, func () { + log.Println("Got all the way to main() name =", name) + }) + }) + + g.NewButton("NewButton(more2 d)", func () { + name := "d" + strconv.Itoa(buttonCounter) + log.Println("NewButton(more2 d) Adding button", name) + buttonCounter += 1 + more2.NewButton(name, func () { + log.Println("Got all the way to main() name =", name) + }) + }) + + g.NewButton("NewGroup()", func () { + name := "neat " + strconv.Itoa(buttonCounter) + log.Println("NewGroup() Adding button", name) + buttonCounter += 1 + more.NewGroup(name) + }) + + g.NewButton("gui.DebugWindow()", func () { + gui.DebugWindow() + }) +} diff --git a/examples/cloudflare/Makefile b/examples/cloudflare/Makefile new file mode 100644 index 0000000..bcd88c6 --- /dev/null +++ b/examples/cloudflare/Makefile @@ -0,0 +1,18 @@ +run: build + ./cloudflare + +build-release: + go get -v -u -x . + go build + ./cloudflare + +build: + GO111MODULE="off" go get -v -x . + GO111MODULE="off" go build + +update: + GO111MODULE="off" go get -v -u -x . + +log: + reset + tail -f /tmp/witgui.* /tmp/guilogfile diff --git a/examples/cloudflare/argv.go b/examples/cloudflare/argv.go new file mode 100644 index 0000000..38579c7 --- /dev/null +++ b/examples/cloudflare/argv.go @@ -0,0 +1,30 @@ +// This creates a simple hello world window +package main + +import ( + "fmt" + arg "github.com/alexflint/go-arg" + "git.wit.org/wit/gui" + log "git.wit.org/wit/gui/log" +) + + +var args struct { + Foo string + Bar bool + User string `arg:"env:USER"` + Demo bool `help:"run a demo"` + gui.GuiArgs + log.LogArgs +} + +func init() { + arg.MustParse(&args) + fmt.Println(args.Foo, args.Bar, args.User) + + if (args.Gui != "") { + gui.GuiArg.Gui = args.Gui + } + log.Log(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui) + +} diff --git a/examples/cloudflare/dns.go b/examples/cloudflare/dns.go new file mode 100644 index 0000000..eb8de23 --- /dev/null +++ b/examples/cloudflare/dns.go @@ -0,0 +1,132 @@ +// This is a simple example +package main + +import ( + "os" + "log" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "strconv" +) + +// Define a struct to match the JSON structure of the response. +// This structure should be adjusted based on the actual format of the response. +type DNSRecords struct { + Result []struct { + ID string `json:"id"` + Type string `json:"type"` + Name string `json:"name"` + Content string `json:"content"` + Proxied bool `json:"proxied"` + Proxiable bool `json:"proxiable"` + TTL int `json:"ttl"` + } `json:"result"` +} + +// var domain string = "wit.org" +// var os.Getenv("CLOUDFLARE_DOMAIN") + +func loadDNS(hostname string) { + log.Println("adding DNS record") + + newt := mainWindow.NewTab(hostname) + newg := newt.NewGroup("more") + grid := newg.NewGrid("gridnuts", 5, gridH) + +// grid.NewButton("Type", func () { +// log.Println("sort by Type") +// }) + typedrop := grid.NewDropdown("type") + typedrop.AddText("A") + typedrop.AddText("AAAA") + typedrop.AddText("CNAME") + typedrop.Custom = func () { + log.Println("custom dropdown() a =", typedrop.Name, typedrop.S) + } + grid.NewButton("Name", func () { + log.Println("sort by Name") + }) + grid.NewButton("Protection", func () { + log.Println("sort proxied") + }) + grid.NewButton("TTL", func () { + log.Println("sort by TTL") + }) + grid.NewButton("Value", func () { + log.Println("sort by Value") + }) + + newt.NewButton("Save", func () { + log.Println("save stuff to cloudflare") + }) + + records := getRecords() + for _, record := range records.Result { + grid.NewLabel(record.Type) + textbox := grid.NewTextbox(record.Name) + textbox.SetText(record.Name) + if (record.Proxied) { + grid.NewLabel("Proxied") + } else { + grid.NewLabel("DNS") + } + var ttl, short string + if (record.TTL == 1) { + ttl = "Auto" + } else { + ttl = strconv.Itoa(record.TTL) + } + grid.NewLabel(ttl) + // short = fmt.Sprintf("%80s", record.Content) + short = record.Content + if len(short) > 40 { + short = short[:40] // Slice the first 20 characters + } + + namebox := grid.NewTextbox(short) + namebox.SetText(short) + + fmt.Printf("ID: %s, Type: %s, Name: %s, short Content: %s\n", record.ID, record.Type, record.Name, short) + fmt.Printf("\tproxied: %b, %b, string TTL: %i\n", record.Proxied, record.Proxiable, ttl) + } +} + +func getRecords() *DNSRecords { + var url string = os.Getenv("CLOUDFLARE_URL") + req, err := http.NewRequest("GET", url, nil) + if err != nil { + fmt.Println(err) + return nil + } + + var authKey string = os.Getenv("CLOUDFLARE_AUTHKEY") + var email string = os.Getenv("CLOUDFLARE_EMAIL") + + // Set headers + req.Header.Set("X-Auth-Key", authKey) + req.Header.Set("X-Auth-Email", email) + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + fmt.Println(err) + return nil + } + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + fmt.Println(err) + return nil + } + + var records DNSRecords + if err := json.Unmarshal(body, &records); err != nil { + fmt.Println(err) + return nil + } + + return &records +} diff --git a/examples/cloudflare/main.go b/examples/cloudflare/main.go new file mode 100644 index 0000000..b83d276 --- /dev/null +++ b/examples/cloudflare/main.go @@ -0,0 +1,84 @@ +// This is a simple example +package main + +import ( + "os" + "fmt" + "log" + "git.wit.org/wit/gui" +) + +var title string = "Cloudflare DNS Control Panel" +var outfile string = "/tmp/guilogfile" +var myGui *gui.Node + +var buttonCounter int = 5 +var gridW int = 5 +var gridH int = 3 + +var mainWindow, more, more2 *gui.Node + +func main() { + myGui = gui.New().Default() + buttonWindow() + + // This is just a optional goroutine to watch that things are alive + gui.Watchdog() + gui.StandardExit() +} + +// This creates a window +func buttonWindow() { + var t, g *gui.Node + + log.Println("buttonWindow() START") + + mainWindow = myGui.NewWindow(title).SetText(title) + t = mainWindow.NewTab("Cloudflare") + g = t.NewGroup("buttons") + g1 := t.NewGroup("buttonGroup 2") + + more = g1.NewGroup("more") + showCloudflareCredentials(more) + + // more2 = g1.NewGrid("gridnuts", gridW, gridH) + + var domain string = os.Getenv("CLOUDFLARE_DOMAIN") + if (domain == "") { + domain = "example.org" + } + + g.NewButton("Load " + domain + " DNS", func () { + loadDNS(domain) + }) + + g.NewButton("Load 'gocui'", func () { + // this set the xterm and mate-terminal window title. maybe works generally? + fmt.Println("\033]0;" + title + "blah \007") + myGui.LoadToolkit("gocui") + }) + + g.NewButton("Load 'andlabs'", func () { + myGui.LoadToolkit("andlabs") + }) + + g.NewButton("gui.DebugWindow()", func () { + gui.DebugWindow() + }) +} + +func showCloudflareCredentials(box *gui.Node) { + grid := box.NewGrid("credsGrid", 2, 4) // width = 2 + + grid.NewLabel("Domain") + grid.NewLabel(os.Getenv("CLOUDFLARE_DOMAIN")) + + grid.NewLabel("Auth Key") + grid.NewLabel(os.Getenv("CLOUDFLARE_AUTHKEY")) + + grid.NewLabel("Email") + grid.NewLabel(os.Getenv("CLOUDFLARE_EMAIL")) + + grid.NewLabel("URL") + grid.NewLabel(os.Getenv("CLOUDFLARE_URL")) +} diff --git a/examples/console-ui-helloworld/Makefile b/examples/console-ui-helloworld/Makefile new file mode 100644 index 0000000..f63c8a9 --- /dev/null +++ b/examples/console-ui-helloworld/Makefile @@ -0,0 +1,15 @@ +run: build + ./console-ui-helloworld + reset + ldd ./console-ui-helloworld + +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/examples/console-ui-helloworld/keybindings.go b/examples/console-ui-helloworld/keybindings.go new file mode 100644 index 0000000..8c4623b --- /dev/null +++ b/examples/console-ui-helloworld/keybindings.go @@ -0,0 +1,130 @@ +// 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 ( +// "errors" +// "fmt" + "log" +// "strings" + + "github.com/awesome-gocui/gocui" +) + +func initKeybindings(g *gocui.Gui) error { + log.Println("got to initKeybindings") + if err := g.SetKeybinding("", 'q', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return gocui.ErrQuit + }); err != nil { + return err + } + if err := g.SetKeybinding("", 'Q', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return gocui.ErrQuit + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return gocui.ErrQuit + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeySpace, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return newView(g) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyBackspace, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return delView(g) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyBackspace2, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return delView(g) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + log.Println("tab", v.Name()) + return nextView(g, true) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyArrowLeft, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return moveView(g, v, -delta, 0) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyArrowRight, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return moveView(g, v, delta, 0) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyArrowDown, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + log.Println("down", v.Name()) + return moveView(g, v, 0, delta) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + log.Println("up", v.Name()) + return moveView(g, v, 0, -delta) + }); err != nil { + return err + } + if err := g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + log.Println("enter", v.Name()) + return nil + }); err != nil { + return err + } + if err := g.SetKeybinding("", 't', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + _, err := g.SetViewOnTop(views[curView]) + return err + }); err != nil { + return err + } + if err := g.SetKeybinding("", 'b', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + _, err := g.SetViewOnBottom(views[curView]) + return err + }); err != nil { + return err + } + if err := g.SetKeybinding("", 'j', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + return newJ(g) + }); err != nil { + return err + } + if err := g.SetKeybinding("", 'h', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + log.Println("help", v.Name()) + tmp, _ := g.SetViewOnTop("help") + log.Println("help 2", tmp.Name()) +// g.SetView("help", 2, 2, 30, 15, 0); + g.SetCurrentView("help") +// moveView(g, tmp, 0, -delta) + if err := g.DeleteView("help"); err != nil { + panic(err) + } + return nil + }); err != nil { + return err + } + return nil +} diff --git a/examples/console-ui-helloworld/log.go b/examples/console-ui-helloworld/log.go new file mode 100644 index 0000000..b05beaf --- /dev/null +++ b/examples/console-ui-helloworld/log.go @@ -0,0 +1,35 @@ +// 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/examples/console-ui-helloworld/main.go b/examples/console-ui-helloworld/main.go new file mode 100644 index 0000000..d16b805 --- /dev/null +++ b/examples/console-ui-helloworld/main.go @@ -0,0 +1,83 @@ +// 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 ( + "errors" + "fmt" + "log" + + "github.com/awesome-gocui/gocui" +) + +const delta = 1 + +var ( + views = []string{} + curView = -1 + idxView = 0 + currentX = 5 + currentY = 2 + groupSize = 0 + baseGui *gocui.Gui +) + +var helpLabel *gocui.View + +func main() { + // setup log to write to a file +// logInit() + + g, err := gocui.NewGui(gocui.OutputNormal, true) + baseGui = g + if err != nil { + log.Panicln(err) + } + defer g.Close() + + g.Highlight = true + g.SelFgColor = gocui.ColorRed + g.SelFrameColor = gocui.ColorRed + + g.SetManagerFunc(layout) + + if err := initKeybindings(g); err != nil { + log.Panicln(err) + } + if err := newView(g); err != nil { + log.Panicln(err) + } + + addButton("hello") + + addGroup("blank") + addButton("world") + + if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) { + log.Panicln(err) + } +} + +func layout(g *gocui.Gui) error { + var err error + maxX, _ := g.Size() + helpLabel, err = g.SetView("help", maxX-32, 0, maxX-1, 11, 0) + if err != nil { + if !errors.Is(err, gocui.ErrUnknownView) { + return err + } + fmt.Fprintln(helpLabel, "KEYBINDINGS") + fmt.Fprintln(helpLabel, "Enter: Click Button") + fmt.Fprintln(helpLabel, "Tab/Space: Switch Buttons") + fmt.Fprintln(helpLabel, "") + fmt.Fprintln(helpLabel, "h: Help") + fmt.Fprintln(helpLabel, "Backspace: Delete Button") + fmt.Fprintln(helpLabel, "Arrow keys: Move Button") + fmt.Fprintln(helpLabel, "t: Move Button to the top") + fmt.Fprintln(helpLabel, "b: Move Button to the button") + fmt.Fprintln(helpLabel, "Ctrl-C or Q: Exit") + } + return nil +} diff --git a/examples/console-ui-helloworld/newJ.go b/examples/console-ui-helloworld/newJ.go new file mode 100644 index 0000000..47c7439 --- /dev/null +++ b/examples/console-ui-helloworld/newJ.go @@ -0,0 +1,46 @@ +// 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 ( + "errors" + "fmt" + "log" + "strings" + + "github.com/awesome-gocui/gocui" +) + +var topX int = 2 +var bottomX int = 20 +var topY int = 2 +var bottomY int = 7 + +func newJ(g *gocui.Gui) error { + // maxX, maxY := g.Size() + name := fmt.Sprintf("jcarr %v test ", idxView) + v, err := g.SetView(name, topX, topY, bottomX, bottomY, 0) + if err == nil { + return err + } + if !errors.Is(err, gocui.ErrUnknownView) { + return err + } + + v.Wrap = true + fmt.Fprintln(v, name) + fmt.Fprintln(v, strings.Repeat("foo\n", 2)) + // fmt.Fprintln(v, strings.Repeat(name+" ", 30)) + log.Println("newJ added a new view", v.Name()) + + if _, err := g.SetCurrentView(name); err != nil { + return err + } + + views = append(views, name) + curView = len(views) - 1 + idxView += 1 + return nil +} diff --git a/examples/console-ui-helloworld/views.go b/examples/console-ui-helloworld/views.go new file mode 100644 index 0000000..50287c2 --- /dev/null +++ b/examples/console-ui-helloworld/views.go @@ -0,0 +1,114 @@ +// 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 ( + "errors" + "fmt" + "log" + "strings" + + "github.com/awesome-gocui/gocui" +) + +func addGroup(name string) { + log.Println("addGroup()", name) + currentY = 2 + currentX += groupSize + 6 +} + +func addButton(name string) error { + t := len(name) + v, err := baseGui.SetView(name, currentX, currentY, currentX+t+3, currentY+2, 0) + if err == nil { + return err + } + if !errors.Is(err, gocui.ErrUnknownView) { + return err + } + + v.Wrap = true + fmt.Fprintln(v, " " + name) + fmt.Fprintln(v, strings.Repeat("foo\n", 2)) + + if _, err := baseGui.SetCurrentView(name); err != nil { + return err + } + + views = append(views, name) + curView = len(views) - 1 + idxView += 1 + currentY += 3 + if (groupSize < len(views)) { + groupSize = len(views) + } + return nil +} + +func newView(g *gocui.Gui) error { + maxX, maxY := g.Size() + name := fmt.Sprintf("v%v", idxView) + v, err := g.SetView(name, maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5, 0) + if err == nil { + return err + } + if !errors.Is(err, gocui.ErrUnknownView) { + return err + } + + v.Wrap = true + fmt.Fprintln(v, strings.Repeat(name+" ", 30)) + + if _, err := g.SetCurrentView(name); err != nil { + return err + } + + views = append(views, name) + curView = len(views) - 1 + idxView += 1 + return nil +} + +func delView(g *gocui.Gui) error { + if len(views) <= 1 { + return nil + } + + if err := g.DeleteView(views[curView]); err != nil { + return err + } + views = append(views[:curView], views[curView+1:]...) + + return nextView(g, false) +} + +func nextView(g *gocui.Gui, disableCurrent bool) error { + next := curView + 1 + if next > len(views)-1 { + next = 0 + } + + if _, err := g.SetCurrentView(views[next]); err != nil { + return err + } + + curView = next + return nil +} + +func moveView(g *gocui.Gui, v *gocui.View, dx, dy int) error { + name := v.Name() + x0, y0, x1, y1, err := g.ViewPosition(name) + if err != nil { + return err + } + log.Println(x0, y0, x1, y1) + if _, err := g.SetView(name, x0+dx, y0+dy, x1+dx, y1+dy, 0); err != nil { + return err + } + x0, y0, x1, y1, err = g.ViewPosition(name) + log.Println(x0, y0, x1, y1) + return nil +} diff --git a/examples/example_test.go b/examples/example_test.go new file mode 100644 index 0000000..f65cad1 --- /dev/null +++ b/examples/example_test.go @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package gui_test + +import ( + "git.wit.org/wit/gui" +) + +// This example demonstrates how to create a NewWindow() +// +// Interacting with a GUI in a cross platform fashion adds some +// unusual problems. To obvuscate those, andlabs/ui starts a +// goroutine that interacts with the native gui toolkits +// on the Linux, MacOS, Windows, etc. +// +// Because of this oddity, to initialize a new window, the +// function is not passed any arguements and instead passes +// the information via the Config type. +// +func ExampleNewWindow() { + // Define the name and size + gui.Config.Title = "WIT GUI Window 1" + gui.Config.Width = 640 + gui.Config.Height = 480 + + // Create the Window + gui.NewWindow() + + // Output: + // You get a window +} diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile new file mode 100644 index 0000000..961ed8c --- /dev/null +++ b/examples/helloworld/Makefile @@ -0,0 +1,14 @@ +run: build + ./helloworld + +build-release: + go get -v -u -x . + go build + ./helloworld + +build: + GO111MODULE="off" go get -v -x . + GO111MODULE="off" go build + +update: + GO111MODULE="off" go get -v -u -x . diff --git a/examples/helloworld/main.go b/examples/helloworld/main.go new file mode 100644 index 0000000..3d8ba40 --- /dev/null +++ b/examples/helloworld/main.go @@ -0,0 +1,23 @@ +// This is a simple example +package main + +import ( + "log" + "git.wit.org/wit/gui" +) + +func main() { + helloworld() + // This is just a optional goroutine to watch that things are alive + gui.Watchdog() +} + +// This creates a window +func helloworld() { + myGui := gui.New().Default() + myWindow := myGui.NewWindow("helloworld golang wit/gui window") + + myWindow.NewButton("hello", func () { + log.Println("world") + }) +} diff --git a/go.mod b/go.mod index 83a8db6..b6c0a30 100644 --- a/go.mod +++ b/go.mod @@ -1,22 +1,25 @@ -module git.wit.org/wit/gui +module gui -go 1.18 +go 1.21.1 require ( + git.wit.org/wit/gui v0.8.6 github.com/alexflint/go-arg v1.4.3 github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e github.com/awesome-gocui/gocui v1.1.0 - github.com/davecgh/go-spew v1.1.1 - golang.org/x/image v0.0.0-20221017200508-ffcb3fe7d1bf ) require ( github.com/alexflint/go-scalar v1.2.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/gdamore/encoding v1.0.0 // indirect github.com/gdamore/tcell/v2 v2.6.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/rivo/uniseg v0.4.4 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.9.0 // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/term v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect diff --git a/go.sum b/go.sum index 820b861..460ca76 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +git.wit.org/wit/gui v0.8.6 h1:n4V1eSm2LPmObGniX8kTQPT07xxumV5rPuDlXVGz/n8= +git.wit.org/wit/gui v0.8.6/go.mod h1:Bzt8Nzznjmo4AjBZtMg+wJEFNdpGvP6amxacVLgVCWg= github.com/alexflint/go-arg v1.4.3 h1:9rwwEBpMXfKQKceuZfYcwuc/7YY7tWJbFsgG5cAU/uo= github.com/alexflint/go-arg v1.4.3/go.mod h1:3PZ/wp/8HuqRZMUUgu7I+e1qcpUbvmS258mRXkFH4IA= github.com/alexflint/go-scalar v1.1.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= @@ -27,18 +29,19 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs= -golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 h1:Lj6HJGCSn5AjxRAH2+r35Mir4icalbqku+CLUtjnvXY= -golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= -golang.org/x/image v0.0.0-20221017200508-ffcb3fe7d1bf h1:nq7IoIHc0jQHd2/cn0Oedp7Z9gH80pVTiDd9bF7u+O4= -golang.org/x/image v0.0.0-20221017200508-ffcb3fe7d1bf/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -59,9 +62,7 @@ golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/plugin.go b/plugin.go index 42dc7cc..c43b4af 100644 --- a/plugin.go +++ b/plugin.go @@ -129,9 +129,10 @@ func searchPaths(name string) *aplug { return p } } else { - log(logError, filename, "was not embedded. Error:", err) + log(logError, filename, "was not embedded in the binary. Error:", err) } + log(logError, "fuck off") // attempt to write out the file from the internal resource filename = "toolkit/" + name + ".so" p := initToolkit(name, filename) @@ -167,12 +168,20 @@ func searchPaths(name string) *aplug { // load module // 1. open the shared object file to load the symbols func initToolkit(name string, filename string) *aplug { + if _, err := os.Stat(filename); err != nil { + if os.IsNotExist(err) { + log(true, "missing plugin", name, "as filename", filename) + return nil + } + } + log(true, "Found plugin", name, "as filename", filename) + plug, err := plugin.Open(filename) if err != nil { - log(debugGui, "plugin FAILED =", filename, err) + log(debugError, "plugin FAILED =", filename, err) return nil } - log(debugGui, "initToolkit() loading plugin =", filename) + log(debugPlugin, "initToolkit() loading plugin =", filename) var newPlug *aplug newPlug = new(aplug) -- cgit v1.2.3