Documentation
¶
Overview ¶
Package keymap turns key events into named actions.
Keeping key knowledge out of the UI is what lets the whole mapping be tested without a terminal. There is one map, Default; nothing overrides it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action int
Action is something the user asked for, independent of how they asked.
const ( // ActionNone means the event is not a command; the widget should handle // it as ordinary input. ActionNone Action = iota // Running. ActionRun ActionRunAll ActionCancel // ActionCopyOrCancel is Ctrl+C, whose meaning depends on whether text is // selected. The keymap cannot see that state, so it names the ambiguity // instead of guessing. ActionCopyOrCancel // Cursor movement. These are the one place ⌘ and Ctrl differ: on macOS // ⌘← goes to the start of a line while Ctrl← moves by word. ActionWordLeft ActionWordRight ActionSelectWordLeft ActionSelectWordRight ActionLineStart ActionLineEnd ActionSelectLineStart ActionSelectLineEnd ActionDeleteWordLeft ActionDeleteToLineStart // Editing. ActionCopy ActionCut ActionPaste ActionSelectAll ActionToggleComment ActionDuplicateLine ActionDeleteLine // Navigation and panes. ActionNextPane ActionPrevPane ActionToggleSidebar ActionRefreshSchema ActionUseSchema ActionComplete ActionFind ActionFindNext ActionFindPrev ActionSearchHistory // ActionCycleTab moves through the tabs of whichever pane has focus. ActionCycleTab // ActionInspect shows the selected result row read down the page instead // of across it. ActionInspect // ActionSortColumn orders the results by the selected column, and back // again — the third press restores the order the server sent. ActionSortColumn // ActionCopyRow puts the row under the grid's cursor on the clipboard, // tab separated, so it lands in a spreadsheet as columns. ActionCopyRow // ActionCopyResult puts the whole result on the clipboard, in a format // chosen when the key is pressed. ActionCopyResult // ActionSwitchDataSource opens the datasource list: connect to another // one, or add, edit and delete entries. ActionSwitchDataSource // Application. ActionHelp ActionQuit )
func AllActions ¶
func AllActions() []Action
AllActions lists every bindable action in help-screen order.
type Binding ¶
type Binding struct {
Key tcell.Key
Rune rune // only meaningful when Key is tcell.KeyRune
Mods tcell.ModMask
}
Binding is one key combination in a canonical form.
Canonical means: a combination that can be written as a rune is stored as KeyRune plus a lower-case rune, never as one of tcell's control-code constants. Terminals disagree about which form they send — an extended terminal reports Ctrl+A as KeyRune 'a' with ModCtrl, a legacy one as KeyCtrlA — and folding both into one shape is what lets a single registration serve every terminal.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map resolves key events to actions.
func (*Map) DisplayBindings ¶
DisplayBindings returns an action's bindings with duplicates collapsed, for the help screen.
Some bindings exist only so a key keeps working on terminals that cannot report it properly — Ctrl+J standing in for Ctrl+Enter, for instance. They render identically to the binding they stand for, and listing both makes the table look broken. They stay bound; they just stop being advertised.