summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/context/list_context_trait.go5
-rw-r--r--pkg/gui/context/menu_context.go5
-rw-r--r--pkg/gui/context/suggestions_context.go5
-rw-r--r--pkg/gui/controllers/list_controller.go17
-rw-r--r--pkg/gui/types/context.go1
5 files changed, 29 insertions, 4 deletions
diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go
index d7315c9ec..eb738e332 100644
--- a/pkg/gui/context/list_context_trait.go
+++ b/pkg/gui/context/list_context_trait.go
@@ -118,3 +118,8 @@ func (self *ListContextTrait) IsItemVisible(item types.HasUrn) bool {
}
return false
}
+
+// By default, list contexts supporta range select
+func (self *ListContextTrait) RangeSelectEnabled() bool {
+ return true
+}
diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go
index b5c1a3c20..131aa8665 100644
--- a/pkg/gui/context/menu_context.go
+++ b/pkg/gui/context/menu_context.go
@@ -195,3 +195,8 @@ func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error {
return nil
}
+
+// There is currently no need to use range-select in a menu so we're disabling it.
+func (self *MenuContext) RangeSelectEnabled() bool {
+ return false
+}
diff --git a/pkg/gui/context/suggestions_context.go b/pkg/gui/context/suggestions_context.go
index 0921a7329..30781fce1 100644
--- a/pkg/gui/context/suggestions_context.go
+++ b/pkg/gui/context/suggestions_context.go
@@ -90,3 +90,8 @@ func (self *SuggestionsContext) RefreshSuggestions() {
}
})
}
+
+// There is currently no need to use range-select in the suggestions view so we're disabling it.
+func (self *SuggestionsContext) RangeSelectEnabled() bool {
+ return false
+}
diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go
index 9b7a740b5..dc876b3fc 100644
--- a/pkg/gui/controllers/list_controller.go
+++ b/pkg/gui/controllers/list_controller.go
@@ -183,7 +183,7 @@ func (self *ListController) isFocused() bool {
}
func (self *ListController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
- return []*types.Binding{
+ bindings := []*types.Binding{
{Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.PrevItemAlt), Handler: self.HandlePrevLine},
{Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.PrevItem), Handler: self.HandlePrevLine},
{Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.NextItemAlt), Handler: self.HandleNextLine},
@@ -194,10 +194,19 @@ func (self *ListController) GetKeybindings(opts types.KeybindingsOpts) []*types.
{Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.ScrollLeft), Handler: self.HandleScrollLeft},
{Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.ScrollRight), Handler: self.HandleScrollRight},
{Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.GotoBottom), Handler: self.HandleGotoBottom, Description: self.c.Tr.GotoBottom},
- {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.ToggleRangeSelect), Handler: self.HandleToggleRangeSelect, Description: self.c.Tr.ToggleRangeSelect},
- {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.RangeSelectDown), Handler: self.HandleRangeSelectDown, Description: self.c.Tr.RangeSelectDown},
- {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.RangeSelectUp), Handler: self.HandleRangeSelectUp, Description: self.c.Tr.RangeSelectUp},
}
+
+ if self.context.RangeSelectEnabled() {
+ bindings = append(bindings,
+ []*types.Binding{
+ {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.ToggleRangeSelect), Handler: self.HandleToggleRangeSelect, Description: self.c.Tr.ToggleRangeSelect},
+ {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.RangeSelectDown), Handler: self.HandleRangeSelectDown, Description: self.c.Tr.RangeSelectDown},
+ {Tag: "navigation", Key: opts.GetKey(opts.Config.Universal.RangeSelectUp), Handler: self.HandleRangeSelectUp, Description: self.c.Tr.RangeSelectUp},
+ }...,
+ )
+ }
+
+ return bindings
}
func (self *ListController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go
index a3f0ad24a..860a49588 100644
--- a/pkg/gui/types/context.go
+++ b/pkg/gui/types/context.go
@@ -144,6 +144,7 @@ type IListContext interface {
FocusLine()
IsListContext() // used for type switch
+ RangeSelectEnabled() bool
}
type IPatchExplorerContext interface {