A type alias for a user-defined command function.
A type alias for a simple immutable string dataset.
Construct a new command registry.
A signal emitted when a command has changed.
This signal is useful for visual representations of commands which need to refresh when the state of a relevant command has changed.
A signal emitted when a command has executed.
Care should be taken when consuming this signal. It is intended to be used largely for debugging and logging purposes. It should not be (ab)used for general purpose spying on command execution.
A signal emitted when a key binding is changed.
A read-only array of the key bindings in the registry.
Clear the internal pending state.
Clear the pending timeout.
Execute the command for the given key binding.
If the command is missing or disabled, a warning will be logged.
Handle the partial match timeout.
Replay the keydown events which were suppressed.
Start or restart the pending timeout.
Add a command to the registry.
The unique id of the command.
The options for the command.
A disposable which will remove the command.
Add a key binding to the registry.
The options for creating the key binding.
A disposable which removes the added key binding.
If multiple key bindings are registered for the same sequence, the binding with the highest selector specificity is executed first. A tie is broken by using the most recently added key binding.
Ambiguous key bindings are resolved with a timeout. As an example,
suppose two key bindings are registered: one with the key sequence
['Ctrl D']
, and another with ['Ctrl D', 'Ctrl W']
. If the user
presses Ctrl D
, the first binding cannot be immediately executed
since the user may intend to complete the chord with Ctrl W
. For
such cases, a timer is used to allow the chord to be completed. If
the chord is not completed before the timeout, the first binding
is executed.
Get the short form caption for a specific command.
The id of the command of interest.
The arguments for the command.
The caption for the command, or an empty string if the command is not registered.
Get the extra class name for a specific command.
The id of the command of interest.
The arguments for the command.
The class name for the command, or an empty string if the command is not registered.
Get the dataset for a specific command.
The id of the command of interest.
The arguments for the command.
The dataset for the command, or an empty dataset if the command is not registered.
Execute a specific command.
The id of the command of interest.
The arguments for the command.
A promise which resolves with the result of the command.
The promise will reject if the command throws an exception, or if the command is not registered.
Test whether a specific command is registered.
The id of the command of interest.
true
if the command is registered, false
otherwise.
Get the icon class for a specific command.
The id of the command of interest.
The arguments for the command.
The icon class for the command, or an empty string if the command is not registered.
Get the icon label for a specific command.
The id of the command of interest.
The arguments for the command.
The icon label for the command, or an empty string if the command is not registered.
Test whether a specific command is enabled.
The id of the command of interest.
The arguments for the command.
A boolean indicating whether the command is enabled,
or false
if the command is not registered.
Test whether a specific command is toggled.
The id of the command of interest.
The arguments for the command.
A boolean indicating whether the command is toggled,
or false
if the command is not registered.
Test whether a specific command is visible.
The id of the command of interest.
The arguments for the command.
A boolean indicating whether the command is visible,
or false
if the command is not registered.
Get the display label for a specific command.
The id of the command of interest.
The arguments for the command.
The display label for the command, or an empty string if the command is not registered.
List the ids of the registered commands.
A new array of the registered command ids.
Get the mnemonic index for a specific command.
The id of the command of interest.
The arguments for the command.
The mnemonic index for the command, or -1
if the
command is not registered.
Notify listeners that the state of a command has changed.
The id of the command which has changed. If more than one command has changed, this argument should be omitted.
Process a 'keydown'
event and invoke a matching key binding.
The event object for a 'keydown'
event.
This should be called in response to a 'keydown'
event in order
to invoke the command for the best matching key binding.
The registry does not install its own listener for 'keydown'
events. This allows the application full control over the nodes
and phase for which the registry processes 'keydown'
events.
Get the usage help text for a specific command.
The id of the command of interest.
The arguments for the command.
The usage text for the command, or an empty string if the command is not registered.
Create a normalized keystroke for a 'keydown'
event.
The event object for a 'keydown'
event.
A normalized keystroke, or an empty string if the event does not represent a valid keystroke for the given layout.
Normalize a keystroke into a canonical representation.
The keystroke of interest.
The normalized representation of the keystroke.
This normalizes the keystroke by removing duplicate modifiers and extra primary keys, and assembling the parts in a canonical order.
The Cmd
modifier is ignored on non-Mac platforms.
Parse a keystroke into its constituent components.
The keystroke of interest.
The parsed components of the keystroke.
The keystroke should be of the form:
[<modifier 1> [<modifier 2> [<modifier N> ]]]<primary key>
The supported modifiers are: Accel
, Alt
, Cmd
, Ctrl
, and
Shift
. The Accel
modifier is translated to Cmd
on Mac and
Ctrl
on all other platforms.
The parsing is tolerant and will not throw exceptions. Notably:
Generated using TypeDoc
An object which manages a collection of commands. The namespace for the
CommandRegistry
class statics.Notes
A command registry can be used to populate a variety of action-based widgets, such as command palettes, menus, and toolbars.