Command Parameter Objects
When a command is executed the command parameters property determines what expressions are passed into the parameters of the function called by the command.
A typical command will be defined something like this:
In this case, the CommandParameters property is set to Expression and this determines what expressions are passed to the FactorCommand function.
If no CommandParameters property is present on a command, the default command parameter settings of Command parameters: HighlightExpression are used.
Commands can be defined to act on the highlighted term or on the whole expression. For example, the Left and Right commands, which move the highlighted term in the parent object are examples of commands that need the parent expression of the highlighted term in order to be able to work correctly. Because of this, the Left and Right commands have the Command parameters: Expression property.
The parameters of the CommandParameters property can be one or more of the following:
Command parameter | Description |
---|---|
HighlightExpression |
This is the default if a command object definition doesn't have a command parameters property. This parameter is just the highlighted expression. No Highlight objects are inserted. |
Expression |
Includes the whole expression and inserts a Highlight(term) object in place of any term that is highlighted. The expression will only include terms up to the first ContentList. |
ExpressionList | Includes all of the expressions in the ContentList rather than just the current expression. This is used in commands like Enter and Backspace where the previous or next expression in the ContentList is needed |
Declarations | Any expression if type Declaration in the current Document module will be passed into this paramter when Declarations appears in the CommandParameters property. If there is more than one declaration in the module, a List is created. See Declaration Objects for more details. |
FromClipboard | If this setting appears in a CommandParameters property in a command the expression on the clipboard is included in the parameters passed to the function. For an example, look at the Paste command in the Core library. |
ModuleSettings | The module settings include the notation, the edit mode and the type of module (Object module, Unit test module, or Document module). This command parameter is added to commands like Backspace and Copy where one or more of the module settings is used to determine how expressions are processed. |
The Expression parameter type property is used with the command parameter property to determine how the expression passed to a command is built. When the Expression parameter type is DisplaySettings the terms of the expression will include information about any display properties that have been applied to the term.
Expression parameter type | Description |
---|---|
Normal | |
DisplaySettings |
If this term has settings (like the rendering name) attached to it, it's replaced by Setting[term, settings]. Examples of the use of the DisplaySettings expression parameter type include the Rendering Options command and the Increment and Decrement commands. These commands act on the display settings of the highlighted expression. |
You can see examples of how these objects are used by looking at the Execution Details for commands like Left, Right and Move. To do this, turn on the Execution Details, highlight an appropriate expression and invoke one of these commands.