diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-17 13:20:45 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-17 13:20:45 +0200 |
| commit | c09ad2afa420b0e4a558bf05a0672d5f9785d3ad (patch) | |
| tree | bcd63270e4475be00fcc4529be486f6d1fe4459e | |
| parent | 33e196b645be18f788f79937bf936eaebb642d65 (diff) | |
| -rw-r--r-- | menu/input.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/menu/input.go b/menu/input.go index 5c75430..6d05749 100644 --- a/menu/input.go +++ b/menu/input.go @@ -5,6 +5,10 @@ import tea "github.com/charmbracelet/bubbletea" func (m *Model) HandleInput(msg tea.KeyMsg) (tea.Cmd, error) { var cmd tea.Cmd switch msg.String() { + case "h", "left": + m.Leap(-1) + case "l", "right": + m.Leap(1) case "up", "k": m.Index-- case "down", "j": @@ -20,3 +24,19 @@ func (m *Model) HandleInput(msg tea.KeyMsg) (tea.Cmd, error) { return cmd, nil } + +func (m *Model) Leap(direction int) { + for { + source, target := m.Result() + m.Index += direction + m.Validate() + newSource, newTarget := m.Result() + if target == newTarget { + return + } + + if source != newSource { + return + } + } +} |
