next up previous contents index
Next: Macro File Format Up: The Attributes Menu: Set Previous: Key Mapping File   Contents   Index


The Define Macro Button: Assign a Macro to a Key

Pressing the Define Macro button in the Attributes Menu 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 obtained from environment variables, in particular the value of HOME.

Macros can be attached to any combination of a keyboard key and modifier key(s), with the exceptions of Enter, Esc, Backspace, and the ``bare'' modifier keys (Shift, Ctrl, etc). However, not all key combinations will work. For example, the expansion of keyboard menu accelerators occurs before macro expansion, so menu accelerator key combinations can not be used as macros. Also, key combinations that are intercepted by the window manager, which may include some combinations involving the Alt key, can not be used as macros. Otherwise, macro definitions have higher priority than most other functions in Xic.

Macros are not expanded when the prompt line is in text editing mode. 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 `o' is mapped to something, but you want to enter a literal `o' to trigger the Open command (``op''). One would type ```op'', after which the keypress buffer would contain ``op'' triggering the Open 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. Backspace removes the last event when defining a macro. To enter Esc, Backspace, or Enter into the macro, use Ctrl-Esc, Ctrl-Backspace, Ctrl-Enter.

For example, Suppose we want to define Ctrl-x to ``press'' the Expand button. In the Define Macro command, press Ctrl and x and release. In response to the next prompt, select the Expand button 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. 19 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.



Subsections
next up previous contents index
Next: Macro File Format Up: The Attributes Menu: Set Previous: Key Mapping File   Contents   Index
Stephen R. Whiteley 2022-05-28