next up previous contents index
Next: Macro File Format Up: The Key Map Button: Previous: Key Mapping File   Contents   Index


Keyboard Macros

Entering `n' or just Enter at the first prompt of the Kay Map command allows the user to enter a macro. The generated macros are stored in a file named .xicmacros or .xicmacros.ext, where ext is the current technology file extension. In all cases, when a macro file is produced, which occurs after any new macro is defined, the file is written in the current directory as .xicmacros. The new file contains definitions for all current macros. The user can add the suffix and move the file to their home directory if desired.

When Xic starts, it looks for a macro file in the following sequence, and inputs the first one (and only one) found:
1. current directory using same extension as tech file.
2. home directory using same extension as tech file.
3. current directory with no extension.
4. home directory with no extension.

Under Windows, the home directory is taken as the value of the HOME environment variable, if set.

Macros can be attached to any key combination of a keyboard key, except the Enter, Esc, and the ``bare'' modifier keys (Shift, Ctrl, etc). Under Unix/Linux, the macro supersedes any other function for the key, such as for menu accelerators, or other predefined operations in Xic, thus the key to be mapped should be chosen with care. Under Windows, The expansion of keyboard accelerators occurs before macro expansion, so menu accelerator keys can not be used as macros. Also, the Alt key is treated specially by Windows, and therefor can not be used as part of the macro sequence.

Macros are not expanded when the input editor is active, i.e., the word ``INPUT'' is printed in red to the left of the prompt line. The macro expansion can be suppressed for the next key combination by pressing the macro suppression character first. The macro suppression character is the backquote (`). The macro suppression character is eliminated from the keypress buffer after the next key is typed. For example, suppose `d' is mapped to something, but you want to enter a literal `d' to trigger the Edit command (``edi''). One would type ``e`di'', after which the keypress buffer would contain ``edi'' triggering the Edit command.

While recording a macro, button and key presses will not have the normal effect, but the events are stored in the macro and will have the normal effect when the macro is invoked. Button presses will open a menu in the normal way, and selected menu commands will become active, but subsequent events will be swallowed by the macro recorder. In most cases, one can send events to a pop-up by performing the actions, which won't be carried out but will be recorded in the macro.

Note that while recording a macro, if a command is initiated that uses the prompt line, the macro string display will be overwritten. It will come back after the first event. However, if the command uses the prompt line for input, the macro definition will be terminated as if Esc was entered.

Pressing Enter while a drawing window has the keyboard focus terminates the macro definition. Pressing Esc terminates a macro without saving it. Bsp removes the last event when defining a macro. To enter Esc, Bsp, or Enter into the macro, use Ctrl-Esc, Ctrl-Bsp, Ctrl-Enter.

For example, Suppose we want to define Ctrl-X to ``press'' the Expand button. In the Key Map command, press Enter at the first prompt (don't want the keyboard fix), and press Ctrl and x and release. In response to the next prompt, select the Expand in the View Menu, move the pointer into a drawing window, and press the Enter key. From then on, Ctrl-X will be equivalent to pressing the Expand button.

To undefine a macro, define it with a null definition for the body.

See the description of the ``!!'' interface in Chapt. 14 for information on using script functions in macros.

In the present GTK-based user interface, there is less need for macros due to the rich set of keyboard accelerators available.


next up previous contents index
Next: Macro File Format Up: The Key Map Button: Previous: Key Mapping File   Contents   Index
Stephen R. Whiteley 2006-10-23