diff options
| author | David Schlachter <t480-debian-git@schlachter.ca> | 2026-01-08 01:29:08 -0500 |
|---|---|---|
| committer | David Schlachter <t480-debian-git@schlachter.ca> | 2026-01-08 01:29:08 -0500 |
| commit | 9567725cc98b6706d25230a2558a8faf1e0794b9 (patch) | |
| tree | 55f7ef7c12c318dcf825bb54b0f174e432d88032 | |
| parent | bfa6f9641a59e1c388b33d1bc1be2bbe9e4d3a86 (diff) | |
Better UI, allow clearing the view
| -rw-r--r-- | main.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -95,8 +95,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.wordAddStatus = fmt.Sprintf("✅ Added '%s' to Anki", string(msg)) case tea.KeyMsg: switch msg.Type { - case tea.KeyCtrlC, tea.KeyEsc: + case tea.KeyCtrlC: return m, tea.Quit + case tea.KeyEsc: + m.currentWord = "" + m.currentDefinition = "" + m.wordInput.SetValue("") + m.vp.SetContent("") case tea.KeyEnter: return m, addCard(m.c, m.currentWord, m.currentDefinition) } @@ -127,7 +132,7 @@ func (m model) View() string { "Look up a word:\n\n%s\n\n%s\n%s\n\n%s\n%s", m.wordInput.View(), m.wordAddStatus, - "(esc to quit)", + "(ctrl-c to quit, esc to clear)", "Current definition:\n", m.vp.View(), ) + "\n" |
