summaryrefslogtreecommitdiffstats
path: root/pkg/gui/list_context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-19 18:06:51 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commita32947e7a777cb1f1bc16ea9693bd3d01519ea4b (patch)
tree2efeb58fefe076426501653aee238b83bbda1850 /pkg/gui/list_context.go
parent2fdadd383a2609921abd4aeb99e67bd5f1bbc0fc (diff)
prepare for OnRender prop
Diffstat (limited to 'pkg/gui/list_context.go')
-rw-r--r--pkg/gui/list_context.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go
index 7a1248d22..9454aadf9 100644
--- a/pkg/gui/list_context.go
+++ b/pkg/gui/list_context.go
@@ -11,9 +11,12 @@ type ListContext struct {
OnFocusLost func() error
OnItemSelect func() error
OnClickSelectedItem func() error
- Gui *Gui
- RendersToMainView bool
- Kind int
+
+ // 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
+ OnRender func() error
+ Gui *Gui
+ RendersToMainView bool
+ Kind int
}
func (lc *ListContext) GetKey() string {
@@ -40,6 +43,10 @@ func (lc *ListContext) HandleFocus() error {
return lc.OnFocus()
}
+func (lc *ListContext) HandleRender() error {
+ return lc.OnRender()
+}
+
func (lc *ListContext) handlePrevLine(g *gocui.Gui, v *gocui.View) error {
return lc.handleLineChange(-1)
}
@@ -187,9 +194,9 @@ func (gui *Gui) branchesListContext() *ListContext {
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Branches.SelectedLine },
OnFocus: gui.handleBranchSelect,
OnItemSelect: gui.handleBranchSelect,
- Gui: gui,
- RendersToMainView: true,
- Kind: SIDE_CONTEXT,
+ Gui: gui,
+ RendersToMainView: true,
+ Kind: SIDE_CONTEXT,
}
}