all repos — todo.txt-go @ main

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	Quit           key.Binding
12	Check          key.Binding
13	Clean          key.Binding
14	Add            key.Binding
15	SortByPriority key.Binding
16	SortByDate     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.SortByPriority, 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.SortByPriority, k.SortByDate, 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	SortByPriority: key.NewBinding(
57		key.WithKeys("p"),
58		key.WithHelp("p", "Sort by priority"),
59	),
60	SortByDate: key.NewBinding(
61		key.WithKeys("s"),
62		key.WithHelp("s", "Sort by date"),
63	),
64	Help: key.NewBinding(
65		key.WithKeys("?"),
66		key.WithHelp("?", "More help"),
67	),
68	Check: key.NewBinding(
69		key.WithKeys(" ", "enter"),
70		key.WithHelp("space", "Check task"),
71	),
72	Clean: key.NewBinding(
73		key.WithKeys("u"),
74		key.WithHelp("u", "Clean completed tasks"),
75	),
76	Quit: key.NewBinding(
77		key.WithKeys("ctrl+c", "q"),
78		key.WithHelp("q", "Quit"),
79	),
80}