Skip to content

Commit 2b29dce

Browse files
committed
feat: add project count display to header
1 parent ff59754 commit 2b29dce

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

internal/tui/model.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (m Model) View() string {
124124
}
125125

126126
func viewSmall(m Model, l layout) string {
127-
content := renderHeader(l.innerWidth, m.keys) +
127+
content := renderHeader(l.innerWidth, m.keys, len(m.filtered), len(m.projects)) +
128128
renderInput(m.query) +
129129
renderList(l, m.filtered, m.cursor, 0) +
130130
renderFooter(l.innerWidth, m.keys)
@@ -136,7 +136,7 @@ func viewBoxed(m Model, l layout) string {
136136
fixedHeight := max(len(m.projects), minFixedListHeight)
137137
fixedHeight = min(fixedHeight, maxBoxedListHeight)
138138
fixedHeight = min(fixedHeight, l.maxListHeight)
139-
content := renderHeader(l.innerWidth, m.keys) +
139+
content := renderHeader(l.innerWidth, m.keys, len(m.filtered), len(m.projects)) +
140140
renderInput(m.query) +
141141
renderList(l, m.filtered, m.cursor, fixedHeight) +
142142
renderFooter(l.innerWidth, m.keys)
@@ -167,12 +167,13 @@ func calculateLayout(width, height, maxLineWidth int) layout {
167167
}
168168
}
169169

170-
func renderHeader(innerWidth int, keys KeyMap) string {
170+
func renderHeader(innerWidth int, keys KeyMap, filteredCount, totalCount int) string {
171171
title := titleStyle.Render("Projects")
172+
counter := pathStyle.Render(fmt.Sprintf(" (%d/%d)", filteredCount, totalCount))
172173
escHint := keymapKeyStyle.Render(keys.Cancel.Help().Key)
173-
padding := max(innerWidth-lipgloss.Width(title)-lipgloss.Width(escHint), 1)
174+
padding := max(innerWidth-lipgloss.Width(title)-lipgloss.Width(counter)-lipgloss.Width(escHint), 1)
174175

175-
return title + strings.Repeat(" ", padding) + escHint + "\n\n"
176+
return title + counter + strings.Repeat(" ", padding) + escHint + "\n\n"
176177
}
177178

178179
func renderInput(query string) string {

0 commit comments

Comments
 (0)