summaryrefslogtreecommitdiffstats
path: root/pkg/gui/list_context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-11-02 16:39:15 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-11-05 07:58:21 +1100
commit802cfb1a0436568c72fc998249f10f8150b352a3 (patch)
tree599f8a8bd52b786312a11f3b3cac2a2d5b7c597e /pkg/gui/list_context.go
parent2fc1498517523a20a3080816ec50ee9e7fbe533d (diff)
render commit graph
Diffstat (limited to 'pkg/gui/list_context.go')
-rw-r--r--pkg/gui/list_context.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go
index c8ef850a0..290ac3a37 100644
--- a/pkg/gui/list_context.go
+++ b/pkg/gui/list_context.go
@@ -14,6 +14,10 @@ type ListContext struct {
// 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)
OnGetPanelState func() IListPanelState
+ // if this is true, we'll call GetDisplayStrings for just the visible part of the
+ // view and re-render that. This is useful when you need to render different
+ // content based on the selection (e.g. for showing the selected commit)
+ RenderSelection bool
Gui *Gui
@@ -60,10 +64,17 @@ type ListItem interface {
func (self *ListContext) FocusLine() {
view, err := self.Gui.g.View(self.ViewName)
if err != nil {
+ // ignoring error for now
return
}
+ // we need a way of knowing whether we've rendered to the view yet.
view.FocusPoint(0, self.GetPanelState().GetSelectedLineIdx())
+ if self.RenderSelection {
+ _, originY := view.Origin()
+ displayStrings := self.GetDisplayStrings(originY, view.InnerHeight())
+ self.Gui.renderDisplayStringsAtPos(view, originY, displayStrings)
+ }
view.Footer = formatListFooter(self.GetPanelState().GetSelectedLineIdx(), self.GetItemsLength())
}