all repos — todo.txt-go @ 935dbed84d9005c5192cd30f7eafcc1bd9e32cd2

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