A type alias for a user-defined command function.
A type alias for a simple immutable string dataset.
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. The command system is used by many components for many user actions. Handlers registered with this signal must return quickly to ensure the overall application remains responsive.
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.
Get the description for a specific command.
The id of the command of interest.
The description for the command.
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 renderer for a specific command.
DEPRECATED: if set to a string value, the .icon field will function as an alias for the .iconClass field, for backwards compatibility. In the future when this is removed, the default return type will become undefined.
The id of the command of interest.
The arguments for the command.
The icon renderer for the command, or an empty string if the command is not registered.
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 toggleable.
The id of the command of interest.
The arguments for the command.
A boolean indicating whether the command is toggleable,
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.
When the keydown event is processed, if the event target or any of its
ancestor nodes has a data-lm-suppress-shortcuts
attribute, its keydown
events will not invoke commands.
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.
Format keystrokes for display on the local system.
If a list of keystrokes is provided, it will be displayed as a comma-separated string
The keystrokes to format
The keystrokes representation
Check if 'keydown'
event is caused by pressing a modifier key that should be ignored.
The event object for a 'keydown'
event.
true
if modifier key was pressed, false
otherwise.
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.
Get the platform-specific normalized keys for an options object.
The options for the key binding.
Array of combined, normalized keys.
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.