main
6d86999 ยท 6 months ago 26 commits
 1package keys
 2
 3import (
 4	"github.com/charmbracelet/bubbles/key"
 5	tea "github.com/charmbracelet/bubbletea"
 6)
 7
 8type KeyMap struct {
 9	Quit    key.Binding
10	Refresh key.Binding
11
12	NextSection key.Binding
13	PrevSection key.Binding
14	CursorUp    key.Binding
15	CursorDown  key.Binding
16	Execute     key.Binding
17	Info        key.Binding
18	Delete      key.Binding
19	SwitchTable key.Binding
20	AddRule     key.Binding
21	CustomInput key.Binding
22	Back        key.Binding
23}
24
25var Bindings = KeyMap{
26	CursorUp: key.NewBinding(
27		key.WithKeys("up", "k"),
28	),
29
30	CursorDown: key.NewBinding(
31		key.WithKeys("down", "j"),
32	),
33
34	PrevSection: key.NewBinding(
35		key.WithKeys("shift+tab", "left"),
36	),
37
38	NextSection: key.NewBinding(
39		key.WithKeys("tab", "right"),
40	),
41
42	Refresh: key.NewBinding(
43		key.WithKeys("r"),
44	),
45
46	Quit: key.NewBinding(
47		key.WithKeys("q", "esc", "ctrl+c"),
48	),
49
50	Execute: key.NewBinding(
51		key.WithKeys(" ", "enter"),
52	),
53
54	Info: key.NewBinding(
55		key.WithKeys("i"),
56	),
57
58	Delete: key.NewBinding(
59		key.WithKeys("d"),
60	),
61
62	SwitchTable: key.NewBinding(
63		key.WithKeys("s"),
64	),
65
66	AddRule: key.NewBinding(
67		key.WithKeys("a"),
68	),
69
70	CustomInput: key.NewBinding(
71		key.WithKeys("c"),
72	),
73
74	Back: key.NewBinding(
75		key.WithKeys("b", "backspace"),
76	),
77}
78
79type RefreshMsg struct{}
80
81func Refresh() tea.Cmd {
82	return func() tea.Msg {
83		return RefreshMsg{}
84	}
85}