summaryrefslogtreecommitdiff
path: root/internal/switcher/keys.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-11-23 18:12:03 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2024-11-23 18:12:03 -0500
commit89094fecf4cb1c018f15c976641cd18c255eac28 (patch)
tree9f6e32c38013bc526399ab324891e0b3269e50dc /internal/switcher/keys.go
Semi-working POC
Diffstat (limited to 'internal/switcher/keys.go')
-rw-r--r--internal/switcher/keys.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/switcher/keys.go b/internal/switcher/keys.go
new file mode 100644
index 0000000..94eb6fb
--- /dev/null
+++ b/internal/switcher/keys.go
@@ -0,0 +1,33 @@
+package switcher
+
+import "github.com/charmbracelet/bubbles/key"
+
+type keybinds struct {
+ next, prev, quit key.Binding
+}
+
+func newKeybinds() keybinds {
+ return keybinds{
+ next: key.NewBinding(
+ key.WithKeys("tab"),
+ key.WithHelp("tab", "next picker"),
+ ),
+ prev: key.NewBinding(
+ key.WithKeys("shift+tab"),
+ key.WithHelp("shift+tab", "previous picker"),
+ ),
+ quit: key.NewBinding(
+ key.WithKeys("q", "ctrl+c"),
+ key.WithHelp("q", "quit"),
+ ),
+ }
+}
+
+func Keys() []key.Binding {
+ k := newKeybinds()
+ return []key.Binding{k.next, k.prev}
+}
+
+func (m Model) AllKeys() []key.Binding {
+ return append(Keys(), m.pickers[m.active].AllKeys()...)
+}