Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Commands

Thomas Wilburn edited this page Dec 5, 2013 · 9 revisions

Caret is powered by a command architecture: menus, keyboard events, and plugins respond to command/argument messages for almost all user-facing operations (and many internal operations, as well). This page lists all the known commands and their effects, should you want to customize your menus or keyboard mappings.

Commands consist of two parts, the command string and an (optional) argument. Command strings are themselves split into two parts: the namespace and the verb, separated by a colon. Arguments are not required for all commands, but allow some commands to operate in different ways or with some variation. Browsing through the menu and keyboard settings should show numerous examples of these commands in action, and they are also often attached to Caret's DOM elements by way of command and argument attributes.

App commands

  • app:exit - Close the Caret window
  • app:about - Display the "About Caret" dialog.
  • app:check-for-updates - query the update server for the latest version. If there is a newer version, Caret will display a notification and prompt you to restart.
  • status:set - Display a message in the status bar.
  • status:clear - Remove any message in the status bar.
  • status:toast - Display a message in the status bar, then remove it automatically. Recommended over status:set and status:clear, and useful for posting information from plugins.
  • init:startup - Internal use only. Fired when Caret starts up, once all settings are loaded for the first time.
  • init:restart - Internal use only. Fired when settings files change or are reloaded, so that modules can reinitialize to the new values.

Editor commands

  • ace:command - Triggers Ace commands through its execCommand method. The argument is the Ace command you want to fire. See Ace docs/source for more information.
  • ace:togglemacro - Turns Ace's macro recording on or off, and displays its state in the statusbar.
  • editor:insert - Calls Ace's insert() method with the text specified in the argument.
  • editor:default-zoom - Resets the zoom to its default size.
  • editor:adjust-zoom - Moves the font size up or down by the number of pixels passed into the argument.
  • editor:theme - Change the editor's theme to the value specified by the argument.
  • sublime:expand-to-line
  • sublime:expand-to-paragraph
  • sublime:expand-to-matching
  • sublime:tabs-to-spaces
  • sublime:spaces-to-tabs

Session commands (tab management)

  • session:new-file - Opens a new tab. If an argument is provided, it will be used as the starting content. If not, it'll be empty.
  • session:open-file - Opens a new tab from a file.
  • session:save-file - Saves the file. If the file is new, will ask where to save.
  • session:save-file-as - Like session:save-file but always asks for a destination.
  • session:revert-file - Reload the tab's contents from disk.
  • session:check-file - Test to see if the file has been modified since it was last loaded.
  • session:open-settings-file - Open one of the JSON settings "files" from sync storage. The argument should specify the file name.
  • session:open-settings-defaults - Open the default form of the settings JSON.
  • session:open-launch - Internal use only. Opens files from the Files app.
  • session:raise-tab - Bring the tab at the index specified by the argument to the foreground. Will also fire session:check-file.
  • session:close-tab - Close the current tab. Will ask to save if the contents have been modified.
  • session:change-tab - Jumps to the last used tab. Not usually called through commands.
  • session:render - Internal use only. Used to trigger a re-render of the tab elements.
  • session:syntax - Detect the syntax mode for a tab based on its extension.

Project commands

  • project:add-dir - Open the "Add directory" window.
  • project:remove-all - Strip all directories from the current project.
  • project:generate - Trigger the "Save Project File" action.
  • project:open-file - Open a file in the project, specifying the file's display path in the argument.
  • project:refresh-dir - Reload the directory listing in the project navigator panel.
  • project:open - Ask the user for the location of a project file and load it.
  • project:edit - Open the current project file in a new tab and watch it for changes.
  • project:clear - Unset the current project from memory.

API/Plugin commands (still in beta)

  • api:execute - Looks in the External Commands JSON file and fires off a command matching the ID provided in the argument. See the JSON file for how these commands should be structured. You can use this to send messages to other Chrome apps and extensions, assuming they can accept messages from Caret.
  • Other applications can send messages to Caret's ID with the following format:
{
  command: "commandName",
  argument: "optional"
}

This format should look familiar if you've edited the keys.json or menus.json files at all.

Internal commands (module-to-module communication)

  • settings:change-local - Notify the settings module that a virtual settings file has been changed and needs to be reloaded from storage.
  • settings:delete-local - Erase any custom settings JSON for the file specified in the command argument.

Clone this wiki locally