summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorDavid Schlachter <t480-debian-git@schlachter.ca>2026-01-08 01:29:08 -0500
committerDavid Schlachter <t480-debian-git@schlachter.ca>2026-01-08 01:29:08 -0500
commit9567725cc98b6706d25230a2558a8faf1e0794b9 (patch)
tree55f7ef7c12c318dcf825bb54b0f174e432d88032 /main.go
parentbfa6f9641a59e1c388b33d1bc1be2bbe9e4d3a86 (diff)
Better UI, allow clearing the view
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 7 insertions, 2 deletions
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"