diff options
Diffstat (limited to 'internal/ui/table.go')
| -rw-r--r-- | internal/ui/table.go | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go index 4c5aa3d..755e077 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 @@ -130,13 +131,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 } @@ -186,6 +193,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 @@ -211,6 +231,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 ) |
