feat: the logo on top of the status pane's rows
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
09bacd8438
commit
5bbb3f42c9
5 files changed
+49
-2
No files matched your search
@@ -37,6 +37,9 @@ type List[T any] struct {
|
||||
// Age says how old the items are ("2h ago") while they reload, by
|
||||
// the counter.
|
||||
Age string
|
||||
// Header lines (a logo) go above the items, when the pane has room
|
||||
// for them and there's no filter.
|
||||
Header []string
|
||||
|
||||
item Item[T]
|
||||
items []T
|
||||
@@ -163,9 +166,29 @@ func (l List[T]) rows() int {
|
||||
if l.filtering {
|
||||
r--
|
||||
}
|
||||
if l.headerShown() {
|
||||
r -= len(l.Header) + 1
|
||||
}
|
||||
return max(0, r)
|
||||
}
|
||||
|
||||
// headerMinRows is how many item rows the header leaves at least.
|
||||
const headerMinRows = 5
|
||||
|
||||
// headerShown reports whether Header fits: as wide as the pane allows,
|
||||
// leaving headerMinRows, a blank line under it, and no filter.
|
||||
func (l List[T]) headerShown() bool {
|
||||
if len(l.Header) == 0 || l.filtering || l.input.Value() != "" {
|
||||
return false
|
||||
}
|
||||
for _, line := range l.Header {
|
||||
if ansi.StringWidth(line) > l.w-3 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return l.h-2-len(l.Header)-1 >= headerMinRows
|
||||
}
|
||||
|
||||
// Filtering reports whether the filter input has focus.
|
||||
func (l List[T]) Filtering() bool { return l.filtering }
|
||||
|
||||
@@ -329,6 +352,12 @@ func (l List[T]) View(st styles.Styles, focused bool, spin string) string {
|
||||
if l.filtering {
|
||||
body = append(body, l.input.View())
|
||||
}
|
||||
if l.headerShown() {
|
||||
for _, line := range l.Header {
|
||||
body = append(body, st.Notice.Render(" "+line))
|
||||
}
|
||||
body = append(body, "")
|
||||
}
|
||||
|
||||
switch {
|
||||
case l.Loading && len(l.items) == 0:
|
||||
|
||||
Reference in new issue
Block a user