From f1b03471114dae90613bf3d830b34e837cc1cf7d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 25 Aug 2026 09:19:34 +0200 Subject: [PATCH] Allow a list to render its footer elsewhere The footer is drawn on the bottom border of the list's view, which is not always a free row: a panel that puts something else below the list shares that border with it, and has to render the footer there instead. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gui/context/list_context_trait.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go index 9ab24cf9b..77e071991 100644 --- a/pkg/gui/context/list_context_trait.go +++ b/pkg/gui/context/list_context_trait.go @@ -28,6 +28,11 @@ type ListContextTrait struct { // true if we're inside the OnSearchSelect call; in that case we don't want to update the search // result index. inOnSearchSelect bool + + // If set, this renders the "x of y" footer instead of the default, which puts + // it on the bottom border of the list's own view. A list that is part of a + // composite panel can use this to put it somewhere else; see MenuContext. + renderFooter func(footer string) } func (self *ListContextTrait) IsListContext() {} @@ -81,7 +86,13 @@ func (self *ListContextTrait) refreshViewport() { } func (self *ListContextTrait) setFooter() { - self.GetViewTrait().SetFooter(formatListFooter(self.list.GetSelectedLineIdx(), self.list.Len())) + footer := formatListFooter(self.list.GetSelectedLineIdx(), self.list.Len()) + if self.renderFooter != nil { + self.renderFooter(footer) + return + } + + self.GetViewTrait().SetFooter(footer) } func formatListFooter(selectedLineIdx int, length int) string {