From c4f9bac85eeafb4916b57d6f8953fa930d6d098e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 8 Feb 2025 13:28:19 -0600 Subject: add config default to show stdout onscreen on start --- stdoutShow.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'stdoutShow.go') diff --git a/stdoutShow.go b/stdoutShow.go index f74bf80..5f980bd 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -95,6 +95,13 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { me.stdout.tk.v = v me.stdout.tk.DrawAt(me.stdout.lastW, me.stdout.lastH) relocateStdoutOffscreen() + /* + if me.stdout.outputOffscreen { + me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) + } else { + relocateStdoutOffscreen() + } + */ return v } @@ -135,12 +142,24 @@ func (tk *guiWidget) relocateStdout(w int, h int) { // of functions like fmt.Fprintf, fmt.Fprintln, io.Copy, etc. Clear must // be called to clear the view's buffer. +func (w stdout) Write(p []byte) (n int, err error) { + me.writeMutex.Lock() + defer me.writeMutex.Unlock() + + lines := strings.Split(strings.TrimSpace(string(p)), "\n") + me.stdout.outputS = append(me.stdout.outputS, lines...) + + return len(p), nil +} + func (w *guiWidget) Write(p []byte) (n int, err error) { w.tainted = true me.writeMutex.Lock() defer me.writeMutex.Unlock() tk := me.stdout.tk + lines := strings.Split(strings.TrimSpace(string(p)), "\n") + me.stdout.outputS = append(me.stdout.outputS, lines...) if tk.v == nil { // optionally write the output to /tmp @@ -154,9 +173,6 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { } } else { // display the output in the gocui window - lines := strings.Split(strings.TrimSpace(string(p)), "\n") - me.stdout.outputS = append(me.stdout.outputS, lines...) - var cur []string // chop off the last lines in the buffer chop := len(me.stdout.outputS) - (me.stdout.h - 1) -- cgit v1.2.3