From 517d844b3c8257dd796244e6a151deceabedab42 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 2 Feb 2025 13:06:30 -0600 Subject: more work on the ever illusive floating stdout window --- Makefile | 10 +++++++--- debug.go | 4 ++++ eventBindings.go | 1 - eventMouseClick.go | 1 - init.go | 8 ++++---- plugin.go | 6 ++++++ tree.go | 32 -------------------------------- treeCallback.go | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 53 insertions(+), 41 deletions(-) delete mode 100644 tree.go create mode 100644 treeCallback.go diff --git a/Makefile b/Makefile index 97cef99..59b21f6 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,14 @@ VERSION = $(shell git describe --tags) BUILDTIME = $(shell date +%Y.%m.%d) -all: gocui.so - @#ldd gocui.so +all: goimports vet gocui + @ldd gocui.so -gocui.so: goimports +vet: + @GO111MODULE=off go vet + @echo this go plugin builds okay + +gocui: GO111MODULE=off go build -v -work -buildmode=plugin -o gocui.so \ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" diff --git a/debug.go b/debug.go index 37d1c3c..2b740d4 100644 --- a/debug.go +++ b/debug.go @@ -55,6 +55,10 @@ func (w *guiWidget) dumpWidget(s string) { if w.node.WidgetType == widget.Box { end = fmt.Sprintf("%5s %-8s %s", w.cuiName, w.node.WidgetType, w.node.State.Direction.String()) } else { + curval := w.String() + if curval == "" { + curval = w.node.GetLabel() + } end = fmt.Sprintf("%5s %-8s %s", w.cuiName, w.node.WidgetType, w.String()) } log.Log(NOW, s1, s, end) diff --git a/eventBindings.go b/eventBindings.go index 6d2c613..e923f2d 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -124,7 +124,6 @@ func doPanic(g *gocui.Gui, v *gocui.View) error { log.Log(GOCUI, "do panic() here") standardClose() panic("forced panic in gocui") - return nil } func dumpWidgets(g *gocui.Gui, v *gocui.View) error { diff --git a/eventMouseClick.go b/eventMouseClick.go index d473a46..386e2cb 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -132,5 +132,4 @@ func click(g *gocui.Gui, v *gocui.View) error { return nil } */ - return nil } diff --git a/init.go b/init.go index d1028d9..c1e8dc9 100644 --- a/init.go +++ b/init.go @@ -77,9 +77,9 @@ func standardClose() { me.baseGui.Close() log.Log(NOW, "standardExit() doing outf.Close()") outf.Close() - os.Stdin = os.Stdin - os.Stdout = os.Stdout - os.Stderr = os.Stderr + // os.Stdin = os.Stdin + // os.Stdout = os.Stdout + // os.Stderr = os.Stderr log.Log(NOW, "standardExit() send back Quit()") } @@ -110,7 +110,7 @@ func mainGogui() { outf, err = os.OpenFile("/tmp/captureMode.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { - log.Error(err, "error opening file: %v") + log.Info("error opening file:", err) os.Exit(0) } origStdout = os.Stdout diff --git a/plugin.go b/plugin.go index 469a606..a311930 100644 --- a/plugin.go +++ b/plugin.go @@ -40,6 +40,7 @@ func newAdd(n *tree.Node) { w.Show() } +// for gocui as a GUI plugin, SetTitle & SetLabel are identical to SetText func newSetTitle(n *tree.Node, s string) { newSetText(n, s) } @@ -48,6 +49,9 @@ func newSetLabel(n *tree.Node, s string) { newSetText(n, s) } +// newSetText() and newAddText() are simple. They take the event sent +// to the GO plugin from the application and lookup the plugin structure +// then pass that event to gocui. This is the transfer point func newSetText(n *tree.Node, s string) { if n == nil { log.Warn("Tree Error: Add() sent n == nil") @@ -180,6 +184,7 @@ func (w *guiWidget) SetText(text string) { } } +/* func (w *guiWidget) Set(val any) { if w == nil { log.Log(WARN, "Set() w == nil. val =", val) @@ -196,3 +201,4 @@ func (w *guiWidget) Set(val any) { w.labelN = widget.GetString(val) } } +*/ diff --git a/tree.go b/tree.go deleted file mode 100644 index 1ead288..0000000 --- a/tree.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017-2025 WIT.COM Inc. All rights reserved. -// Use of this source code is governed by the GPL 3.0 - -package main - -/* - This is reference code for toolkit developers - - This is how information is passed in GO back to the application - via the GO 'plugin' concept - - TODO: switch this to protocol buffers -*/ - -import ( - "go.wit.com/widget" -) - -// Other goroutines must use this to access the GUI -// -// 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.) -// -// this sets the channel to send user events back from the plugin -func Callback(guiCallback chan widget.Action) { - me.myTree.Callback(guiCallback) -} - -func PluginChannel() chan widget.Action { - return me.myTree.PluginChannel() -} diff --git a/treeCallback.go b/treeCallback.go new file mode 100644 index 0000000..1ead288 --- /dev/null +++ b/treeCallback.go @@ -0,0 +1,32 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +/* + This is reference code for toolkit developers + + This is how information is passed in GO back to the application + via the GO 'plugin' concept + + TODO: switch this to protocol buffers +*/ + +import ( + "go.wit.com/widget" +) + +// Other goroutines must use this to access the GUI +// +// 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.) +// +// this sets the channel to send user events back from the plugin +func Callback(guiCallback chan widget.Action) { + me.myTree.Callback(guiCallback) +} + +func PluginChannel() chan widget.Action { + return me.myTree.PluginChannel() +} -- cgit v1.2.3