diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-22 17:05:01 +0300 |
|---|---|---|
| committer | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-22 17:05:01 +0300 |
| commit | 90f2d2efbf374f6ea82a46d2d701a099dbae1c89 (patch) | |
| tree | a7881192a026b8d4b472e5af872db40f8b3b0728 | |
| parent | 8a83fbf747bda27f5859ad84c2f20a9afb753e39 (diff) | |
Center help screen
| -rw-r--r-- | internal/ui/table.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go index c3e1748..47ab784 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -849,7 +849,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // View renders the table UI. func (m Model) View() string { if m.showHelp { - return lipgloss.JoinVertical(lipgloss.Left, + lines := []string{ m.tbl.HelpView(), "enter/i: edit or expand cell", "E: edit task", @@ -872,7 +872,11 @@ func (m Model) View() string { "esc: close help/search", "q: quit", "H: help", // show help toggle line - ) + } + for i, l := range lines { + lines[i] = centerLines(l, m.tbl.Width()) + } + return lipgloss.JoinVertical(lipgloss.Top, lines...) } view := lipgloss.JoinVertical(lipgloss.Left, m.topStatusLine(), @@ -1363,3 +1367,12 @@ func (m *Model) applyTheme() { m.tblStyles.Highlight = m.tblStyles.Highlight.Background(lipgloss.Color(m.theme.RowBG)).Foreground(lipgloss.Color(m.theme.RowFG)) m.tbl.SetStyles(m.tblStyles) } + +func centerLines(s string, width int) string { + lines := strings.Split(strings.TrimRight(s, "\n"), "\n") + style := lipgloss.NewStyle().Width(width).Align(lipgloss.Center) + for i, l := range lines { + lines[i] = style.Render(l) + } + return strings.Join(lines, "\n") +} |
