diff options
| author | Jeff Carr <[email protected]> | 2025-03-25 07:27:37 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-25 13:17:00 -0500 |
| commit | 1552eedc185e85b46498898e68867afaef308301 (patch) | |
| tree | 8fc5cdfbc77cde184842197b2cde5cce8d85d34b | |
| parent | 4523eda0fa2372d97fb5db800b79b53c218ef627 (diff) | |
save the output window state
| -rw-r--r-- | debug.go | 3 | ||||
| -rw-r--r-- | eventBindingsStdout.go | 22 | ||||
| -rw-r--r-- | eventMouseDrag.go | 2 | ||||
| -rw-r--r-- | find.go | 14 | ||||
| -rw-r--r-- | init.go | 28 | ||||
| -rw-r--r-- | plugin.go | 2 | ||||
| -rw-r--r-- | structs.go | 10 | ||||
| -rw-r--r-- | table.go | 15 | ||||
| -rw-r--r-- | widgetAdd.go (renamed from treeAdd.go) | 0 | ||||
| -rw-r--r-- | widgetCommon.go (renamed from treeWidget.go) | 0 | ||||
| -rw-r--r-- | widgetDraw.go (renamed from treeDraw.go) | 0 |
11 files changed, 76 insertions, 20 deletions
@@ -86,6 +86,9 @@ func (tk *guiWidget) dumpWidget(s string) { } else { end = fmt.Sprintf("%-8s %-8s %s", tk.WidgetType(), tk.cuiName, tk.String()) } + if tk.findParentTable() != nil { + end += " (table)" + } log.Log(GOCUI, s1, s, end) } diff --git a/eventBindingsStdout.go b/eventBindingsStdout.go index f48ed77..f1c574e 100644 --- a/eventBindingsStdout.go +++ b/eventBindingsStdout.go @@ -8,12 +8,14 @@ import ( "github.com/awesome-gocui/gocui" "go.wit.com/log" + "go.wit.com/toolkits/tree" ) func theStdout(g *gocui.Gui, v *gocui.View) error { // me.stdout.pager = 0 infos := fmt.Sprintf("pager=%d len(%d) ", me.stdout.pager, len(me.stdout.outputS)) infos += fmt.Sprintf("last(%d,%d)", me.stdout.lastW, me.stdout.lastH) + me.stdout.changed = true if me.stdout.outputOnTop { if me.stdout.outputOffscreen { @@ -22,18 +24,38 @@ func theStdout(g *gocui.Gui, v *gocui.View) error { me.stdout.lastW = me.stdout.tk.gocuiSize.w0 me.stdout.lastH = me.stdout.tk.gocuiSize.h0 relocateStdoutOffscreen() + new1 := new(tree.ToolkitConfig) + new1.Plugin = "gocui" + new1.Name = "stdoutoffscreen" + new1.Value = "true" + me.myTree.ConfigSave(new1) return nil } else { me.stdout.outputOffscreen = true log.Info("stdout moved on screen", infos) + new1 := new(tree.ToolkitConfig) + new1.Plugin = "gocui" + new1.Name = "stdoutoffscreen" + new1.Value = "false" + me.myTree.ConfigSave(new1) } // move the stdout window back onscreen me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) me.stdout.outputOnTop = false setThingsOnTop() + new1 := new(tree.ToolkitConfig) + new1.Plugin = "gocui" + new1.Name = "stdoutlevel" + new1.Value = "bottom" + me.myTree.ConfigSave(new1) } else { me.stdout.outputOnTop = true setThingsOnTop() + new1 := new(tree.ToolkitConfig) + new1.Plugin = "gocui" + new1.Name = "stdoutlevel" + new1.Value = "top" + me.myTree.ConfigSave(new1) } return nil } diff --git a/eventMouseDrag.go b/eventMouseDrag.go index 5559fac..62aa916 100644 --- a/eventMouseDrag.go +++ b/eventMouseDrag.go @@ -48,6 +48,7 @@ func mouseMove(g *gocui.Gui) { // old hack. create the 'msg' view if it does not yet exist // TODO: put this somewhere more correct if widgetView, _ := g.View("msg"); widgetView == nil { + me.stdout.changed = true if createStdout(g) { return } @@ -138,5 +139,6 @@ func (tk *guiWidget) moveNew() { // log.Info("Resize false", w, h, newW, newH) } setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn + me.stdout.changed = true } } @@ -186,6 +186,20 @@ func (tk *guiWidget) findParentWindow() *guiWidget { return tk.parent.findParentWindow() } +func (tk *guiWidget) findParentTable() *guiWidget { + if tk.isTable { + log.Info("findParentTAble()", tk.labelN, tk.cuiName, tk.node.WidgetId) + return tk + } + if tk.node.WidgetId == 0 { + return nil + } + if tk.parent == nil { + return nil + } + return tk.parent.findParentWindow() +} + func (tk *guiWidget) findWidgetByName(name string) *guiWidget { if tk.cuiName == name { return tk @@ -14,10 +14,13 @@ import ( "runtime" "runtime/debug" "runtime/pprof" + "strconv" + "strings" "time" "github.com/awesome-gocui/gocui" "go.wit.com/log" + "go.wit.com/toolkits/tree" ) // sent via -ldflags @@ -184,6 +187,19 @@ func initPlugin() { me.stdout.lastW = 4 me.stdout.lastH = 20 + if val, err := me.myTree.ConfigFind("stdoutsize"); err == nil { + parts := strings.Fields(val) + if len(parts) == 4 { + log.Info("initial stdout settings:", parts) + me.stdout.w, _ = strconv.Atoi(parts[0]) + me.stdout.h, _ = strconv.Atoi(parts[1]) + me.stdout.lastW, _ = strconv.Atoi(parts[2]) + me.stdout.lastH, _ = strconv.Atoi(parts[3]) + } else { + log.Info("initial stdout settings parse error:", parts) + } + } + // just make up unique values for these me.dropdown.wId = -77 me.textbox.wId = -55 @@ -376,6 +392,18 @@ func refreshGocui() { me.newWindowTrigger <- me.treeRoot.TK.(*guiWidget) me.refresh = false } + if me.stdout.changed { + log.Log(NOW, "newWindowTrigger() TODO: gocui should save the stdout size & location here") + me.stdout.changed = false + me.stdout.tk.dumpWidget("save") + new1 := new(tree.ToolkitConfig) + new1.Plugin = "gocui" + new1.Name = "stdoutsize" + width := me.stdout.tk.gocuiSize.w1 - me.stdout.tk.gocuiSize.w0 + height := me.stdout.tk.gocuiSize.h1 - me.stdout.tk.gocuiSize.h0 + new1.Value = fmt.Sprintf("%d %d %d %d", width, height, me.stdout.tk.gocuiSize.w0, me.stdout.tk.gocuiSize.h0) + me.myTree.ConfigSave(new1) + } } // this code updates the clock @@ -16,7 +16,7 @@ func newAdd(n *tree.Node) { return } if n.TK != nil { - log.Warn("Tree Add() sent a widget we aleady seem to have") + log.Log(INFO, "Tree Add() sent a widget we aleady seem to have") // this is done to protect the plugin being 'refreshed' with the // widget binary tree. TODO: find a way to keep them in sync return @@ -116,11 +116,10 @@ type stdout struct { disable bool // disable the stdout window. do not change os.Stdout & os.Stderr lastW int // the last 'w' location (used to move from offscreen to onscreen) lastH int // the last 'h' location (used to move from offscreen to onscreen) - // mouseOffsetW int // the current 'w' offset - // mouseOffsetH int // the current 'h' offset - init bool // moves the window offscreen on startup - outputS []string // the buffer of all the output - pager int // allows the user to page through the buffer + init bool // moves the window offscreen on startup + outputS []string // the buffer of all the output + pager int // allows the user to page through the buffer + changed bool // indicates the user has changed stdout. gocui should remember the state here } // settings for the dropdown window @@ -241,6 +240,7 @@ type guiWidget struct { color *colorT // what color to use colorLast colorT // the last color the widget had defaultColor *colorT // the default colors // TODO: make a function for this instead + isTable bool // is this a table? } // THIS IS GO COMPILER MAGIC @@ -13,20 +13,6 @@ import ( "go.wit.com/widget" ) -/* -func initGridPB(pb *guipb.Widget) *guiWidget { - var w *guiWidget - w = new(guiWidget) - - w.pb = pb - w.parent = me.treeRoot.TK.(*guiWidget) - w.wtype = widget.Window - w.cuiName = fmt.Sprintf("%d %s", pb.Id, "TK") - w.labelN = pb.Name - return w -} -*/ - func initGridPB(pb *guipb.Widget) *guiWidget { var w *guiWidget w = new(guiWidget) @@ -35,6 +21,7 @@ func initGridPB(pb *guipb.Widget) *guiWidget { w.wtype = widget.Grid w.cuiName = fmt.Sprintf("%d %s", pb.Id, "TK") w.labelN = pb.Name + w.isTable = true return w } diff --git a/treeAdd.go b/widgetAdd.go index 6bb459b..6bb459b 100644 --- a/treeAdd.go +++ b/widgetAdd.go diff --git a/treeWidget.go b/widgetCommon.go index 15d269c..15d269c 100644 --- a/treeWidget.go +++ b/widgetCommon.go diff --git a/treeDraw.go b/widgetDraw.go index d678678..d678678 100644 --- a/treeDraw.go +++ b/widgetDraw.go |
