all repos — todo.txt-go @ 601f4a83a9da7611413da0b9ac67f720ee77b709

CLI tool for todo.txt files written in Go

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	Edit           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.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.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	Edit: key.NewBinding(
58		key.WithKeys("e", "enter"),
59		key.WithHelp("e|Enter", "Edit task"),
60	),
61	SortByPriority: key.NewBinding(
62		key.WithKeys("p"),
63		key.WithHelp("p", "Sort by priority"),
64	),
65	SortByDate: key.NewBinding(
66		key.WithKeys("s"),
67		key.WithHelp("s", "Sort by date"),
68	),
69	Help: key.NewBinding(
70		key.WithKeys("?"),
71		key.WithHelp("?", "More help"),
72	),
73	Check: key.NewBinding(
74		key.WithKeys(" ", "x"),
75		key.WithHelp("space", "Check task"),
76	),
77	Clean: key.NewBinding(
78		key.WithKeys("u"),
79		key.WithHelp("u", "Clean completed tasks"),
80	),
81	Quit: key.NewBinding(
82		key.WithKeys("ctrl+c", "q"),
83		key.WithHelp("q", "Quit"),
84	),
85}