From bf30a97b8abefd550d795479af1781a53ad635c6 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 18:42:43 +0300 Subject: Add A hotkey to replace annotations --- internal/ui/table.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'internal/ui/table.go') diff --git a/internal/ui/table.go b/internal/ui/table.go index a3f6581..a208d58 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -21,9 +21,10 @@ type Model struct { tbl atable.Model showHelp bool - annotating bool - annotateID int - annotateInput textinput.Model + annotating bool + annotateID int + annotateInput textinput.Model + replaceAnnotations bool filter string tasks []task.Task @@ -129,13 +130,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.annotating { switch msg.Type { case tea.KeyEnter: - task.Annotate(m.annotateID, m.annotateInput.Value()) + if m.replaceAnnotations { + task.ReplaceAnnotations(m.annotateID, m.annotateInput.Value()) + m.replaceAnnotations = false + } else { + task.Annotate(m.annotateID, m.annotateInput.Value()) + } m.annotating = false m.annotateInput.Blur() m.reload() return m, nil case tea.KeyEsc: m.annotating = false + m.replaceAnnotations = false m.annotateInput.Blur() return m, nil } @@ -185,6 +192,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if id, err := strconv.Atoi(idStr); err == nil { m.annotateID = id m.annotating = true + m.replaceAnnotations = false + m.annotateInput.SetValue("") + m.annotateInput.Focus() + return m, nil + } + } + case "A": + if row := m.tbl.SelectedRow(); row != nil { + idStr := ansi.Strip(row[0]) + if id, err := strconv.Atoi(idStr); err == nil { + m.annotateID = id + m.annotating = true + m.replaceAnnotations = true m.annotateInput.SetValue("") m.annotateInput.Focus() return m, nil @@ -210,6 +230,7 @@ func (m Model) View() string { "E: edit task", "s: toggle start/stop", "a: annotate task", + "A: replace annotations", "q: quit", "?: help", // show help toggle line ) -- cgit v1.2.3