Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
215 lines (184 loc) · 17.9 KB

cp.commands.md

File metadata and controls

215 lines (184 loc) · 17.9 KB

docs » cp.commands


Commands Module.

Submodules

API Overview

API Documentation

Constants

Signature cp.commands.DEFAULT_EXTENSION -> string
Type Constant
Description The menubar position priority.

Functions

Signature cp.commands.getShortcutsPath(name) -> string
Type Function
Description Returns the path to the named shortcut set.
Signature cp.commands.group(id) -> cp.command or nil
Type Function
Description Creates a collection of commands. These commands can be enabled or disabled as a group.
Parameters
  • id - The ID to retrieve
Returns
  • cp.commands - The command group with the specified ID, or nil if none exists.
Signature cp.commands.groupIds() -> table
Type Function
Description Returns an array of IDs of command groups which have been created.
Parameters
  • None
Returns
  • table - The array of group IDs.
Signature cp.commands.groups() -> table of cp.commands
Type Function
Description Returns a table with the set of commands.
Parameters
  • id - The ID to retrieve
Returns
  • cp.commands - The command group with the specified ID, or nil if none exists.
Signature cp.commands.loadFromFile(name) -> boolean
Type Function
Description Loads a shortcut set from the standard location with the specified name.
Parameters
  • name - The name of the shortcut set. E.g. "My Custom Shortcuts"
Returns
  • true if the file was found and loaded successfully.
Signature cp.commands.new(id) -> cp.commands
Type Function
Description Creates a collection of commands. These commands can be enabled or disabled as a group.
Parameters
  • id - The unique ID for this command group.
Returns
  • cp.commands - The command group that was created.
Signature cp.commands.saveToFile(name) -> boolean
Type Function
Description Saves the current shortcuts for all groups to a file in the standard location with the provided name.
Parameters
  • name - The name of the command set. E.g. "My Custom Commands"
Returns
  • true if the shortcuts were saved successfully.

Fields

Signature cp.commands.enabled <cp.prop: boolean>
Type Field
Description If enabled, the commands in the group will be active as well.
Signature cp.commands.isEditable <cp.prop: boolean>
Type Field
Description If set to false, the command group is not user-editable.

Methods

Signature cp.commands:activate(successFn, failureFn) -> nil
Type Method
Description Will trigger an 'activate' event, and then execute either the successFn or failureFn if the
Parameters
  • successFn - the function to call if successfully activated.
  • failureFn - the function to call if not activated after 5 seconds.
Returns
  • Nothing.
Signature cp.commands:add(commandId) -> cp.commands.command
Type Method
Description Adds a new command with the specified ID to this group. Additional configuration
Parameters
  • commandId - The unique ID for the new command.
Returns
  • The new cp.commands.command instance.
Signature cp.commands:clear() -> cp.commands
Type Method
Description Clears all commands and their shortcuts.
Parameters
  • None
Returns
  • The command group instance.
Signature cp.commands:deleteShortcuts() -> cp.commands
Type Method
Description Clears all shortcuts associated with commands in this command group.
Parameters
  • None
Returns
  • The command group instance.
Signature cp.commands:disable() -> cp.commands
Type Method
Description Disables the command group.
Parameters
  • None
Returns
  • The command group instance.
Signature cp.commands:enable() -> cp.commands
Type Method
Description Enables the command group.
Parameters
  • None
Returns
  • The command group instance.
Signature cp.commands:get(commandId) -> cp.commands.command
Type Method
Description Returns the command with the specified ID, or nil if none exists.
Parameters
  • commandId - The command ID to retrieve.
Returns
  • The cp.commands.command, or nil.
Signature cp.commands:getAll() -> table of cp.commands.command
Type Method
Description Returns the table of commands, with the key being the ID and the value being the command instance. Eg:
Signature cp.commands:id() -> string
Type Method
Description Returns the unique ID of the command group.
Parameters
  • None
Returns
  • The command group ID string.
Signature cp.commands:loadShortcuts(data) -> nil
Type Method
Description Loads the shortcut details in the data table and applies them to the commands in this group.
Parameters
  • data - The data table containing shortcuts.
Returns
  • Nothing
Signature cp.commands:saveShortcuts() -> table
Type Method
Description Returns a table that is approprate to be saved to file that contains the shortuct
Parameters
  • None
Returns
  • The table of shortcuts for commands.
Signature cp.commands:watch(events) -> cp.commands
Type Method
Description Adds an event watcher to the command group.
Parameters
  • events - The table of events to watch for (see Notes).
Returns
  • The command group instance.
Notes
  • The table can have properties with the following functions, which will be called for the specific event: add(command): Called after the provided cp.commands.command instance has been added. activate() Called when the command group is activated. enable(): Called when the command group is enabled. disable(): Called when the command group is disabled.