summaryrefslogtreecommitdiff
path: root/menu
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-17 13:20:45 +0200
committerewy <ewy0@protonmail.com>2026-04-17 13:20:45 +0200
commitc09ad2afa420b0e4a558bf05a0672d5f9785d3ad (patch)
treebcd63270e4475be00fcc4529be486f6d1fe4459e /menu
parent33e196b645be18f788f79937bf936eaebb642d65 (diff)
allow left/right (h/l) to leap through sources instead of going one by oneHEADmaster
Diffstat (limited to 'menu')
-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
+ }
+ }
+}