all repos — todo.txt-go @ 7def563420741ab6ef1577c7e3b04807f980eeb2

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