diff --git a/README.md b/README.md index ac5f449..8632c77 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ For other commands and options see, `daylog --help`. `daylog tui` opens an interactive terminal UI for browsing and editing your logs. It lands on a ledger of every day, newest first, with a preview of each. From there you can: - `↑`/`↓` move, `enter` to open a day -- `a` append a one-line entry, `e` open the day in `$EDITOR`, `y` copy the log +- `a` append a one-line entry, `e` open the day in `$EDITOR`, `c` copy the log (works from the day list too) - `/` filter by date or text (searches log contents), `n` start a new day from a date - `t` toggle todos, `p` switch projects, `?` for full help, `q` to quit diff --git a/internal/tui/keymap.go b/internal/tui/keymap.go index e2ac89e..415f272 100644 --- a/internal/tui/keymap.go +++ b/internal/tui/keymap.go @@ -60,8 +60,8 @@ func defaultKeyMap() keyMap { key.WithHelp("e", "edit in $EDITOR"), ), Copy: key.NewBinding( - key.WithKeys("y"), - key.WithHelp("y", "copy log"), + key.WithKeys("c"), + key.WithHelp("c", "copy log"), ), Projects: key.NewBinding( key.WithKeys("p"), diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index 930db38..403b0da 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -1260,13 +1260,32 @@ func TestCopyKey(t *testing.T) { m := newTestModel(t, projectPath, today) - _, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'y'}}) + _, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}}) if cmd == nil { t.Fatal("expected a copy cmd") } // don't execute it — that would touch the real clipboard } +// c copies from the ledger too, hitting the highlighted day (not today, when a +// different day is highlighted). mirrors the log-view TestCopyKey +func TestCopyKeyFromLedger(t *testing.T) { + today := time.Date(2026, 7, 10, 12, 0, 0, 0, time.Local) + projectPath := t.TempDir() + seedLog(t, projectPath, "2026/07/08", "- older entry\n") + + m := newLedgerModel(t, projectPath, today) + m.moveLedgerCursor(1) // highlight 2026/07/08 + if day, _ := m.selectedDay(); day != "2026/07/08" { + t.Fatalf("expected 2026/07/08 selected, got %s", day) + } + + _, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}}) + if cmd == nil { + t.Fatal("expected a copy cmd from the ledger") + } +} + func TestCopyMissingLogReportsError(t *testing.T) { projectPath := t.TempDir() diff --git a/internal/tui/update.go b/internal/tui/update.go index fc0f690..fec4584 100644 --- a/internal/tui/update.go +++ b/internal/tui/update.go @@ -340,6 +340,14 @@ func (m Model) onLedgerKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { } return m, openEditor(m.projectPath, day) + case key.Matches(msg, m.keys.Copy): + // copy the selected day from the list, same as in the log view + day, ok := m.selectedDay() + if !ok { + return m, nil + } + return m, copyDay(m.projectPath, day) + case key.Matches(msg, m.keys.Older): m.moveLedgerCursor(1) // older = further down the newest-first list return m, nil diff --git a/internal/tui/view.go b/internal/tui/view.go index 3bc3471..eeaddcd 100644 --- a/internal/tui/view.go +++ b/internal/tui/view.go @@ -496,7 +496,7 @@ func (m Model) footerView() string { if m.dayFilter.Focused() { return footer.Render("filter by date or text • ↑/↓ move • enter open • esc clear") } - return footer.Render("↑/↓ move • enter open • a append • n new day • / filter • p project • ? help") + return footer.Render("↑/↓ move • enter open • a append • c copy • n new day • / filter • p project • ? help") } if m.status != "" {