1 # Wishrc startup for ToolScript (xcircuit)
3 # Loads the shared object (xcircuit.so) file into Tcl, runs the
4 # wrapper script to generate the GUI, then runs the initialization
5 # routine for the XCircuit package.
9 set envlibdir
[array get env
"XCIRCUIT_LIB_DIR"]
10 if {$envlibdir == {}} {
11 set XCIRCUIT_LIB_DIR LIBDIR
15 set envsrcdir
[array get env
"XCIRCUIT_SRC_DIR"]
16 if {$envsrcdir != {}} {
17 set path
[lindex $envsrcdir 1]
20 set XCIRCUIT_SRC_DIR
$path
24 if {[string compare
$tcl_platform(platform
) "windows"] == 0} {
31 if {![file exists
${tcllibdir
}/xcircuit
$libext]} {
32 set tcllibdir
${path
}/tcl
34 if {![file exists
${tcllibdir
}/xcircuit
$libext]} {
35 puts stderr
"Error: Cannot find file xcircuit$libext"
37 load ${tcllibdir
}/xcircuit
$libext
39 package require Xcircuit
41 # It is important to make sure no magic commands overlap with Tcl built-in
42 # commands, because otherwise the namespace import will fail.
44 proc pushnamespace
{ name
} {
46 set y
[namespace eval ${name
} info commands
::${name
}::*]
50 regsub -all {\*} $v {\\*} i
51 set x
[namespace tail
$i]
52 if {[lsearch $z $x] < 0} {
55 puts "Warning: ${name} command '$x' use fully-qualified name '$v'"
60 proc popnamespace
{ name
} {
62 set l
[expr [string length
${name
}] + 5]
64 while {[set v
[lsearch $z ${name
}_tcl_
*]] >= 0} {
66 set w
[string range
$y $l end
]
67 interp alias
{} ::$w {}
69 puts "Info: replacing ::$w with ::$y"
71 namespace forget
::${name
}::*
74 set auto_noexec
1 ;# don't EVER call UNIX commands w/o "shell" in front
76 # Have we called xcircuit from tkcon?
78 if {[lsearch [interp aliases
] tkcon
] != -1} {
82 # Rename conflicting TkCon commands before pushing xcircuit's namespace
84 if {[lsearch [info commands
] orig_edit
] < 0} { rename edit orig_edit
}
87 # Extend the "unknown" command-line handler to be compatible with the
88 # way we have renamed certain core Tcl/Tk functions.
90 rename unknown tcl_unknown
91 proc unknown { args
} {
93 # Check for commands which were renamed to tcl_(command)
95 set cmd
[lindex $args 0]
96 if {[lsearch [info commands
] tcl_
$cmd] >= 0} {
97 set arglist
[concat tcl_
$cmd [lrange $args 1 end
]]
98 set ret
[catch {eval $arglist} result
]
102 return -code $ret -errorcode $errorCode $result
105 return [eval [concat tcl_unknown
$args]]
109 # Rename conflicting Tcl/Tk commands before pushing xcircuit's namespace
111 if {[lsearch [info commands
] tcl_label
] < 0} {catch {rename label tcl_label
}}
113 # Allow commands in the xcircuit namespace to be called from the toplevel namespace
115 pushnamespace xcircuit
117 #----------------------------------------------------------------------
118 # Cross-Application section
119 #----------------------------------------------------------------------
121 # Check namespaces for existence of other applications
125 set nlist
[namespace children
]
128 ::magic { set UsingMagic
1 }
129 ::irsim { set UsingIRSIM
1 }
130 ::netgen { set UsingNetgen
1 }
134 # Setup IRSIM assuming that the Tcl version is installed.
135 # We do not need to rename procedure irsim to NULL because it is
136 # redefined in a script, which simply overwrites the original.
138 proc irsim
{ args
} {
140 set irsimscript
[glob -nocomplain ${CAD_ROOT
}/irsim
/tcl
/irsim.tcl
]
141 if { ${irsimscript
} == {} } {
142 puts stderr
"\"irsim\" requires Tcl-based IRSIM version 9.6 or newer."
143 puts stderr
"Could not find script \"irsim.tcl\". If IRSIM is installed in a"
144 puts stderr
"place other than CAD_ROOT (=${CAD_ROOT}), use the command"
145 puts stderr
"\"source <path>/irsim.tcl\" before doing \"irsim\"."
152 # Setup Magic assuming that the Tcl version is installed.
154 proc magic
{ args
} {
156 set magicscript
[glob -nocomplain ${CAD_ROOT
}/magic
/tcl
/magic.tcl
]
157 if { ${magicscript
} == {} } {
158 puts stderr
"\"magic\" requires Tcl-based Magic version 7.2 or newer."
159 puts stderr
"Could not find script \"magic.tcl\". If Magic is installed in a"
160 puts stderr
"place other than CAD_ROOT (=${CAD_ROOT}), use the command"
161 puts stderr
"\"source <path>/magic.tcl\"."
164 set argc
[llength $args]
165 uplevel #0 source $magicscript
169 # Setup Netgen assuming that the Tcl version is installed.
171 proc netgen
{ args
} {
173 set netgenscript
[glob -nocomplain ${CAD_ROOT
}/netgen
/tcl
/netgen.tcl
]
174 if { ${netgenscript
} == {} } {
175 puts stderr
"\"netgen\" requires Tcl-based Netgen version 1.2 or newer."
176 puts stderr
"Could not find script \"netgen.tcl\". If Netgen is installed in a"
177 puts stderr
"place other than CAD_ROOT (=${CAD_ROOT}), use the command"
178 puts stderr
"\"source <path>/netgen.tcl\"."
181 set argc
[llength $args]
186 # Source the default resources file
188 catch {source ${tcllibdir
}/resource.tcl
}
190 # Sourcing of individual resource overrides
192 set envhomedir
[array get env
"HOME"]
193 if {$envhomedir != {}} {
194 set homepath
[lindex $envhomedir 1]
195 set homedefaults
${homepath
}/.Xdefaults
196 if {[file exists
$homedefaults]} {
197 if {[catch {option readfile
$homedefaults userDefault
}]} {
198 puts stderr
"Warning: Error parsing file $homedefaults"
206 # Run the xcircuit start function
208 if {[string length
$argv] == 0} {
209 # Source the GUI-generating script
210 source ${tcllibdir
}/wrapper.tcl
211 xcircuit
::start .xcircuit
214 set argafter
{xcircuit
::start}
215 for {set i
0} {$i < $argc} {incr i
1} {
216 set x
[lindex $argv $i]
217 switch -regexp -- $x {
222 set XCOps
(library
) "all"
225 # this option already handled---absorb it and do nothing.
233 # Set up for interactive or filter (batch) mode processing
235 # Source the GUI-generating script
236 source ${tcllibdir
}/wrapper.tcl
237 set argafter
[linsert $argafter 1 .xcircuit
]
238 } elseif
{[info commands
wm] != ""} {
239 simple .xcdummy
-exitproc "quitnocheck"
240 set XCOps
(window
) .xcdummy
243 eval $argafter ;# xcircuit::start .xcircuit ${argv}
247 # The GUI wrapper iconifies the window while generating it
248 catch {wm deiconify
$XCOps(toplevel)}
250 # Invoke the "wire" button by default
251 catch {$XCOps(focus).mainframe.toolbar.bw invoke
}
253 # Xcircuit start function drops back to interpreter after initialization & setup
255 if {[info commands
wm] != ""} {
256 if {[string range
[wm title .
] 0 3] == "wish"} {
259 if {[string range
[wm title .
] 0 8] == "xcircexec"} {