From 36514cbb6818dd06e13b2dff20fa4f0ac67ce545 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 25 Mar 2025 08:56:33 -0500 Subject: fix arrow up & down on scrolling stdout --- eventBindingsStdout.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'eventBindingsStdout.go') diff --git a/eventBindingsStdout.go b/eventBindingsStdout.go index f1c574e..8387ea2 100644 --- a/eventBindingsStdout.go +++ b/eventBindingsStdout.go @@ -77,14 +77,12 @@ func stdoutHome(g *gocui.Gui, v *gocui.View) error { } func stdoutArrowUp(g *gocui.Gui, v *gocui.View) error { - me.stdout.pager += 1 - me.stdout.tk.refreshStdout() + stdoutWheelsUp() return nil } func stdoutArrowDown(g *gocui.Gui, v *gocui.View) error { - me.stdout.pager -= 1 - me.stdout.tk.refreshStdout() + stdoutWheelsDown() return nil } @@ -103,3 +101,23 @@ func stdoutPgdn(g *gocui.Gui, v *gocui.View) error { tk.refreshStdout() return nil } + +// scrolling up with the mouse wheel (or trackpad) +func stdoutWheelsUp() { + // log.Info("private wheels up") + me.stdout.pager -= 2 + if me.stdout.pager < 0 { + me.stdout.pager = 0 + } + me.stdout.tk.refreshStdout() +} + +// scrolling down with the mouse wheel (or trackpad) +func stdoutWheelsDown() { + // log.Info("you've landed") + me.stdout.pager += 2 + if me.stdout.pager > len(me.stdout.outputS) { + me.stdout.pager = len(me.stdout.outputS) + } + me.stdout.tk.refreshStdout() +} -- cgit v1.2.3