Skip to content

Commit 177d62c

Browse files
committed
d
1 parent e365787 commit 177d62c

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

internal/ui/table.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@ func (m *Model) updateTableColumns() {
294294
m.table.SetColumns(columns)
295295
}
296296

297+
// getTableWidth returns the current total width of the table
298+
func (m *Model) getTableWidth() int {
299+
columns := m.table.Columns()
300+
totalWidth := 0
301+
for _, col := range columns {
302+
totalWidth += col.Width
303+
}
304+
// Add border and separator widths (2 for borders + 3 for column separators)
305+
totalWidth += 5
306+
return totalWidth
307+
}
308+
297309
// max returns the maximum of two integers
298310
func max(a, b int) int {
299311
if a > b {

internal/ui/view.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,16 @@ func (m Model) renderListView() string {
133133
components = append(components, m.styles.TableFocused.Render(m.table.View()))
134134
}
135135

136-
// Add the help text
136+
// Add the help text - constrained to table width
137137
theme := GetCurrentTheme()
138138
mutedStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Muted))
139139

140+
// Calculate table width from current columns
141+
tableWidth := m.getTableWidth()
142+
140143
var helpParts []string
141144
if !m.searchMode {
142-
helpParts = append(helpParts, mutedStyle.Render(" ↑/↓: navigate • Enter: connect • a: add • c: themes • ctrl+s: search focus "))
145+
helpParts = append(helpParts, mutedStyle.Render("↑/↓: navigate • Enter: connect • a: add • c: themes • ctrl+s: search focus "))
143146
if m.appConfig != nil && m.appConfig.StartInSearchMode {
144147
onStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Primary)).Bold(true)
145148
helpParts = append(helpParts, onStyle.Render("[on]"))
@@ -148,7 +151,7 @@ func (m Model) renderListView() string {
148151
}
149152
helpParts = append(helpParts, mutedStyle.Render(" • h: help • q: quit"))
150153
} else {
151-
helpParts = append(helpParts, mutedStyle.Render(" Type to filter • Enter: validate • Tab: switch • ctrl+s: search focus "))
154+
helpParts = append(helpParts, mutedStyle.Render("Type to filter • Enter: validate • Tab: switch • ctrl+s: search focus "))
152155
if m.appConfig != nil && m.appConfig.StartInSearchMode {
153156
onStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Primary)).Bold(true)
154157
helpParts = append(helpParts, onStyle.Render("[on]"))
@@ -157,7 +160,10 @@ func (m Model) renderListView() string {
157160
}
158161
helpParts = append(helpParts, mutedStyle.Render(" • Esc: exit"))
159162
}
160-
components = append(components, strings.Join(helpParts, ""))
163+
164+
// Constrain help text to table width using lipgloss
165+
helpStyle := lipgloss.NewStyle().Width(tableWidth).Align(lipgloss.Center)
166+
components = append(components, helpStyle.Render(strings.Join(helpParts, "")))
161167

162168
// Join all components vertically with center alignment
163169
mainView := lipgloss.Place(

0 commit comments

Comments
 (0)