summaryrefslogtreecommitdiffstats
path: root/pkg/gui/list_context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-23 10:50:27 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commitfda9f4ea7a476a11d4a50cbbd9ce657fe69ae2cb (patch)
tree499299faa4d6a6d59f9b10ad989448d52dddcd28 /pkg/gui/list_context.go
parentf876d8fdc82235f75a11a5807f05b4d8b469d521 (diff)
centralise logic for rendering options map
Diffstat (limited to 'pkg/gui/list_context.go')
-rw-r--r--pkg/gui/list_context.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go
index 23a96952d..5b64aa435 100644
--- a/pkg/gui/list_context.go
+++ b/pkg/gui/list_context.go
@@ -13,6 +13,7 @@ type ListContext struct {
OnFocus func() error
OnFocusLost func() error
OnClickSelectedItem func() error
+ OnGetOptionsMap func() map[string]string
// the boolean here tells us whether the item is nil. This is needed because you can't work it out on the calling end once the pointer is wrapped in an interface (unless you want to use reflection)
SelectedItem func() (ListItem, bool)
@@ -70,6 +71,13 @@ func (lc *ListContext) GetSelectedItemId() string {
return item.ID()
}
+func (lc *ListContext) GetOptionsMap() map[string]string {
+ if lc.OnGetOptionsMap != nil {
+ return lc.OnGetOptionsMap()
+ }
+ return nil
+}
+
// OnFocus assumes that the content of the context has already been rendered to the view. OnRender is the function which actually renders the content to the view
func (lc *ListContext) OnRender() error {
view, err := lc.Gui.g.View(lc.ViewName)
@@ -241,6 +249,7 @@ func (gui *Gui) menuListContext() *ListContext {
Gui: gui,
ResetMainViewOriginOnFocus: false,
Kind: PERSISTENT_POPUP,
+ OnGetOptionsMap: gui.getMenuOptions,
// no GetDisplayStrings field because we do a custom render on menu creation
}