diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 20:50:55 +0300 |
|---|---|---|
| committer | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 20:50:55 +0300 |
| commit | 6c9d3879658d38036bdf56aa85dcb591429c7811 (patch) | |
| tree | d801e2d56581afea6c727338d4c0f17f7329d881 | |
| parent | d36db73032bdad71e98c601694c9060df6d6fd78 (diff) | |
ui: add top status bar
| -rw-r--r-- | internal/ui/table.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go index 79b5410..8d1b07c 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -125,7 +125,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: m.tbl.SetWidth(msg.Width) - m.tbl.SetHeight(msg.Height - 2) + // Leave room for two status bars and the optional annotation + // input line. + m.tbl.SetHeight(msg.Height - 3) return m, nil case editDoneMsg: // Ignore any error and reload tasks once editing completes. @@ -251,6 +253,7 @@ func (m Model) View() string { ) } view := lipgloss.JoinVertical(lipgloss.Left, + m.topStatusLine(), m.tbl.View(), m.statusLine(), ) @@ -264,16 +267,23 @@ func (m Model) View() string { } func (m Model) statusLine() string { + status := fmt.Sprintf("Total:%d InProgress:%d Due:%d", m.total, m.inProgress, m.due) + return lipgloss.NewStyle(). + Foreground(lipgloss.Color("229")). + Background(lipgloss.Color("57")). + Render(status) +} + +func (m Model) topStatusLine() string { header := "" cols := m.tbl.Columns() if idx := m.tbl.ColumnCursor(); idx >= 0 && idx < len(cols) { header = cols[idx].Title } - status := fmt.Sprintf("%s Total:%d InProgress:%d Due:%d", header, m.total, m.inProgress, m.due) return lipgloss.NewStyle(). Foreground(lipgloss.Color("229")). Background(lipgloss.Color("57")). - Render(status) + Render(header) } func taskToRow(t task.Task) atable.Row { |
