diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-16 17:28:14 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-23 13:03:37 +1100 |
commit | a5f3515ad87f978c24d9454d45a454d824eb0897 (patch) | |
tree | 59022c18ae15cc5c89e235215a65d6775dab10a2 /pkg/gui/types | |
parent | a67ad447813ceaf389254b723b0783cf1021f40d (diff) |
Set groundwork for better disabled reasons with range select
Something dumb that we're currently doing is expecting list items
to define an ID method which returns a string. We use that when copying
items to clipboard with ctrl+o and when getting a ref name for diffing.
This commit gets us a little deeper into that hole by explicitly requiring
list items to implement that method so that we can easily use the new
helper functions in list_controller_trait.go.
In future we need to just remove the whole ID thing entirely but I'm too
lazy to do that right now.
Diffstat (limited to 'pkg/gui/types')
-rw-r--r-- | pkg/gui/types/common.go | 6 | ||||
-rw-r--r-- | pkg/gui/types/context.go | 1 | ||||
-rw-r--r-- | pkg/gui/types/suggestion.go | 5 |
3 files changed, 12 insertions, 0 deletions
diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 9053e43f9..86bf63548 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -242,6 +242,12 @@ type MenuItem struct { Section *MenuSection } +// Defining this for the sake of conforming to the HasID interface, which is used +// in list contexts. +func (self *MenuItem) ID() string { + return self.Label +} + type Model struct { CommitFiles []*models.CommitFile Files []*models.File diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index 860a49588..92b07a729 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -136,6 +136,7 @@ type IListContext interface { Context GetSelectedItemId() string + GetSelectedItemIds() ([]string, int, int) IsItemVisible(item HasUrn) bool GetList() IList diff --git a/pkg/gui/types/suggestion.go b/pkg/gui/types/suggestion.go index ed8b6ef44..1d4516932 100644 --- a/pkg/gui/types/suggestion.go +++ b/pkg/gui/types/suggestion.go @@ -6,3 +6,8 @@ type Suggestion struct { // label is what is actually displayed so it can e.g. contain color Label string } + +// Conforming to the HasID interface, which is needed for list contexts +func (self *Suggestion) ID() string { + return self.Value +} |