diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 18:43:18 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 18:43:18 +0300 |
| commit | a9e322ff7e83364868dc56fd9ac1d8acbc5ce08b (patch) | |
| tree | f854d7a853229e13728368985bdba463b379d0c0 /internal/ui/table.go | |
| parent | 6acfce72b3ed9d814e546dc35ebfb45c8f833f41 (diff) | |
| parent | bf30a97b8abefd550d795479af1781a53ad635c6 (diff) | |
Merge pull request #26 from snonux/codex/add-a-hotkey-for-annotations-and-help
Add annotation replacement hotkey
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 ) |
