all repos — todo.txt-go @ 1102e482d1dceefe79abdd9f52155c929327cdef

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