summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-06 20:59:15 -0600
committerJeff Carr <[email protected]>2025-02-06 20:59:15 -0600
commit0b265d2b72a474c11512982ce937d7323ff8b41c (patch)
treebc82ce208687414abfb2346fb1cefd1c7764c951
parent5d1a3b2578580bd2d41e47d3ab3e6f48411c8613 (diff)
stdout paging updates
-rw-r--r--eventBindings.go28
-rw-r--r--stdoutShow.go16
2 files changed, 26 insertions, 18 deletions
diff --git a/eventBindings.go b/eventBindings.go
index eaf8d92..16d5549 100644
--- a/eventBindings.go
+++ b/eventBindings.go
@@ -5,7 +5,6 @@ package main
import (
"fmt"
- "slices"
"strings"
"syscall"
@@ -104,28 +103,20 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
}
func stdoutPgup(g *gocui.Gui, v *gocui.View) error {
- me.stdout.pager = 0
- log.Info(fmt.Sprintf("try to page up in the stdout buffer here pager=%d len(%d)", me.stdout.pager, len(me.stdout.outputS)))
+ me.stdout.pager -= 40
+ if me.stdout.pager < 0 {
+ me.stdout.pager = 0
+ }
+ tk := me.stdout.tk
+ tk.refreshStdout()
return nil
}
func stdoutPgdn(g *gocui.Gui, v *gocui.View) error {
me.stdout.pager += 10
- log.Info(fmt.Sprintf("try to page down in the stdout buffer here pager=%d len(%d)", me.stdout.pager, len(me.stdout.outputS)))
- tk := me.stdout.tk
-
- 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)))
- return nil
- }
- var cur []string
- // chop off the last lines in the buffer
- chop := len(me.stdout.outputS) - (me.stdout.pager + me.stdout.h)
- cur = append(cur, me.stdout.outputS[chop:chop+me.stdout.h]...)
- slices.Reverse(cur)
- tk.v.Clear()
- fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
+ tk := me.stdout.tk
+ tk.refreshStdout()
return nil
}
@@ -155,10 +146,11 @@ func tabCycleWindows(g *gocui.Gui, v *gocui.View) error {
}
func theStdout(g *gocui.Gui, v *gocui.View) error {
+ me.stdout.pager = 0
if me.stdout.outputOnTop {
if me.stdout.outputOffscreen {
me.stdout.outputOffscreen = false
- log.Info("set stdout off screen here")
+ log.Info(fmt.Sprintf("set stdout off screen pager=%d len(%d)", me.stdout.pager, len(me.stdout.outputS)))
relocateStdoutOffscreen()
return nil
} else {
diff --git a/stdoutShow.go b/stdoutShow.go
index 61f2246..24f1e66 100644
--- a/stdoutShow.go
+++ b/stdoutShow.go
@@ -175,3 +175,19 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
return len(p), nil
}
+
+// lets the user page up and down through the stdout buffer
+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)))
+ return
+ }
+
+ var cur []string
+ // chop off the last lines in the buffer
+ chop := len(me.stdout.outputS) - (me.stdout.pager + me.stdout.h)
+ cur = append(cur, me.stdout.outputS[chop:chop+me.stdout.h]...)
+ slices.Reverse(cur)
+ tk.v.Clear()
+ fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
+}