From 87098cee7b70679849e76ba608f28f1b94a5316e Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Sat, 22 Dec 2018 00:43:59 +0100 Subject: 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. --- termui/bug_table.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'termui') 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) } -- cgit