summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--menu/input.go20
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
+ }
+ }
+}