From 86aa5fb001bb873da1a491391f12b17a1a1990a0 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 3 Sep 2025 01:56:01 -0500 Subject: [PATCH] reverse in STDOUT is no longer the default --- eventBindings.go | 14 ++++++++++++++ eventBindingsStdout.go | 12 ++++++++++-- help.go | 20 ++++++++++++-------- stdoutShow.go | 4 +++- structs.go | 1 + 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/eventBindings.go b/eventBindings.go index 5e06f8b..d355156 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -58,6 +58,7 @@ func registerHandlers(g *gocui.Gui) { g.SetKeybinding("", 'L', gocui.ModNone, printWidgetTree) // 'L' list all widgets in tree view g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons + g.SetKeybinding("", 'r', gocui.ModNone, reverseStdout) // 'r' turns scrolling of STDOUT upside down g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?) } @@ -184,6 +185,19 @@ func theFind(g *gocui.Gui, v *gocui.View) error { return nil } +func reverseStdout(g *gocui.Gui, v *gocui.View) error { + if me.stdout.reverse { + me.stdout.reverse = false + log.Info("stdout scrolling normal") + } else { + me.stdout.reverse = true + log.Info("stdout scrolling is reversed. this is sometimes useful when you") + log.Info("only need to see a few most recent lines and have the STDOUT window") + log.Info("take up minimal realestate at the bottom of your window") + } + return nil +} + // is run whenever anyone hits 'd' (in an open space) func theLetterD(g *gocui.Gui, v *gocui.View) error { // widgets that don't have physical existance in diff --git a/eventBindingsStdout.go b/eventBindingsStdout.go index 8387ea2..8e59b7d 100644 --- a/eventBindingsStdout.go +++ b/eventBindingsStdout.go @@ -77,12 +77,20 @@ func stdoutHome(g *gocui.Gui, v *gocui.View) error { } func stdoutArrowUp(g *gocui.Gui, v *gocui.View) error { - stdoutWheelsUp() + if me.stdout.reverse { + stdoutWheelsDown() + } else { + stdoutWheelsUp() + } return nil } func stdoutArrowDown(g *gocui.Gui, v *gocui.View) error { - stdoutWheelsDown() + if me.stdout.reverse { + stdoutWheelsUp() + } else { + stdoutWheelsDown() + } return nil } diff --git a/help.go b/help.go index 21e39b1..3d07f92 100644 --- a/help.go +++ b/help.go @@ -25,16 +25,20 @@ import ( var helpText []string = []string{"Help Menu", "", - "Tab: toggle through windows", - "'O': toggle STDOUT", - "'H': toggle this gocui menu", - "'D': toggle light/dark mode", - "CTRL-c: quit()", + "Tab toggle through windows", + "'O' toggle STDOUT", + "'H' toggle this gocui menu", + "'D' toggle light/dark mode", + "CTRL-z background to shell", + "CTRL-c quit()", "", "Debugging:", - "'S': Supermouse mode", - "'M': list all widget positions", - "'L': list all widgets in tree", + "'S' Supermouse mode", + "'M' list all widget positions", + "'L' list all widgets in tree", + " scroll up the STDOUT window", + " scroll down the STDOUT window", + "'r' reverse STDOUT scrolling", } func hideHelp() { diff --git a/stdoutShow.go b/stdoutShow.go index 429294c..9d67d5e 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -211,7 +211,9 @@ func (tk *guiWidget) refreshStdout() { // 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) + if me.stdout.reverse { + slices.Reverse(cur) + } tk.v.Clear() fmt.Fprintln(tk.v, strings.Join(cur, "\n")) } diff --git a/structs.go b/structs.go index c9337b1..97c9dae 100644 --- a/structs.go +++ b/structs.go @@ -120,6 +120,7 @@ type stdout struct { outputS []string // the buffer of all the output pager int // allows the user to page through the buffer changed bool // indicates the user has changed stdout. gocui should remember the state here + reverse bool // flip the STDOUT upside down so new STDOUT lines are at the top } // settings for the dropdown window