diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-04 09:42:34 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-05 07:58:21 +1100 |
commit | 1d40d03bb222c03e42771e185f4da6fa277faae9 (patch) | |
tree | fdf2e26ebb059647d9a2a04360d87945b7b0cf4a /pkg/gui/list_context.go | |
parent | 9a9e3d506d5aa22d06f2adfc25427200c561edf1 (diff) |
Diffstat (limited to 'pkg/gui/list_context.go')
-rw-r--r-- | pkg/gui/list_context.go | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go index 56e229273..a7c47e480 100644 --- a/pkg/gui/list_context.go +++ b/pkg/gui/list_context.go @@ -2,6 +2,8 @@ package gui import ( "fmt" + + "github.com/jesseduffield/gocui" ) type ListContext struct { @@ -160,22 +162,14 @@ func (self *ListContext) handleNextLine() error { } func (self *ListContext) handleScrollLeft() error { - if self.ignoreKeybinding() { - return nil - } - - // get the view, move the origin - view, err := self.Gui.g.View(self.ViewName) - if err != nil { - return nil - } - - self.Gui.scrollLeft(view) - - return self.HandleFocus() + return self.scroll(self.Gui.scrollLeft) } func (self *ListContext) handleScrollRight() error { + return self.scroll(self.Gui.scrollRight) +} + +func (self *ListContext) scroll(scrollFunc func(*gocui.View)) error { if self.ignoreKeybinding() { return nil } @@ -186,7 +180,7 @@ func (self *ListContext) handleScrollRight() error { return nil } - self.Gui.scrollRight(view) + scrollFunc(view) return self.HandleFocus() } |