[Magic-dev] How to add custom commands to .magicrc?
R. Timothy Edwards
tim at opencircuitdesign.com
Fri Dec 14 09:43:55 EST 2007
Dear Graham,
> I want to have magic power up with a grid. When I use the grid command in my
> .magicrc file
>
> grid 8 8 4 0
>
> nothing happens. The command is read and accepted (a deliberate syntax error
> gives an error message) but no grid appears.
The problem with the .magicrc file is that it is run only once, at
the start, before any windows are defined. Commands like "grid" are
per-window settings, not global, and so a window has to be defined
before the grid can be defined.
In magic version 7.5, the correct way to make this work is to put the
following in your .magicrc file:
set Opts(callback) "grid 8 8 4 0"
which saves the statement in a Tcl variable and then applies it to
each new layout window that is created. If you're using magic version
7.4, just add the following to tcltk/wrapper.tcl (I'm adding it to the
distribution now) at line 1272:
# If the variable $Opts(callback) is defined, then attempt to execute it.
catch {eval $Opts(callback)}
# If the variable $Winopts(callback) is defined, then attempt to execute it.
catch {eval $Winopts(${framename}, callback)}
The second statement allows you to define something to be applied to just a
single window and no others; e.g., "set Winopts(.layout1, callback) "grid 8 8 4 0""
would just produce the grid on the initial layout window, but no others.
Regards,
Tim
+--------------------------------+-------------------------------------+
| Dr. R. Timothy Edwards (Tim) | email: tim at opencircuitdesign.com |
| Open Circuit Design, Inc. | web: http://opencircuitdesign.com |
| 22815 Timber Creek Lane | phone: (301) 528-9364 |
| Clarksburg, MD 20871-4001 | cell: (240) 401-0616 |
+--------------------------------+-------------------------------------+
More information about the magic-dev
mailing list