Private constructor to enforce singleton pattern. Initializes the command stack with system and default command groups.
StaticDEFAUT_The name of the default user command group
StaticSYSTEMT_The name of the system command group
The command currently executing, or null when no command is active.
A command is considered active from the moment markActive is
called by the dispatcher up until its trigger() promise settles and
clearActive releases the slot.
Adds a command to the specified command group.
The name of the command group. If empty, uses the default group.
The global (untranslated) name of the command. Must be unique within the group.
The local (translated) name of the command. Defaults to global name if empty.
The command object to add to the stack.
OptionalcmdAlias: string | string[]Optional command alias or alias list. Aliases are case-insensitive and normalized to uppercase during registration.
Cancels the currently active command, if any, and waits for it to settle.
Mirrors AutoCAD's behavior of cancelling the running command when a new
one starts: the active prompt is rejected via
AcEditor.cancelActiveInput (which maps to AcEdPromptStatus.Cancel
inside the prompt result), and the command's trigger() promise is awaited
so its commandEnded lifecycle hook completes before the caller proceeds.
Calling this method when no command is active is a no-op.
Releases the active slot if it currently belongs to the supplied command.
Guarded by an identity check so that out-of-order callbacks (for example, a late cleanup after the slot has already been taken by a successor command) cannot clear unrelated state.
Command whose active slot should be released
Gets all aliases of the specified command in a command group.
Target command object
OptionalcommandGroupName: stringOptional command group name. If omitted, the first matching group is used.
Alias list in registration order
Return an iterator that can be used to traverse all of command objects in this command stack (that is, the iterator iterates through all commands in all groups).
Return an iterator that can be used to traverse all of command objects in this command stack.
Search through all of the global and untranslated names in all of the command groups in the command stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not be found. If more than one command of the same name is present in the command stack (that is, in separate command groups), then the first one found is used.
If a mode is specified, the command is only returned if it is compatible with that mode. Higher value modes are compatible with lower value modes.
Input the command name to search for
Optionalmode: AcEdOpenModeOptional access mode to check compatibility. Only returns the command if it's compatible with this mode.
Return the matched AcEdCommand object if a match is found and compatible with the mode. Otherwise, return undefined.
Search through all of the local and translated names in all of the command groups in the command stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not be found. If more than one command of the same name is present in the command stack (that is, in separate command groups), then the first one found is used.
If a mode is specified, the command is only returned if it is compatible with that mode. Higher value modes are compatible with lower value modes.
Input the command name to search for
Optionalmode: AcEdOpenModeOptional access mode to check compatibility. Only returns the command if it's compatible with this mode.
Return the matched AcEdCommand object if a match is found and compatible with the mode. Otherwise, return undefined.
Records the command that is about to begin executing.
Called by the dispatcher immediately after invoking cmd.trigger(context).
The supplied view is used to reach the editor's input manager when an
outside caller requests cancellation via cancelActive.
Command that just started executing
View bound to the command's execution context
Promise returned by the command's trigger() call
Removes all of registered commands
Remove the command with the global and untranslated name cmdGlobalName from the cmdGroupName
command group. Return true if successful. Return false if no command with the global and untranslated
name cmdGlobalName is found in the cmdGroupName command group.
Input the name of the command group containing the command to be removed
Input the command name which is to be removed from cmdGroupName
Return true if successful. Return false if no command with the global and untranslated
name cmdGlobalName is found in the cmdGroupName command group.
Remove the command group with the name GroupName from the command stack and delete the command group
dictionary object and all the AcEdCommand objects stored within it.
Input the name of the command group to be removed from the command stack.
Return true if successful. Return false if no command group is found with the name GroupName.
Fuzzy search for commands by prefix using the command iterator.
This method iterates through all commands in all command groups and returns those whose global or local names start with the provided prefix. The search is case-insensitive. If a mode is specified, only commands compatible with that mode are returned. Higher value modes are compatible with lower value modes.
The prefix string to search for. Case-insensitive.
Optionalmode: AcEdOpenModeOptional access mode to filter commands. Only commands compatible with this mode are returned.
An array of objects containing matched commands and their corresponding group names.
The class to create, define, and register command objects.
It is used to manages all command registration and lookup functionality. Commands are organized into groups, with system commands (ACAD) and user commands (USER) being the default groups.
Example