diff options
| author | David Schlachter <t480-debian-git@schlachter.ca> | 2026-01-09 00:15:59 -0500 |
|---|---|---|
| committer | David Schlachter <t480-debian-git@schlachter.ca> | 2026-01-09 00:15:59 -0500 |
| commit | 7bba547637129f9b883a983fe45e4ecf08eb85ea (patch) | |
| tree | 21321a1fbc7deed2be7c20814676a8009ebb828f | |
| parent | b390b93e1c86f90c9044323d6a4fa7f59bafc4f0 (diff) | |
Add definition scrolling
| -rw-r--r-- | ui.go | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -8,6 +8,7 @@ import ( "regexp" "strings" + "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" @@ -42,7 +43,18 @@ func initialModel(c *http.Client, db *sql.DB, apiURL, ankiDeck, ankiModel, first ti.Focus() ti.CharLimit = 156 ti.Width = 36 + vp := viewport.New(80, 30) + vp.KeyMap = viewport.KeyMap{ + PageDown: key.NewBinding( + key.WithKeys("pgdown", " ", "f"), + key.WithHelp("f/pgdn", "page down"), + ), + PageUp: key.NewBinding( + key.WithKeys("pgup", "b"), + key.WithHelp("b/pgup", "page up"), + ), + } if firstWord != "" { ti.SetValue(firstWord) @@ -150,7 +162,7 @@ func (m model) View() string { "\x1b[1;30;42mLook up a word:\x1b[0m\n\n%s\n\n\x1b[1;30;42mStatus:\x1b[0m %s\n\n%s\n\n%s\n%s", m.wordInput.View(), formatStatus(m.err, m.wordAddStatus), - "(ctrl-c to quit, esc to clear, enter to add to Anki)", + "(Ctrl-C to quit, Esc to clear, Enter to add to Anki, PgUp/Down to scroll)", "\x1b[1;30;42mCurrent definition:\x1b[0m\n", m.vp.View(), ) + "\n" |
