From 9567725cc98b6706d25230a2558a8faf1e0794b9 Mon Sep 17 00:00:00 2001 From: David Schlachter Date: Thu, 8 Jan 2026 01:29:08 -0500 Subject: Better UI, allow clearing the view --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index ef4e7ad..c018275 100644 --- a/main.go +++ b/main.go @@ -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" -- cgit v1.2.3