diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-28 13:44:20 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-28 14:02:53 +1100 |
commit | 229f5ee48c75ca0c8a78345f9da44dc4b2b2e625 (patch) | |
tree | c30bdf055d06816272814406d2aed15477bfa724 /pkg/gui/list_view.go | |
parent | 96c7741ba06359cbc253e615e3160a905512330c (diff) |
add keybindings for paging in list panels and jumping to top/bottom
Diffstat (limited to 'pkg/gui/list_view.go')
-rw-r--r-- | pkg/gui/list_view.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pkg/gui/list_view.go b/pkg/gui/list_view.go index 90ea7b8b0..99039eb13 100644 --- a/pkg/gui/list_view.go +++ b/pkg/gui/list_view.go @@ -42,6 +42,40 @@ func (lv *listView) handleLineChange(change int) error { return lv.handleItemSelect(lv.gui.g, view) } +func (lv *listView) handleNextPage(g *gocui.Gui, v *gocui.View) error { + view, err := lv.gui.g.View(lv.viewName) + if err != nil { + return nil + } + _, height := view.Size() + delta := height - 1 + if delta == 0 { + delta = 1 + } + return lv.handleLineChange(delta) +} + +func (lv *listView) handleGotoTop(g *gocui.Gui, v *gocui.View) error { + return lv.handleLineChange(-lv.getItemsLength()) +} + +func (lv *listView) handleGotoBottom(g *gocui.Gui, v *gocui.View) error { + return lv.handleLineChange(lv.getItemsLength()) +} + +func (lv *listView) handlePrevPage(g *gocui.Gui, v *gocui.View) error { + view, err := lv.gui.g.View(lv.viewName) + if err != nil { + return nil + } + _, height := view.Size() + delta := height - 1 + if delta == 0 { + delta = 1 + } + return lv.handleLineChange(-delta) +} + func (lv *listView) handleClick(g *gocui.Gui, v *gocui.View) error { if !lv.gui.isPopupPanel(lv.viewName) && lv.gui.popupPanelFocused() { return nil |