From 2a5734892a85804b6c44a0cd8dd22d20fed21d96 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 6 Feb 2025 19:00:00 -0600 Subject: trying to fix Hidden() to use the parent --- eventBindings.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'eventBindings.go') diff --git a/eventBindings.go b/eventBindings.go index e3f1994..eaf8d92 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -5,6 +5,7 @@ package main import ( "fmt" + "slices" "strings" "syscall" @@ -103,12 +104,28 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error { } func stdoutPgup(g *gocui.Gui, v *gocui.View) error { - log.Info("try to page up in the stdout buffer here") + 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))) return nil } func stdoutPgdn(g *gocui.Gui, v *gocui.View) error { - log.Info("try to page down in the stdout buffer here") + 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")) return nil } -- cgit v1.2.3