Files
task-master/internal/ui/keys.go
T
SkrueckenandCursor 24c1e146ec Add offline-first task-master TUI with tickets, board lists, and undo.
Charm-based CLI with JSON persistence, status/list filters, external editor editing, command-history undo/redo, and glamour markdown without AutoStyle OSC hangs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-19 10:21:48 +02:00

94 lines
2.0 KiB
Go

package ui
import "github.com/charmbracelet/bubbles/key"
// KeyMap defines vim-style bindings for the TUI.
type KeyMap struct {
Up key.Binding
Down key.Binding
New key.Binding
Search key.Binding
Project key.Binding
Board key.Binding
Status key.Binding
Edit key.Binding
Delete key.Binding
Undo key.Binding
Redo key.Binding
Quit key.Binding
Enter key.Binding
Escape key.Binding
}
// DefaultKeyMap returns the default key bindings.
func DefaultKeyMap() KeyMap {
return KeyMap{
Up: key.NewBinding(
key.WithKeys("k", "up"),
key.WithHelp("j/k", "navigate"),
),
Down: key.NewBinding(
key.WithKeys("j", "down"),
key.WithHelp("j/k", "navigate"),
),
New: key.NewBinding(
key.WithKeys("n"),
key.WithHelp("n", "new"),
),
Search: key.NewBinding(
key.WithKeys("/"),
key.WithHelp("/", "search"),
),
Project: key.NewBinding(
key.WithKeys("p"),
key.WithHelp("p", "project"),
),
Board: key.NewBinding(
key.WithKeys("l", "tab"),
key.WithHelp("l", "list"),
),
Status: key.NewBinding(
key.WithKeys("s", "enter"),
key.WithHelp("s", "status"),
),
Edit: key.NewBinding(
key.WithKeys("e"),
key.WithHelp("e", "edit"),
),
Delete: key.NewBinding(
key.WithKeys("X"),
key.WithHelp("X", "delete"),
),
Undo: key.NewBinding(
key.WithKeys("u", "ctrl+z"),
key.WithHelp("u", "undo"),
),
Redo: key.NewBinding(
key.WithKeys("ctrl+r", "U"),
key.WithHelp("U", "redo"),
),
Quit: key.NewBinding(
key.WithKeys("q", "ctrl+c"),
key.WithHelp("q", "quit"),
),
Enter: key.NewBinding(
key.WithKeys("enter"),
key.WithHelp("enter", "confirm"),
),
Escape: key.NewBinding(
key.WithKeys("esc"),
key.WithHelp("esc", "cancel"),
),
}
}
// ShortHelp implements help.KeyMap.
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.Up, k.New, k.Search, k.Project, k.Board, k.Status, k.Edit, k.Delete, k.Undo, k.Redo, k.Quit}
}
// FullHelp implements help.KeyMap.
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{k.ShortHelp()}
}