summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui_driver.go
diff options
context:
space:
mode:
authorstk <stk@ableton.com>2023-02-15 21:04:12 +0100
committerstk <stk@ableton.com>2023-02-15 21:22:11 +0100
commitff2a799200e4fb8229d5557fbfb5dcf2e3ff29b0 (patch)
treeeb0cdb99929b435e3d0c3008c7eec578077946a3 /pkg/gui/gui_driver.go
parent31fcec16d917809e5452350457910b6dda56b3a3 (diff)
Make SelectedLine/SelectedLineIdx work in staging/stagingSecondary views
While we try to keep the view's cursor position in sync with the context state's selectedLineIdx (at least when pressing up or down), there are enough situations where the two run out of sync; for example when initially opening the view, or after staging a hunk, or when scrolling the view using the wheel. While it would be possible to fix these situations to keep them always in sync, it doesn't seem worth it, because the view's cursor position isn't really used for anything else. So we rather special-case the SelectedLine/SelectedLineIdx functions of ViewDriver to query the context state's selectedLineIdx directly if it is a patch explorer context.
Diffstat (limited to 'pkg/gui/gui_driver.go')
-rw-r--r--pkg/gui/gui_driver.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go
index cf1e3bbb4..239d1a43e 100644
--- a/pkg/gui/gui_driver.go
+++ b/pkg/gui/gui_driver.go
@@ -49,6 +49,15 @@ func (self *GuiDriver) CurrentContext() types.Context {
return self.gui.c.CurrentContext()
}
+func (self *GuiDriver) ContextForView(viewName string) types.Context {
+ context, ok := self.gui.contextForView(viewName)
+ if !ok {
+ return nil
+ }
+
+ return context
+}
+
func (self *GuiDriver) Fail(message string) {
self.gui.g.Close()
// need to give the gui time to close