User Defined Actions
Prev
Next

User Defined Actions

Actions are very common in every application. You meed them often when you use any application. Clicking on a toolbar icon, selecting a menu item or using a shortcut usually executes an action. In Quanta Plus actions are taken to the next level. Instead of hardcoded actions (that are created by the application programmer at the source code level) it is possible for the ordinary user to create and modify actions and by this way adding new functionality to Quanta Plus. These are the user defined actions, and many of the standard Quanta Plus actions are user defined (and user modifiable) actions as well.

There are three types of user definable actions:

Creating actions

You can create an action by going to Settings->Configure Actions . Click on New Action and you will face a similar dialog:



Type

Specifies the action's type (Text, Tag, Script).

Text

The user visible name of the action.

The button near the Text label

The icon assigned to this action. Click on it in order to change the current icon.

Tool tip

Short description of what the action does.

Shortcut

The shortcut assigned to this action. Click on Custom or the button near Custom to assign a shortcut; click on None to remove the currently assigned shortcut.

Container toolbars

The user defined toolbars where this action appears. See the section called “Creating Toolbars”.

Detailed Settings

Specific settings for the different type of actions. See below.

Text actions



The simplest actions. You can enter some text in the Detailed Settings area and whenever the action is executed this text will be inserted in your document at the current cursor position. See the below example.

Tag actions

Useful to insert XML tags, but of course you can use them for other purposes as well.



<tag>

The name of the tag.

</tag>

If checked when the action is executed this text will be inserted as a closing tag. If there is a selected area in the document before you execute the action, the <tag> will be inserted before the selected area and the </tag> after.

Run "Edit tag" dialog if available

If checked and there is a tagXML file for this tag, a tag editing dialog will be shown prior of inserting the tag inside the document, so you can fine-tune the tag attributes.

The <tag> and </tag> will be inserted as you've typed there. The <, > or the / sign won't be automatically appended.

Script actions



The most powerful action type. With the help of this action you can run external applications (usually scripts, but it's not limited to scripts), which can alter your document or use your document (or part of your document) as input. Examples from Quanta Plus itself are the Quick Start dialog, the various View In... actions for the (X)HTML DTEPs.

First you have to enter the name of your script with the interpreter as well. Example: sh /home/myHome/myScript.sh.

Although you can use full paths, the recommended way is to use the %scriptdir variable in the command line, like sh %scriptdir/myScript.sh. This way Quanta Plus will try to locate your script in the following places:

  • global script folder: $TDEDIR/share/apps/quanta/scripts

  • local script folder: $TDEHOME/share/apps/quanta/scripts

  • your path: $PATH

There are other special variables that you can use in the command line:
  • %f: will be replaced with the URL of the current document. In case of local documents, file:/ will be stripped from the document.

  • %input: will be replaced with the selected input. See below.

  • %projectbase: will be replaced with the URL of the current project. It is empty if no project is loaded.

  • %pid: will be replaced with the PID of the running Quanta Plus process. If Quanta Plus is running in unique mode, the "unique " text will be prepended to the PID number. Useful when you use DCOP to control Quanta Plus from the external script.

  • %userarguments: useful in case of events. This entry will be replaced by the event properties in the following order:

    First argument

    The unique id of the script

    Second argument

    the event name

    Third argument

    the parameters for the event, usually the file name of the current document or the path to the project file.

Aside of the above methods the script can receive input from Quanta Plus on the standard input. In the Input combobox you can select what to send to the standard input. Choices are:

  • None: nothing is sent to the script.

  • Current document: the whole document is sent to the script.

  • Selected text: the selected area of the document is sent to the script. Using the %input variable usually makes sense only when using this setting.

Similar to the Input you can catch the output of the executed application. There are two kind of outputs:

  • normal output, printed to the standard output;

  • error messages, printed to the standard error.

You can specify what should happen with the text printed to the standard output. This can be done by modifying the value of the Output combobox:
  • None: the output of the application is ignored.

  • Insert in cursor position: the output will be inserted in the current document and the cursor position.

  • Replace selection: the selected area of the document will be replaced with the output.

  • Replace selection: the selected area of the document will be replaced with the output.

  • Create a new document: a new document will be created and will contain all the output of the script.

  • Replace current document: the entire document will be replaced with the output.

  • Message window: the output will appear in the Messages toolview.

The choices for the standard error output (Error) are the same as for the normal output.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team