From b8b8a409ea77f457bbb3490f5282bf9b3ff88c3e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 9 Feb 2025 01:40:57 -0600 Subject: show stdout buffer when it is small --- stdoutShow.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'stdoutShow.go') diff --git a/stdoutShow.go b/stdoutShow.go index 5e3b305..2c9cd58 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -133,6 +133,13 @@ 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) Height() int { + if w.tk == nil { + return 40 + } + return w.tk.gocuiSize.Height() - 2 +} + func (w stdout) Write(p []byte) (n int, err error) { me.writeMutex.Lock() defer me.writeMutex.Unlock() @@ -200,6 +207,11 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { func (tk *guiWidget) refreshStdout() { if len(me.stdout.outputS) < me.stdout.h+me.stdout.pager { // log.Info(fmt.Sprintf("buffer too small=%d len(%d)", me.stdout.pager, len(me.stdout.outputS))) + var cur []string + cur = append(cur, me.stdout.outputS...) + slices.Reverse(cur) + tk.v.Clear() + fmt.Fprintln(tk.v, strings.Join(cur, "\n")) return } -- cgit v1.2.3