From eba5ea8cc072e950df19ad5b97e3c99794ab790e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 9 Feb 2025 01:46:04 -0600 Subject: [PATCH] leave this code as a reminder for later --- init.go | 16 +++++++++++++--- stdoutShow.go | 30 +----------------------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/init.go b/init.go index 4810658..a743f74 100644 --- a/init.go +++ b/init.go @@ -263,11 +263,21 @@ func refreshGocui() { me.clock.tk.v.WriteString(me.clock.tk.labelN) } } + lastRefresh = time.Now() } else { - // log.Info("refresh skip on mouseDown") - // me.baseGui.Update() + me.baseGui.Update(testRefresh) + if time.Since(lastRefresh) > 3*time.Second { + if me.clock.tk != nil && !me.showHelp { + // also double check the gocui view exists + if me.clock.tk.v != nil { + me.clock.tk.v.Clear() + me.clock.tk.labelN = time.Now().Format("15:04:05") + me.clock.tk.v.WriteString(me.clock.tk.labelN) + } + } + lastRefresh = time.Now() + } } - lastRefresh = time.Now() } } } diff --git a/stdoutShow.go b/stdoutShow.go index 2c9cd58..a17ef2f 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -163,6 +163,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { return len(p), nil } if tk.v == nil { + // redo this old code v, _ := me.baseGui.View("msg") if v != nil { // fmt.Fprintln(outf, "found msg") @@ -171,35 +172,6 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { return len(p), nil } tk.refreshStdout() - /* - // optionally write the output to /tmp - s := fmt.Sprint(string(p)) - s = strings.TrimSuffix(s, "\n") - fmt.Fprintln(outf, s) - v, _ := me.baseGui.View("msg") - if v != nil { - // fmt.Fprintln(outf, "found msg") - tk.v = v - } - } else { - // display the output in the gocui window - var cur []string - // chop off the last lines in the buffer - chop := len(me.stdout.outputS) - (me.stdout.h - 1) - if chop < 0 { - chop = 0 - } - if len(me.stdout.outputS) > chop { - cur = append(cur, me.stdout.outputS[chop:]...) - } else { - cur = append(cur, me.stdout.outputS...) - } - slices.Reverse(cur) - tk.v.Clear() - fmt.Fprintln(tk.v, strings.Join(cur, "\n")) - } - */ - return len(p), nil }