diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 00:09:33 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 00:09:33 +0300 |
| commit | 77620dcd609aa53a81effd23174d56e622f16cc8 (patch) | |
| tree | 8c1c605913013d16fafe865729e7ac236eb5b594 /internal | |
| parent | 15dcd6f5baad135b1472b79886bce9a77189dcf3 (diff) | |
| parent | 0dd71db839d29b638e3072259bc9ab44c6864a2d (diff) | |
Merge pull request #8 from snonux/codex/update-ui,-add-hotkeys,-and-help-screen
Improve UI with time-based due dates and help
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/ui/table.go | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go index 682a680..af85acb 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -7,7 +7,10 @@ import ( ) // Model wraps a Bubble Tea table.Model to display tasks. -type Model struct{ tbl table.Model } +type Model struct { + tbl table.Model + showHelp bool +} // New creates a new UI model with the provided rows. func New(rows []table.Row) Model { @@ -45,11 +48,38 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: m.tbl.SetWidth(msg.Width) m.tbl.SetHeight(msg.Height - 2) + return m, nil + case tea.KeyMsg: + switch msg.String() { + case "?": + m.showHelp = true + return m, nil + case "q": + if m.showHelp { + m.showHelp = false + return m, nil + } + return m, tea.Quit + } + } + + if m.showHelp { + return m, nil } + var cmd tea.Cmd m.tbl, cmd = m.tbl.Update(msg) return m, cmd } // View renders the table UI. -func (m Model) View() string { return m.tbl.View() } +func (m Model) View() string { + if m.showHelp { + return lipgloss.JoinVertical(lipgloss.Left, + m.tbl.HelpView(), + "q: quit", + "?: help", // show help toggle line + ) + } + return m.tbl.View() +} |
