aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-12-23 21:16:27 +0100
committerMichael Muré <batolettre@gmail.com>2018-12-23 21:16:27 +0100
commitfb87d44888ff7d7e528156c6d4b7b508e17ddbae (patch)
tree2ea7e285bd45a05342021079eceb199ded2468b5 /termui
parent87098cee7b70679849e76ba608f28f1b94a5316e (diff)
downloadgit-bug-fb87d44888ff7d7e528156c6d4b7b508e17ddbae.tar.gz
termui: don't reset the cursor when paginating with left/right
See https://github.com/MichaelMure/git-bug/pull/83 for the rationale
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index 36ce7525..091e9b99 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -343,7 +343,17 @@ func (bt *bugTable) cursorDown(g *gocui.Gui, v *gocui.View) error {
// 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)
+ _, max := v.Size()
+
+ if bt.pageCursor+max >= len(bt.allIds) {
+ return nil
+ }
+
+ bt.pageCursor += max
+ bt.selectCursor = 0
+ _ = v.SetCursor(0, bt.selectCursor)
+
+ return bt.doPaginate(max)
}
y = minInt(y+1, bt.getTableLength()-1)
@@ -359,7 +369,17 @@ func (bt *bugTable) cursorUp(g *gocui.Gui, v *gocui.View) error {
// If we are at the top of the page, switch to the previous one.
if y-1 < 0 {
- return bt.previousPage(g, v)
+ _, 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)
}
y = maxInt(y-1, 0)
@@ -391,8 +411,6 @@ 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)
}
@@ -403,9 +421,8 @@ func (bt *bugTable) previousPage(g *gocui.Gui, v *gocui.View) error {
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)
}