diff options
| -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" |
