summaryrefslogtreecommitdiffstats
path: root/pkg/gui/list_context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-11-02 20:35:53 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-11-05 07:58:21 +1100
commit37be9dbea18f52a544a1dd134657c02c1ee61aef (patch)
treea18a51d7f998e41a76a2268c897d34133241229b /pkg/gui/list_context.go
parentf6ec7babf55c4a43bc8048e8a84970a8de8250b9 (diff)
support scrolling left and right
Diffstat (limited to 'pkg/gui/list_context.go')
-rw-r--r--pkg/gui/list_context.go51
1 files changed, 48 insertions, 3 deletions
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go
index 290ac3a37..56e229273 100644
--- a/pkg/gui/list_context.go
+++ b/pkg/gui/list_context.go
@@ -30,6 +30,8 @@ type IListContext interface {
OnRender() error
handlePrevLine() error
handleNextLine() error
+ handleScrollLeft() error
+ handleScrollRight() error
handleLineChange(change int) error
handleNextPage() error
handleGotoTop() error
@@ -69,7 +71,7 @@ func (self *ListContext) FocusLine() {
}
// we need a way of knowing whether we've rendered to the view yet.
- view.FocusPoint(0, self.GetPanelState().GetSelectedLineIdx())
+ view.FocusPoint(view.OriginX(), self.GetPanelState().GetSelectedLineIdx())
if self.RenderSelection {
_, originY := view.Origin()
displayStrings := self.GetDisplayStrings(originY, view.InnerHeight())
@@ -117,6 +119,13 @@ func (self *ListContext) HandleFocusLost() error {
return self.OnFocusLost()
}
+ view, err := self.Gui.g.View(self.ViewName)
+ if err != nil {
+ return nil
+ }
+
+ _ = view.SetOriginX(0)
+
return nil
}
@@ -150,8 +159,44 @@ func (self *ListContext) handleNextLine() error {
return self.handleLineChange(1)
}
+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()
+}
+
+func (self *ListContext) handleScrollRight() 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.scrollRight(view)
+
+ return self.HandleFocus()
+}
+
+func (self *ListContext) ignoreKeybinding() bool {
+ return !self.Gui.isPopupPanel(self.ViewName) && self.Gui.popupPanelFocused()
+}
+
func (self *ListContext) handleLineChange(change int) error {
- if !self.Gui.isPopupPanel(self.ViewName) && self.Gui.popupPanelFocused() {
+ if self.ignoreKeybinding() {
return nil
}
@@ -195,7 +240,7 @@ func (self *ListContext) handlePrevPage() error {
}
func (self *ListContext) handleClick() error {
- if !self.Gui.isPopupPanel(self.ViewName) && self.Gui.popupPanelFocused() {
+ if self.ignoreKeybinding() {
return nil
}