From c97fd4091adeaadbf6b42c5a01a57105438d774c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20B=C3=BCtow?= <1224732+snonux@users.noreply.github.com> Date: Fri, 20 Jun 2025 10:16:11 +0300 Subject: Toggle start/stop with s and widen task column --- internal/ui/table.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/internal/ui/table.go b/internal/ui/table.go index ed91187..73a53dd 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -50,7 +50,7 @@ func New(filter string) (Model, error) { func newTable(rows []atable.Row) atable.Model { cols := []atable.Column{ {Title: "ID", Width: 4}, - {Title: "Task", Width: 30}, + {Title: "Task", Width: 45}, {Title: "Age", Width: 6}, {Title: "Pri", Width: 4}, {Title: "Tags", Width: 15}, @@ -137,14 +137,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "s": if row := m.tbl.SelectedRow(); row != nil { if id, err := strconv.Atoi(row[0]); err == nil { - task.Start(id) - m.reload() - } - } - case "S": - if row := m.tbl.SelectedRow(); row != nil { - if id, err := strconv.Atoi(row[0]); err == nil { - task.Stop(id) + idx := m.tbl.Cursor() + if idx >= 0 && idx < len(m.tasks) { + if m.tasks[idx].Start == "" { + task.Start(id) + } else { + task.Stop(id) + } + } m.reload() } } @@ -166,8 +166,7 @@ func (m Model) View() string { return lipgloss.JoinVertical(lipgloss.Left, m.tbl.HelpView(), "E: edit task", - "s: start task", - "S: stop task", + "s: toggle start/stop", "q: quit", "?: help", // show help toggle line ) -- cgit v1.2.3