summaryrefslogtreecommitdiff
path: root/menu/input.go
diff options
context:
space:
mode:
Diffstat (limited to 'menu/input.go')
-rw-r--r--menu/input.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/menu/input.go b/menu/input.go
new file mode 100644
index 0000000..5c75430
--- /dev/null
+++ b/menu/input.go
@@ -0,0 +1,22 @@
+package menu
+
+import tea "github.com/charmbracelet/bubbletea"
+
+func (m *Model) HandleInput(msg tea.KeyMsg) (tea.Cmd, error) {
+ var cmd tea.Cmd
+ switch msg.String() {
+ case "up", "k":
+ m.Index--
+ case "down", "j":
+ m.Index++
+ case "q", "esc", "ctrl+c":
+ m.Quit = true
+ cmd = tea.Quit
+ case "space", " ", "enter", "ctrl+d":
+ cmd = tea.Quit
+ }
+
+ m.Validate()
+
+ return cmd, nil
+}