From 1552eedc185e85b46498898e68867afaef308301 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 25 Mar 2025 07:27:37 -0500 Subject: save the output window state --- init.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'init.go') diff --git a/init.go b/init.go index b13f634..2820bcf 100644 --- a/init.go +++ b/init.go @@ -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 -- cgit v1.2.3