1 /*----------------------------------------------------------------------*/
4 /* Written by R. Timothy Edwards for MultiGiG, Inc., September 2004 */
5 /* This file mainly lifted from the main application routine for */
6 /* "wish" from the Tk distribution. */
8 /* This is a compact re-write of the "wish" executable that calls */
9 /* Tk_MainEx with application-specific processing. Specifically, */
10 /* "wish" doesn't allow the startup script (~/.wishrc) to be renamed. */
11 /* However, for xcircuit running as an extension of Tcl, we want to */
12 /* source the xcircuit.tcl file instead of ~/.wishrc. So, all this */
13 /* file really does is to set the Tcl variable "tcl_rcFileName" to */
14 /* xcircuit.tcl, so that it will be processed as the startup script, */
15 /* followed by a drop back to the Tcl interpreter command-line main */
18 /* This is a standalone executable. However, it is only called when */
19 /* "-noconsole" is specified on the UNIX command-line. When the */
20 /* console is used, the console is capable of sourcing the magic.tcl */
21 /* script itself, and so it uses "wish" as the executable. However, */
22 /* the console redirects standard input, so it prevents magic from */
23 /* being used in a batch processing mode. Thus, to batch-process with */
24 /* xcircuit, use "xcircuit -noc < script.tcl" or, interactively, */
25 /* "xcircuit -noc << EOF" followed by commands entered from stdin */
26 /* and ending with "EOF". */
28 /* The "xcircexec" method replaces the former use of "wish" with the */
29 /* "xcircuit" script setting HOME to point to the directory containing */
30 /* ".wishrc", a symbolic link to "xcircuit.tcl". That failed to work */
31 /* on remote systems because the $HOME environment variable is also */
32 /* used to find the user's .Xauthority file to authenticate the X11 */
34 /*----------------------------------------------------------------------*/
41 /*----------------------------------------------------------------------*/
42 /* Application initiation. This is exactly like the AppInit routine */
43 /* for "wish", minus the cruft, but with "tcl_rcFileName" set to */
44 /* "xcircuit.tcl" instead of "~/.wishrc". */
45 /*----------------------------------------------------------------------*/
48 xcircuit_AppInit(interp
)
51 if (Tcl_Init(interp
) == TCL_ERROR
) {
54 if (Tk_Init(interp
) == TCL_ERROR
) {
57 Tcl_StaticPackage(interp
, "Tk", Tk_Init
, Tk_SafeInit
);
59 /* This is where we replace the home ".wishrc" file with */
60 /* xcircuit's startup script. */
62 Tcl_SetVar(interp
, "tcl_rcFileName", SCRIPTS_DIR
"/xcircuit.tcl",
67 /*----------------------------------------------------------------------*/
68 /* The main procedure; replacement for "wish". */
69 /*----------------------------------------------------------------------*/
76 Tk_Main(argc
, argv
, xcircuit_AppInit
);
80 /*----------------------------------------------------------------------*/