aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorCyril Roelandt <tipecaml@gmail.com>2018-12-22 00:43:59 +0100
committerCyril Roelandt <tipecaml@gmail.com>2018-12-22 01:39:38 +0100
commit87098cee7b70679849e76ba608f28f1b94a5316e (patch)
tree4018254a0930f4e6d537092f4a12d2387df385e7 /termui
parent1174265e598c40863fc1a16d1b1583aafa0dcd6d (diff)
downloadgit-bug-87098cee7b70679849e76ba608f28f1b94a5316e.tar.gz
Termui: Better position the cursor when changing page.
After moving to the previous page, users probably want to have their cursor on the last entry of the page. When moving to the next page, they probably want it to be on the first entry.
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index cb3f6964..36ce7525 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -391,6 +391,8 @@ func (bt *bugTable) nextPage(g *gocui.Gui, v *gocui.View) error {
}
bt.pageCursor += max
+ bt.selectCursor = 0
+ _ = v.SetCursor(0, bt.selectCursor)
return bt.doPaginate(max)
}
@@ -398,7 +400,12 @@ func (bt *bugTable) nextPage(g *gocui.Gui, v *gocui.View) error {
func (bt *bugTable) previousPage(g *gocui.Gui, v *gocui.View) error {
_, max := v.Size()
+ if bt.pageCursor == 0 {
+ return nil
+ }
bt.pageCursor = maxInt(0, bt.pageCursor-max)
+ bt.selectCursor = max - 1
+ _ = v.SetCursor(0, bt.selectCursor)
return bt.doPaginate(max)
}