summaryrefslogtreecommitdiffstats
path: root/pkg/gui/types
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-09-05 22:27:28 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-09-18 10:20:23 +0200
commite592d81b601d19d429ab61b7f3bd478de9844204 (patch)
treed912b28d3b39f731aca8ca3ac10269d58198086e /pkg/gui/types
parentf2f50ccf758033e817b20849a0175e7a383a3856 (diff)
Add Enabled func to Binding
Diffstat (limited to 'pkg/gui/types')
-rw-r--r--pkg/gui/types/common.go1
-rw-r--r--pkg/gui/types/keybindings.go7
2 files changed, 8 insertions, 0 deletions
diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go
index 21ba78d9a..5f1363f03 100644
--- a/pkg/gui/types/common.go
+++ b/pkg/gui/types/common.go
@@ -104,6 +104,7 @@ type IGuiCommon interface {
State() IStateAccessor
KeybindingsOpts() KeybindingsOpts
+ CallKeybindingHandler(binding *Binding) error
// hopefully we can remove this once we've moved all our keybinding stuff out of the gui god struct.
GetInitialKeybindingsWithCustomCommands() ([]*Binding, []*gocui.ViewMouseBinding)
diff --git a/pkg/gui/types/keybindings.go b/pkg/gui/types/keybindings.go
index 95978e762..4c3d02c6f 100644
--- a/pkg/gui/types/keybindings.go
+++ b/pkg/gui/types/keybindings.go
@@ -25,6 +25,13 @@ type Binding struct {
// to be displayed if the keybinding is highlighted from within a menu
Tooltip string
+
+ // Function to decide whether the command is enabled, and why. If this
+ // returns an empty string, it is; if it returns a non-empty string, it is
+ // disabled and we show the given text in an error message when trying to
+ // invoke it. When left nil, the command is always enabled. Note that this
+ // function must not do expensive calls.
+ GetDisabledReason func() string
}
// A guard is a decorator which checks something before executing a handler