summaryrefslogtreecommitdiff
path: root/stdoutShow.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-09 01:40:57 -0600
committerJeff Carr <[email protected]>2025-02-09 01:40:57 -0600
commitb8b8a409ea77f457bbb3490f5282bf9b3ff88c3e (patch)
treed584d7cefb0bf6a1976d9b16567e25d57621c39b /stdoutShow.go
parent010bd2a33fc64e182fe1190e11d6ef2f841088f8 (diff)
show stdout buffer when it is small
Diffstat (limited to 'stdoutShow.go')
-rw-r--r--stdoutShow.go12
1 files changed, 12 insertions, 0 deletions
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
}