aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorCyril Roelandt <tipecaml@gmail.com>2018-12-22 00:06:40 +0100
committerCyril Roelandt <tipecaml@gmail.com>2018-12-22 00:06:40 +0100
commit1174265e598c40863fc1a16d1b1583aafa0dcd6d (patch)
tree918a87f8194394983a478ae5044fd979e7f3ec15 /termui
parent47b2aa4cc1c20ae37d846da4ea71e09c0c918192 (diff)
downloadgit-bug-1174265e598c40863fc1a16d1b1583aafa0dcd6d.tar.gz
Termui: switch to the previous/next page when going up/down.
Rather than using 'h' or 'l' to load the previous or next page, allow users to do this automatically when going up or down the list with 'k' or 'j'. This is the default behaviour in mutt, for instance.
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index 1545dbc9..cb3f6964 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -340,8 +340,13 @@ func (bt *bugTable) renderFooter(v *gocui.View, maxX int) {
func (bt *bugTable) cursorDown(g *gocui.Gui, v *gocui.View) error {
_, y := v.Cursor()
- y = minInt(y+1, bt.getTableLength()-1)
+ // If we are at the bottom of the page, switch to the next one.
+ if y+1 > bt.getTableLength()-1 {
+ return bt.nextPage(g, v)
+ }
+
+ y = minInt(y+1, bt.getTableLength()-1)
// window is too small to set the cursor properly, ignoring the error
_ = v.SetCursor(0, y)
bt.selectCursor = y
@@ -351,8 +356,13 @@ func (bt *bugTable) cursorDown(g *gocui.Gui, v *gocui.View) error {
func (bt *bugTable) cursorUp(g *gocui.Gui, v *gocui.View) error {
_, y := v.Cursor()
- y = maxInt(y-1, 0)
+ // If we are at the top of the page, switch to the previous one.
+ if y-1 < 0 {
+ return bt.previousPage(g, v)
+ }
+
+ y = maxInt(y-1, 0)
// window is too small to set the cursor properly, ignoring the error
_ = v.SetCursor(0, y)
bt.selectCursor = y