all repos — todo.txt-go @ afca122bfa3e223153006ae7ee265831fa699607

keymap.go (view raw)

 1package main
 2
 3import "github.com/charmbracelet/bubbles/key"
 4
 5type keyMap struct {
 6	Up            key.Binding
 7	Down          key.Binding
 8	Priority      key.Binding
 9	ClearPriority key.Binding
10	Help          key.Binding
11	SaveQuit      key.Binding
12	Quit          key.Binding
13	Check         key.Binding
14	Clean         key.Binding
15	Add           key.Binding
16	Sort          key.Binding
17}
18
19// ShortHelp returns keybindings to be shown in the mini help view. It's part
20// of the key.Map interface.
21func (k keyMap) ShortHelp() []key.Binding {
22	return []key.Binding{k.Check, k.Add, k.Sort, k.SaveQuit, k.Help}
23}
24
25// FullHelp returns keybindings for the expanded help view. It's part of the
26// key.Map interface.
27func (k keyMap) FullHelp() [][]key.Binding {
28	return [][]key.Binding{
29		{k.Check, k.Priority, k.Up},
30		{k.Add, k.ClearPriority, k.Clean, k.Down},
31		{k.Sort, k.SaveQuit, k.Quit},
32	}
33}
34
35var keys = keyMap{
36	Up: key.NewBinding(
37		key.WithKeys("up", "k"),
38		key.WithHelp("↑/k", "Move up"),
39	),
40	Down: key.NewBinding(
41		key.WithKeys("down", "j"),
42		key.WithHelp("↓/j", "Move down"),
43	),
44	Priority: key.NewBinding(
45		key.WithKeys("a", "b", "c", "d"),
46		key.WithHelp("a|b|c", "Set priority"),
47	),
48	ClearPriority: key.NewBinding(
49		key.WithKeys("z"),
50		key.WithHelp("z", "Clear priority"),
51	),
52	Add: key.NewBinding(
53		key.WithKeys("A", "+"),
54		key.WithHelp("A|+", "Add new task"),
55	),
56	Sort: key.NewBinding(
57		key.WithKeys("s"),
58		key.WithHelp("s", "Sort tasks"),
59	),
60	Help: key.NewBinding(
61		key.WithKeys("?"),
62		key.WithHelp("?", "More help"),
63	),
64	Check: key.NewBinding(
65		key.WithKeys(" ", "enter"),
66		key.WithHelp("space", "Check task"),
67	),
68	Clean: key.NewBinding(
69		key.WithKeys("u"),
70		key.WithHelp("u", "Clean completed tasks"),
71	),
72	SaveQuit: key.NewBinding(
73		key.WithKeys("q", "esc"),
74		key.WithHelp("q", "Save & quit"),
75	),
76	Quit: key.NewBinding(
77		key.WithKeys("ctrl+c"),
78		key.WithHelp("ctrl+c", "Cancel & quit"),
79	),
80}