From 517d844b3c8257dd796244e6a151deceabedab42 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 2 Feb 2025 13:06:30 -0600 Subject: [PATCH] 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 => treeCallback.go | 0 7 files changed, 21 insertions(+), 9 deletions(-) rename tree.go => treeCallback.go (100%) 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/treeCallback.go similarity index 100% rename from tree.go rename to treeCallback.go