Chapter 2. Writing macro-commands

Table of Contents
1. How commands are executed
2. A sequence of commands
3. Alternative commands
4. Testing if a command can be executed
5. The "%_" variable
6. Macro-variables
7. Simple use of named variables
8. General use of get
9. Variables mapped to the selection in XXE
10. Contextual commands

The macro-command examples you'll find in this tutorial can be tested by creating a file called customize.xxe in XXE_user_preferences_dir/addon/ and binding the command to be tested to a keystroke.

[Note]

XXE user preferences directory is:

  • $HOME/.xxe10/ on Linux.

  • $HOME/Library/Application Support/XMLmind/XMLEditor10/ on the Mac.

  • %APPDATA%\XMLmind\XMLEditor10\ on Windows. Example: C:\Users\john\AppData\Roaming\XMLmind\XMLEditor10\.

    If you cannot see the "AppData" directory using Microsoft Windows File Manager, turn on Tools>Folder Options>View>File and Folders>Show hidden files and folders.

Example: this customize.xxe file binds a macro-command named convertToBold to keystroke F2.

<?xml version='1.0' encoding='ISO-8859-1'?>
<configuration
  xmlns="http://www.xmlmind.com/xmleditor/schema/configuration"
  xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration">

<binding>
  <keyPressed code="F2" />
  <command name="convertToBold" />
</binding>

<command name="convertToBold">
  <macro repeatable="true" undoable="true" 
         label="Convert to Bold">
    <sequence>
      <command name="convert" 
               parameter="[implicitElement] emphasis" />
      <command name="putAttribute" parameter="role bold" />
    </sequence>
  </macro>
</command>

</configuration>

More information about customizing XMLmind XML Editor in XMLmind XML Editor - Configuration and Deployment.

The examples used in this tutorial are found in XXE_install_dir/doc/commands/macro_tutorial/customize.xxe.