macro [window_type] [key [value]]
where key is the name of a valid key (see below), and value is a magic command-line command. If present, window_type must be one of the four window types accepted by the specialopen command: layout, color, netlist, and wind3d. If omitted, the layout window is assumed by default, unless the command has been called from inside a window (using the colon or semicolon escape to the command-line), in which case that window type is assumed.
The macro command translates keystrokes typed into a layout window into magic command-line commands. When the key key is pressed in a layout window, the command stored in value is executed relative to that layout window. The default bindings are specified in the system .magic file, read at startup. These macros may be arbitrarily rebound using the macro command.
A key macro may be unbound from a command by passing an empty string ("") for the value.
key is any valid name for a keyboard keypress event. In its simplest form, this may just be the name of the key, such as "g" or "X". The space bar key must be quoted in double-quotes; most other characters may be unquoted. Control characters may be specified by the two-character combination of the carat ("^") key followed by a capital letter, such as "^Z". The use of embedded control characters is deprecated, as it is incompatible with Tcl syntax.
key may also be specified as any valid X11 name for a key as defined in the include file keysymdef.h on UNIX systems. This allows specification of function keys such as "XK_F8" or keypad keys such as "XK_KP_Right".
Buttons are treated just like keys for the purpose of defining macros. While the official names for buttons in keysymdef.h are "XK_Pointer_Button_1", etc., the macro command accepts the abbreviated forms Button1, and so forth.
Finally, key modifiers may be prepended to the key name. Valid key modifiers are Shift_, Control_, Alt_, and Meta_, and may be coupled in any combination. Mouse buttons may also be combined with key modifiers, so, for example, Shift_Button1 is a legal, unique binding.
macro is implemented as a built-in window command in magic.
|Return to command index|
Last updated: November 10, 2004 at 10:34am