all repos — todo.txt-go @ b96964548e9f9e5011e04321998d0f30e527f0ce

CLI tool for todo.txt files written in Go

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