Documentation
¶
Overview ¶
Package keybinding holds keys, the keymap, chords and the keybinding resolver (SPEC §11.3).
Index ¶
- Constants
- func DefaultKeybindingsJSON(reg *Registry) string
- func ParseUserFile(text string) ([]Item, []Problem)
- func UserKeybindingsPath(paths storage.Paths, profile string) (string, error)
- func ValidateWhen(when string) error
- func WhenIsEntirelyIncluded(a, b contextkey.Expr) bool
- func WhensOverlap(a, b string) bool
- type Chord
- type ChordMatch
- type CommandInfo
- type Dispatcher
- func (d *Dispatcher) Dispatch(ctx contextkey.Context, press Chord) Outcome
- func (d *Dispatcher) Expire() bool
- func (d *Dispatcher) InChordMode() bool
- func (d *Dispatcher) LeaveChordMode()
- func (d *Dispatcher) PendingLabel() string
- func (d *Dispatcher) Recording() bool
- func (d *Dispatcher) SetRecorder(r Recorder)
- func (d *Dispatcher) SetResolver(r *Resolver)
- type Editing
- func (e Editing) Add(text, command, key, when string, args any) (string, error)
- func (e Editing) Edit(text string, row Row, key, when string) (string, error)
- func (e Editing) Overwrite(text string, rows []Row) (string, error)
- func (e Editing) Remove(text string, row Row) (string, error)
- func (e Editing) Reset(text string, row Row) (string, error)
- func (e Editing) UpdateWhen(text string, row Row, when string) (string, error)
- type Item
- type Key
- type KeyMatches
- type KeyRecorder
- type Keybinding
- type Model
- type Outcome
- type Problem
- type Recorder
- type Registry
- type Resolution
- type Resolver
- func (r *Resolver) DefaultBoundCommands() map[string]bool
- func (r *Resolver) DefaultKeybindings() []Item
- func (r *Resolver) Keybindings() []Item
- func (r *Resolver) LookupKeybindings(command string) []Item
- func (r *Resolver) LookupPrimaryKeybinding(command string, ctx contextkey.Context, enforceContextCheck bool) (Item, bool)
- func (r *Resolver) Replace(o *Resolver)
- func (r *Resolver) Resolve(ctx contextkey.Context, currentChords []string, keypress string) Resolution
- type Result
- type ResultKind
- type Row
- type Rule
- type Source
Constants ¶
const ( // WeightEditorCore is the weight of the editor's own commands. WeightEditorCore = 0 // WeightEditorContrib is the weight of editor contributions. WeightEditorContrib = 100 // WeightWorkbenchContrib is the weight of workbench commands. WeightWorkbenchContrib = 200 )
Weights order the built-in keybindings: of two bindings for the same key whose conditions both hold, the one with the greater weight wins (it comes later in the sorted list).
Ported from VS Code: src/vs/platform/keybinding/common/keybindingsRegistry.ts
const ChordTimeout = 5 * time.Second
ChordTimeout is how long the dispatcher waits for the next chord of a sequence before it forgets the chords pressed so far.
const DefaultKeybindingsHeader = "// Override key bindings by placing them into your key bindings file."
DefaultKeybindingsHeader is the comment the default keybindings document starts with.
const EmptyUserFile = "// Place your key bindings in this file to override the defaults\n[\n]\n"
EmptyUserFile is the text of a keybindings.json that Emetos makes.
Variables ¶
This section is empty.
Functions ¶
func DefaultKeybindingsJSON ¶
DefaultKeybindingsJSON is the text of the default keybindings document ("Open Default Keyboard Shortcuts (JSON)", SPEC §11.3): a JSONC array with a line for each built-in keybinding, in the order of the keymap, in the layout VS Code writes. Lines are separated by "\n".
Ported from VS Code: src/vs/workbench/services/keybinding/common/keybindingIO.ts (writeKeybindingItem) and src/vs/workbench/services/keybinding/browser/keybindingService.ts (getDefaultKeybindingsContent)
func ParseUserFile ¶
ParseUserFile reads the text of keybindings.json: an array of objects with "key" (chords such as "ctrl+k ctrl+c"), "command" (a leading "-" removes a built-in keybinding of that command), "when" and "args". The result are the user's items, in file order, to pass as the overrides of NewResolver. An entry whose key, command or when-clause cannot be read is reported in the problems and skipped; VS Code would keep an entry with an unknown key as an unbound command, which makes a removal with a typo remove every key of the command, so Emetos does not.
Ported from VS Code: src/vs/workbench/services/keybinding/common/keybindingIO.ts
func UserKeybindingsPath ¶
UserKeybindingsPath is the keybindings.json of a profile (SPEC §11.3), next to its settings.json.
func ValidateWhen ¶
ValidateWhen checks a when-clause that is going into the file; an empty text is no clause. It fails with the tag WhenClauseInvalid of package contextkey.
func WhenIsEntirelyIncluded ¶
func WhenIsEntirelyIncluded(a, b contextkey.Expr) bool
WhenIsEntirelyIncluded reports whether it is provable that when-clause a implies b. A nil clause or true is "always".
func WhensOverlap ¶
WhensOverlap tells whether two when-clauses, written as text, can hold together (see FindConflicts). A text that is not a clause is compared as text.
Types ¶
type Chord ¶
Chord is a key pressed together with modifiers. Ctrl is the Ctrl key and Meta the Super (Windows) key; Emetos runs on Linux only, so there is no CtrlCmd.
Ported from VS Code: src/vs/base/common/keybindings.ts (KeyCodeChord)
func (Chord) AriaLabel ¶
AriaLabel is the chord as a screen reader should read it: "Control+Shift+K".
func (Chord) Dispatch ¶
Dispatch is the string the resolver matches a pressed chord with: the modifiers in the order ctrl, shift, alt, meta, then the name of the key in the UI, such as "ctrl+shift+K". It is empty for a modifier key alone.
Ported from VS Code: src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
func (Chord) IsModifierKey ¶
IsModifierKey tells whether the chord is a modifier key alone (or has no key at all).
func (Chord) UserSettingsLabel ¶
UserSettingsLabel is the chord as keybindings.json spells it: "ctrl+shift+k".
type ChordMatch ¶
type ChordMatch struct {
Ctrl, Shift, Alt, Meta, Key bool
}
ChordMatch says which parts of a chord a search matched: the modifiers and the key.
type CommandInfo ¶
type CommandInfo struct {
// ID is the command id.
ID string
// Title and Category are those of the command; both empty for a command the palette does not list.
Title, Category string
}
CommandInfo is what the model needs to know of a command: its id and the words the UI calls it.
func (CommandInfo) Label ¶
func (c CommandInfo) Label() string
Label is the name of the command in the table, "Category: Title", "Title", or "" when it has none.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher turns key presses into commands: it keeps the chords pressed so far, asks the resolver what the sequence means, and tells the caller what to do. It does not run commands itself and is not safe for concurrent use: call it from the UI thread.
Ported from VS Code: src/vs/platform/keybinding/common/abstractKeybindingService.ts
func NewDispatcher ¶
func NewDispatcher(r *Resolver, now func() time.Time) *Dispatcher
NewDispatcher makes a dispatcher over a resolver. now is the clock for the chord timeout; nil means time.Now.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(ctx contextkey.Context, press Chord) Outcome
Dispatch resolves a key press against the keymap in the context ctx of the focused widget. A press of a modifier key alone does nothing and keeps a pending chord.
func (*Dispatcher) Expire ¶
func (d *Dispatcher) Expire() bool
Expire leaves chord mode when no chord was pressed for ChordTimeout. The UI calls it from a timer (VS Code checks every 500 ms). It reports whether it left chord mode.
func (*Dispatcher) InChordMode ¶
func (d *Dispatcher) InChordMode() bool
InChordMode tells whether a chord was pressed and the dispatcher waits for the next.
func (*Dispatcher) LeaveChordMode ¶
func (d *Dispatcher) LeaveChordMode()
LeaveChordMode forgets the chords pressed so far.
func (*Dispatcher) PendingLabel ¶
func (d *Dispatcher) PendingLabel() string
PendingLabel is the chords pressed so far as the UI shows them, "Ctrl+K, Ctrl+B"; empty when not in chord mode.
func (*Dispatcher) Recording ¶
func (d *Dispatcher) Recording() bool
Recording tells whether the dispatcher is in recording mode.
func (*Dispatcher) SetRecorder ¶
func (d *Dispatcher) SetRecorder(r Recorder)
SetRecorder starts recording mode: every press goes to r, and nothing is resolved. A nil recorder ends it. Starting it forgets pending chords.
func (*Dispatcher) SetResolver ¶
func (d *Dispatcher) SetResolver(r *Resolver)
SetResolver replaces the keymap (after keybindings.json changed) and forgets pending chords.
type Editing ¶
type Editing struct {
Format jsonc.FormattingOptions
}
Editing edits the text of keybindings.json. Format says how the lines it adds are indented.
func (Editing) Add ¶
Add adds the keybinding of a command to the file: an entry with the key, the command, the when-clause and the arguments (nil for none). It fails with the tags KeybindingEditKeyMissing, those of ParseKeybinding and WhenClauseInvalid, KeybindingEditCommandMissing, KeybindingsEditFileInvalid and KeybindingsEditNotArray.
func (Editing) Edit ¶
Edit gives a row another key and when-clause. A keybinding of the file is changed in place; a built-in one is removed with a "-command" entry and replaced by an entry of the new key; a command without a keybinding gets one. It fails with the tags of Add, and KeybindingEntryNotFound.
func (Editing) Overwrite ¶
Overwrite takes the keybindings of the rows away together, as Remove does for each: the user's entries are deleted (the last first, so the positions of the others hold) and the built-in ones get their "-command" entries. It fails with the tags of Remove.
func (Editing) Remove ¶
Remove takes the keybinding of a row away: the entry of the file is deleted; a built-in keybinding gets a "-command" entry (unless the file has it already). It fails with the tags KeybindingEditUnbound, KeybindingEntryNotFound, KeybindingsEditFileInvalid and KeybindingsEditNotArray.
func (Editing) Reset ¶
Reset gives a command its built-in keybindings back: every entry of the file for the command, its own keybindings and its "-command" entries, is deleted. A row that is a built-in keybinding changes nothing. It fails with the tags KeybindingsEditFileInvalid and KeybindingsEditNotArray.
type Item ¶
type Item struct {
// Keybinding is the key sequence as it was written; nil when the item has no key (a
// removal that matches every key of the command, or an unbound command).
Keybinding Keybinding
// Chords are the dispatch strings of the keybinding (see Chord.Dispatch). They are empty
// when the keybinding is nil or has a chord that cannot be dispatched.
Chords []string
// Command is the id of the command. A leading "-" marks a removal of the default
// keybindings of that command; a leading "^" was cut off and set Bubble.
Command string
// Bubble is set when the command id started with "^": the key is not consumed by the
// command, other handlers see it too.
Bubble bool
// Args are the JSON-compatible arguments passed to the command.
Args any
// When is the condition the context must satisfy; nil means always.
When contextkey.Expr
// IsDefault is set for the keybindings of the built-in keymap, false for the user's.
IsDefault bool
// FileEntry is the position of the entry in keybindings.json that made the item, counted from 1, or 0 for an
// item that was not read from the file (the keybindings UI finds the entry to edit with it).
FileEntry int
// contains filtered or unexported fields
}
Item is one keybinding: a key sequence that runs a command when its when-clause holds.
Ported from VS Code: src/vs/platform/keybinding/common/resolvedKeybindingItem.ts
func HandleRemovals ¶
HandleRemovals drops the items whose command is a removal ("-command") and the default items they remove. Only default items can be removed.
func NewItem ¶
func NewItem(kb Keybinding, command string, args any, when contextkey.Expr, isDefault bool) Item
NewItem makes an Item. The command may start with "^" (see Item.Bubble) or "-" (a removal). A modifier-only keybinding such as "shift shift" is dispatched by the lone modifier names.
type Key ¶
type Key int
Key is a key of the keyboard, independent of the layout and of Glutter. The values and the names are VS Code's KeyCode: letters and digits are the keys of a US layout, punctuation is named by its US-layout key (SPEC §9.3).
Ported from VS Code: src/vs/base/common/keyCodes.ts
const ( Unknown Key = iota Backspace Tab Enter Shift Ctrl Alt PauseBreak CapsLock Escape Space PageUp PageDown End Home LeftArrow UpArrow RightArrow DownArrow Insert Delete Digit0 Digit1 Digit2 Digit3 Digit4 Digit5 Digit6 Digit7 Digit8 Digit9 KeyA KeyB KeyC KeyD KeyE KeyF KeyG KeyH KeyI KeyJ KeyK KeyL KeyM KeyN KeyO KeyP KeyQ KeyR KeyS KeyT KeyU KeyV KeyW KeyX KeyY KeyZ Meta ContextMenu F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 NumLock ScrollLock Semicolon Equal Comma Minus Period Slash Backquote BracketLeft Backslash BracketRight Quote OEM8 IntlBackslash Numpad0 Numpad1 Numpad2 Numpad3 Numpad4 Numpad5 Numpad6 Numpad7 Numpad8 Numpad9 NumpadMultiply NumpadAdd NumpadSeparator NumpadSubtract NumpadDecimal NumpadDivide KeyInComposition ABNTC1 ABNTC2 AudioVolumeMute AudioVolumeUp AudioVolumeDown BrowserSearch BrowserHome BrowserBack BrowserForward MediaTrackNext MediaTrackPrevious MediaStop MediaPlayPause LaunchMediaPlayer LaunchMail LaunchApp2 Clear )
The keys. Unknown is the zero value and stands for a key without a name.
func KeyFromString ¶
KeyFromString finds a key by the name the UI shows ("K", "LeftArrow"), ignoring case. It returns Unknown when there is no such key.
func KeyFromUserSettings ¶
KeyFromUserSettings finds a key by a name of keybindings.json ("k", "left", "oem_minus"), ignoring case. It returns Unknown when there is no such key.
func (Key) IsModifier ¶
IsModifier tells whether the key is Ctrl, Shift, Alt or Meta.
func (Key) UserSettings ¶
UserSettings is the name of the key in keybindings.json, in lower case: "k", "left", "[".
type KeyMatches ¶
type KeyMatches struct {
First, Chord ChordMatch
}
KeyMatches are the matches of a search in the keybinding of a row: its first chord and, for a sequence, the second.
type KeyRecorder ¶
type KeyRecorder struct {
// Max is the number of chords a keybinding can have; zero means 2.
Max int
// contains filtered or unexported fields
}
KeyRecorder is a Recorder that collects the chords of a keybinding: each press of a key with its modifiers adds a chord, up to Max chords, after which the next press starts over. Modifier-only presses are not chords; Modifiers shows them while the user holds the keys.
func (*KeyRecorder) Keybinding ¶
func (r *KeyRecorder) Keybinding() Keybinding
Keybinding is the chords recorded so far.
func (*KeyRecorder) Modifiers ¶
func (r *KeyRecorder) Modifiers() Chord
Modifiers are the modifier keys held at the last modifier-only press, as a chord with no key; it is cleared by the next key.
type Keybinding ¶
type Keybinding []Chord
Keybinding is a sequence of chords: one chord, or several pressed one after the other (such as ctrl+k ctrl+c). A nil Keybinding is no key at all.
Ported from VS Code: src/vs/base/common/keybindings.ts (Keybinding)
func ParseKeybinding ¶
func ParseKeybinding(input string) (Keybinding, error)
ParseKeybinding reads a keybinding as keybindings.json spells it: chords separated by white space, each made of modifiers (ctrl, shift, alt, meta, win, cmd) and a key joined with "+", such as "ctrl+shift+k ctrl+c". Case is ignored. An empty input is no keybinding (nil, nil). The [ScanCode] spelling of VS Code is not supported.
Ported from VS Code: src/vs/base/common/keybindingParser.ts
func (Keybinding) AriaLabel ¶
func (k Keybinding) AriaLabel() string
AriaLabel is the keybinding as a screen reader should read it.
func (Keybinding) DispatchChords ¶
func (k Keybinding) DispatchChords() []string
DispatchChords are the strings the resolver matches, one per chord. It is nil when the keybinding has no chords or one of them is a modifier key alone.
func (Keybinding) Equal ¶
func (k Keybinding) Equal(o Keybinding) bool
Equal tells whether two keybindings are the same sequence.
func (Keybinding) Label ¶
func (k Keybinding) Label() string
Label is the keybinding as the UI shows it: "Ctrl+K Ctrl+C".
func (Keybinding) SingleModifierChords ¶
func (k Keybinding) SingleModifierChords() []string
SingleModifierChords are the strings for a keybinding made of modifier keys alone ("ctrl", "shift", "alt", "meta"), such as the double press "shift shift". It is nil when some chord is not a lone modifier.
func (Keybinding) UserSettingsLabel ¶
func (k Keybinding) UserSettingsLabel() string
UserSettingsLabel is the keybinding as keybindings.json spells it: "ctrl+k ctrl+c".
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the list of rows of the keybindings editor. Make one with NewModel; it does not change.
func NewModel ¶
func NewModel(defaults, user []Item, commands []CommandInfo) *Model
NewModel makes the rows from the built-in keybindings, the user's (as ParseUserFile gives them) and the commands. The built-in keybindings that a user's "-command" entry removes are not listed, a command that has no keybinding is listed once without one, and rows are ordered as the editor shows them: those with a keybinding first, then by the name of the command, then the user's before the built-in ones.
func NewModelOfRows ¶
NewModelOfRows makes a model of rows as they are given: their ids are not made again, and rows with the same id are not left out, which NewModel never produces. It lets a test show the editor a model it cannot make.
func (*Model) Fetch ¶
Fetch lists the rows that a search finds, in the order of the table. An empty search finds every row.
func (*Model) FindConflicts ¶
func (m *Model) FindConflicts(kb Keybinding, when, command string) []Row
FindConflicts lists the rows of other commands that have the same key sequence as kb under a when-clause that can hold together with when (SPEC §11.3): the keybindings editor warns about them when the user defines a keybinding, and offers to overwrite them.
Two when-clauses can hold together unless one of them provably excludes the other: they are the same text, one of them is empty, or neither implies the negation of the other (contextkey.Implies; "editorFocus" and "!editorFocus", or "a == 1" and "a == 2", exclude each other, "editorTextFocus" and "textInputFocus" do not). VS Code's editor warns of every row that has the keys whatever its when-clause, and its resolver proves inclusion only (KeybindingResolver.whenIsEntirelyIncluded); this is the middle: a keybinding that is shadowed by another is flagged, one in a place that cannot hold with it is not. A keybinding that is the beginning of another sequence (ctrl+k and ctrl+k ctrl+c) is not reported: only the same sequence is.
command is the command the keybinding is for; its own rows are not conflicts.
Ported from VS Code: src/vs/platform/keybinding/common/keybindingResolver.ts (whenIsEntirelyIncluded, the conflict test of the resolver)
func (*Model) ForCommand ¶
ForCommand lists the rows of a command.
type Outcome ¶
type Outcome struct {
// Handled tells that the key was used (a command runs, a chord is pending, the press
// was recorded, or a chord was cancelled), so the widget must not see it. When false the
// key is left alone and Glutter may type its character.
Handled bool
// Command is the command to run, empty when there is none.
Command string
// Args are the arguments of the command.
Args any
// Bubble is set when the keybinding's command id started with "^": run the command but
// let other handlers see the key too.
Bubble bool
// Status is a message for the status bar ("(Ctrl+K) was pressed. Waiting for second key of
// chord..."); empty when the press says nothing.
Status string
// ClearStatus is set when a status message of an earlier press is to be removed (the
// chord ended).
ClearStatus bool
}
Outcome is what the dispatcher decided for one key press.
type Problem ¶
type Problem struct {
// Index is the position of the entry in the array, or -1 for the file as a whole.
Index int
// Err says what is wrong; it is an *errors.Error with a tag of this package.
Err error
}
Problem is something wrong with keybindings.json. The entry it concerns is skipped, the others still apply.
type Recorder ¶
type Recorder interface {
Record(press Chord)
}
Recorder receives every key press while the dispatcher is in recording mode, modifier-only presses included (the keybindings UI uses it to record a key to search or to bind).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry collects the built-in keybindings. Make one with NewRegistry; it has no global instance.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry makes a registry with the default keymap of Emetos: VS Code's keymap for Linux, for the commands Emetos has. VS Code registers its defaults in code, in the keybindings of each command's registration; each step that adds a command adds its binding here, with the key, secondary keys, when-clause and weight it has there. A when that VS Code builds from the command's key expression and its precondition is written out in full.
Ported from VS Code: src/vs/editor/browser/coreCommands.ts, src/vs/editor/browser/editorExtensions.ts and the contributions under src/vs/editor/contrib/ (linesOperations, multicursor, smartSelect, wordOperations, cursorUndo, lineSelection)
func (*Registry) Defaults ¶
Defaults returns the built-in keybindings, ordered by weight, then by command, then by the second weight. The sort is stable, so rules registered first stay first among equals.
func (*Registry) MustRegister ¶
MustRegister is Register for the built-in table; it panics on an invalid rule.
type Resolution ¶
type Resolution struct {
Kind ResultKind
// Command is the command to run for KbFound; empty when the matching keybinding has no
// command (it unbinds the key).
Command string
// Args are the arguments of the command.
Args any
// Bubble tells that the key is not consumed (the command id had a "^" prefix).
Bubble bool
}
Resolution is the result of resolving a key press.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver maps key sequences to commands and commands to key sequences.
Ported from VS Code: src/vs/platform/keybinding/common/keybindingResolver.ts
func NewResolver ¶
NewResolver makes a resolver from the built-in keybindings and the user's, applying the removals ("-command" items) of both. log receives an explanation of every resolution; it may be nil.
func (*Resolver) DefaultBoundCommands ¶
DefaultBoundCommands are the commands that have a built-in keybinding.
func (*Resolver) DefaultKeybindings ¶
DefaultKeybindings are the built-in items, before removals.
func (*Resolver) Keybindings ¶
Keybindings are all the items in effect, after removals, built-in ones first.
func (*Resolver) LookupKeybindings ¶
LookupKeybindings returns the keybindings that run a command, the most specific (the last one defined) first.
func (*Resolver) LookupPrimaryKeybinding ¶
func (r *Resolver) LookupPrimaryKeybinding(command string, ctx contextkey.Context, enforceContextCheck bool) (Item, bool)
LookupPrimaryKeybinding returns the keybinding to show for a command: the last one whose when-clause holds in ctx. When none holds it returns the last one, or nothing when enforceContextCheck is set.
func (*Resolver) Replace ¶
Replace makes the resolver what o is, in place: the holders of r (the menus, the status bar, the dispatcher of a window) see the keybindings of o from now on. It is how a window follows keybindings.json when the file changes.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(ctx contextkey.Context, currentChords []string, keypress string) Resolution
Resolve tells what happens when the user presses keypress (a Chord.Dispatch string) after the chords in currentChords: ctrl+k is pending and ctrl+c is pressed, for example.
type Result ¶
type Result struct {
Row Row
// Label, ID, When and Source are the places the search matched in the text of those columns, as rune
// offsets.
Label, ID, When, Source []fuzzy.Match
// Keybinding says which chords and keys of the keybinding matched; nil when the search did not match it.
Keybinding *KeyMatches
}
Result is a row that a search found, with where the search matched in it (for the highlights).
type ResultKind ¶
type ResultKind int
ResultKind tells what a key press resolved to.
const ( // NoMatchingKb means no keybinding has this sequence of chords. NoMatchingKb ResultKind = iota // MoreChordsNeeded means a keybinding starts with this sequence but is longer. MoreChordsNeeded // KbFound means a keybinding matches and its command is to be run. KbFound )
The kinds of resolution result.
type Row ¶
type Row struct {
// ID names the row: the command, the keybinding, the when-clause and the source.
ID string
// Command is the id of the command.
Command string
// Label is the name of the command ("Category: Title"), empty for a command without a title.
Label string
// Keybinding is the key sequence; nil for a command that has none.
Keybinding Keybinding
// Key is the keybinding as keybindings.json writes it ("ctrl+k ctrl+c"), and KeyLabel as the UI shows it
// ("Ctrl+K Ctrl+C"); both empty without a keybinding.
Key, KeyLabel string
// When is the when-clause in its normal form, or "".
When string
// Source says where the row comes from.
Source Source
// Args are the arguments of the command.
Args any
// FileEntry is the position of the entry of keybindings.json that made the row, counted from 1; 0 for a
// built-in keybinding or a command without one.
FileEntry int
}
Row is a row of the table: a command with one keybinding (or none) and the condition it holds under.
type Rule ¶
type Rule struct {
// Command is the command id, optionally with a "^" prefix.
Command string
// Weight orders rules (see WeightEditorCore).
Weight int
// Args are the arguments passed to the command.
Args any
// When is the condition for the keybinding; nil means always.
When contextkey.Expr
// Primary is the first key, such as "ctrl+shift+k".
Primary string
// Secondary are alternative keys for the same command.
Secondary []string
}
Rule is a built-in keybinding as the code that registers a command writes it: a command with a primary key and secondary keys, in the syntax of keybindings.json. Keys are already those of Linux; an empty Primary registers no primary key.
type Source ¶
type Source int
Source says where the keybinding of a row comes from.