Documentation
¶
Overview ¶
Package keymap provides user-configurable key bindings for revdiff. It maps key names (as returned by bubbletea's KeyMsg.String()) to action names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidAction ¶
IsValidAction returns true if the action name is recognized.
Types ¶
type Action ¶
type Action string
Action represents a named action that a key can trigger.
const ( ActionDown Action = "down" ActionUp Action = "up" ActionPageDown Action = "page_down" ActionPageUp Action = "page_up" ActionHalfPageDown Action = "half_page_down" ActionHalfPageUp Action = "half_page_up" ActionHome Action = "home" ActionEnd Action = "end" ActionScrollLeft Action = "scroll_left" ActionScrollRight Action = "scroll_right" ActionNextItem Action = "next_item" ActionPrevItem Action = "prev_item" ActionNextHunk Action = "next_hunk" ActionPrevHunk Action = "prev_hunk" ActionTogglePane Action = "toggle_pane" ActionFocusTree Action = "focus_tree" ActionFocusDiff Action = "focus_diff" ActionSearch Action = "search" ActionConfirm Action = "confirm" ActionAnnotateFile Action = "annotate_file" ActionDeleteAnnotation Action = "delete_annotation" ActionAnnotList Action = "annot_list" ActionToggleCollapsed Action = "toggle_collapsed" ActionToggleWrap Action = "toggle_wrap" ActionToggleTree Action = "toggle_tree" ActionToggleLineNums Action = "toggle_line_numbers" ActionToggleHunk Action = "toggle_hunk" ActionFilter Action = "filter" ActionQuit Action = "quit" ActionDiscardQuit Action = "discard_quit" ActionHelp Action = "help" ActionDismiss Action = "dismiss" )
action constants for all mappable actions.
type HelpEntryWithKeys ¶
type HelpEntryWithKeys struct {
Action Action
Description string
Keys string // formatted as "key1 / key2"
}
HelpEntryWithKeys is a help entry with the effective key bindings attached.
type HelpSection ¶
type HelpSection struct {
Name string
Entries []HelpEntryWithKeys
}
HelpSection groups help entries under a section heading.
type Keymap ¶
type Keymap struct {
// contains filtered or unexported fields
}
Keymap maps key names to actions. Keys are stored as the string returned by bubbletea's tea.KeyMsg.String().
func Load ¶
Load reads a keybindings file from path and returns a Keymap with defaults overridden by the file contents. Returns error if the file cannot be opened or parsed.
func LoadOrDefault ¶
LoadOrDefault loads keybindings from path if the file exists, otherwise returns Default(). Parse errors are logged as warnings and Default() is returned.
func (*Keymap) Dump ¶
Dump writes the effective bindings to w in the keybindings file format, grouped by section with # comments. Output can be loaded back with Parse.
func (*Keymap) HelpSections ¶
func (km *Keymap) HelpSections() []HelpSection
HelpSections returns grouped help entries with effective key bindings. Actions with no bound keys are omitted.