summaryrefslogtreecommitdiff
path: root/menu/input.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-14 21:43:10 +0200
committerewy <ewy0@protonmail.com>2026-04-14 21:43:16 +0200
commit8c3c69641cdcfc602992e6168602546f579dd3f9 (patch)
tree882f303546d04b16d0903dcfac403f4568d768db /menu/input.go
parented0c8861ed071ff12f42fe6ebbe0925ed23171d9 (diff)
move input to separate file
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
+}