jasonfan commited on
Commit
3aaa866
·
verified ·
1 Parent(s): fde8ffd

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/lib/tcl8.6/opt0.4/optparse.tcl +1072 -0
  2. miniconda3/lib/tcl8.6/opt0.4/pkgIndex.tcl +12 -0
  3. miniconda3/lib/tdbc1.1.9/libtdbc1.1.9.so +0 -0
  4. miniconda3/lib/tdbc1.1.9/libtdbcstub1.1.9.a +0 -0
  5. miniconda3/lib/tdbc1.1.9/pkgIndex.tcl +26 -0
  6. miniconda3/lib/tdbc1.1.9/tdbc.tcl +922 -0
  7. miniconda3/lib/tdbc1.1.9/tdbcConfig.sh +81 -0
  8. miniconda3/lib/tdbcmysql1.1.9/libtdbcmysql1.1.9.so +0 -0
  9. miniconda3/lib/tdbcmysql1.1.9/pkgIndex.tcl +14 -0
  10. miniconda3/lib/tdbcmysql1.1.9/tdbcmysql.tcl +193 -0
  11. miniconda3/lib/tdbcodbc1.1.9/libtdbcodbc1.1.9.so +0 -0
  12. miniconda3/lib/tdbcodbc1.1.9/pkgIndex.tcl +14 -0
  13. miniconda3/lib/tdbcodbc1.1.9/tdbcodbc.tcl +554 -0
  14. miniconda3/lib/tdbcpostgres1.1.9/libtdbcpostgres1.1.9.so +0 -0
  15. miniconda3/lib/tdbcpostgres1.1.9/pkgIndex.tcl +14 -0
  16. miniconda3/lib/tdbcpostgres1.1.9/tdbcpostgres.tcl +135 -0
  17. miniconda3/lib/thread2.8.10/libthread2.8.10.so +0 -0
  18. miniconda3/lib/thread2.8.10/pkgIndex.tcl +68 -0
  19. miniconda3/lib/thread2.8.10/ttrace.tcl +942 -0
  20. miniconda3/lib/tk8.6/bgerror.tcl +272 -0
  21. miniconda3/lib/tk8.6/button.tcl +782 -0
  22. miniconda3/lib/tk8.6/choosedir.tcl +310 -0
  23. miniconda3/lib/tk8.6/clrpick.tcl +694 -0
  24. miniconda3/lib/tk8.6/comdlg.tcl +322 -0
  25. miniconda3/lib/tk8.6/console.tcl +1154 -0
  26. miniconda3/lib/tk8.6/demos/README +44 -0
  27. miniconda3/lib/tk8.6/demos/anilabel.tcl +160 -0
  28. miniconda3/lib/tk8.6/demos/aniwave.tcl +104 -0
  29. miniconda3/lib/tk8.6/demos/arrow.tcl +241 -0
  30. miniconda3/lib/tk8.6/demos/bind.tcl +78 -0
  31. miniconda3/lib/tk8.6/demos/bitmap.tcl +52 -0
  32. miniconda3/lib/tk8.6/demos/browse +66 -0
  33. miniconda3/lib/tk8.6/demos/button.tcl +47 -0
  34. miniconda3/lib/tk8.6/demos/check.tcl +71 -0
  35. miniconda3/lib/tk8.6/demos/clrpick.tcl +54 -0
  36. miniconda3/lib/tk8.6/demos/colors.tcl +99 -0
  37. miniconda3/lib/tk8.6/demos/combo.tcl +61 -0
  38. miniconda3/lib/tk8.6/demos/cscroll.tcl +171 -0
  39. miniconda3/lib/tk8.6/demos/ctext.tcl +176 -0
  40. miniconda3/lib/tk8.6/demos/dialog1.tcl +25 -0
  41. miniconda3/lib/tk8.6/demos/dialog2.tcl +18 -0
  42. miniconda3/lib/tk8.6/demos/en.msg +97 -0
  43. miniconda3/lib/tk8.6/demos/entry1.tcl +34 -0
  44. miniconda3/lib/tk8.6/demos/entry2.tcl +46 -0
  45. miniconda3/lib/tk8.6/demos/entry3.tcl +185 -0
  46. miniconda3/lib/tk8.6/demos/filebox.tcl +81 -0
  47. miniconda3/lib/tk8.6/demos/floor.tcl +1372 -0
  48. miniconda3/lib/tk8.6/demos/fontchoose.tcl +67 -0
  49. miniconda3/lib/tk8.6/demos/form.tcl +38 -0
  50. miniconda3/lib/tk8.6/demos/goldberg.tcl +1834 -0
miniconda3/lib/tcl8.6/opt0.4/optparse.tcl ADDED
@@ -0,0 +1,1072 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # optparse.tcl --
2
+ #
3
+ # (private) Option parsing package
4
+ # Primarily used internally by the safe:: code.
5
+ #
6
+ # WARNING: This code will go away in a future release
7
+ # of Tcl. It is NOT supported and you should not rely
8
+ # on it. If your code does rely on this package you
9
+ # may directly incorporate this code into your application.
10
+
11
+ package require Tcl 8.5-
12
+ # When this version number changes, update the pkgIndex.tcl file
13
+ # and the install directory in the Makefiles.
14
+ package provide opt 0.4.9
15
+
16
+ namespace eval ::tcl {
17
+
18
+ # Exported APIs
19
+ namespace export OptKeyRegister OptKeyDelete OptKeyError OptKeyParse \
20
+ OptProc OptProcArgGiven OptParse \
21
+ Lempty Lget \
22
+ Lassign Lvarpop Lvarpop1 Lvarset Lvarincr \
23
+ SetMax SetMin
24
+
25
+
26
+ ################# Example of use / 'user documentation' ###################
27
+
28
+ proc OptCreateTestProc {} {
29
+
30
+ # Defines ::tcl::OptParseTest as a test proc with parsed arguments
31
+ # (can't be defined before the code below is loaded (before "OptProc"))
32
+
33
+ # Every OptProc give usage information on "procname -help".
34
+ # Try "tcl::OptParseTest -help" and "tcl::OptParseTest -a" and
35
+ # then other arguments.
36
+ #
37
+ # example of 'valid' call:
38
+ # ::tcl::OptParseTest save -4 -pr 23 -libsok SybTcl\
39
+ # -nostatics false ch1
40
+ OptProc OptParseTest {
41
+ {subcommand -choice {save print} "sub command"}
42
+ {arg1 3 "some number"}
43
+ {-aflag}
44
+ {-intflag 7}
45
+ {-weirdflag "help string"}
46
+ {-noStatics "Not ok to load static packages"}
47
+ {-nestedloading1 true "OK to load into nested children"}
48
+ {-nestedloading2 -boolean true "OK to load into nested children"}
49
+ {-libsOK -choice {Tk SybTcl}
50
+ "List of packages that can be loaded"}
51
+ {-precision -int 12 "Number of digits of precision"}
52
+ {-intval 7 "An integer"}
53
+ {-scale -float 1.0 "Scale factor"}
54
+ {-zoom 1.0 "Zoom factor"}
55
+ {-arbitrary foobar "Arbitrary string"}
56
+ {-random -string 12 "Random string"}
57
+ {-listval -list {} "List value"}
58
+ {-blahflag -blah abc "Funny type"}
59
+ {arg2 -boolean "a boolean"}
60
+ {arg3 -choice "ch1 ch2"}
61
+ {?optarg? -list {} "optional argument"}
62
+ } {
63
+ foreach v [info locals] {
64
+ puts stderr [format "%14s : %s" $v [set $v]]
65
+ }
66
+ }
67
+ }
68
+
69
+ ################### No User serviceable part below ! ###############
70
+
71
+ # Array storing the parsed descriptions
72
+ variable OptDesc
73
+ array set OptDesc {}
74
+ # Next potentially free key id (numeric)
75
+ variable OptDescN 0
76
+
77
+ # Inside algorithm/mechanism description:
78
+ # (not for the faint-hearted ;-)
79
+ #
80
+ # The argument description is parsed into a "program tree"
81
+ # It is called a "program" because it is the program used by
82
+ # the state machine interpreter that use that program to
83
+ # actually parse the arguments at run time.
84
+ #
85
+ # The general structure of a "program" is
86
+ # notation (pseudo bnf like)
87
+ # name :== definition defines "name" as being "definition"
88
+ # { x y z } means list of x, y, and z
89
+ # x* means x repeated 0 or more time
90
+ # x+ means "x x*"
91
+ # x? means optionally x
92
+ # x | y means x or y
93
+ # "cccc" means the literal string
94
+ #
95
+ # program :== { programCounter programStep* }
96
+ #
97
+ # programStep :== program | singleStep
98
+ #
99
+ # programCounter :== {"P" integer+ }
100
+ #
101
+ # singleStep :== { instruction parameters* }
102
+ #
103
+ # instruction :== single element list
104
+ #
105
+ # (the difference between singleStep and program is that \
106
+ # llength [lindex $program 0] >= 2
107
+ # while
108
+ # llength [lindex $singleStep 0] == 1
109
+ # )
110
+ #
111
+ # And for this application:
112
+ #
113
+ # singleStep :== { instruction varname {hasBeenSet currentValue} type
114
+ # typeArgs help }
115
+ # instruction :== "flags" | "value"
116
+ # type :== knowType | anyword
117
+ # knowType :== "string" | "int" | "boolean" | "boolflag" | "float"
118
+ # | "choice"
119
+ #
120
+ # for type "choice" typeArgs is a list of possible choices, the first one
121
+ # is the default value. for all other types the typeArgs is the default value
122
+ #
123
+ # a "boolflag" is the type for a flag whose presence or absence, without
124
+ # additional arguments means respectively true or false (default flag type).
125
+ #
126
+ # programCounter is the index in the list of the currently processed
127
+ # programStep (thus starting at 1 (0 is {"P" prgCounterValue}).
128
+ # If it is a list it points toward each currently selected programStep.
129
+ # (like for "flags", as they are optional, form a set and programStep).
130
+
131
+ # Performance/Implementation issues
132
+ # ---------------------------------
133
+ # We use tcl lists instead of arrays because with tcl8.0
134
+ # they should start to be much faster.
135
+ # But this code use a lot of helper procs (like Lvarset)
136
+ # which are quite slow and would be helpfully optimized
137
+ # for instance by being written in C. Also our structure
138
+ # is complex and there is maybe some places where the
139
+ # string rep might be calculated at great expense. to be checked.
140
+
141
+ #
142
+ # Parse a given description and saves it here under the given key
143
+ # generate a unused keyid if not given
144
+ #
145
+ proc ::tcl::OptKeyRegister {desc {key ""}} {
146
+ variable OptDesc
147
+ variable OptDescN
148
+ if {[string equal $key ""]} {
149
+ # in case a key given to us as a parameter was a number
150
+ while {[info exists OptDesc($OptDescN)]} {incr OptDescN}
151
+ set key $OptDescN
152
+ incr OptDescN
153
+ }
154
+ # program counter
155
+ set program [list [list "P" 1]]
156
+
157
+ # are we processing flags (which makes a single program step)
158
+ set inflags 0
159
+
160
+ set state {}
161
+
162
+ # flag used to detect that we just have a single (flags set) subprogram.
163
+ set empty 1
164
+
165
+ foreach item $desc {
166
+ if {$state == "args"} {
167
+ # more items after 'args'...
168
+ return -code error "'args' special argument must be the last one"
169
+ }
170
+ set res [OptNormalizeOne $item]
171
+ set state [lindex $res 0]
172
+ if {$inflags} {
173
+ if {$state == "flags"} {
174
+ # add to 'subprogram'
175
+ lappend flagsprg $res
176
+ } else {
177
+ # put in the flags
178
+ # structure for flag programs items is a list of
179
+ # {subprgcounter {prg flag 1} {prg flag 2} {...}}
180
+ lappend program $flagsprg
181
+ # put the other regular stuff
182
+ lappend program $res
183
+ set inflags 0
184
+ set empty 0
185
+ }
186
+ } else {
187
+ if {$state == "flags"} {
188
+ set inflags 1
189
+ # sub program counter + first sub program
190
+ set flagsprg [list [list "P" 1] $res]
191
+ } else {
192
+ lappend program $res
193
+ set empty 0
194
+ }
195
+ }
196
+ }
197
+ if {$inflags} {
198
+ if {$empty} {
199
+ # We just have the subprogram, optimize and remove
200
+ # unneeded level:
201
+ set program $flagsprg
202
+ } else {
203
+ lappend program $flagsprg
204
+ }
205
+ }
206
+
207
+ set OptDesc($key) $program
208
+
209
+ return $key
210
+ }
211
+
212
+ #
213
+ # Free the storage for that given key
214
+ #
215
+ proc ::tcl::OptKeyDelete {key} {
216
+ variable OptDesc
217
+ unset OptDesc($key)
218
+ }
219
+
220
+ # Get the parsed description stored under the given key.
221
+ proc OptKeyGetDesc {descKey} {
222
+ variable OptDesc
223
+ if {![info exists OptDesc($descKey)]} {
224
+ return -code error "Unknown option description key \"$descKey\""
225
+ }
226
+ set OptDesc($descKey)
227
+ }
228
+
229
+ # Parse entry point for people who don't want to register with a key,
230
+ # for instance because the description changes dynamically.
231
+ # (otherwise one should really use OptKeyRegister once + OptKeyParse
232
+ # as it is way faster or simply OptProc which does it all)
233
+ # Assign a temporary key, call OptKeyParse and then free the storage
234
+ proc ::tcl::OptParse {desc arglist} {
235
+ set tempkey [OptKeyRegister $desc]
236
+ set ret [catch {uplevel 1 [list ::tcl::OptKeyParse $tempkey $arglist]} res]
237
+ OptKeyDelete $tempkey
238
+ return -code $ret $res
239
+ }
240
+
241
+ # Helper function, replacement for proc that both
242
+ # register the description under a key which is the name of the proc
243
+ # (and thus unique to that code)
244
+ # and add a first line to the code to call the OptKeyParse proc
245
+ # Stores the list of variables that have been actually given by the user
246
+ # (the other will be sets to their default value)
247
+ # into local variable named "Args".
248
+ proc ::tcl::OptProc {name desc body} {
249
+ set namespace [uplevel 1 [list ::namespace current]]
250
+ if {[string match "::*" $name] || [string equal $namespace "::"]} {
251
+ # absolute name or global namespace, name is the key
252
+ set key $name
253
+ } else {
254
+ # we are relative to some non top level namespace:
255
+ set key "${namespace}::${name}"
256
+ }
257
+ OptKeyRegister $desc $key
258
+ uplevel 1 [list ::proc $name args "set Args \[::tcl::OptKeyParse $key \$args\]\n$body"]
259
+ return $key
260
+ }
261
+ # Check that a argument has been given
262
+ # assumes that "OptProc" has been used as it will check in "Args" list
263
+ proc ::tcl::OptProcArgGiven {argname} {
264
+ upvar Args alist
265
+ expr {[lsearch $alist $argname] >=0}
266
+ }
267
+
268
+ #######
269
+ # Programs/Descriptions manipulation
270
+
271
+ # Return the instruction word/list of a given step/(sub)program
272
+ proc OptInstr {lst} {
273
+ lindex $lst 0
274
+ }
275
+ # Is a (sub) program or a plain instruction ?
276
+ proc OptIsPrg {lst} {
277
+ expr {[llength [OptInstr $lst]]>=2}
278
+ }
279
+ # Is this instruction a program counter or a real instr
280
+ proc OptIsCounter {item} {
281
+ expr {[lindex $item 0]=="P"}
282
+ }
283
+ # Current program counter (2nd word of first word)
284
+ proc OptGetPrgCounter {lst} {
285
+ Lget $lst {0 1}
286
+ }
287
+ # Current program counter (2nd word of first word)
288
+ proc OptSetPrgCounter {lstName newValue} {
289
+ upvar $lstName lst
290
+ set lst [lreplace $lst 0 0 [concat "P" $newValue]]
291
+ }
292
+ # returns a list of currently selected items.
293
+ proc OptSelection {lst} {
294
+ set res {}
295
+ foreach idx [lrange [lindex $lst 0] 1 end] {
296
+ lappend res [Lget $lst $idx]
297
+ }
298
+ return $res
299
+ }
300
+
301
+ # Advance to next description
302
+ proc OptNextDesc {descName} {
303
+ uplevel 1 [list Lvarincr $descName {0 1}]
304
+ }
305
+
306
+ # Get the current description, eventually descend
307
+ proc OptCurDesc {descriptions} {
308
+ lindex $descriptions [OptGetPrgCounter $descriptions]
309
+ }
310
+ # get the current description, eventually descend
311
+ # through sub programs as needed.
312
+ proc OptCurDescFinal {descriptions} {
313
+ set item [OptCurDesc $descriptions]
314
+ # Descend untill we get the actual item and not a sub program
315
+ while {[OptIsPrg $item]} {
316
+ set item [OptCurDesc $item]
317
+ }
318
+ return $item
319
+ }
320
+ # Current final instruction adress
321
+ proc OptCurAddr {descriptions {start {}}} {
322
+ set adress [OptGetPrgCounter $descriptions]
323
+ lappend start $adress
324
+ set item [lindex $descriptions $adress]
325
+ if {[OptIsPrg $item]} {
326
+ return [OptCurAddr $item $start]
327
+ } else {
328
+ return $start
329
+ }
330
+ }
331
+ # Set the value field of the current instruction.
332
+ proc OptCurSetValue {descriptionsName value} {
333
+ upvar $descriptionsName descriptions
334
+ # Get the current item full address.
335
+ set adress [OptCurAddr $descriptions]
336
+ # Use the 3rd field of the item (see OptValue / OptNewInst).
337
+ lappend adress 2
338
+ Lvarset descriptions $adress [list 1 $value]
339
+ # ^hasBeenSet flag
340
+ }
341
+
342
+ # Empty state means done/paste the end of the program.
343
+ proc OptState {item} {
344
+ lindex $item 0
345
+ }
346
+
347
+ # current state
348
+ proc OptCurState {descriptions} {
349
+ OptState [OptCurDesc $descriptions]
350
+ }
351
+
352
+ #######
353
+ # Arguments manipulation
354
+
355
+ # Returns the argument that has to be processed now.
356
+ proc OptCurrentArg {lst} {
357
+ lindex $lst 0
358
+ }
359
+ # Advance to next argument.
360
+ proc OptNextArg {argsName} {
361
+ uplevel 1 [list Lvarpop1 $argsName]
362
+ }
363
+ #######
364
+
365
+
366
+
367
+
368
+
369
+ # Loop over all descriptions, calling OptDoOne which will
370
+ # eventually eat all the arguments.
371
+ proc OptDoAll {descriptionsName argumentsName} {
372
+ upvar $descriptionsName descriptions
373
+ upvar $argumentsName arguments
374
+ # puts "entered DoAll"
375
+ # Nb: the places where "state" can be set are tricky to figure
376
+ # because DoOne sets the state to flagsValue and return -continue
377
+ # when needed...
378
+ set state [OptCurState $descriptions]
379
+ # We'll exit the loop in "OptDoOne" or when state is empty.
380
+ while 1 {
381
+ set curitem [OptCurDesc $descriptions]
382
+ # Do subprograms if needed, call ourselves on the sub branch
383
+ while {[OptIsPrg $curitem]} {
384
+ OptDoAll curitem arguments
385
+ # puts "done DoAll sub"
386
+ # Insert back the results in current tree
387
+ Lvarset1nc descriptions [OptGetPrgCounter $descriptions]\
388
+ $curitem
389
+ OptNextDesc descriptions
390
+ set curitem [OptCurDesc $descriptions]
391
+ set state [OptCurState $descriptions]
392
+ }
393
+ # puts "state = \"$state\" - arguments=($arguments)"
394
+ if {[Lempty $state]} {
395
+ # Nothing left to do, we are done in this branch:
396
+ break
397
+ }
398
+ # The following statement can make us terminate/continue
399
+ # as it use return -code {break, continue, return and error}
400
+ # codes
401
+ OptDoOne descriptions state arguments
402
+ # If we are here, no special return code where issued,
403
+ # we'll step to next instruction :
404
+ # puts "new state = \"$state\""
405
+ OptNextDesc descriptions
406
+ set state [OptCurState $descriptions]
407
+ }
408
+ }
409
+
410
+ # Process one step for the state machine,
411
+ # eventually consuming the current argument.
412
+ proc OptDoOne {descriptionsName stateName argumentsName} {
413
+ upvar $argumentsName arguments
414
+ upvar $descriptionsName descriptions
415
+ upvar $stateName state
416
+
417
+ # the special state/instruction "args" eats all
418
+ # the remaining args (if any)
419
+ if {($state == "args")} {
420
+ if {![Lempty $arguments]} {
421
+ # If there is no additional arguments, leave the default value
422
+ # in.
423
+ OptCurSetValue descriptions $arguments
424
+ set arguments {}
425
+ }
426
+ # puts "breaking out ('args' state: consuming every reminding args)"
427
+ return -code break
428
+ }
429
+
430
+ if {[Lempty $arguments]} {
431
+ if {$state == "flags"} {
432
+ # no argument and no flags : we're done
433
+ # puts "returning to previous (sub)prg (no more args)"
434
+ return -code return
435
+ } elseif {$state == "optValue"} {
436
+ set state next; # not used, for debug only
437
+ # go to next state
438
+ return
439
+ } else {
440
+ return -code error [OptMissingValue $descriptions]
441
+ }
442
+ } else {
443
+ set arg [OptCurrentArg $arguments]
444
+ }
445
+
446
+ switch $state {
447
+ flags {
448
+ # A non-dash argument terminates the options, as does --
449
+
450
+ # Still a flag ?
451
+ if {![OptIsFlag $arg]} {
452
+ # don't consume the argument, return to previous prg
453
+ return -code return
454
+ }
455
+ # consume the flag
456
+ OptNextArg arguments
457
+ if {[string equal "--" $arg]} {
458
+ # return from 'flags' state
459
+ return -code return
460
+ }
461
+
462
+ set hits [OptHits descriptions $arg]
463
+ if {$hits > 1} {
464
+ return -code error [OptAmbigous $descriptions $arg]
465
+ } elseif {$hits == 0} {
466
+ return -code error [OptFlagUsage $descriptions $arg]
467
+ }
468
+ set item [OptCurDesc $descriptions]
469
+ if {[OptNeedValue $item]} {
470
+ # we need a value, next state is
471
+ set state flagValue
472
+ } else {
473
+ OptCurSetValue descriptions 1
474
+ }
475
+ # continue
476
+ return -code continue
477
+ }
478
+ flagValue -
479
+ value {
480
+ set item [OptCurDesc $descriptions]
481
+ # Test the values against their required type
482
+ if {[catch {OptCheckType $arg\
483
+ [OptType $item] [OptTypeArgs $item]} val]} {
484
+ return -code error [OptBadValue $item $arg $val]
485
+ }
486
+ # consume the value
487
+ OptNextArg arguments
488
+ # set the value
489
+ OptCurSetValue descriptions $val
490
+ # go to next state
491
+ if {$state == "flagValue"} {
492
+ set state flags
493
+ return -code continue
494
+ } else {
495
+ set state next; # not used, for debug only
496
+ return ; # will go on next step
497
+ }
498
+ }
499
+ optValue {
500
+ set item [OptCurDesc $descriptions]
501
+ # Test the values against their required type
502
+ if {![catch {OptCheckType $arg\
503
+ [OptType $item] [OptTypeArgs $item]} val]} {
504
+ # right type, so :
505
+ # consume the value
506
+ OptNextArg arguments
507
+ # set the value
508
+ OptCurSetValue descriptions $val
509
+ }
510
+ # go to next state
511
+ set state next; # not used, for debug only
512
+ return ; # will go on next step
513
+ }
514
+ }
515
+ # If we reach this point: an unknown
516
+ # state as been entered !
517
+ return -code error "Bug! unknown state in DoOne \"$state\"\
518
+ (prg counter [OptGetPrgCounter $descriptions]:\
519
+ [OptCurDesc $descriptions])"
520
+ }
521
+
522
+ # Parse the options given the key to previously registered description
523
+ # and arguments list
524
+ proc ::tcl::OptKeyParse {descKey arglist} {
525
+
526
+ set desc [OptKeyGetDesc $descKey]
527
+
528
+ # make sure -help always give usage
529
+ if {[string equal -nocase "-help" $arglist]} {
530
+ return -code error [OptError "Usage information:" $desc 1]
531
+ }
532
+
533
+ OptDoAll desc arglist
534
+
535
+ if {![Lempty $arglist]} {
536
+ return -code error [OptTooManyArgs $desc $arglist]
537
+ }
538
+
539
+ # Analyse the result
540
+ # Walk through the tree:
541
+ OptTreeVars $desc "#[expr {[info level]-1}]"
542
+ }
543
+
544
+ # determine string length for nice tabulated output
545
+ proc OptTreeVars {desc level {vnamesLst {}}} {
546
+ foreach item $desc {
547
+ if {[OptIsCounter $item]} continue
548
+ if {[OptIsPrg $item]} {
549
+ set vnamesLst [OptTreeVars $item $level $vnamesLst]
550
+ } else {
551
+ set vname [OptVarName $item]
552
+ upvar $level $vname var
553
+ if {[OptHasBeenSet $item]} {
554
+ # puts "adding $vname"
555
+ # lets use the input name for the returned list
556
+ # it is more useful, for instance you can check that
557
+ # no flags at all was given with expr
558
+ # {![string match "*-*" $Args]}
559
+ lappend vnamesLst [OptName $item]
560
+ set var [OptValue $item]
561
+ } else {
562
+ set var [OptDefaultValue $item]
563
+ }
564
+ }
565
+ }
566
+ return $vnamesLst
567
+ }
568
+
569
+
570
+ # Check the type of a value
571
+ # and emit an error if arg is not of the correct type
572
+ # otherwise returns the canonical value of that arg (ie 0/1 for booleans)
573
+ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
574
+ # puts "checking '$arg' against '$type' ($typeArgs)"
575
+
576
+ # only types "any", "choice", and numbers can have leading "-"
577
+
578
+ switch -exact -- $type {
579
+ int {
580
+ if {![string is integer -strict $arg]} {
581
+ error "not an integer"
582
+ }
583
+ return $arg
584
+ }
585
+ float {
586
+ return [expr {double($arg)}]
587
+ }
588
+ script -
589
+ list {
590
+ # if llength fail : malformed list
591
+ if {[llength $arg]==0 && [OptIsFlag $arg]} {
592
+ error "no values with leading -"
593
+ }
594
+ return $arg
595
+ }
596
+ boolean {
597
+ if {![string is boolean -strict $arg]} {
598
+ error "non canonic boolean"
599
+ }
600
+ # convert true/false because expr/if is broken with "!,...
601
+ return [expr {$arg ? 1 : 0}]
602
+ }
603
+ choice {
604
+ if {$arg ni $typeArgs} {
605
+ error "invalid choice"
606
+ }
607
+ return $arg
608
+ }
609
+ any {
610
+ return $arg
611
+ }
612
+ string -
613
+ default {
614
+ if {[OptIsFlag $arg]} {
615
+ error "no values with leading -"
616
+ }
617
+ return $arg
618
+ }
619
+ }
620
+ return neverReached
621
+ }
622
+
623
+ # internal utilities
624
+
625
+ # returns the number of flags matching the given arg
626
+ # sets the (local) prg counter to the list of matches
627
+ proc OptHits {descName arg} {
628
+ upvar $descName desc
629
+ set hits 0
630
+ set hitems {}
631
+ set i 1
632
+
633
+ set larg [string tolower $arg]
634
+ set len [string length $larg]
635
+ set last [expr {$len-1}]
636
+
637
+ foreach item [lrange $desc 1 end] {
638
+ set flag [OptName $item]
639
+ # lets try to match case insensitively
640
+ # (string length ought to be cheap)
641
+ set lflag [string tolower $flag]
642
+ if {$len == [string length $lflag]} {
643
+ if {[string equal $larg $lflag]} {
644
+ # Exact match case
645
+ OptSetPrgCounter desc $i
646
+ return 1
647
+ }
648
+ } elseif {[string equal $larg [string range $lflag 0 $last]]} {
649
+ lappend hitems $i
650
+ incr hits
651
+ }
652
+ incr i
653
+ }
654
+ if {$hits} {
655
+ OptSetPrgCounter desc $hitems
656
+ }
657
+ return $hits
658
+ }
659
+
660
+ # Extract fields from the list structure:
661
+
662
+ proc OptName {item} {
663
+ lindex $item 1
664
+ }
665
+ proc OptHasBeenSet {item} {
666
+ Lget $item {2 0}
667
+ }
668
+ proc OptValue {item} {
669
+ Lget $item {2 1}
670
+ }
671
+
672
+ proc OptIsFlag {name} {
673
+ string match "-*" $name
674
+ }
675
+ proc OptIsOpt {name} {
676
+ string match {\?*} $name
677
+ }
678
+ proc OptVarName {item} {
679
+ set name [OptName $item]
680
+ if {[OptIsFlag $name]} {
681
+ return [string range $name 1 end]
682
+ } elseif {[OptIsOpt $name]} {
683
+ return [string trim $name "?"]
684
+ } else {
685
+ return $name
686
+ }
687
+ }
688
+ proc OptType {item} {
689
+ lindex $item 3
690
+ }
691
+ proc OptTypeArgs {item} {
692
+ lindex $item 4
693
+ }
694
+ proc OptHelp {item} {
695
+ lindex $item 5
696
+ }
697
+ proc OptNeedValue {item} {
698
+ expr {![string equal [OptType $item] boolflag]}
699
+ }
700
+ proc OptDefaultValue {item} {
701
+ set val [OptTypeArgs $item]
702
+ switch -exact -- [OptType $item] {
703
+ choice {return [lindex $val 0]}
704
+ boolean -
705
+ boolflag {
706
+ # convert back false/true to 0/1 because expr !$bool
707
+ # is broken..
708
+ if {$val} {
709
+ return 1
710
+ } else {
711
+ return 0
712
+ }
713
+ }
714
+ }
715
+ return $val
716
+ }
717
+
718
+ # Description format error helper
719
+ proc OptOptUsage {item {what ""}} {
720
+ return -code error "invalid description format$what: $item\n\
721
+ should be a list of {varname|-flagname ?-type? ?defaultvalue?\
722
+ ?helpstring?}"
723
+ }
724
+
725
+
726
+ # Generate a canonical form single instruction
727
+ proc OptNewInst {state varname type typeArgs help} {
728
+ list $state $varname [list 0 {}] $type $typeArgs $help
729
+ # ^ ^
730
+ # | |
731
+ # hasBeenSet=+ +=currentValue
732
+ }
733
+
734
+ # Translate one item to canonical form
735
+ proc OptNormalizeOne {item} {
736
+ set lg [Lassign $item varname arg1 arg2 arg3]
737
+ # puts "called optnormalizeone '$item' v=($varname), lg=$lg"
738
+ set isflag [OptIsFlag $varname]
739
+ set isopt [OptIsOpt $varname]
740
+ if {$isflag} {
741
+ set state "flags"
742
+ } elseif {$isopt} {
743
+ set state "optValue"
744
+ } elseif {![string equal $varname "args"]} {
745
+ set state "value"
746
+ } else {
747
+ set state "args"
748
+ }
749
+
750
+ # apply 'smart' 'fuzzy' logic to try to make
751
+ # description writer's life easy, and our's difficult :
752
+ # let's guess the missing arguments :-)
753
+
754
+ switch $lg {
755
+ 1 {
756
+ if {$isflag} {
757
+ return [OptNewInst $state $varname boolflag false ""]
758
+ } else {
759
+ return [OptNewInst $state $varname any "" ""]
760
+ }
761
+ }
762
+ 2 {
763
+ # varname default
764
+ # varname help
765
+ set type [OptGuessType $arg1]
766
+ if {[string equal $type "string"]} {
767
+ if {$isflag} {
768
+ set type boolflag
769
+ set def false
770
+ } else {
771
+ set type any
772
+ set def ""
773
+ }
774
+ set help $arg1
775
+ } else {
776
+ set help ""
777
+ set def $arg1
778
+ }
779
+ return [OptNewInst $state $varname $type $def $help]
780
+ }
781
+ 3 {
782
+ # varname type value
783
+ # varname value comment
784
+
785
+ if {[regexp {^-(.+)$} $arg1 x type]} {
786
+ # flags/optValue as they are optional, need a "value",
787
+ # on the contrary, for a variable (non optional),
788
+ # default value is pointless, 'cept for choices :
789
+ if {$isflag || $isopt || ($type == "choice")} {
790
+ return [OptNewInst $state $varname $type $arg2 ""]
791
+ } else {
792
+ return [OptNewInst $state $varname $type "" $arg2]
793
+ }
794
+ } else {
795
+ return [OptNewInst $state $varname\
796
+ [OptGuessType $arg1] $arg1 $arg2]
797
+ }
798
+ }
799
+ 4 {
800
+ if {[regexp {^-(.+)$} $arg1 x type]} {
801
+ return [OptNewInst $state $varname $type $arg2 $arg3]
802
+ } else {
803
+ return -code error [OptOptUsage $item]
804
+ }
805
+ }
806
+ default {
807
+ return -code error [OptOptUsage $item]
808
+ }
809
+ }
810
+ }
811
+
812
+ # Auto magic lazy type determination
813
+ proc OptGuessType {arg} {
814
+ if { $arg == "true" || $arg == "false" } {
815
+ return boolean
816
+ }
817
+ if {[string is integer -strict $arg]} {
818
+ return int
819
+ }
820
+ if {[string is double -strict $arg]} {
821
+ return float
822
+ }
823
+ return string
824
+ }
825
+
826
+ # Error messages front ends
827
+
828
+ proc OptAmbigous {desc arg} {
829
+ OptError "ambigous option \"$arg\", choose from:" [OptSelection $desc]
830
+ }
831
+ proc OptFlagUsage {desc arg} {
832
+ OptError "bad flag \"$arg\", must be one of" $desc
833
+ }
834
+ proc OptTooManyArgs {desc arguments} {
835
+ OptError "too many arguments (unexpected argument(s): $arguments),\
836
+ usage:"\
837
+ $desc 1
838
+ }
839
+ proc OptParamType {item} {
840
+ if {[OptIsFlag $item]} {
841
+ return "flag"
842
+ } else {
843
+ return "parameter"
844
+ }
845
+ }
846
+ proc OptBadValue {item arg {err {}}} {
847
+ # puts "bad val err = \"$err\""
848
+ OptError "bad value \"$arg\" for [OptParamType $item]"\
849
+ [list $item]
850
+ }
851
+ proc OptMissingValue {descriptions} {
852
+ # set item [OptCurDescFinal $descriptions]
853
+ set item [OptCurDesc $descriptions]
854
+ OptError "no value given for [OptParamType $item] \"[OptName $item]\"\
855
+ (use -help for full usage) :"\
856
+ [list $item]
857
+ }
858
+
859
+ proc ::tcl::OptKeyError {prefix descKey {header 0}} {
860
+ OptError $prefix [OptKeyGetDesc $descKey] $header
861
+ }
862
+
863
+ # determine string length for nice tabulated output
864
+ proc OptLengths {desc nlName tlName dlName} {
865
+ upvar $nlName nl
866
+ upvar $tlName tl
867
+ upvar $dlName dl
868
+ foreach item $desc {
869
+ if {[OptIsCounter $item]} continue
870
+ if {[OptIsPrg $item]} {
871
+ OptLengths $item nl tl dl
872
+ } else {
873
+ SetMax nl [string length [OptName $item]]
874
+ SetMax tl [string length [OptType $item]]
875
+ set dv [OptTypeArgs $item]
876
+ if {[OptState $item] != "header"} {
877
+ set dv "($dv)"
878
+ }
879
+ set l [string length $dv]
880
+ # limit the space allocated to potentially big "choices"
881
+ if {([OptType $item] != "choice") || ($l<=12)} {
882
+ SetMax dl $l
883
+ } else {
884
+ if {![info exists dl]} {
885
+ set dl 0
886
+ }
887
+ }
888
+ }
889
+ }
890
+ }
891
+ # output the tree
892
+ proc OptTree {desc nl tl dl} {
893
+ set res ""
894
+ foreach item $desc {
895
+ if {[OptIsCounter $item]} continue
896
+ if {[OptIsPrg $item]} {
897
+ append res [OptTree $item $nl $tl $dl]
898
+ } else {
899
+ set dv [OptTypeArgs $item]
900
+ if {[OptState $item] != "header"} {
901
+ set dv "($dv)"
902
+ }
903
+ append res [string trimright [format "\n %-*s %-*s %-*s %s" \
904
+ $nl [OptName $item] $tl [OptType $item] \
905
+ $dl $dv [OptHelp $item]]]
906
+ }
907
+ }
908
+ return $res
909
+ }
910
+
911
+ # Give nice usage string
912
+ proc ::tcl::OptError {prefix desc {header 0}} {
913
+ # determine length
914
+ if {$header} {
915
+ # add faked instruction
916
+ set h [list [OptNewInst header Var/FlagName Type Value Help]]
917
+ lappend h [OptNewInst header ------------ ---- ----- ----]
918
+ lappend h [OptNewInst header {(-help} "" "" {gives this help)}]
919
+ set desc [concat $h $desc]
920
+ }
921
+ OptLengths $desc nl tl dl
922
+ # actually output
923
+ return "$prefix[OptTree $desc $nl $tl $dl]"
924
+ }
925
+
926
+
927
+ ################ General Utility functions #######################
928
+
929
+ #
930
+ # List utility functions
931
+ # Naming convention:
932
+ # "Lvarxxx" take the list VARiable name as argument
933
+ # "Lxxxx" take the list value as argument
934
+ # (which is not costly with Tcl8 objects system
935
+ # as it's still a reference and not a copy of the values)
936
+ #
937
+
938
+ # Is that list empty ?
939
+ proc ::tcl::Lempty {list} {
940
+ expr {[llength $list]==0}
941
+ }
942
+
943
+ # Gets the value of one leaf of a lists tree
944
+ proc ::tcl::Lget {list indexLst} {
945
+ if {[llength $indexLst] <= 1} {
946
+ return [lindex $list $indexLst]
947
+ }
948
+ Lget [lindex $list [lindex $indexLst 0]] [lrange $indexLst 1 end]
949
+ }
950
+ # Sets the value of one leaf of a lists tree
951
+ # (we use the version that does not create the elements because
952
+ # it would be even slower... needs to be written in C !)
953
+ # (nb: there is a non trivial recursive problem with indexes 0,
954
+ # which appear because there is no difference between a list
955
+ # of 1 element and 1 element alone : [list "a"] == "a" while
956
+ # it should be {a} and [listp a] should be 0 while [listp {a b}] would be 1
957
+ # and [listp "a b"] maybe 0. listp does not exist either...)
958
+ proc ::tcl::Lvarset {listName indexLst newValue} {
959
+ upvar $listName list
960
+ if {[llength $indexLst] <= 1} {
961
+ Lvarset1nc list $indexLst $newValue
962
+ } else {
963
+ set idx [lindex $indexLst 0]
964
+ set targetList [lindex $list $idx]
965
+ # reduce refcount on targetList (not really usefull now,
966
+ # could be with optimizing compiler)
967
+ # Lvarset1 list $idx {}
968
+ # recursively replace in targetList
969
+ Lvarset targetList [lrange $indexLst 1 end] $newValue
970
+ # put updated sub list back in the tree
971
+ Lvarset1nc list $idx $targetList
972
+ }
973
+ }
974
+ # Set one cell to a value, eventually create all the needed elements
975
+ # (on level-1 of lists)
976
+ variable emptyList {}
977
+ proc ::tcl::Lvarset1 {listName index newValue} {
978
+ upvar $listName list
979
+ if {$index < 0} {return -code error "invalid negative index"}
980
+ set lg [llength $list]
981
+ if {$index >= $lg} {
982
+ variable emptyList
983
+ for {set i $lg} {$i<$index} {incr i} {
984
+ lappend list $emptyList
985
+ }
986
+ lappend list $newValue
987
+ } else {
988
+ set list [lreplace $list $index $index $newValue]
989
+ }
990
+ }
991
+ # same as Lvarset1 but no bound checking / creation
992
+ proc ::tcl::Lvarset1nc {listName index newValue} {
993
+ upvar $listName list
994
+ set list [lreplace $list $index $index $newValue]
995
+ }
996
+ # Increments the value of one leaf of a lists tree
997
+ # (which must exists)
998
+ proc ::tcl::Lvarincr {listName indexLst {howMuch 1}} {
999
+ upvar $listName list
1000
+ if {[llength $indexLst] <= 1} {
1001
+ Lvarincr1 list $indexLst $howMuch
1002
+ } else {
1003
+ set idx [lindex $indexLst 0]
1004
+ set targetList [lindex $list $idx]
1005
+ # reduce refcount on targetList
1006
+ Lvarset1nc list $idx {}
1007
+ # recursively replace in targetList
1008
+ Lvarincr targetList [lrange $indexLst 1 end] $howMuch
1009
+ # put updated sub list back in the tree
1010
+ Lvarset1nc list $idx $targetList
1011
+ }
1012
+ }
1013
+ # Increments the value of one cell of a list
1014
+ proc ::tcl::Lvarincr1 {listName index {howMuch 1}} {
1015
+ upvar $listName list
1016
+ set newValue [expr {[lindex $list $index]+$howMuch}]
1017
+ set list [lreplace $list $index $index $newValue]
1018
+ return $newValue
1019
+ }
1020
+ # Removes the first element of a list
1021
+ # and returns the new list value
1022
+ proc ::tcl::Lvarpop1 {listName} {
1023
+ upvar $listName list
1024
+ set list [lrange $list 1 end]
1025
+ }
1026
+ # Same but returns the removed element
1027
+ # (Like the tclX version)
1028
+ proc ::tcl::Lvarpop {listName} {
1029
+ upvar $listName list
1030
+ set el [lindex $list 0]
1031
+ set list [lrange $list 1 end]
1032
+ return $el
1033
+ }
1034
+ # Assign list elements to variables and return the length of the list
1035
+ proc ::tcl::Lassign {list args} {
1036
+ # faster than direct blown foreach (which does not byte compile)
1037
+ set i 0
1038
+ set lg [llength $list]
1039
+ foreach vname $args {
1040
+ if {$i>=$lg} break
1041
+ uplevel 1 [list ::set $vname [lindex $list $i]]
1042
+ incr i
1043
+ }
1044
+ return $lg
1045
+ }
1046
+
1047
+ # Misc utilities
1048
+
1049
+ # Set the varname to value if value is greater than varname's current value
1050
+ # or if varname is undefined
1051
+ proc ::tcl::SetMax {varname value} {
1052
+ upvar 1 $varname var
1053
+ if {![info exists var] || $value > $var} {
1054
+ set var $value
1055
+ }
1056
+ }
1057
+
1058
+ # Set the varname to value if value is smaller than varname's current value
1059
+ # or if varname is undefined
1060
+ proc ::tcl::SetMin {varname value} {
1061
+ upvar 1 $varname var
1062
+ if {![info exists var] || $value < $var} {
1063
+ set var $value
1064
+ }
1065
+ }
1066
+
1067
+
1068
+ # everything loaded fine, lets create the test proc:
1069
+ # OptCreateTestProc
1070
+ # Don't need the create temp proc anymore:
1071
+ # rename OptCreateTestProc {}
1072
+ }
miniconda3/lib/tcl8.6/opt0.4/pkgIndex.tcl ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tcl package index file, version 1.1
2
+ # This file is generated by the "pkg_mkIndex -direct" command
3
+ # and sourced either when an application starts up or
4
+ # by a "package unknown" script. It invokes the
5
+ # "package ifneeded" command to set up package-related
6
+ # information so that packages will be loaded automatically
7
+ # in response to "package require" commands. When this
8
+ # script is sourced, the variable $dir must contain the
9
+ # full path name of this file's directory.
10
+
11
+ if {![package vsatisfies [package provide Tcl] 8.5-]} {return}
12
+ package ifneeded opt 0.4.9 [list source -encoding utf-8 [file join $dir optparse.tcl]]
miniconda3/lib/tdbc1.1.9/libtdbc1.1.9.so ADDED
Binary file (24.3 kB). View file
 
miniconda3/lib/tdbc1.1.9/libtdbcstub1.1.9.a ADDED
Binary file (3.04 kB). View file
 
miniconda3/lib/tdbc1.1.9/pkgIndex.tcl ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- tcl -*-
2
+ # Tcl package index file, version 1.1
3
+ #
4
+ # Make sure that TDBC is running in a compatible version of Tcl, and
5
+ # that TclOO is available.
6
+
7
+ if {![package vsatisfies [package provide Tcl] 8.6-]} {
8
+ return
9
+ }
10
+ apply {{dir} {
11
+ set libraryfile [file join $dir tdbc.tcl]
12
+ if {![file exists $libraryfile] && [info exists ::env(TDBC_LIBRARY)]} {
13
+ set libraryfile [file join $::env(TDBC_LIBRARY) tdbc.tcl]
14
+ }
15
+ if {[package vsatisfies [package provide Tcl] 9.0-]} {
16
+ package ifneeded tdbc 1.1.9 \
17
+ "package require TclOO;\
18
+ [list load [file join $dir libtcl9tdbc1.1.9.so] [string totitle tdbc]]\;\
19
+ [list source -encoding utf-8 $libraryfile]"
20
+ } else {
21
+ package ifneeded tdbc 1.1.9 \
22
+ "package require TclOO;\
23
+ [list load [file join $dir libtdbc1.1.9.so] [string totitle tdbc]]\;\
24
+ [list source -encoding utf-8 $libraryfile]"
25
+ }
26
+ }} $dir
miniconda3/lib/tdbc1.1.9/tdbc.tcl ADDED
@@ -0,0 +1,922 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tdbc.tcl --
2
+ #
3
+ # Definitions of base classes from which TDBC drivers' connections,
4
+ # statements and result sets may inherit.
5
+ #
6
+ # Copyright (c) 2008 by Kevin B. Kenny
7
+ # See the file "license.terms" for information on usage and redistribution
8
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
+ #
10
+ # RCS: @(#) $Id$
11
+ #
12
+ #------------------------------------------------------------------------------
13
+
14
+ package require TclOO
15
+
16
+ namespace eval ::tdbc {
17
+ namespace export connection statement resultset
18
+ variable generalError [list TDBC GENERAL_ERROR HY000 {}]
19
+ }
20
+
21
+ #------------------------------------------------------------------------------
22
+ #
23
+ # tdbc::ParseConvenienceArgs --
24
+ #
25
+ # Parse the convenience arguments to a TDBC 'execute',
26
+ # 'executewithdictionary', or 'foreach' call.
27
+ #
28
+ # Parameters:
29
+ # argv - Arguments to the call
30
+ # optsVar -- Name of a variable in caller's scope that will receive
31
+ # a dictionary of the supplied options
32
+ #
33
+ # Results:
34
+ # Returns any args remaining after parsing the options.
35
+ #
36
+ # Side effects:
37
+ # Sets the 'opts' dictionary to the options.
38
+ #
39
+ #------------------------------------------------------------------------------
40
+
41
+ proc tdbc::ParseConvenienceArgs {argv optsVar} {
42
+
43
+ variable generalError
44
+ upvar 1 $optsVar opts
45
+
46
+ set opts [dict create -as dicts]
47
+ set i 0
48
+
49
+ # Munch keyword options off the front of the command arguments
50
+
51
+ foreach {key value} $argv {
52
+ if {[string index $key 0] eq {-}} {
53
+ switch -regexp -- $key {
54
+ -as? {
55
+ if {$value ne {dicts} && $value ne {lists}} {
56
+ set errorcode $generalError
57
+ lappend errorcode badVarType $value
58
+ return -code error \
59
+ -errorcode $errorcode \
60
+ "bad variable type \"$value\":\
61
+ must be lists or dicts"
62
+ }
63
+ dict set opts -as $value
64
+ }
65
+ -c(?:o(?:l(?:u(?:m(?:n(?:s(?:v(?:a(?:r(?:i(?:a(?:b(?:le?)?)?)?)?)?)?)?)?)?)?)?)?) {
66
+ dict set opts -columnsvariable $value
67
+ }
68
+ -- {
69
+ incr i
70
+ break
71
+ }
72
+ default {
73
+ set errorcode $generalError
74
+ lappend errorcode badOption $key
75
+ return -code error \
76
+ -errorcode $errorcode \
77
+ "bad option \"$key\":\
78
+ must be -as or -columnsvariable"
79
+ }
80
+ }
81
+ } else {
82
+ break
83
+ }
84
+ incr i 2
85
+ }
86
+
87
+ return [lrange $argv[set argv {}] $i end]
88
+
89
+ }
90
+
91
+
92
+
93
+ #------------------------------------------------------------------------------
94
+ #
95
+ # tdbc::connection --
96
+ #
97
+ # Class that represents a generic connection to a database.
98
+ #
99
+ #-----------------------------------------------------------------------------
100
+
101
+ oo::class create ::tdbc::connection {
102
+
103
+ # statementSeq is the sequence number of the last statement created.
104
+ # statementClass is the name of the class that implements the
105
+ # 'statement' API.
106
+ # primaryKeysStatement is the statement that queries primary keys
107
+ # foreignKeysStatement is the statement that queries foreign keys
108
+
109
+ variable statementSeq primaryKeysStatement foreignKeysStatement
110
+
111
+ # The base class constructor accepts no arguments. It sets up the
112
+ # machinery to do the bookkeeping to keep track of what statements
113
+ # are associated with the connection. The derived class constructor
114
+ # is expected to set the variable, 'statementClass' to the name
115
+ # of the class that represents statements, so that the 'prepare'
116
+ # method can invoke it.
117
+
118
+ constructor {} {
119
+ set statementSeq 0
120
+ namespace eval Stmt {}
121
+ }
122
+
123
+ # The 'close' method is simply an alternative syntax for destroying
124
+ # the connection.
125
+
126
+ method close {} {
127
+ my destroy
128
+ }
129
+
130
+ # The 'prepare' method creates a new statement against the connection,
131
+ # giving its constructor the current statement and the SQL code to
132
+ # prepare. It uses the 'statementClass' variable set by the constructor
133
+ # to get the class to instantiate.
134
+
135
+ method prepare {sqlcode} {
136
+ return [my statementCreate Stmt::[incr statementSeq] [self] $sqlcode]
137
+ }
138
+
139
+ # The 'statementCreate' method delegates to the constructor
140
+ # of the class specified by the 'statementClass' variable. It's
141
+ # intended for drivers designed before tdbc 1.0b10. Current ones
142
+ # should forward this method to the constructor directly.
143
+
144
+ method statementCreate {name instance sqlcode} {
145
+ my variable statementClass
146
+ return [$statementClass create $name $instance $sqlcode]
147
+ }
148
+
149
+ # Derived classes are expected to implement the 'prepareCall' method,
150
+ # and have it call 'prepare' as needed (or do something else and
151
+ # install the resulting statement)
152
+
153
+ # The 'statements' method lists the statements active against this
154
+ # connection.
155
+
156
+ method statements {} {
157
+ info commands Stmt::*
158
+ }
159
+
160
+ # The 'resultsets' method lists the result sets active against this
161
+ # connection.
162
+
163
+ method resultsets {} {
164
+ set retval {}
165
+ foreach statement [my statements] {
166
+ foreach resultset [$statement resultsets] {
167
+ lappend retval $resultset
168
+ }
169
+ }
170
+ return $retval
171
+ }
172
+
173
+ # The 'transaction' method executes a block of Tcl code as an
174
+ # ACID transaction against the database.
175
+
176
+ method transaction {script} {
177
+ my begintransaction
178
+ set status [catch {uplevel 1 $script} result options]
179
+ if {$status in {0 2 3 4}} {
180
+ set status2 [catch {my commit} result2 options2]
181
+ if {$status2 == 1} {
182
+ set status 1
183
+ set result $result2
184
+ set options $options2
185
+ }
186
+ }
187
+ switch -exact -- $status {
188
+ 0 {
189
+ # do nothing
190
+ }
191
+ 2 - 3 - 4 {
192
+ set options [dict merge {-level 1} $options[set options {}]]
193
+ dict incr options -level
194
+ }
195
+ default {
196
+ my rollback
197
+ }
198
+ }
199
+ return -options $options $result
200
+ }
201
+
202
+ # The 'allrows' method prepares a statement, then executes it with
203
+ # a given set of substituents, returning a list of all the rows
204
+ # that the statement returns. Optionally, it stores the names of
205
+ # the columns in '-columnsvariable'.
206
+ # Usage:
207
+ # $db allrows ?-as lists|dicts? ?-columnsvariable varName? ?--?
208
+ # sql ?dictionary?
209
+
210
+ method allrows args {
211
+
212
+ variable ::tdbc::generalError
213
+
214
+ # Grab keyword-value parameters
215
+
216
+ set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
217
+
218
+ # Check postitional parameters
219
+
220
+ set cmd [list [self] prepare]
221
+ if {[llength $args] == 1} {
222
+ set sqlcode [lindex $args 0]
223
+ } elseif {[llength $args] == 2} {
224
+ lassign $args sqlcode dict
225
+ } else {
226
+ set errorcode $generalError
227
+ lappend errorcode wrongNumArgs
228
+ return -code error -errorcode $errorcode \
229
+ "wrong # args: should be [lrange [info level 0] 0 1]\
230
+ ?-option value?... ?--? sqlcode ?dictionary?"
231
+ }
232
+ lappend cmd $sqlcode
233
+
234
+ # Prepare the statement
235
+
236
+ set stmt [uplevel 1 $cmd]
237
+
238
+ # Delegate to the statement to accumulate the results
239
+
240
+ set cmd [list $stmt allrows {*}$opts --]
241
+ if {[info exists dict]} {
242
+ lappend cmd $dict
243
+ }
244
+ set status [catch {
245
+ uplevel 1 $cmd
246
+ } result options]
247
+
248
+ # Destroy the statement
249
+
250
+ catch {
251
+ $stmt close
252
+ }
253
+
254
+ return -options $options $result
255
+ }
256
+
257
+ # The 'foreach' method prepares a statement, then executes it with
258
+ # a supplied set of substituents. For each row of the result,
259
+ # it sets a variable to the row and invokes a script in the caller's
260
+ # scope.
261
+ #
262
+ # Usage:
263
+ # $db foreach ?-as lists|dicts? ?-columnsVariable varName? ?--?
264
+ # varName sql ?dictionary? script
265
+
266
+ method foreach args {
267
+
268
+ variable ::tdbc::generalError
269
+
270
+ # Grab keyword-value parameters
271
+
272
+ set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
273
+
274
+ # Check postitional parameters
275
+
276
+ set cmd [list [self] prepare]
277
+ if {[llength $args] == 3} {
278
+ lassign $args varname sqlcode script
279
+ } elseif {[llength $args] == 4} {
280
+ lassign $args varname sqlcode dict script
281
+ } else {
282
+ set errorcode $generalError
283
+ lappend errorcode wrongNumArgs
284
+ return -code error -errorcode $errorcode \
285
+ "wrong # args: should be [lrange [info level 0] 0 1]\
286
+ ?-option value?... ?--? varname sqlcode ?dictionary? script"
287
+ }
288
+ lappend cmd $sqlcode
289
+
290
+ # Prepare the statement
291
+
292
+ set stmt [uplevel 1 $cmd]
293
+
294
+ # Delegate to the statement to iterate over the results
295
+
296
+ set cmd [list $stmt foreach {*}$opts -- $varname]
297
+ if {[info exists dict]} {
298
+ lappend cmd $dict
299
+ }
300
+ lappend cmd $script
301
+ set status [catch {
302
+ uplevel 1 $cmd
303
+ } result options]
304
+
305
+ # Destroy the statement
306
+
307
+ catch {
308
+ $stmt close
309
+ }
310
+
311
+ # Adjust return level in the case that the script [return]s
312
+
313
+ if {$status == 2} {
314
+ set options [dict merge {-level 1} $options[set options {}]]
315
+ dict incr options -level
316
+ }
317
+ return -options $options $result
318
+ }
319
+
320
+ # The 'BuildPrimaryKeysStatement' method builds a SQL statement to
321
+ # retrieve the primary keys from a database. (It executes once the
322
+ # first time the 'primaryKeys' method is executed, and retains the
323
+ # prepared statement for reuse.)
324
+
325
+ method BuildPrimaryKeysStatement {} {
326
+
327
+ # On some databases, CONSTRAINT_CATALOG is always NULL and
328
+ # JOINing to it fails. Check for this case and include that
329
+ # JOIN only if catalog names are supplied.
330
+
331
+ set catalogClause {}
332
+ if {[lindex [set count [my allrows -as lists {
333
+ SELECT COUNT(*)
334
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
335
+ WHERE CONSTRAINT_CATALOG IS NOT NULL}]] 0 0] != 0} {
336
+ set catalogClause \
337
+ {AND xtable.CONSTRAINT_CATALOG = xcolumn.CONSTRAINT_CATALOG}
338
+ }
339
+ set primaryKeysStatement [my prepare "
340
+ SELECT xtable.TABLE_SCHEMA AS \"tableSchema\",
341
+ xtable.TABLE_NAME AS \"tableName\",
342
+ xtable.CONSTRAINT_CATALOG AS \"constraintCatalog\",
343
+ xtable.CONSTRAINT_SCHEMA AS \"constraintSchema\",
344
+ xtable.CONSTRAINT_NAME AS \"constraintName\",
345
+ xcolumn.COLUMN_NAME AS \"columnName\",
346
+ xcolumn.ORDINAL_POSITION AS \"ordinalPosition\"
347
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS xtable
348
+ INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE xcolumn
349
+ ON xtable.CONSTRAINT_SCHEMA = xcolumn.CONSTRAINT_SCHEMA
350
+ AND xtable.TABLE_NAME = xcolumn.TABLE_NAME
351
+ AND xtable.CONSTRAINT_NAME = xcolumn.CONSTRAINT_NAME
352
+ $catalogClause
353
+ WHERE xtable.TABLE_NAME = :tableName
354
+ AND xtable.CONSTRAINT_TYPE = 'PRIMARY KEY'
355
+ "]
356
+ }
357
+
358
+ # The default implementation of the 'primarykeys' method uses the
359
+ # SQL INFORMATION_SCHEMA to retrieve primary key information. Databases
360
+ # that might not have INFORMATION_SCHEMA must overload this method.
361
+
362
+ method primarykeys {tableName} {
363
+ if {![info exists primaryKeysStatement]} {
364
+ my BuildPrimaryKeysStatement
365
+ }
366
+ tailcall $primaryKeysStatement allrows [list tableName $tableName]
367
+ }
368
+
369
+ # The 'BuildForeignKeysStatements' method builds a SQL statement to
370
+ # retrieve the foreign keys from a database. (It executes once the
371
+ # first time the 'foreignKeys' method is executed, and retains the
372
+ # prepared statements for reuse.)
373
+
374
+ method BuildForeignKeysStatement {} {
375
+
376
+ # On some databases, CONSTRAINT_CATALOG is always NULL and
377
+ # JOINing to it fails. Check for this case and include that
378
+ # JOIN only if catalog names are supplied.
379
+
380
+ set catalogClause1 {}
381
+ set catalogClause2 {}
382
+ if {[lindex [set count [my allrows -as lists {
383
+ SELECT COUNT(*)
384
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
385
+ WHERE CONSTRAINT_CATALOG IS NOT NULL}]] 0 0] != 0} {
386
+ set catalogClause1 \
387
+ {AND fkc.CONSTRAINT_CATALOG = rc.CONSTRAINT_CATALOG}
388
+ set catalogClause2 \
389
+ {AND pkc.CONSTRAINT_CATALOG = rc.CONSTRAINT_CATALOG}
390
+ }
391
+
392
+ foreach {exists1 clause1} {
393
+ 0 {}
394
+ 1 { AND pkc.TABLE_NAME = :primary}
395
+ } {
396
+ foreach {exists2 clause2} {
397
+ 0 {}
398
+ 1 { AND fkc.TABLE_NAME = :foreign}
399
+ } {
400
+ set stmt [my prepare "
401
+ SELECT rc.CONSTRAINT_CATALOG AS \"foreignConstraintCatalog\",
402
+ rc.CONSTRAINT_SCHEMA AS \"foreignConstraintSchema\",
403
+ rc.CONSTRAINT_NAME AS \"foreignConstraintName\",
404
+ rc.UNIQUE_CONSTRAINT_CATALOG
405
+ AS \"primaryConstraintCatalog\",
406
+ rc.UNIQUE_CONSTRAINT_SCHEMA AS \"primaryConstraintSchema\",
407
+ rc.UNIQUE_CONSTRAINT_NAME AS \"primaryConstraintName\",
408
+ rc.UPDATE_RULE AS \"updateAction\",
409
+ rc.DELETE_RULE AS \"deleteAction\",
410
+ pkc.TABLE_CATALOG AS \"primaryCatalog\",
411
+ pkc.TABLE_SCHEMA AS \"primarySchema\",
412
+ pkc.TABLE_NAME AS \"primaryTable\",
413
+ pkc.COLUMN_NAME AS \"primaryColumn\",
414
+ fkc.TABLE_CATALOG AS \"foreignCatalog\",
415
+ fkc.TABLE_SCHEMA AS \"foreignSchema\",
416
+ fkc.TABLE_NAME AS \"foreignTable\",
417
+ fkc.COLUMN_NAME AS \"foreignColumn\",
418
+ pkc.ORDINAL_POSITION AS \"ordinalPosition\"
419
+ FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc
420
+ INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE fkc
421
+ ON fkc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
422
+ AND fkc.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA
423
+ $catalogClause1
424
+ INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE pkc
425
+ ON pkc.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME
426
+ AND pkc.CONSTRAINT_SCHEMA = rc.UNIQUE_CONSTRAINT_SCHEMA
427
+ $catalogClause2
428
+ AND pkc.ORDINAL_POSITION = fkc.ORDINAL_POSITION
429
+ WHERE 1=1
430
+ $clause1
431
+ $clause2
432
+ ORDER BY \"foreignConstraintCatalog\", \"foreignConstraintSchema\", \"foreignConstraintName\", \"ordinalPosition\"
433
+ "]
434
+ dict set foreignKeysStatement $exists1 $exists2 $stmt
435
+ }
436
+ }
437
+ }
438
+
439
+ # The default implementation of the 'foreignkeys' method uses the
440
+ # SQL INFORMATION_SCHEMA to retrieve primary key information. Databases
441
+ # that might not have INFORMATION_SCHEMA must overload this method.
442
+
443
+ method foreignkeys {args} {
444
+
445
+ variable ::tdbc::generalError
446
+
447
+ # Check arguments
448
+
449
+ set argdict {}
450
+ if {[llength $args] % 2 != 0} {
451
+ set errorcode $generalError
452
+ lappend errorcode wrongNumArgs
453
+ return -code error -errorcode $errorcode \
454
+ "wrong # args: should be [lrange [info level 0] 0 1]\
455
+ ?-option value?..."
456
+ }
457
+ foreach {key value} $args {
458
+ if {$key ni {-primary -foreign}} {
459
+ set errorcode $generalError
460
+ lappend errorcode badOption
461
+ return -code error -errorcode $errorcode \
462
+ "bad option \"$key\", must be -primary or -foreign"
463
+ }
464
+ set key [string range $key 1 end]
465
+ if {[dict exists $argdict $key]} {
466
+ set errorcode $generalError
467
+ lappend errorcode dupOption
468
+ return -code error -errorcode $errorcode \
469
+ "duplicate option \"$key\" supplied"
470
+ }
471
+ dict set argdict $key $value
472
+ }
473
+
474
+ # Build the statements that query foreign keys. There are four
475
+ # of them, one for each combination of whether -primary
476
+ # and -foreign is specified.
477
+
478
+ if {![info exists foreignKeysStatement]} {
479
+ my BuildForeignKeysStatement
480
+ }
481
+ set stmt [dict get $foreignKeysStatement \
482
+ [dict exists $argdict primary] \
483
+ [dict exists $argdict foreign]]
484
+ tailcall $stmt allrows $argdict
485
+ }
486
+
487
+ # Derived classes are expected to implement the 'begintransaction',
488
+ # 'commit', and 'rollback' methods.
489
+
490
+ # Derived classes are expected to implement 'tables' and 'columns' method.
491
+
492
+ }
493
+
494
+ #------------------------------------------------------------------------------
495
+ #
496
+ # Class: tdbc::statement
497
+ #
498
+ # Class that represents a SQL statement in a generic database
499
+ #
500
+ #------------------------------------------------------------------------------
501
+
502
+ oo::class create tdbc::statement {
503
+
504
+ # resultSetSeq is the sequence number of the last result set created.
505
+ # resultSetClass is the name of the class that implements the 'resultset'
506
+ # API.
507
+
508
+ variable resultSetClass resultSetSeq
509
+
510
+ # The base class constructor accepts no arguments. It initializes
511
+ # the machinery for tracking the ownership of result sets. The derived
512
+ # constructor is expected to invoke the base constructor, and to
513
+ # set a variable 'resultSetClass' to the fully-qualified name of the
514
+ # class that represents result sets.
515
+
516
+ constructor {} {
517
+ set resultSetSeq 0
518
+ namespace eval ResultSet {}
519
+ }
520
+
521
+ # The 'execute' method on a statement runs the statement with
522
+ # a particular set of substituted variables. It actually works
523
+ # by creating the result set object and letting that objects
524
+ # constructor do the work of running the statement. The creation
525
+ # is wrapped in an [uplevel] call because the substitution proces
526
+ # may need to access variables in the caller's scope.
527
+
528
+ # WORKAROUND: Take out the '0 &&' from the next line when
529
+ # Bug 2649975 is fixed
530
+ if {0 && [package vsatisfies [package provide Tcl] 8.6]} {
531
+ method execute args {
532
+ tailcall my resultSetCreate \
533
+ [namespace current]::ResultSet::[incr resultSetSeq] \
534
+ [self] {*}$args
535
+ }
536
+ } else {
537
+ method execute args {
538
+ return \
539
+ [uplevel 1 \
540
+ [list \
541
+ [self] resultSetCreate \
542
+ [namespace current]::ResultSet::[incr resultSetSeq] \
543
+ [self] {*}$args]]
544
+ }
545
+ }
546
+
547
+ # The 'ResultSetCreate' method is expected to be a forward to the
548
+ # appropriate result set constructor. If it's missing, the driver must
549
+ # have been designed for tdbc 1.0b9 and earlier, and the 'resultSetClass'
550
+ # variable holds the class name.
551
+
552
+ method resultSetCreate {name instance args} {
553
+ return [uplevel 1 [list $resultSetClass create \
554
+ $name $instance {*}$args]]
555
+ }
556
+
557
+ # The 'resultsets' method returns a list of result sets produced by
558
+ # the current statement
559
+
560
+ method resultsets {} {
561
+ info commands ResultSet::*
562
+ }
563
+
564
+ # The 'allrows' method executes a statement with a given set of
565
+ # substituents, and returns a list of all the rows that the statement
566
+ # returns. Optionally, it stores the names of columns in
567
+ # '-columnsvariable'.
568
+ #
569
+ # Usage:
570
+ # $statement allrows ?-as lists|dicts? ?-columnsvariable varName? ?--?
571
+ # ?dictionary?
572
+
573
+
574
+ method allrows args {
575
+
576
+ variable ::tdbc::generalError
577
+
578
+ # Grab keyword-value parameters
579
+
580
+ set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
581
+
582
+ # Check postitional parameters
583
+
584
+ set cmd [list [self] execute]
585
+ if {[llength $args] == 0} {
586
+ # do nothing
587
+ } elseif {[llength $args] == 1} {
588
+ lappend cmd [lindex $args 0]
589
+ } else {
590
+ set errorcode $generalError
591
+ lappend errorcode wrongNumArgs
592
+ return -code error -errorcode $errorcode \
593
+ "wrong # args: should be [lrange [info level 0] 0 1]\
594
+ ?-option value?... ?--? ?dictionary?"
595
+ }
596
+
597
+ # Get the result set
598
+
599
+ set resultSet [uplevel 1 $cmd]
600
+
601
+ # Delegate to the result set's [allrows] method to accumulate
602
+ # the rows of the result.
603
+
604
+ set cmd [list $resultSet allrows {*}$opts]
605
+ set status [catch {
606
+ uplevel 1 $cmd
607
+ } result options]
608
+
609
+ # Destroy the result set
610
+
611
+ catch {
612
+ rename $resultSet {}
613
+ }
614
+
615
+ # Adjust return level in the case that the script [return]s
616
+
617
+ if {$status == 2} {
618
+ set options [dict merge {-level 1} $options[set options {}]]
619
+ dict incr options -level
620
+ }
621
+ return -options $options $result
622
+ }
623
+
624
+ # The 'foreach' method executes a statement with a given set of
625
+ # substituents. It runs the supplied script, substituting the supplied
626
+ # named variable. Optionally, it stores the names of columns in
627
+ # '-columnsvariable'.
628
+ #
629
+ # Usage:
630
+ # $statement foreach ?-as lists|dicts? ?-columnsvariable varName? ?--?
631
+ # variableName ?dictionary? script
632
+
633
+ method foreach args {
634
+
635
+ variable ::tdbc::generalError
636
+
637
+ # Grab keyword-value parameters
638
+
639
+ set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
640
+
641
+ # Check positional parameters
642
+
643
+ set cmd [list [self] execute]
644
+ if {[llength $args] == 2} {
645
+ lassign $args varname script
646
+ } elseif {[llength $args] == 3} {
647
+ lassign $args varname dict script
648
+ lappend cmd $dict
649
+ } else {
650
+ set errorcode $generalError
651
+ lappend errorcode wrongNumArgs
652
+ return -code error -errorcode $errorcode \
653
+ "wrong # args: should be [lrange [info level 0] 0 1]\
654
+ ?-option value?... ?--? varName ?dictionary? script"
655
+ }
656
+
657
+ # Get the result set
658
+
659
+ set resultSet [uplevel 1 $cmd]
660
+
661
+ # Delegate to the result set's [foreach] method to evaluate
662
+ # the script for each row of the result.
663
+
664
+ set cmd [list $resultSet foreach {*}$opts -- $varname $script]
665
+ set status [catch {
666
+ uplevel 1 $cmd
667
+ } result options]
668
+
669
+ # Destroy the result set
670
+
671
+ catch {
672
+ rename $resultSet {}
673
+ }
674
+
675
+ # Adjust return level in the case that the script [return]s
676
+
677
+ if {$status == 2} {
678
+ set options [dict merge {-level 1} $options[set options {}]]
679
+ dict incr options -level
680
+ }
681
+ return -options $options $result
682
+ }
683
+
684
+ # The 'close' method is syntactic sugar for invoking the destructor
685
+
686
+ method close {} {
687
+ my destroy
688
+ }
689
+
690
+ # Derived classes are expected to implement their own constructors,
691
+ # plus the following methods:
692
+
693
+ # paramtype paramName ?direction? type ?scale ?precision??
694
+ # Declares the type of a parameter in the statement
695
+
696
+ }
697
+
698
+ #------------------------------------------------------------------------------
699
+ #
700
+ # Class: tdbc::resultset
701
+ #
702
+ # Class that represents a result set in a generic database.
703
+ #
704
+ #------------------------------------------------------------------------------
705
+
706
+ oo::class create tdbc::resultset {
707
+
708
+ constructor {} { }
709
+
710
+ # The 'allrows' method returns a list of all rows that a given
711
+ # result set returns.
712
+
713
+ method allrows args {
714
+
715
+ variable ::tdbc::generalError
716
+
717
+ # Parse args
718
+
719
+ set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
720
+ if {[llength $args] != 0} {
721
+ set errorcode $generalError
722
+ lappend errorcode wrongNumArgs
723
+ return -code error -errorcode $errorcode \
724
+ "wrong # args: should be [lrange [info level 0] 0 1]\
725
+ ?-option value?... ?--? varName script"
726
+ }
727
+
728
+ # Do -columnsvariable if requested
729
+
730
+ if {[dict exists $opts -columnsvariable]} {
731
+ upvar 1 [dict get $opts -columnsvariable] columns
732
+ }
733
+
734
+ # Assemble the results
735
+
736
+ if {[dict get $opts -as] eq {lists}} {
737
+ set delegate nextlist
738
+ } else {
739
+ set delegate nextdict
740
+ }
741
+ set results [list]
742
+ while {1} {
743
+ set columns [my columns]
744
+ while {[my $delegate row]} {
745
+ lappend results $row
746
+ }
747
+ if {![my nextresults]} break
748
+ }
749
+ return $results
750
+
751
+ }
752
+
753
+ # The 'foreach' method runs a script on each row from a result set.
754
+
755
+ method foreach args {
756
+
757
+ variable ::tdbc::generalError
758
+
759
+ # Grab keyword-value parameters
760
+
761
+ set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
762
+
763
+ # Check positional parameters
764
+
765
+ if {[llength $args] != 2} {
766
+ set errorcode $generalError
767
+ lappend errorcode wrongNumArgs
768
+ return -code error -errorcode $errorcode \
769
+ "wrong # args: should be [lrange [info level 0] 0 1]\
770
+ ?-option value?... ?--? varName script"
771
+ }
772
+
773
+ # Do -columnsvariable if requested
774
+
775
+ if {[dict exists $opts -columnsvariable]} {
776
+ upvar 1 [dict get $opts -columnsvariable] columns
777
+ }
778
+
779
+ # Iterate over the groups of results
780
+ while {1} {
781
+
782
+ # Export column names to caller
783
+
784
+ set columns [my columns]
785
+
786
+ # Iterate over the rows of one group of results
787
+
788
+ upvar 1 [lindex $args 0] row
789
+ if {[dict get $opts -as] eq {lists}} {
790
+ set delegate nextlist
791
+ } else {
792
+ set delegate nextdict
793
+ }
794
+ while {[my $delegate row]} {
795
+ set status [catch {
796
+ uplevel 1 [lindex $args 1]
797
+ } result options]
798
+ switch -exact -- $status {
799
+ 0 - 4 { # OK or CONTINUE
800
+ }
801
+ 2 { # RETURN
802
+ set options \
803
+ [dict merge {-level 1} $options[set options {}]]
804
+ dict incr options -level
805
+ return -options $options $result
806
+ }
807
+ 3 { # BREAK
808
+ set broken 1
809
+ break
810
+ }
811
+ default { # ERROR or unknown status
812
+ return -options $options $result
813
+ }
814
+ }
815
+ }
816
+
817
+ # Advance to the next group of results if there is one
818
+
819
+ if {[info exists broken] || ![my nextresults]} {
820
+ break
821
+ }
822
+ }
823
+
824
+ return
825
+ }
826
+
827
+
828
+ # The 'nextrow' method retrieves a row in the form of either
829
+ # a list or a dictionary.
830
+
831
+ method nextrow {args} {
832
+
833
+ variable ::tdbc::generalError
834
+
835
+ set opts [dict create -as dicts]
836
+ set i 0
837
+
838
+ # Munch keyword options off the front of the command arguments
839
+
840
+ foreach {key value} $args {
841
+ if {[string index $key 0] eq {-}} {
842
+ switch -regexp -- $key {
843
+ -as? {
844
+ dict set opts -as $value
845
+ }
846
+ -- {
847
+ incr i
848
+ break
849
+ }
850
+ default {
851
+ set errorcode $generalError
852
+ lappend errorcode badOption $key
853
+ return -code error -errorcode $errorcode \
854
+ "bad option \"$key\":\
855
+ must be -as or -columnsvariable"
856
+ }
857
+ }
858
+ } else {
859
+ break
860
+ }
861
+ incr i 2
862
+ }
863
+
864
+ set args [lrange $args $i end]
865
+ if {[llength $args] != 1} {
866
+ set errorcode $generalError
867
+ lappend errorcode wrongNumArgs
868
+ return -code error -errorcode $errorcode \
869
+ "wrong # args: should be [lrange [info level 0] 0 1]\
870
+ ?-option value?... ?--? varName"
871
+ }
872
+ upvar 1 [lindex $args 0] row
873
+ if {[dict get $opts -as] eq {lists}} {
874
+ set delegate nextlist
875
+ } else {
876
+ set delegate nextdict
877
+ }
878
+ return [my $delegate row]
879
+ }
880
+
881
+ # Derived classes must override 'nextresults' if a single
882
+ # statement execution can yield multiple sets of results
883
+
884
+ method nextresults {} {
885
+ return 0
886
+ }
887
+
888
+ # Derived classes must override 'outputparams' if statements can
889
+ # have output parameters.
890
+
891
+ method outputparams {} {
892
+ return {}
893
+ }
894
+
895
+ # The 'close' method is syntactic sugar for destroying the result set.
896
+
897
+ method close {} {
898
+ my destroy
899
+ }
900
+
901
+ # Derived classes are expected to implement the following methods:
902
+
903
+ # constructor and destructor.
904
+ # Constructor accepts a statement and an optional
905
+ # a dictionary of substituted parameters and
906
+ # executes the statement against the database. If
907
+ # the dictionary is not supplied, then the default
908
+ # is to get params from variables in the caller's scope).
909
+ # columns
910
+ # -- Returns a list of the names of the columns in the result.
911
+ # nextdict variableName
912
+ # -- Stores the next row of the result set in the given variable
913
+ # in caller's scope, in the form of a dictionary that maps
914
+ # column names to values.
915
+ # nextlist variableName
916
+ # -- Stores the next row of the result set in the given variable
917
+ # in caller's scope, in the form of a list of cells.
918
+ # rowcount
919
+ # -- Returns a count of rows affected by the statement, or -1
920
+ # if the count of rows has not been determined.
921
+
922
+ }
miniconda3/lib/tdbc1.1.9/tdbcConfig.sh ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tdbcConfig.sh --
2
+ #
3
+ # This shell script (for sh) is generated automatically by TDBC's configure
4
+ # script. It will create shell variables for most of the configuration options
5
+ # discovered by the configure script. This script is intended to be included
6
+ # by the configure scripts for TDBC extensions so that they don't have to
7
+ # figure this all out for themselves.
8
+ #
9
+ # The information in this file is specific to a single platform.
10
+ #
11
+ # RCS: @(#) $Id$
12
+
13
+ # TDBC's version number
14
+ tdbc_VERSION=1.1.9
15
+ TDBC_VERSION=1.1.9
16
+
17
+ # Name of the TDBC library - may be either a static or shared library
18
+ tdbc_LIB_FILE=libtdbc1.1.9.so
19
+ TDBC_LIB_FILE=libtdbc1.1.9.so
20
+
21
+ # String to pass to the linker to pick up the TDBC library from its build dir
22
+ tdbc_BUILD_LIB_SPEC="-L/croot/tk_1755243777296/work/tcl8.6.15/unix/pkgs/tdbc1.1.9 -ltdbc1.1.9"
23
+ TDBC_BUILD_LIB_SPEC="-L/croot/tk_1755243777296/work/tcl8.6.15/unix/pkgs/tdbc1.1.9 -ltdbc1.1.9"
24
+
25
+ # String to pass to the linker to pick up the TDBC library from its installed
26
+ # dir.
27
+ tdbc_LIB_SPEC="-L/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9 -ltdbc1.1.9"
28
+ TDBC_LIB_SPEC="-L/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9 -ltdbc1.1.9"
29
+
30
+ # Name of the TBDC stub library
31
+ tdbc_STUB_LIB_FILE="libtdbcstub1.1.9.a"
32
+ TDBC_STUB_LIB_FILE="libtdbcstub1.1.9.a"
33
+
34
+ # String to pass to the linker to pick up the TDBC stub library from its
35
+ # build directory
36
+ tdbc_BUILD_STUB_LIB_SPEC="-L/croot/tk_1755243777296/work/tcl8.6.15/unix/pkgs/tdbc1.1.9 -ltdbcstub1.1.9"
37
+ TDBC_BUILD_STUB_LIB_SPEC="-L/croot/tk_1755243777296/work/tcl8.6.15/unix/pkgs/tdbc1.1.9 -ltdbcstub1.1.9"
38
+
39
+ # String to pass to the linker to pick up the TDBC stub library from its
40
+ # installed directory
41
+ tdbc_STUB_LIB_SPEC="-L/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9 -ltdbcstub1.1.9"
42
+ TDBC_STUB_LIB_SPEC="-L/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9 -ltdbcstub1.1.9"
43
+
44
+ # Path name of the TDBC stub library in its build directory
45
+ tdbc_BUILD_STUB_LIB_PATH="/croot/tk_1755243777296/work/tcl8.6.15/unix/pkgs/tdbc1.1.9/libtdbcstub1.1.9.a"
46
+ TDBC_BUILD_STUB_LIB_PATH="/croot/tk_1755243777296/work/tcl8.6.15/unix/pkgs/tdbc1.1.9/libtdbcstub1.1.9.a"
47
+
48
+ # Path name of the TDBC stub library in its installed directory
49
+ tdbc_STUB_LIB_PATH="/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9/libtdbcstub1.1.9.a"
50
+ TDBC_STUB_LIB_PATH="/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9/libtdbcstub1.1.9.a"
51
+
52
+ # Location of the top-level source directories from which TDBC was built.
53
+ # This is the directory that contains doc/, generic/ and so on. If TDBC
54
+ # was compiled in a directory other than the source directory, this still
55
+ # points to the location of the sources, not the location where TDBC was
56
+ # compiled.
57
+ tdbc_SRC_DIR="/croot/tk_1755243777296/work/tcl8.6.15/pkgs/tdbc1.1.9"
58
+ TDBC_SRC_DIR="/croot/tk_1755243777296/work/tcl8.6.15/pkgs/tdbc1.1.9"
59
+
60
+ # String to pass to the compiler so that an extension can find installed TDBC
61
+ # headers
62
+ tdbc_INCLUDE_SPEC="-I/mnt/bn/bohanzhainas1/jiashuo/miniconda3/include"
63
+ TDBC_INCLUDE_SPEC="-I/mnt/bn/bohanzhainas1/jiashuo/miniconda3/include"
64
+
65
+ # String to pass to the compiler so that an extension can find TDBC headers
66
+ # in the source directory
67
+ tdbc_BUILD_INCLUDE_SPEC="-I/croot/tk_1755243777296/work/tcl8.6.15/pkgs/tdbc1.1.9/generic"
68
+ TDBC_BUILD_INCLUDE_SPEC="-I/croot/tk_1755243777296/work/tcl8.6.15/pkgs/tdbc1.1.9/generic"
69
+
70
+ # Path name where .tcl files in the tdbc package appear at run time.
71
+ tdbc_LIBRARY_PATH="/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9"
72
+ TDBC_LIBRARY_PATH="/mnt/bn/bohanzhainas1/jiashuo/miniconda3/lib/tdbc1.1.9"
73
+
74
+ # Path name where .tcl files in the tdbc package appear at build time.
75
+ tdbc_BUILD_LIBRARY_PATH="/croot/tk_1755243777296/work/tcl8.6.15/pkgs/tdbc1.1.9/library"
76
+ TDBC_BUILD_LIBRARY_PATH="/croot/tk_1755243777296/work/tcl8.6.15/pkgs/tdbc1.1.9/library"
77
+
78
+ # Additional flags that must be passed to the C compiler to use tdbc
79
+ tdbc_CFLAGS=
80
+ TDBC_CFLAGS=
81
+
miniconda3/lib/tdbcmysql1.1.9/libtdbcmysql1.1.9.so ADDED
Binary file (52.4 kB). View file
 
miniconda3/lib/tdbcmysql1.1.9/pkgIndex.tcl ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Index file to load the TDBC MySQL package.
2
+
3
+ if {![package vsatisfies [package provide Tcl] 8.6-]} {
4
+ return
5
+ }
6
+ if {[package vsatisfies [package provide Tcl] 9.0-]} {
7
+ package ifneeded tdbc::mysql 1.1.9 \
8
+ "[list source -encoding utf-8 [file join $dir tdbcmysql.tcl]]\;\
9
+ [list load [file join $dir libtcl9tdbcmysql1.1.9.so] [string totitle tdbcmysql]]"
10
+ } else {
11
+ package ifneeded tdbc::mysql 1.1.9 \
12
+ "[list source -encoding utf-8 [file join $dir tdbcmysql.tcl]]\;\
13
+ [list load [file join $dir libtdbcmysql1.1.9.so] [string totitle tdbcmysql]]"
14
+ }
miniconda3/lib/tdbcmysql1.1.9/tdbcmysql.tcl ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tdbcmysql.tcl --
2
+ #
3
+ # Class definitions and Tcl-level methods for the tdbc::mysql bridge.
4
+ #
5
+ # Copyright (c) 2008 by Kevin B. Kenny
6
+ # See the file "license.terms" for information on usage and redistribution
7
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8
+ #
9
+ # RCS: @(#) $Id: tdbcmysql.tcl,v 1.47 2008/02/27 02:08:27 kennykb Exp $
10
+ #
11
+ #------------------------------------------------------------------------------
12
+
13
+ package require tdbc
14
+
15
+ ::namespace eval ::tdbc::mysql {
16
+
17
+ namespace export connection datasources drivers
18
+
19
+ }
20
+
21
+ #------------------------------------------------------------------------------
22
+ #
23
+ # tdbc::mysql::connection --
24
+ #
25
+ # Class representing a connection to a database through MYSQL.
26
+ #
27
+ #-------------------------------------------------------------------------------
28
+
29
+ ::oo::class create ::tdbc::mysql::connection {
30
+
31
+ superclass ::tdbc::connection
32
+
33
+ # The constructor is written in C. It takes alternating keywords
34
+ # and values pairs as its argumenta. (See the manual page for the
35
+ # available options.)
36
+
37
+ variable foreignKeysStatement
38
+
39
+ # The 'statementCreate' method delegates to the constructor of the
40
+ # statement class
41
+
42
+ forward statementCreate ::tdbc::mysql::statement create
43
+
44
+ # The 'columns' method returns a dictionary describing the tables
45
+ # in the database
46
+
47
+ method columns {table {pattern %}} {
48
+
49
+ # To return correct lengths of CHARACTER and BINARY columns,
50
+ # we need to know the maximum lengths of characters in each
51
+ # collation. We cache this information only once, on the first
52
+ # call to 'columns'.
53
+
54
+ if {[my NeedCollationInfo]} {
55
+ my SetCollationInfo {*}[my allrows -as lists {
56
+ SELECT coll.id, cs.maxlen
57
+ FROM INFORMATION_SCHEMA.COLLATIONS coll,
58
+ INFORMATION_SCHEMA.CHARACTER_SETS cs
59
+ WHERE cs.CHARACTER_SET_NAME = coll.CHARACTER_SET_NAME
60
+ ORDER BY coll.id DESC
61
+ }]
62
+ }
63
+
64
+ return [my Columns $table $pattern]
65
+ }
66
+
67
+ # The 'preparecall' method gives a portable interface to prepare
68
+ # calls to stored procedures. It delegates to 'prepare' to do the
69
+ # actual work.
70
+
71
+ method preparecall {call} {
72
+ regexp {^[[:space:]]*(?:([A-Za-z_][A-Za-z_0-9]*)[[:space:]]*=)?(.*)} \
73
+ $call -> varName rest
74
+ if {$varName eq {}} {
75
+ my prepare "CALL $rest"
76
+ } else {
77
+ my prepare \\{:$varName=$rest\\}
78
+ }
79
+ }
80
+
81
+ # The 'init', 'begintransaction', 'commit, 'rollback', 'tables'
82
+ # 'NeedCollationInfo', 'SetCollationInfo', and 'Columns' methods
83
+ # are implemented in C.
84
+
85
+ # The 'BuildForeignKeysStatements' method builds a SQL statement to
86
+ # retrieve the foreign keys from a database. (It executes once the
87
+ # first time the 'foreignKeys' method is executed, and retains the
88
+ # prepared statements for reuse.) It is slightly nonstandard because
89
+ # MYSQL doesn't name the PRIMARY constraints uniquely.
90
+
91
+ method BuildForeignKeysStatement {} {
92
+
93
+ foreach {exists1 clause1} {
94
+ 0 {}
95
+ 1 { AND fkc.REFERENCED_TABLE_NAME = :primary}
96
+ } {
97
+ foreach {exists2 clause2} {
98
+ 0 {}
99
+ 1 { AND fkc.TABLE_NAME = :foreign}
100
+ } {
101
+ set stmt [my prepare "
102
+ SELECT rc.CONSTRAINT_SCHEMA AS \"foreignConstraintSchema\",
103
+ rc.CONSTRAINT_NAME AS \"foreignConstraintName\",
104
+ rc.UPDATE_RULE AS \"updateAction\",
105
+ rc.DELETE_RULE AS \"deleteAction\",
106
+ fkc.REFERENCED_TABLE_SCHEMA AS \"primarySchema\",
107
+ fkc.REFERENCED_TABLE_NAME AS \"primaryTable\",
108
+ fkc.REFERENCED_COLUMN_NAME AS \"primaryColumn\",
109
+ fkc.TABLE_SCHEMA AS \"foreignSchema\",
110
+ fkc.TABLE_NAME AS \"foreignTable\",
111
+ fkc.COLUMN_NAME AS \"foreignColumn\",
112
+ fkc.ORDINAL_POSITION AS \"ordinalPosition\"
113
+ FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc
114
+ INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE fkc
115
+ ON fkc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
116
+ AND fkc.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA
117
+ WHERE 1=1
118
+ $clause1
119
+ $clause2
120
+ "]
121
+ dict set foreignKeysStatement $exists1 $exists2 $stmt
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ #------------------------------------------------------------------------------
128
+ #
129
+ # tdbc::mysql::statement --
130
+ #
131
+ # The class 'tdbc::mysql::statement' models one statement against a
132
+ # database accessed through an MYSQL connection
133
+ #
134
+ #------------------------------------------------------------------------------
135
+
136
+ ::oo::class create ::tdbc::mysql::statement {
137
+
138
+ superclass ::tdbc::statement
139
+
140
+ # The 'resultSetCreate' method forwards to the constructor of the
141
+ # result set.
142
+
143
+ forward resultSetCreate ::tdbc::mysql::resultset create
144
+
145
+ # Methods implemented in C:
146
+ #
147
+ # constructor connection SQLCode
148
+ # The constructor accepts the handle to the connection and the SQL code
149
+ # for the statement to prepare. It creates a subordinate namespace to
150
+ # hold the statement's active result sets, and then delegates to the
151
+ # 'init' method, written in C, to do the actual work of preparing the
152
+ # statement.
153
+ # params
154
+ # Returns descriptions of the parameters of a statement.
155
+ # paramtype paramname ?direction? type ?precision ?scale??
156
+ # Declares the type of a parameter in the statement
157
+
158
+ }
159
+
160
+ #------------------------------------------------------------------------------
161
+ #
162
+ # tdbc::mysql::resultset --
163
+ #
164
+ # The class 'tdbc::mysql::resultset' models the result set that is
165
+ # produced by executing a statement against an MYSQL database.
166
+ #
167
+ #------------------------------------------------------------------------------
168
+
169
+ ::oo::class create ::tdbc::mysql::resultset {
170
+
171
+ superclass ::tdbc::resultset
172
+
173
+ # Methods implemented in C include:
174
+
175
+ # constructor statement ?dictionary?
176
+ # -- Executes the statement against the database, optionally providing
177
+ # a dictionary of substituted parameters (default is to get params
178
+ # from variables in the caller's scope).
179
+ # columns
180
+ # -- Returns a list of the names of the columns in the result.
181
+ # nextdict
182
+ # -- Stores the next row of the result set in the given variable in
183
+ # the caller's scope as a dictionary whose keys are
184
+ # column names and whose values are column values, or else
185
+ # as a list of cells.
186
+ # nextlist
187
+ # -- Stores the next row of the result set in the given variable in
188
+ # the caller's scope as a list of cells.
189
+ # rowcount
190
+ # -- Returns a count of rows affected by the statement, or -1
191
+ # if the count of rows has not been determined.
192
+
193
+ }
miniconda3/lib/tdbcodbc1.1.9/libtdbcodbc1.1.9.so ADDED
Binary file (66 kB). View file
 
miniconda3/lib/tdbcodbc1.1.9/pkgIndex.tcl ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Index file to load the TDBC ODBC package.
2
+
3
+ if {![package vsatisfies [package provide Tcl] 8.6-]} {
4
+ return
5
+ }
6
+ if {[package vsatisfies [package provide Tcl] 9.0-]} {
7
+ package ifneeded tdbc::odbc 1.1.9 \
8
+ "[list source -encoding utf-8 [file join $dir tdbcodbc.tcl]]\;\
9
+ [list load [file join $dir libtcl9tdbcodbc1.1.9.so] [string totitle tdbcodbc]]"
10
+ } else {
11
+ package ifneeded tdbc::odbc 1.1.9 \
12
+ "[list source -encoding utf-8 [file join $dir tdbcodbc.tcl]]\;\
13
+ [list load [file join $dir libtdbcodbc1.1.9.so] [string totitle tdbcodbc]]"
14
+ }
miniconda3/lib/tdbcodbc1.1.9/tdbcodbc.tcl ADDED
@@ -0,0 +1,554 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tdbcodbc.tcl --
2
+ #
3
+ # Class definitions and Tcl-level methods for the tdbc::odbc bridge.
4
+ #
5
+ # Copyright (c) 2008 by Kevin B. Kenny
6
+ # See the file "license.terms" for information on usage and redistribution
7
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8
+ #
9
+ # RCS: @(#) $Id: tdbcodbc.tcl,v 1.47 2008/02/27 02:08:27 kennykb Exp $
10
+ #
11
+ #------------------------------------------------------------------------------
12
+
13
+ package require tdbc
14
+
15
+ ::namespace eval ::tdbc::odbc {
16
+
17
+ namespace export connection datasources drivers
18
+
19
+ # Data types that are predefined in ODBC
20
+
21
+ variable sqltypes [dict create \
22
+ 1 char \
23
+ 2 numeric \
24
+ 3 decimal \
25
+ 4 integer \
26
+ 5 smallint \
27
+ 6 float \
28
+ 7 real \
29
+ 8 double \
30
+ 9 datetime \
31
+ 12 varchar \
32
+ 91 date \
33
+ 92 time \
34
+ 93 timestamp \
35
+ -1 longvarchar \
36
+ -2 binary \
37
+ -3 varbinary \
38
+ -4 longvarbinary \
39
+ -5 bigint \
40
+ -6 tinyint \
41
+ -7 bit \
42
+ -8 wchar \
43
+ -9 wvarchar \
44
+ -10 wlongvarchar \
45
+ -11 guid]
46
+ }
47
+
48
+ #------------------------------------------------------------------------------
49
+ #
50
+ # tdbc::odbc::connection --
51
+ #
52
+ # Class representing a connection to a database through ODBC.
53
+ #
54
+ #-------------------------------------------------------------------------------
55
+
56
+ ::oo::class create ::tdbc::odbc::connection {
57
+
58
+ superclass ::tdbc::connection
59
+
60
+ variable statementSeq typemap
61
+
62
+ # The constructor is written in C. It takes the connection string
63
+ # as its argument It sets up a namespace to hold the statements
64
+ # associated with the connection, and then delegates to the 'init'
65
+ # method (written in C) to do the actual work of attaching to the
66
+ # database. When that comes back, it sets up a statement to query
67
+ # the support types, makes a dictionary to enumerate them, and
68
+ # calls back to set a flag if WVARCHAR is seen (If WVARCHAR is
69
+ # seen, the database supports Unicode.)
70
+
71
+ # The 'statementCreate' method forwards to the constructor of the
72
+ # statement class
73
+
74
+ forward statementCreate ::tdbc::odbc::statement create
75
+
76
+ # The 'tables' method returns a dictionary describing the tables
77
+ # in the database
78
+
79
+ method tables {{pattern %}} {
80
+ set stmt [::tdbc::odbc::tablesStatement create \
81
+ Stmt::[incr statementSeq] [self] $pattern]
82
+ set status [catch {
83
+ set retval {}
84
+ $stmt foreach -as dicts row {
85
+ if {[dict exists $row TABLE_NAME]} {
86
+ dict set retval [dict get $row TABLE_NAME] $row
87
+ }
88
+ }
89
+ set retval
90
+ } result options]
91
+ catch {rename $stmt {}}
92
+ return -level 0 -options $options $result
93
+ }
94
+
95
+ # The 'columns' method returns a dictionary describing the tables
96
+ # in the database
97
+
98
+ method columns {table {pattern %}} {
99
+ # Make sure that the type map is initialized
100
+ my typemap
101
+
102
+ # Query the columns from the database
103
+
104
+ set stmt [::tdbc::odbc::columnsStatement create \
105
+ Stmt::[incr statementSeq] [self] $table $pattern]
106
+ set status [catch {
107
+ set retval {}
108
+ $stmt foreach -as dicts origrow {
109
+
110
+ # Map the type, precision, scale and nullable indicators
111
+ # to tdbc's notation
112
+
113
+ set row {}
114
+ dict for {key value} $origrow {
115
+ dict set row [string tolower $key] $value
116
+ }
117
+ if {[dict exists $row column_name]} {
118
+ if {[dict exists $typemap \
119
+ [dict get $row data_type]]} {
120
+ dict set row type \
121
+ [dict get $typemap \
122
+ [dict get $row data_type]]
123
+ } else {
124
+ dict set row type [dict get $row type_name]
125
+ }
126
+ if {[dict exists $row column_size]} {
127
+ dict set row precision \
128
+ [dict get $row column_size]
129
+ }
130
+ if {[dict exists $row decimal_digits]} {
131
+ dict set row scale \
132
+ [dict get $row decimal_digits]
133
+ }
134
+ if {![dict exists $row nullable]} {
135
+ dict set row nullable \
136
+ [expr {!![string trim [dict get $row is_nullable]]}]
137
+ }
138
+ dict set retval [dict get $row column_name] $row
139
+ }
140
+ }
141
+ set retval
142
+ } result options]
143
+ catch {rename $stmt {}}
144
+ return -level 0 -options $options $result
145
+ }
146
+
147
+ # The 'primarykeys' method returns a dictionary describing the primary
148
+ # keys of a table
149
+
150
+ method primarykeys {tableName} {
151
+ set stmt [::tdbc::odbc::primarykeysStatement create \
152
+ Stmt::[incr statementSeq] [self] $tableName]
153
+ set status [catch {
154
+ set retval {}
155
+ $stmt foreach -as dicts row {
156
+ foreach {odbcKey tdbcKey} {
157
+ TABLE_CAT tableCatalog
158
+ TABLE_SCHEM tableSchema
159
+ TABLE_NAME tableName
160
+ COLUMN_NAME columnName
161
+ KEY_SEQ ordinalPosition
162
+ PK_NAME constraintName
163
+ } {
164
+ if {[dict exists $row $odbcKey]} {
165
+ dict set row $tdbcKey [dict get $row $odbcKey]
166
+ dict unset row $odbcKey
167
+ }
168
+ }
169
+ lappend retval $row
170
+ }
171
+ set retval
172
+ } result options]
173
+ catch {rename $stmt {}}
174
+ return -level 0 -options $options $result
175
+ }
176
+
177
+ # The 'foreignkeys' method returns a dictionary describing the foreign
178
+ # keys of a table
179
+
180
+ method foreignkeys {args} {
181
+ set stmt [::tdbc::odbc::foreignkeysStatement create \
182
+ Stmt::[incr statementSeq] [self] {*}$args]
183
+ set status [catch {
184
+ set fkseq 0
185
+ set retval {}
186
+ $stmt foreach -as dicts row {
187
+ foreach {odbcKey tdbcKey} {
188
+ PKTABLE_CAT primaryCatalog
189
+ PKTABLE_SCHEM primarySchema
190
+ PKTABLE_NAME primaryTable
191
+ PKCOLUMN_NAME primaryColumn
192
+ FKTABLE_CAT foreignCatalog
193
+ FKTABLE_SCHEM foreignSchema
194
+ FKTABLE_NAME foreignTable
195
+ FKCOLUMN_NAME foreignColumn
196
+ UPDATE_RULE updateRule
197
+ DELETE_RULE deleteRule
198
+ DEFERRABILITY deferrable
199
+ KEY_SEQ ordinalPosition
200
+ FK_NAME foreignConstraintName
201
+ } {
202
+ if {[dict exists $row $odbcKey]} {
203
+ dict set row $tdbcKey [dict get $row $odbcKey]
204
+ dict unset row $odbcKey
205
+ }
206
+ }
207
+ # Horrible kludge: If the driver doesn't report FK_NAME,
208
+ # make one up.
209
+ if {![dict exists $row foreignConstraintName]} {
210
+ if {![dict exists $row ordinalPosition]
211
+ || [dict get $row ordinalPosition] == 1} {
212
+ set fkname ?[dict get $row foreignTable]?[incr fkseq]
213
+ }
214
+ dict set row foreignConstraintName $fkname
215
+ }
216
+ lappend retval $row
217
+ }
218
+ set retval
219
+ } result options]
220
+ catch {rename $stmt {}}
221
+ return -level 0 -options $options $result
222
+ }
223
+
224
+ # The 'evaldirect' evaluates driver-native SQL code without preparing it,
225
+ # and returns a list of dicts (similar to '$connection allrows -as dicts').
226
+
227
+ method evaldirect {sqlStatement} {
228
+ set stmt [::tdbc::odbc::evaldirectStatement create \
229
+ Stmt::[incr statementSeq] [self] $sqlStatement]
230
+ set status [catch {
231
+ $stmt allrows -as dicts
232
+ } result options]
233
+ catch {rename $stmt {}}
234
+ return -level 0 -options $options $result
235
+ }
236
+
237
+ # The 'prepareCall' method gives a portable interface to prepare
238
+ # calls to stored procedures. It delegates to 'prepare' to do the
239
+ # actual work.
240
+
241
+ method preparecall {call} {
242
+
243
+ regexp {^[[:space:]]*(?:([A-Za-z_][A-Za-z_0-9]*)[[:space:]]*=)?(.*)} \
244
+ $call -> varName rest
245
+ if {$varName eq {}} {
246
+ my prepare \\{CALL $rest\\}
247
+ } else {
248
+ my prepare \\{:$varName=CALL $rest\\}
249
+ }
250
+
251
+ if 0 {
252
+ # Kevin thinks this is going to be
253
+
254
+ if {![regexp -expanded {
255
+ ^\s* # leading whitespace
256
+ (?::([[:alpha:]_][[:alnum:]_]*)\s*=\s*) # possible variable name
257
+ (?:(?:([[:alpha:]_][[:alnum:]_]*)\s*[.]\s*)? # catalog
258
+ ([[:alpha:]_][[:alnum:]_]*)\s*[.]\s*)? # schema
259
+ ([[:alpha:]_][[:alnum:]_]*)\s* # procedure
260
+ (.*)$ # argument list
261
+ } $call -> varName catalog schema procedure arglist]} {
262
+ return -code error \
263
+ -errorCode [list TDBC \
264
+ SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION \
265
+ 42000 ODBC -1] \
266
+ "Syntax error in stored procedure call"
267
+ } else {
268
+ my PrepareCall $varName $catalog $schema $procedure $arglist
269
+ }
270
+
271
+ # at least if making all parameters 'inout' doesn't work.
272
+
273
+ }
274
+
275
+ }
276
+
277
+ # The 'typemap' method returns the type map
278
+
279
+ method typemap {} {
280
+ if {![info exists typemap]} {
281
+ set typemap $::tdbc::odbc::sqltypes
282
+ set typesStmt [tdbc::odbc::typesStatement new [self]]
283
+ $typesStmt foreach row {
284
+ set typeNum [dict get $row DATA_TYPE]
285
+ if {![dict exists $typemap $typeNum]} {
286
+ dict set typemap $typeNum [string tolower \
287
+ [dict get $row TYPE_NAME]]
288
+ }
289
+ switch -exact -- $typeNum {
290
+ -9 {
291
+ [self] HasWvarchar 1
292
+ }
293
+ -5 {
294
+ [self] HasBigint 1
295
+ }
296
+ }
297
+ }
298
+ rename $typesStmt {}
299
+ }
300
+ return $typemap
301
+ }
302
+
303
+ # The 'begintransaction', 'commit' and 'rollback' methods are
304
+ # implemented in C.
305
+
306
+ }
307
+
308
+ #-------------------------------------------------------------------------------
309
+ #
310
+ # tdbc::odbc::statement --
311
+ #
312
+ # The class 'tdbc::odbc::statement' models one statement against a
313
+ # database accessed through an ODBC connection
314
+ #
315
+ #-------------------------------------------------------------------------------
316
+
317
+ ::oo::class create ::tdbc::odbc::statement {
318
+
319
+ superclass ::tdbc::statement
320
+
321
+ # The constructor is implemented in C. It accepts the handle to
322
+ # the connection and the SQL code for the statement to prepare.
323
+ # It creates a subordinate namespace to hold the statement's
324
+ # active result sets, and then delegates to the 'init' method,
325
+ # written in C, to do the actual work of preparing the statement.
326
+
327
+ # The 'resultSetCreate' method forwards to the result set constructor
328
+
329
+ forward resultSetCreate ::tdbc::odbc::resultset create
330
+
331
+ # The 'params' method describes the parameters to the statement
332
+
333
+ method params {} {
334
+ set typemap [[my connection] typemap]
335
+ set result {}
336
+ foreach {name flags typeNum precision scale nullable} [my ParamList] {
337
+ set lst [dict create \
338
+ name $name \
339
+ direction [lindex {unknown in out inout} \
340
+ [expr {($flags & 0x06) >> 1}]] \
341
+ type [dict get $typemap $typeNum] \
342
+ precision $precision \
343
+ scale $scale]
344
+ if {$nullable in {0 1}} {
345
+ dict set list nullable $nullable
346
+ }
347
+ dict set result $name $lst
348
+ }
349
+ return $result
350
+ }
351
+
352
+ # Methods implemented in C:
353
+ # init statement ?dictionary?
354
+ # Does the heavy lifting for the constructor
355
+ # connection
356
+ # Returns the connection handle to which this statement belongs
357
+ # paramtype paramname ?direction? type ?precision ?scale??
358
+ # Declares the type of a parameter in the statement
359
+
360
+ }
361
+
362
+ #------------------------------------------------------------------------------
363
+ #
364
+ # tdbc::odbc::tablesStatement --
365
+ #
366
+ # The class 'tdbc::odbc::tablesStatement' represents the special
367
+ # statement that queries the tables in a database through an ODBC
368
+ # connection.
369
+ #
370
+ #------------------------------------------------------------------------------
371
+
372
+ oo::class create ::tdbc::odbc::tablesStatement {
373
+
374
+ superclass ::tdbc::statement
375
+
376
+ # The constructor is written in C. It accepts the handle to the
377
+ # connection and a pattern to match table names. It works in all
378
+ # ways like the constructor of the 'statement' class except that
379
+ # its 'init' method sets up to enumerate tables and not run a SQL
380
+ # query.
381
+
382
+ # The 'resultSetCreate' method forwards to the result set constructor
383
+
384
+ forward resultSetCreate ::tdbc::odbc::resultset create
385
+
386
+ }
387
+
388
+ #------------------------------------------------------------------------------
389
+ #
390
+ # tdbc::odbc::columnsStatement --
391
+ #
392
+ # The class 'tdbc::odbc::tablesStatement' represents the special
393
+ # statement that queries the columns of a table or view
394
+ # in a database through an ODBC connection.
395
+ #
396
+ #------------------------------------------------------------------------------
397
+
398
+ oo::class create ::tdbc::odbc::columnsStatement {
399
+
400
+ superclass ::tdbc::statement
401
+
402
+ # The constructor is written in C. It accepts the handle to the
403
+ # connection, a table name, and a pattern to match column
404
+ # names. It works in all ways like the constructor of the
405
+ # 'statement' class except that its 'init' method sets up to
406
+ # enumerate tables and not run a SQL query.
407
+
408
+ # The 'resultSetCreate' class forwards to the constructor of the
409
+ # result set
410
+
411
+ forward resultSetCreate ::tdbc::odbc::resultset create
412
+
413
+ }
414
+
415
+ #------------------------------------------------------------------------------
416
+ #
417
+ # tdbc::odbc::primarykeysStatement --
418
+ #
419
+ # The class 'tdbc::odbc::primarykeysStatement' represents the special
420
+ # statement that queries the primary keys on a table through an ODBC
421
+ # connection.
422
+ #
423
+ #------------------------------------------------------------------------------
424
+
425
+ oo::class create ::tdbc::odbc::primarykeysStatement {
426
+
427
+ superclass ::tdbc::statement
428
+
429
+ # The constructor is written in C. It accepts the handle to the
430
+ # connection and a table name. It works in all
431
+ # ways like the constructor of the 'statement' class except that
432
+ # its 'init' method sets up to enumerate primary keys and not run a SQL
433
+ # query.
434
+
435
+ # The 'resultSetCreate' method forwards to the result set constructor
436
+
437
+ forward resultSetCreate ::tdbc::odbc::resultset create
438
+
439
+ }
440
+
441
+ #------------------------------------------------------------------------------
442
+ #
443
+ # tdbc::odbc::foreignkeysStatement --
444
+ #
445
+ # The class 'tdbc::odbc::foreignkeysStatement' represents the special
446
+ # statement that queries the foreign keys on a table through an ODBC
447
+ # connection.
448
+ #
449
+ #------------------------------------------------------------------------------
450
+
451
+ oo::class create ::tdbc::odbc::foreignkeysStatement {
452
+
453
+ superclass ::tdbc::statement
454
+
455
+ # The constructor is written in C. It accepts the handle to the
456
+ # connection and the -primary and -foreign options. It works in all
457
+ # ways like the constructor of the 'statement' class except that
458
+ # its 'init' method sets up to enumerate foreign keys and not run a SQL
459
+ # query.
460
+
461
+ # The 'resultSetCreate' method forwards to the result set constructor
462
+
463
+ forward resultSetCreate ::tdbc::odbc::resultset create
464
+
465
+ }
466
+
467
+ #------------------------------------------------------------------------------
468
+ #
469
+ # tdbc::odbc::evaldirectStatement --
470
+ #
471
+ # The class 'tdbc::odbc::evaldirectStatement' provides a mechanism to
472
+ # execute driver-name SQL code through an ODBC connection. The SQL code
473
+ # is not prepared and no tokenization or variable substitution is done.
474
+ #
475
+ #------------------------------------------------------------------------------
476
+
477
+ oo::class create ::tdbc::odbc::evaldirectStatement {
478
+
479
+ superclass ::tdbc::statement
480
+
481
+ # The constructor is written in C. It accepts the handle to the
482
+ # connection and a SQL statement. It works in all
483
+ # ways like the constructor of the 'statement' class except that
484
+ # its 'init' method does not tokenize or prepare the SQL statement, and
485
+ # sets up to run the SQL query without performing variable substitution.
486
+
487
+ # The 'resultSetCreate' method forwards to the result set constructor
488
+
489
+ forward resultSetCreate ::tdbc::odbc::resultset create
490
+
491
+ }
492
+
493
+ #------------------------------------------------------------------------------
494
+ #
495
+ # tdbc::odbc::typesStatement --
496
+ #
497
+ # The class 'tdbc::odbc::typesStatement' represents the special
498
+ # statement that queries the types available in a database through
499
+ # an ODBC connection.
500
+ #
501
+ #------------------------------------------------------------------------------
502
+
503
+
504
+ oo::class create ::tdbc::odbc::typesStatement {
505
+
506
+ superclass ::tdbc::statement
507
+
508
+ # The constructor is written in C. It accepts the handle to the
509
+ # connection, and (optionally) a data type number. It works in all
510
+ # ways like the constructor of the 'statement' class except that
511
+ # its 'init' method sets up to enumerate types and not run a SQL
512
+ # query.
513
+
514
+ # The 'resultSetCreate' method forwards to the constructor of result sets
515
+
516
+ forward resultSetCreate ::tdbc::odbc::resultset create
517
+
518
+ # The C code contains a variant implementation of the 'init' method.
519
+
520
+ }
521
+
522
+ #------------------------------------------------------------------------------
523
+ #
524
+ # tdbc::odbc::resultset --
525
+ #
526
+ # The class 'tdbc::odbc::resultset' models the result set that is
527
+ # produced by executing a statement against an ODBC database.
528
+ #
529
+ #------------------------------------------------------------------------------
530
+
531
+ ::oo::class create ::tdbc::odbc::resultset {
532
+
533
+ superclass ::tdbc::resultset
534
+
535
+ # Methods implemented in C include:
536
+
537
+ # constructor statement ?dictionary?
538
+ # -- Executes the statement against the database, optionally providing
539
+ # a dictionary of substituted parameters (default is to get params
540
+ # from variables in the caller's scope).
541
+ # columns
542
+ # -- Returns a list of the names of the columns in the result.
543
+ # nextdict
544
+ # -- Stores the next row of the result set in the given variable in
545
+ # the caller's scope as a dictionary whose keys are
546
+ # column names and whose values are column values.
547
+ # nextlist
548
+ # -- Stores the next row of the result set in the given variable in
549
+ # the caller's scope as a list of cells.
550
+ # rowcount
551
+ # -- Returns a count of rows affected by the statement, or -1
552
+ # if the count of rows has not been determined.
553
+
554
+ }
miniconda3/lib/tdbcpostgres1.1.9/libtdbcpostgres1.1.9.so ADDED
Binary file (48.2 kB). View file
 
miniconda3/lib/tdbcpostgres1.1.9/pkgIndex.tcl ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Index file to load the TDBC Postgres package.
2
+
3
+ if {![package vsatisfies [package provide Tcl] 8.6-]} {
4
+ return
5
+ }
6
+ if {[package vsatisfies [package provide Tcl] 9.0-]} {
7
+ package ifneeded tdbc::postgres 1.1.9 \
8
+ "[list source -encoding utf-8 [file join $dir tdbcpostgres.tcl]]\;\
9
+ [list load [file join $dir libtcl9tdbcpostgres1.1.9.so] [string totitle tdbcpostgres]]"
10
+ } else {
11
+ package ifneeded tdbc::postgres 1.1.9 \
12
+ "[list source -encoding utf-8 [file join $dir tdbcpostgres.tcl]]\;\
13
+ [list load [file join $dir libtdbcpostgres1.1.9.so] [string totitle tdbcpostgres]]"
14
+ }
miniconda3/lib/tdbcpostgres1.1.9/tdbcpostgres.tcl ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tdbcpostgres.tcl --
2
+ #
3
+ # Class definitions and Tcl-level methods for the tdbc::postgres bridge.
4
+ #
5
+ # Copyright (c) 2009 by Slawomir Cygan
6
+ #
7
+ # See the file "license.terms" for information on usage and redistribution
8
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
+ #
10
+ #------------------------------------------------------------------------------
11
+
12
+ package require tdbc
13
+
14
+ ::namespace eval ::tdbc::mypostgres {
15
+
16
+ namespace export connection datasources drivers
17
+
18
+ }
19
+
20
+ #------------------------------------------------------------------------------
21
+ #
22
+ # tdbc::postgres::connection --
23
+ #
24
+ # Class representing a connection to a Postgres database.
25
+ #
26
+ #-------------------------------------------------------------------------------
27
+
28
+ ::oo::class create ::tdbc::postgres::connection {
29
+
30
+ superclass ::tdbc::connection
31
+
32
+ # The constructor is written in C. It takes alternating keywords
33
+ # and values pairs as its arguments. (See the manual page for the
34
+ # available options.)
35
+
36
+ # The 'statementCreate' method delegates to the constructor of the
37
+ # statement class
38
+
39
+ forward statementCreate ::tdbc::postgres::statement create
40
+
41
+
42
+ # The 'prepareCall' method gives a portable interface to prepare
43
+ # calls to stored procedures. It delegates to 'prepare' to do the
44
+ # actual work.
45
+
46
+ method preparecall {call} {
47
+ regexp {^[[:space:]]*(?:([A-Za-z_][A-Za-z_0-9]*)[[:space:]]*=)?(.*)} \
48
+ $call -> varName rest
49
+ if {$varName eq {}} {
50
+ my prepare \\{$rest\\}
51
+ } else {
52
+ my prepare \\{:$varName=$rest\\}
53
+ }
54
+ }
55
+
56
+ # The 'init', 'begintransaction', 'commit, 'rollback', 'tables'
57
+ # and 'columns' methods are implemented in C.
58
+
59
+ }
60
+
61
+ #------------------------------------------------------------------------------
62
+ #
63
+ # tdbc::postgres::statement --
64
+ #
65
+ # The class 'tdbc::postgres::statement' models one statement against a
66
+ # database accessed through a Postgres connection
67
+ #
68
+ #------------------------------------------------------------------------------
69
+
70
+ ::oo::class create ::tdbc::postgres::statement {
71
+
72
+ superclass ::tdbc::statement
73
+
74
+ # The 'resultSetCreate' method forwards to the constructor of the
75
+ # result set.
76
+
77
+ forward resultSetCreate ::tdbc::postgres::resultset create
78
+
79
+ # Methods implemented in C:
80
+ #
81
+ # constructor connection SQLCode
82
+ # The constructor accepts the handle to the connection and the SQL code
83
+ # for the statement to prepare. It creates a subordinate namespace to
84
+ # hold the statement's active result sets, and then delegates to the
85
+ # 'init' method, written in C, to do the actual work of preparing the
86
+ # statement.
87
+ # params
88
+ # Returns descriptions of the parameters of a statement.
89
+ # paramtype paramname ?direction? type ?precision ?scale??
90
+ # Declares the type of a parameter in the statement
91
+
92
+ }
93
+
94
+ #------------------------------------------------------------------------------
95
+ #
96
+ # tdbc::postgres::resultset --
97
+ #
98
+ # The class 'tdbc::postgres::resultset' models the result set that is
99
+ # produced by executing a statement against a Postgres database.
100
+ #
101
+ #------------------------------------------------------------------------------
102
+
103
+ ::oo::class create ::tdbc::postgres::resultset {
104
+
105
+ superclass ::tdbc::resultset
106
+
107
+ # The 'nextresults' method is stubbed out; tdbcpostgres does not
108
+ # allow a single call to return multiple results.
109
+
110
+ method nextresults {} {
111
+ while {[my nextdict rubbish]} {}
112
+ return 0
113
+ }
114
+
115
+ # Methods implemented in C include:
116
+
117
+ # constructor statement ?dictionary?
118
+ # -- Executes the statement against the database, optionally providing
119
+ # a dictionary of substituted parameters (default is to get params
120
+ # from variables in the caller's scope).
121
+ # columns
122
+ # -- Returns a list of the names of the columns in the result.
123
+ # nextdict
124
+ # -- Stores the next row of the result set in the given variable in
125
+ # the caller's scope as a dictionary whose keys are
126
+ # column names and whose values are column values, or else
127
+ # as a list of cells.
128
+ # nextlist
129
+ # -- Stores the next row of the result set in the given variable in
130
+ # the caller's scope as a list of cells.
131
+ # rowcount
132
+ # -- Returns a count of rows affected by the statement, or -1
133
+ # if the count of rows has not been determined.
134
+
135
+ }
miniconda3/lib/thread2.8.10/libthread2.8.10.so ADDED
Binary file (98.1 kB). View file
 
miniconda3/lib/thread2.8.10/pkgIndex.tcl ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- tcl -*-
2
+ # Tcl package index file, version 1.1
3
+ #
4
+
5
+ if {![package vsatisfies [package provide Tcl] 8.4]} {
6
+ # Pre-8.4 Tcl interps we dont support at all. Bye!
7
+ # 9.0+ Tcl interps are only supported on 32-bit platforms.
8
+ if {![package vsatisfies [package provide Tcl] 9.0]
9
+ || ($::tcl_platform(pointerSize) != 4)} {
10
+ return
11
+ }
12
+ }
13
+
14
+ # All Tcl 8.4+ interps can [load] Thread 2.8.10
15
+ #
16
+ # For interps that are not thread-enabled, we still call [package ifneeded].
17
+ # This is contrary to the usual convention, but is a good idea because we
18
+ # cannot imagine any other version of Thread that might succeed in a
19
+ # thread-disabled interp. There's nothing to gain by yielding to other
20
+ # competing callers of [package ifneeded Thread]. On the other hand,
21
+ # deferring the error has the advantage that a script calling
22
+ # [package require Thread] in a thread-disabled interp gets an error message
23
+ # about a thread-disabled interp, instead of the message
24
+ # "can't find package Thread".
25
+
26
+ package ifneeded Thread 2.8.10 [list load [file join $dir libthread2.8.10.so] [string totitle thread]]
27
+
28
+ # package Ttrace uses some support machinery.
29
+
30
+ # In Tcl 8.4 interps we use some older interfaces
31
+ if {![package vsatisfies [package provide Tcl] 8.5]} {
32
+ package ifneeded Ttrace 2.8.10 "
33
+ [list proc thread_source {dir} {
34
+ if {[info exists ::env(TCL_THREAD_LIBRARY)] &&
35
+ [file readable $::env(TCL_THREAD_LIBRARY)/ttrace.tcl]} {
36
+ source -encoding utf-8 $::env(TCL_THREAD_LIBRARY)/ttrace.tcl
37
+ } elseif {[file readable [file join $dir .. lib ttrace.tcl]]} {
38
+ source -encoding utf-8 [file join $dir .. lib ttrace.tcl]
39
+ } elseif {[file readable [file join $dir ttrace.tcl]]} {
40
+ source -encoding utf-8 [file join $dir ttrace.tcl]
41
+ }
42
+ if {[namespace which ::ttrace::update] ne ""} {
43
+ ::ttrace::update
44
+ }
45
+ }]
46
+ [list thread_source $dir]
47
+ [list rename thread_source {}]"
48
+ return
49
+ }
50
+
51
+ # In Tcl 8.5+ interps; use [::apply]
52
+
53
+ package ifneeded Ttrace 2.8.10 [list ::apply {{dir} {
54
+ if {[info exists ::env(TCL_THREAD_LIBRARY)] &&
55
+ [file readable $::env(TCL_THREAD_LIBRARY)/ttrace.tcl]} {
56
+ source -encoding utf-8 $::env(TCL_THREAD_LIBRARY)/ttrace.tcl
57
+ } elseif {[file readable [file join $dir .. lib ttrace.tcl]]} {
58
+ source -encoding utf-8 [file join $dir .. lib ttrace.tcl]
59
+ } elseif {[file readable [file join $dir ttrace.tcl]]} {
60
+ source -encoding utf-8 [file join $dir ttrace.tcl]
61
+ }
62
+ if {[namespace which ::ttrace::update] ne ""} {
63
+ ::ttrace::update
64
+ }
65
+ }} $dir]
66
+
67
+
68
+
miniconda3/lib/thread2.8.10/ttrace.tcl ADDED
@@ -0,0 +1,942 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # ttrace.tcl --
3
+ #
4
+ # Copyright (C) 2003 Zoran Vasiljevic, Archiware GmbH. All Rights Reserved.
5
+ #
6
+ # See the file "license.terms" for information on usage and redistribution of
7
+ # this file, and for a DISCLAIMER OF ALL WARRANTIES.
8
+ # ----------------------------------------------------------------------------
9
+ #
10
+ # User level commands:
11
+ #
12
+ # ttrace::eval top-level wrapper (ttrace-savvy eval)
13
+ # ttrace::enable activates registered Tcl command traces
14
+ # ttrace::disable terminates tracing of Tcl commands
15
+ # ttrace::isenabled returns true if ttrace is enabled
16
+ # ttrace::cleanup bring the interp to a pristine state
17
+ # ttrace::update update interp to the latest trace epoch
18
+ # ttrace::config setup some configuration options
19
+ # ttrace::getscript returns a script for initializing interps
20
+ #
21
+ # Commands used for/from trace callbacks:
22
+ #
23
+ # ttrace::atenable register callback to be done at trace enable
24
+ # ttrace::atdisable register callback to be done at trace disable
25
+ # ttrace::addtrace register user-defined tracer callback
26
+ # ttrace::addscript register user-defined script generator
27
+ # ttrace::addresolver register user-defined command resolver
28
+ # ttrace::addcleanup register user-defined cleanup procedures
29
+ # ttrace::addentry adds one entry into the named trace store
30
+ # ttrace::getentry returns the entry value from the named store
31
+ # ttrace::delentry removes the entry from the named store
32
+ # ttrace::getentries returns all entries from the named store
33
+ # ttrace::preload register procedures to be preloaded always
34
+ #
35
+ #
36
+ # Limitations:
37
+ #
38
+ # o. [namespace forget] is still not implemented
39
+ # o. [namespace origin cmd] breaks if cmd is not already defined
40
+ #
41
+ # I left this deliberately. I didn't want to override the [namespace]
42
+ # command in order to avoid potential slowdown.
43
+ #
44
+
45
+ namespace eval ttrace {
46
+
47
+ # Setup some compatibility wrappers
48
+ if {[info commands nsv_set] != ""} {
49
+ variable tvers 0
50
+ variable mutex ns_mutex
51
+ variable elock [$mutex create traceepochmutex]
52
+ # Import the underlying API; faster than recomputing
53
+ interp alias {} [namespace current]::_array {} nsv_array
54
+ interp alias {} [namespace current]::_incr {} nsv_incr
55
+ interp alias {} [namespace current]::_lappend {} nsv_lappend
56
+ interp alias {} [namespace current]::_names {} nsv_names
57
+ interp alias {} [namespace current]::_set {} nsv_set
58
+ interp alias {} [namespace current]::_unset {} nsv_unset
59
+ } elseif {![catch {
60
+ variable tvers [package require Thread]
61
+ }]} {
62
+ variable mutex thread::mutex
63
+ variable elock [$mutex create]
64
+ # Import the underlying API; faster than recomputing
65
+ interp alias {} [namespace current]::_array {} tsv::array
66
+ interp alias {} [namespace current]::_incr {} tsv::incr
67
+ interp alias {} [namespace current]::_lappend {} tsv::lappend
68
+ interp alias {} [namespace current]::_names {} tsv::names
69
+ interp alias {} [namespace current]::_set {} tsv::set
70
+ interp alias {} [namespace current]::_unset {} tsv::unset
71
+ } else {
72
+ error "requires NaviServer/AOLserver or Tcl threading extension"
73
+ }
74
+
75
+ # Keep in sync with the Thread package
76
+ package provide Ttrace 2.8.10
77
+
78
+ # Package variables
79
+ variable resolvers "" ; # List of registered resolvers
80
+ variable tracers "" ; # List of registered cmd tracers
81
+ variable scripts "" ; # List of registered script makers
82
+ variable enables "" ; # List of trace-enable callbacks
83
+ variable disables "" ; # List of trace-disable callbacks
84
+ variable preloads "" ; # List of procedure names to preload
85
+ variable enabled 0 ; # True if trace is enabled
86
+ variable config ; # Array with config options
87
+
88
+ variable epoch -1 ; # The initialization epoch
89
+ variable cleancnt 0 ; # Counter of registered cleaners
90
+
91
+ # Package private namespaces
92
+ namespace eval resolve "" ; # Commands for resolving commands
93
+ namespace eval trace "" ; # Commands registered for tracing
94
+ namespace eval enable "" ; # Commands invoked at trace enable
95
+ namespace eval disable "" ; # Commands invoked at trace disable
96
+ namespace eval script "" ; # Commands for generating scripts
97
+
98
+ # Exported commands
99
+ namespace export unknown
100
+
101
+ # Initialize ttrace shared state
102
+ if {[_array exists ttrace] == 0} {
103
+ _set ttrace lastepoch $epoch
104
+ _set ttrace epochlist ""
105
+ }
106
+
107
+ # Initially, allow creation of epochs
108
+ set config(-doepochs) 1
109
+
110
+ proc eval {cmd args} {
111
+ enable
112
+ set code [catch {uplevel 1 [concat $cmd $args]} result]
113
+ disable
114
+ if {$code == 0} {
115
+ if {[llength [info commands ns_ictl]]} {
116
+ ns_ictl save [getscript]
117
+ } else {
118
+ thread::broadcast {
119
+ package require Ttrace
120
+ ttrace::update
121
+ }
122
+ }
123
+ }
124
+ return -code $code \
125
+ -errorinfo $::errorInfo -errorcode $::errorCode $result
126
+ }
127
+
128
+ proc config {args} {
129
+ variable config
130
+ if {[llength $args] == 0} {
131
+ array get config
132
+ } elseif {[llength $args] == 1} {
133
+ set opt [lindex $args 0]
134
+ set config($opt)
135
+ } else {
136
+ set opt [lindex $args 0]
137
+ set val [lindex $args 1]
138
+ set config($opt) $val
139
+ }
140
+ }
141
+
142
+ proc enable {} {
143
+ variable config
144
+ variable tracers
145
+ variable enables
146
+ variable enabled
147
+ incr enabled 1
148
+ if {$enabled > 1} {
149
+ return
150
+ }
151
+ if {$config(-doepochs) != 0} {
152
+ variable epoch [_newepoch]
153
+ }
154
+ set nsp [namespace current]
155
+ foreach enabler $enables {
156
+ enable::_$enabler
157
+ }
158
+ foreach trace $tracers {
159
+ if {[info commands $trace] != ""} {
160
+ trace add execution $trace leave ${nsp}::trace::_$trace
161
+ }
162
+ }
163
+ }
164
+
165
+ proc disable {} {
166
+ variable enabled
167
+ variable tracers
168
+ variable disables
169
+ incr enabled -1
170
+ if {$enabled > 0} {
171
+ return
172
+ }
173
+ set nsp [namespace current]
174
+ foreach disabler $disables {
175
+ disable::_$disabler
176
+ }
177
+ foreach trace $tracers {
178
+ if {[info commands $trace] != ""} {
179
+ trace remove execution $trace leave ${nsp}::trace::_$trace
180
+ }
181
+ }
182
+ }
183
+
184
+ proc isenabled {} {
185
+ variable enabled
186
+ expr {$enabled > 0}
187
+ }
188
+
189
+ proc update {{from -1}} {
190
+ if {$from < 0} {
191
+ variable epoch [_set ttrace lastepoch]
192
+ } else {
193
+ if {[lsearch [_set ttrace epochlist] $from] < 0} {
194
+ error "no such epoch: $from"
195
+ }
196
+ variable epoch $from
197
+ }
198
+ uplevel 1 [getscript]
199
+ }
200
+
201
+ proc getscript {} {
202
+ variable preloads
203
+ variable epoch
204
+ variable scripts
205
+ append script [_serializensp] \n
206
+ append script "::namespace eval [namespace current] {" \n
207
+ append script "::namespace export unknown" \n
208
+ append script "_useepoch $epoch" \n
209
+ append script "}" \n
210
+ foreach cmd $preloads {
211
+ append script [_serializeproc $cmd] \n
212
+ }
213
+ foreach maker $scripts {
214
+ append script [script::_$maker]
215
+ }
216
+ return $script
217
+ }
218
+
219
+ proc cleanup {args} {
220
+ foreach cmd [info commands resolve::cleaner_*] {
221
+ uplevel 1 $cmd $args
222
+ }
223
+ }
224
+
225
+ proc preload {cmd} {
226
+ variable preloads
227
+ if {[lsearch $preloads $cmd] < 0} {
228
+ lappend preloads $cmd
229
+ }
230
+ }
231
+
232
+ proc atenable {cmd arglist body} {
233
+ variable enables
234
+ if {[lsearch $enables $cmd] < 0} {
235
+ lappend enables $cmd
236
+ set cmd [namespace current]::enable::_$cmd
237
+ proc $cmd $arglist $body
238
+ return $cmd
239
+ }
240
+ }
241
+
242
+ proc atdisable {cmd arglist body} {
243
+ variable disables
244
+ if {[lsearch $disables $cmd] < 0} {
245
+ lappend disables $cmd
246
+ set cmd [namespace current]::disable::_$cmd
247
+ proc $cmd $arglist $body
248
+ return $cmd
249
+ }
250
+ }
251
+
252
+ proc addtrace {cmd arglist body} {
253
+ variable tracers
254
+ if {[lsearch $tracers $cmd] < 0} {
255
+ lappend tracers $cmd
256
+ set tracer [namespace current]::trace::_$cmd
257
+ proc $tracer $arglist $body
258
+ if {[isenabled]} {
259
+ trace add execution $cmd leave $tracer
260
+ }
261
+ return $tracer
262
+ }
263
+ }
264
+
265
+ proc addscript {cmd body} {
266
+ variable scripts
267
+ if {[lsearch $scripts $cmd] < 0} {
268
+ lappend scripts $cmd
269
+ set cmd [namespace current]::script::_$cmd
270
+ proc $cmd args $body
271
+ return $cmd
272
+ }
273
+ }
274
+
275
+ proc addresolver {cmd arglist body} {
276
+ variable resolvers
277
+ if {[lsearch $resolvers $cmd] < 0} {
278
+ lappend resolvers $cmd
279
+ set cmd [namespace current]::resolve::$cmd
280
+ proc $cmd $arglist $body
281
+ return $cmd
282
+ }
283
+ }
284
+
285
+ proc addcleanup {body} {
286
+ variable cleancnt
287
+ set cmd [namespace current]::resolve::cleaner_[incr cleancnt]
288
+ proc $cmd args $body
289
+ return $cmd
290
+ }
291
+
292
+ proc addentry {cmd var val} {
293
+ variable epoch
294
+ _set ${epoch}-$cmd $var $val
295
+ }
296
+
297
+ proc delentry {cmd var} {
298
+ variable epoch
299
+ set ei $::errorInfo
300
+ set ec $::errorCode
301
+ catch {_unset ${epoch}-$cmd $var}
302
+ set ::errorInfo $ei
303
+ set ::errorCode $ec
304
+ }
305
+
306
+ proc getentry {cmd var} {
307
+ variable epoch
308
+ set ei $::errorInfo
309
+ set ec $::errorCode
310
+ if {[catch {_set ${epoch}-$cmd $var} val]} {
311
+ set ::errorInfo $ei
312
+ set ::errorCode $ec
313
+ set val ""
314
+ }
315
+ return $val
316
+ }
317
+
318
+ proc getentries {cmd {pattern *}} {
319
+ variable epoch
320
+ _array names ${epoch}-$cmd $pattern
321
+ }
322
+
323
+ proc unknown {args} {
324
+ set cmd [lindex $args 0]
325
+ if {[uplevel 1 ttrace::_resolve [list $cmd]]} {
326
+ set c [catch {uplevel 1 $cmd [lrange $args 1 end]} r]
327
+ } else {
328
+ set c [catch {uplevel 1 ::tcl::unknown $args} r]
329
+ }
330
+ return -code $c -errorcode $::errorCode -errorinfo $::errorInfo $r
331
+ }
332
+
333
+ proc _resolve {cmd} {
334
+ variable resolvers
335
+ foreach resolver $resolvers {
336
+ if {[uplevel 1 [info comm resolve::$resolver] [list $cmd]]} {
337
+ return 1
338
+ }
339
+ }
340
+ return 0
341
+ }
342
+
343
+ proc _getthread {} {
344
+ if {[info commands ns_thread] == ""} {
345
+ thread::id
346
+ } else {
347
+ ns_thread getid
348
+ }
349
+ }
350
+
351
+ proc _getthreads {} {
352
+ if {[info commands ns_thread] == ""} {
353
+ return [thread::names]
354
+ } else {
355
+ foreach entry [ns_info threads] {
356
+ lappend threads [lindex $entry 2]
357
+ }
358
+ return $threads
359
+ }
360
+ }
361
+
362
+ proc _newepoch {} {
363
+ variable elock
364
+ variable mutex
365
+ $mutex lock $elock
366
+ set old [_set ttrace lastepoch]
367
+ set new [_incr ttrace lastepoch]
368
+ _lappend ttrace $new [_getthread]
369
+ if {$old >= 0} {
370
+ _copyepoch $old $new
371
+ _delepochs
372
+ }
373
+ _lappend ttrace epochlist $new
374
+ $mutex unlock $elock
375
+ return $new
376
+ }
377
+
378
+ proc _copyepoch {old new} {
379
+ foreach var [_names $old-*] {
380
+ set cmd [lindex [split $var -] 1]
381
+ _array reset $new-$cmd [_array get $var]
382
+ }
383
+ }
384
+
385
+ proc _delepochs {} {
386
+ set tlist [_getthreads]
387
+ set elist ""
388
+ foreach epoch [_set ttrace epochlist] {
389
+ if {[_dropepoch $epoch $tlist] == 0} {
390
+ lappend elist $epoch
391
+ } else {
392
+ _unset ttrace $epoch
393
+ }
394
+ }
395
+ _set ttrace epochlist $elist
396
+ }
397
+
398
+ proc _dropepoch {epoch threads} {
399
+ set self [_getthread]
400
+ foreach tid [_set ttrace $epoch] {
401
+ if {$tid != $self && [lsearch $threads $tid] >= 0} {
402
+ lappend alive $tid
403
+ }
404
+ }
405
+ if {[info exists alive]} {
406
+ _set ttrace $epoch $alive
407
+ return 0
408
+ } else {
409
+ foreach var [_names $epoch-*] {
410
+ _unset $var
411
+ }
412
+ return 1
413
+ }
414
+ }
415
+
416
+ proc _useepoch {epoch} {
417
+ if {$epoch >= 0} {
418
+ set tid [_getthread]
419
+ if {[lsearch [_set ttrace $epoch] $tid] == -1} {
420
+ _lappend ttrace $epoch $tid
421
+ }
422
+ }
423
+ }
424
+
425
+ proc _serializeproc {cmd} {
426
+ set dargs [info args $cmd]
427
+ set pbody [info body $cmd]
428
+ set pargs ""
429
+ foreach arg $dargs {
430
+ if {![info default $cmd $arg def]} {
431
+ lappend pargs $arg
432
+ } else {
433
+ lappend pargs [list $arg $def]
434
+ }
435
+ }
436
+ set nsp [namespace qual $cmd]
437
+ if {$nsp == ""} {
438
+ set nsp "::"
439
+ }
440
+ append res [list ::namespace eval $nsp] " {" \n
441
+ append res [list ::proc [namespace tail $cmd] $pargs $pbody] \n
442
+ append res "}" \n
443
+ }
444
+
445
+ proc _serializensp {{nsp ""} {result _}} {
446
+ upvar $result res
447
+ if {$nsp == ""} {
448
+ set nsp [namespace current]
449
+ }
450
+ append res [list ::namespace eval $nsp] " {" \n
451
+ foreach var [info vars ${nsp}::*] {
452
+ set vname [namespace tail $var]
453
+ if {[array exists $var] == 0} {
454
+ append res [list ::variable $vname [set $var]] \n
455
+ } else {
456
+ append res [list ::variable $vname] \n
457
+ append res [list ::array set $vname [array get $var]] \n
458
+ }
459
+ }
460
+ foreach cmd [info procs ${nsp}::*] {
461
+ append res [_serializeproc $cmd] \n
462
+ }
463
+ append res "}" \n
464
+ foreach nn [namespace children $nsp] {
465
+ _serializensp $nn res
466
+ }
467
+ return $res
468
+ }
469
+ }
470
+
471
+ #
472
+ # The code below is ment to be run once during the application start. It
473
+ # provides implementation of tracing callbacks for some Tcl commands. Users
474
+ # can supply their own tracer implementations on-the-fly.
475
+ #
476
+ # The code below will create traces for the following Tcl commands:
477
+ # "namespace", "variable", "load", "proc" and "rename"
478
+ #
479
+ # Also, the Tcl object extension XOTcl 1.1.0 is handled and all XOTcl related
480
+ # things, like classes and objects are traced (many thanks to Gustaf Neumann
481
+ # from XOTcl for his kind help and support).
482
+ #
483
+
484
+ eval {
485
+
486
+ #
487
+ # Register the "load" trace. This will create the following key/value pair
488
+ # in the "load" store:
489
+ #
490
+ # --- key ---- --- value ---
491
+ # <path_of_loaded_image> <name_of_the_init_proc>
492
+ #
493
+ # We normally need only the name_of_the_init_proc for being able to load
494
+ # the package in other interpreters, but we store the path to the image
495
+ # file as well.
496
+ #
497
+
498
+ ttrace::addtrace load {cmdline code args} {
499
+ if {$code != 0} {
500
+ return
501
+ }
502
+ set image [lindex $cmdline 1]
503
+ set initp [lindex $cmdline 2]
504
+ if {$initp == ""} {
505
+ foreach pkg [info loaded] {
506
+ if {[lindex $pkg 0] == $image} {
507
+ set initp [lindex $pkg 1]
508
+ }
509
+ }
510
+ }
511
+ ttrace::addentry load $image $initp
512
+ }
513
+
514
+ ttrace::addscript load {
515
+ append res "\n"
516
+ foreach entry [ttrace::getentries load] {
517
+ set initp [ttrace::getentry load $entry]
518
+ append res "::load {} $initp" \n
519
+ }
520
+ return $res
521
+ }
522
+
523
+ #
524
+ # Register the "namespace" trace. This will create the following key/value
525
+ # entry in "namespace" store:
526
+ #
527
+ # --- key ---- --- value ---
528
+ # ::fully::qualified::namespace 1
529
+ #
530
+ # It will also fill the "proc" store for procedures and commands imported
531
+ # in this namespace with following:
532
+ #
533
+ # --- key ---- --- value ---
534
+ # ::fully::qualified::proc [list <ns> "" ""]
535
+ #
536
+ # The <ns> is the name of the namespace where the command or procedure is
537
+ # imported from.
538
+ #
539
+
540
+ ttrace::addtrace namespace {cmdline code args} {
541
+ if {$code != 0} {
542
+ return
543
+ }
544
+ set nop [lindex $cmdline 1]
545
+ set cns [uplevel 1 namespace current]
546
+ if {$cns == "::"} {
547
+ set cns ""
548
+ }
549
+ switch -glob $nop {
550
+ eva* {
551
+ set nsp [lindex $cmdline 2]
552
+ if {![string match "::*" $nsp]} {
553
+ set nsp ${cns}::$nsp
554
+ }
555
+ ttrace::addentry namespace $nsp 1
556
+ }
557
+ imp* {
558
+ # - parse import arguments (skip opt "-force")
559
+ set opts [lrange $cmdline 2 end]
560
+ if {[string match "-fo*" [lindex $opts 0]]} {
561
+ set opts [lrange $cmdline 3 end]
562
+ }
563
+ # - register all imported procs and commands
564
+ foreach opt $opts {
565
+ if {![string match "::*" [::namespace qual $opt]]} {
566
+ set opt ${cns}::$opt
567
+ }
568
+ # - first import procs
569
+ foreach entry [ttrace::getentries proc $opt] {
570
+ set cmd ${cns}::[::namespace tail $entry]
571
+ set nsp [::namespace qual $entry]
572
+ set done($cmd) 1
573
+ set entry [list 0 $nsp "" ""]
574
+ ttrace::addentry proc $cmd $entry
575
+ }
576
+
577
+ # - then import commands
578
+ foreach entry [info commands $opt] {
579
+ set cmd ${cns}::[::namespace tail $entry]
580
+ set nsp [::namespace qual $entry]
581
+ if {[info exists done($cmd)] == 0} {
582
+ set entry [list 0 $nsp "" ""]
583
+ ttrace::addentry proc $cmd $entry
584
+ }
585
+ }
586
+ }
587
+ }
588
+ }
589
+ }
590
+
591
+ ttrace::addscript namespace {
592
+ append res \n
593
+ foreach entry [ttrace::getentries namespace] {
594
+ append res "::namespace eval $entry {}" \n
595
+ }
596
+ return $res
597
+ }
598
+
599
+ #
600
+ # Register the "variable" trace. This will create the following key/value
601
+ # entry in the "variable" store:
602
+ #
603
+ # --- key ---- --- value ---
604
+ # ::fully::qualified::variable 1
605
+ #
606
+ # The variable value itself is ignored at the time of
607
+ # trace/collection. Instead, we take the real value at the time of script
608
+ # generation.
609
+ #
610
+
611
+ ttrace::addtrace variable {cmdline code args} {
612
+ if {$code != 0} {
613
+ return
614
+ }
615
+ set opts [lrange $cmdline 1 end]
616
+ if {[llength $opts]} {
617
+ set cns [uplevel 1 namespace current]
618
+ if {$cns == "::"} {
619
+ set cns ""
620
+ }
621
+ foreach {var val} $opts {
622
+ if {![string match "::*" $var]} {
623
+ set var ${cns}::$var
624
+ }
625
+ ttrace::addentry variable $var 1
626
+ }
627
+ }
628
+ }
629
+
630
+ ttrace::addscript variable {
631
+ append res \n
632
+ foreach entry [ttrace::getentries variable] {
633
+ set cns [namespace qual $entry]
634
+ set var [namespace tail $entry]
635
+ append res "::namespace eval $cns {" \n
636
+ append res "::variable $var"
637
+ if {[array exists $entry]} {
638
+ append res "\n::array set $var [list [array get $entry]]" \n
639
+ } elseif {[info exists $entry]} {
640
+ append res " [list [set $entry]]" \n
641
+ } else {
642
+ append res \n
643
+ }
644
+ append res "}" \n
645
+ }
646
+ return $res
647
+ }
648
+
649
+
650
+ #
651
+ # Register the "rename" trace. It will create the following key/value pair
652
+ # in "rename" store:
653
+ #
654
+ # --- key ---- --- value ---
655
+ # ::fully::qualified::old ::fully::qualified::new
656
+ #
657
+ # The "new" value may be empty, for commands that have been deleted. In
658
+ # such cases we also remove any traced procedure definitions.
659
+ #
660
+
661
+ ttrace::addtrace rename {cmdline code args} {
662
+ if {$code != 0} {
663
+ return
664
+ }
665
+ set cns [uplevel 1 namespace current]
666
+ if {$cns == "::"} {
667
+ set cns ""
668
+ }
669
+ set old [lindex $cmdline 1]
670
+ if {![string match "::*" $old]} {
671
+ set old ${cns}::$old
672
+ }
673
+ set new [lindex $cmdline 2]
674
+ if {$new != ""} {
675
+ if {![string match "::*" $new]} {
676
+ set new ${cns}::$new
677
+ }
678
+ ttrace::addentry rename $old $new
679
+ } else {
680
+ ttrace::delentry proc $old
681
+ }
682
+ }
683
+
684
+ ttrace::addscript rename {
685
+ append res \n
686
+ foreach old [ttrace::getentries rename] {
687
+ set new [ttrace::getentry rename $old]
688
+ append res "::rename $old {$new}" \n
689
+ }
690
+ return $res
691
+ }
692
+
693
+ #
694
+ # Register the "proc" trace. This will create the following key/value pair
695
+ # in the "proc" store:
696
+ #
697
+ # --- key ---- --- value ---
698
+ # ::fully::qualified::proc [list <epoch> <ns> <arglist> <body>]
699
+ #
700
+ # The <epoch> chages anytime one (re)defines a proc. The <ns> is the
701
+ # namespace where the command was imported from. If empty, the <arglist>
702
+ # and <body> will hold the actual procedure definition. See the
703
+ # "namespace" tracer implementation also.
704
+ #
705
+
706
+ ttrace::addtrace proc {cmdline code args} {
707
+ if {$code != 0} {
708
+ return
709
+ }
710
+ set cns [uplevel 1 namespace current]
711
+ if {$cns == "::"} {
712
+ set cns ""
713
+ }
714
+ set cmd [lindex $cmdline 1]
715
+ if {![string match "::*" $cmd]} {
716
+ set cmd ${cns}::$cmd
717
+ }
718
+ set dargs [info args $cmd]
719
+ set pbody [info body $cmd]
720
+ set pargs ""
721
+ foreach arg $dargs {
722
+ if {![info default $cmd $arg def]} {
723
+ lappend pargs $arg
724
+ } else {
725
+ lappend pargs [list $arg $def]
726
+ }
727
+ }
728
+ set pdef [ttrace::getentry proc $cmd]
729
+ if {$pdef == ""} {
730
+ set epoch -1 ; # never traced before
731
+ } else {
732
+ set epoch [lindex $pdef 0]
733
+ }
734
+ ttrace::addentry proc $cmd [list [incr epoch] "" $pargs $pbody]
735
+ }
736
+
737
+ ttrace::addscript proc {
738
+ return {
739
+ if {[info command ::tcl::unknown] == ""} {
740
+ rename ::unknown ::tcl::unknown
741
+ namespace import -force ::ttrace::unknown
742
+ }
743
+ if {[info command ::tcl::info] == ""} {
744
+ rename ::info ::tcl::info
745
+ }
746
+ proc ::info args {
747
+ set cmd [lindex $args 0]
748
+ set hit [lsearch -glob {commands procs args default body} $cmd*]
749
+ if {$hit > 1} {
750
+ if {[catch {uplevel 1 ::tcl::info $args}]} {
751
+ uplevel 1 ttrace::_resolve [list [lindex $args 1]]
752
+ }
753
+ return [uplevel 1 ::tcl::info $args]
754
+ }
755
+ if {$hit == -1} {
756
+ return [uplevel 1 ::tcl::info $args]
757
+ }
758
+ set cns [uplevel 1 namespace current]
759
+ if {$cns == "::"} {
760
+ set cns ""
761
+ }
762
+ set pat [lindex $args 1]
763
+ if {![string match "::*" $pat]} {
764
+ set pat ${cns}::$pat
765
+ }
766
+ set fns [ttrace::getentries proc $pat]
767
+ if {[string match $cmd* commands]} {
768
+ set fns [concat $fns [ttrace::getentries xotcl $pat]]
769
+ }
770
+ foreach entry $fns {
771
+ if {$cns != [namespace qual $entry]} {
772
+ set lazy($entry) 1
773
+ } else {
774
+ set lazy([namespace tail $entry]) 1
775
+ }
776
+ }
777
+ foreach entry [uplevel 1 ::tcl::info $args] {
778
+ set lazy($entry) 1
779
+ }
780
+ array names lazy
781
+ }
782
+ }
783
+ }
784
+
785
+ #
786
+ # Register procedure resolver. This will try to resolve the command in the
787
+ # current namespace first, and if not found, in global namespace. It also
788
+ # handles commands imported from other namespaces.
789
+ #
790
+
791
+ ttrace::addresolver resolveprocs {cmd {export 0}} {
792
+ set cns [uplevel 1 namespace current]
793
+ set name [namespace tail $cmd]
794
+ if {$cns == "::"} {
795
+ set cns ""
796
+ }
797
+ if {![string match "::*" $cmd]} {
798
+ set ncmd ${cns}::$cmd
799
+ set gcmd ::$cmd
800
+ } else {
801
+ set ncmd $cmd
802
+ set gcmd $cmd
803
+ }
804
+ set pdef [ttrace::getentry proc $ncmd]
805
+ if {$pdef == ""} {
806
+ set pdef [ttrace::getentry proc $gcmd]
807
+ if {$pdef == ""} {
808
+ return 0
809
+ }
810
+ set cmd $gcmd
811
+ } else {
812
+ set cmd $ncmd
813
+ }
814
+ set epoch [lindex $pdef 0]
815
+ set pnsp [lindex $pdef 1]
816
+ if {$pnsp != ""} {
817
+ set nsp [namespace qual $cmd]
818
+ if {$nsp == ""} {
819
+ set nsp ::
820
+ }
821
+ set cmd ${pnsp}::$name
822
+ if {[resolveprocs $cmd 1] == 0 && [info commands $cmd] == ""} {
823
+ return 0
824
+ }
825
+ namespace eval $nsp "namespace import -force $cmd"
826
+ } else {
827
+ uplevel 0 [list ::proc $cmd [lindex $pdef 2] [lindex $pdef 3]]
828
+ if {$export} {
829
+ set nsp [namespace qual $cmd]
830
+ if {$nsp == ""} {
831
+ set nsp ::
832
+ }
833
+ namespace eval $nsp "namespace export $name"
834
+ }
835
+ }
836
+ variable resolveproc
837
+ set resolveproc($cmd) $epoch
838
+ return 1
839
+ }
840
+
841
+ #
842
+ # For XOTcl, the entire item introspection/tracing is delegated to XOTcl
843
+ # itself. The xotcl store is filled with this:
844
+ #
845
+ # --- key ---- --- value ---
846
+ # ::fully::qualified::item <body>
847
+ #
848
+ # The <body> is the script used to generate the entire item (class,
849
+ # object). Note that we do not fill in this during code tracing. It is
850
+ # done during the script generation. In this step, only the placeholder is
851
+ # set.
852
+ #
853
+ # NOTE: we assume all XOTcl commands are imported in global namespace
854
+ #
855
+
856
+ ttrace::atenable XOTclEnabler {args} {
857
+ if {[info commands ::xotcl::Class] == ""} {
858
+ return
859
+ }
860
+ if {[info commands ::xotcl::_creator] == ""} {
861
+ ::xotcl::Class create ::xotcl::_creator -instproc create {args} {
862
+ set result [next]
863
+ if {![string match ::xotcl::_* $result]} {
864
+ ttrace::addentry xotcl $result ""
865
+ }
866
+ return $result
867
+ }
868
+ }
869
+ ::xotcl::Class instmixin ::xotcl::_creator
870
+ }
871
+
872
+ ttrace::atdisable XOTclDisabler {args} {
873
+ if { [info commands ::xotcl::Class] == ""
874
+ || [info commands ::xotcl::_creator] == ""} {
875
+ return
876
+ }
877
+ ::xotcl::Class instmixin ""
878
+ ::xotcl::_creator destroy
879
+ }
880
+
881
+ set resolver [ttrace::addresolver resolveclasses {classname} {
882
+ set cns [uplevel 1 namespace current]
883
+ set script [ttrace::getentry xotcl $classname]
884
+ if {$script == ""} {
885
+ set name [namespace tail $classname]
886
+ if {$cns == "::"} {
887
+ set script [ttrace::getentry xotcl ::$name]
888
+ } else {
889
+ set script [ttrace::getentry xotcl ${cns}::$name]
890
+ if {$script == ""} {
891
+ set script [ttrace::getentry xotcl ::$name]
892
+ }
893
+ }
894
+ if {$script == ""} {
895
+ return 0
896
+ }
897
+ }
898
+ uplevel 1 [list namespace eval $cns $script]
899
+ return 1
900
+ }]
901
+
902
+ ttrace::addscript xotcl [subst -nocommands {
903
+ if {![catch {Serializer new} ss]} {
904
+ foreach entry [ttrace::getentries xotcl] {
905
+ if {[ttrace::getentry xotcl \$entry] == ""} {
906
+ ttrace::addentry xotcl \$entry [\$ss serialize \$entry]
907
+ }
908
+ }
909
+ \$ss destroy
910
+ return {::xotcl::Class proc __unknown name {$resolver \$name}}
911
+ }
912
+ }]
913
+
914
+ #
915
+ # Register callback to be called on cleanup. This will trash lazily loaded
916
+ # procs which have changed since.
917
+ #
918
+
919
+ ttrace::addcleanup {
920
+ variable resolveproc
921
+ foreach cmd [array names resolveproc] {
922
+ set def [ttrace::getentry proc $cmd]
923
+ if {$def != ""} {
924
+ set new [lindex $def 0]
925
+ set old $resolveproc($cmd)
926
+ if {[info command $cmd] != "" && $new != $old} {
927
+ catch {rename $cmd ""}
928
+ }
929
+ }
930
+ }
931
+ }
932
+ }
933
+
934
+ # EOF
935
+ return
936
+
937
+ # Local Variables:
938
+ # mode: tcl
939
+ # fill-column: 78
940
+ # tab-width: 8
941
+ # indent-tabs-mode: nil
942
+ # End:
miniconda3/lib/tk8.6/bgerror.tcl ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bgerror.tcl --
2
+ #
3
+ # Implementation of the bgerror procedure. It posts a dialog box with
4
+ # the error message and gives the user a chance to see a more detailed
5
+ # stack trace, and possible do something more interesting with that
6
+ # trace (like save it to a log). This is adapted from work done by
7
+ # Donal K. Fellows.
8
+ #
9
+ # Copyright (c) 1998-2000 by Ajuba Solutions.
10
+ # Copyright (c) 2007 by ActiveState Software Inc.
11
+ # Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
12
+ # Copyright (c) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
13
+
14
+ namespace eval ::tk::dialog::error {
15
+ namespace import -force ::tk::msgcat::*
16
+ namespace export bgerror
17
+ option add *ErrorDialog.function.text [mc "Save To Log"] \
18
+ widgetDefault
19
+ option add *ErrorDialog.function.command [namespace code SaveToLog]
20
+ option add *ErrorDialog*Label.font TkCaptionFont widgetDefault
21
+ if {[tk windowingsystem] eq "aqua"} {
22
+ option add *ErrorDialog*background systemAlertBackgroundActive \
23
+ widgetDefault
24
+ option add *ErrorDialog*info.text.background \
25
+ systemTextBackgroundColor widgetDefault
26
+ option add *ErrorDialog*Button.highlightBackground \
27
+ systemAlertBackgroundActive widgetDefault
28
+ }
29
+ }
30
+
31
+ proc ::tk::dialog::error::Return {which code} {
32
+ variable button
33
+
34
+ .bgerrorDialog.$which state {active selected focus}
35
+ update idletasks
36
+ after 100
37
+ set button $code
38
+ }
39
+
40
+ proc ::tk::dialog::error::Details {} {
41
+ set w .bgerrorDialog
42
+ set caption [option get $w.function text {}]
43
+ set command [option get $w.function command {}]
44
+ if {($caption eq "") || ($command eq "")} {
45
+ grid forget $w.function
46
+ }
47
+ lappend command [$w.top.info.text get 1.0 end-1c]
48
+ $w.function configure -text $caption -command $command
49
+ grid $w.top.info - -sticky nsew -padx 3m -pady 3m
50
+ }
51
+
52
+ proc ::tk::dialog::error::SaveToLog {text} {
53
+ if {$::tcl_platform(platform) eq "windows"} {
54
+ set allFiles *.*
55
+ } else {
56
+ set allFiles *
57
+ }
58
+ set types [list \
59
+ [list [mc "Log Files"] .log] \
60
+ [list [mc "Text Files"] .txt] \
61
+ [list [mc "All Files"] $allFiles] \
62
+ ]
63
+ set filename [tk_getSaveFile -title [mc "Select Log File"] \
64
+ -filetypes $types -defaultextension .log -parent .bgerrorDialog]
65
+ if {$filename ne {}} {
66
+ set f [open $filename w]
67
+ puts -nonewline $f $text
68
+ close $f
69
+ }
70
+ return
71
+ }
72
+
73
+ proc ::tk::dialog::error::Destroy {w} {
74
+ if {$w eq ".bgerrorDialog"} {
75
+ variable button
76
+ set button -1
77
+ }
78
+ }
79
+
80
+ proc ::tk::dialog::error::DeleteByProtocol {} {
81
+ variable button
82
+ set button 1
83
+ }
84
+
85
+ proc ::tk::dialog::error::ReturnInDetails w {
86
+ bind $w <Return> {}; # Remove this binding
87
+ $w invoke
88
+ return -code break
89
+ }
90
+
91
+ # ::tk::dialog::error::bgerror --
92
+ #
93
+ # This is the default version of bgerror.
94
+ # It tries to execute tkerror, if that fails it posts a dialog box
95
+ # containing the error message and gives the user a chance to ask
96
+ # to see a stack trace.
97
+ #
98
+ # Arguments:
99
+ # err - The error message.
100
+ #
101
+ proc ::tk::dialog::error::bgerror {err {flag 1}} {
102
+ global errorInfo
103
+ variable button
104
+
105
+ set info $errorInfo
106
+
107
+ set ret [catch {::tkerror $err} msg];
108
+ if {$ret != 1} {return -code $ret $msg}
109
+
110
+ # The application's tkerror either failed or was not found
111
+ # so we use the default dialog. But on Aqua we cannot display
112
+ # the dialog if the background error occurs in an idle task
113
+ # being processed inside of [NSView drawRect]. In that case
114
+ # we post the dialog as an after task instead.
115
+ set windowingsystem [tk windowingsystem]
116
+ if {$windowingsystem eq "aqua"} {
117
+ if $flag {
118
+ set errorInfo $info
119
+ after 500 [list bgerror "$err" 0]
120
+ return
121
+ }
122
+ }
123
+
124
+ set ok [mc OK]
125
+ # Truncate the message if it is too wide (>maxLine characters) or
126
+ # too tall (>4 lines). Truncation occurs at the first point at
127
+ # which one of those conditions is met.
128
+ set displayedErr ""
129
+ set lines 0
130
+ set maxLine 45
131
+ foreach line [split $err \n] {
132
+ if {[string length $line] > $maxLine} {
133
+ append displayedErr "[string range $line 0 $maxLine-3]..."
134
+ break
135
+ }
136
+ if {$lines > 4} {
137
+ append displayedErr "..."
138
+ break
139
+ } else {
140
+ append displayedErr "${line}\n"
141
+ }
142
+ incr lines
143
+ }
144
+
145
+ set title [mc "Application Error"]
146
+ set text [mc "Error: %1\$s" $displayedErr]
147
+ set buttons [list ok $ok dismiss [mc "Skip Messages"] \
148
+ function [mc "Details >>"]]
149
+
150
+ # 1. Create the top-level window and divide it into top
151
+ # and bottom parts.
152
+
153
+ set dlg .bgerrorDialog
154
+ set bg [ttk::style lookup . -background]
155
+ destroy $dlg
156
+ toplevel $dlg -class ErrorDialog -background $bg
157
+ wm withdraw $dlg
158
+ wm title $dlg $title
159
+ wm iconname $dlg ErrorDialog
160
+ wm protocol $dlg WM_DELETE_WINDOW [namespace code DeleteByProtocol]
161
+
162
+ if {$windowingsystem eq "aqua"} {
163
+ ::tk::unsupported::MacWindowStyle style $dlg moveableAlert {}
164
+ } elseif {$windowingsystem eq "x11"} {
165
+ wm attributes $dlg -type dialog
166
+ }
167
+
168
+ ttk::frame $dlg.bot
169
+ ttk::frame $dlg.top
170
+ pack $dlg.bot -side bottom -fill both
171
+ pack $dlg.top -side top -fill both -expand 1
172
+
173
+ set W [ttk::frame $dlg.top.info]
174
+ text $W.text -setgrid true -height 10 -wrap char \
175
+ -yscrollcommand [list $W.scroll set]
176
+ if {$windowingsystem ne "aqua"} {
177
+ $W.text configure -width 40
178
+ }
179
+
180
+ ttk::scrollbar $W.scroll -command [list $W.text yview]
181
+ pack $W.scroll -side right -fill y
182
+ pack $W.text -side left -expand yes -fill both
183
+ $W.text insert 0.0 "$err\n$info"
184
+ $W.text mark set insert 0.0
185
+ bind $W.text <Button-1> {focus %W}
186
+ $W.text configure -state disabled
187
+
188
+ # 2. Fill the top part with bitmap and message
189
+
190
+ # Max-width of message is the width of the screen...
191
+ set wrapwidth [winfo screenwidth $dlg]
192
+ # ...minus the width of the icon, padding and a fudge factor for
193
+ # the window manager decorations and aesthetics.
194
+ set wrapwidth [expr {$wrapwidth-60-[winfo pixels $dlg 9m]}]
195
+ ttk::label $dlg.msg -justify left -text $text -wraplength $wrapwidth
196
+ ttk::label $dlg.bitmap -image ::tk::icons::error
197
+
198
+ grid $dlg.bitmap $dlg.msg -in $dlg.top -row 0 -padx 3m -pady 3m
199
+ grid configure $dlg.bitmap -sticky ne
200
+ grid configure $dlg.msg -sticky nsw -padx {0 3m}
201
+ grid rowconfigure $dlg.top 1 -weight 1
202
+ grid columnconfigure $dlg.top 1 -weight 1
203
+
204
+ # 3. Create a row of buttons at the bottom of the dialog.
205
+
206
+ set i 0
207
+ foreach {name caption} $buttons {
208
+ ttk::button $dlg.$name -text $caption -default normal \
209
+ -command [namespace code [list set button $i]]
210
+ grid $dlg.$name -in $dlg.bot -column $i -row 0 -sticky ew -padx 10
211
+ grid columnconfigure $dlg.bot $i -weight 1
212
+ # We boost the size of some Mac buttons for l&f
213
+ if {$windowingsystem eq "aqua"} {
214
+ if {($name eq "ok") || ($name eq "dismiss")} {
215
+ grid columnconfigure $dlg.bot $i -minsize 90
216
+ }
217
+ grid configure $dlg.$name -pady 7
218
+ }
219
+ incr i
220
+ }
221
+ # The "OK" button is the default for this dialog.
222
+ $dlg.ok configure -default active
223
+
224
+ bind $dlg <Return> [namespace code {Return ok 0}]
225
+ bind $dlg <Escape> [namespace code {Return dismiss 1}]
226
+ bind $dlg <Destroy> [namespace code {Destroy %W}]
227
+ bind $dlg.function <Return> [namespace code {ReturnInDetails %W}]
228
+ $dlg.function configure -command [namespace code Details]
229
+
230
+ # 6. Withdraw the window, then update all the geometry information
231
+ # so we know how big it wants to be, then center the window in the
232
+ # display (Motif style) and de-iconify it.
233
+
234
+ ::tk::PlaceWindow $dlg
235
+
236
+ # 7. Set a grab and claim the focus too.
237
+
238
+ ::tk::SetFocusGrab $dlg $dlg.ok
239
+
240
+ # 8. Ensure that we are topmost.
241
+
242
+ raise $dlg
243
+ if {[tk windowingsystem] eq "win32"} {
244
+ # Place it topmost if we aren't at the top of the stacking
245
+ # order to ensure that it's seen
246
+ if {[lindex [wm stackorder .] end] ne "$dlg"} {
247
+ wm attributes $dlg -topmost 1
248
+ }
249
+ }
250
+
251
+ # 9. Wait for the user to respond, then restore the focus and
252
+ # return the index of the selected button. Restore the focus
253
+ # before deleting the window, since otherwise the window manager
254
+ # may take the focus away so we can't redirect it. Finally,
255
+ # restore any grab that was in effect.
256
+
257
+ vwait [namespace which -variable button]
258
+ set copy $button; # Save a copy...
259
+
260
+ ::tk::RestoreFocusGrab $dlg $dlg.ok destroy
261
+
262
+ if {$copy == 1} {
263
+ return -code break
264
+ }
265
+ }
266
+
267
+ namespace eval :: {
268
+ # Fool the indexer
269
+ proc bgerror err {}
270
+ rename bgerror {}
271
+ namespace import ::tk::dialog::error::bgerror
272
+ }
miniconda3/lib/tk8.6/button.tcl ADDED
@@ -0,0 +1,782 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # button.tcl --
2
+ #
3
+ # This file defines the default bindings for Tk label, button,
4
+ # checkbutton, and radiobutton widgets and provides procedures
5
+ # that help in implementing those bindings.
6
+ #
7
+ # Copyright (c) 1992-1994 The Regents of the University of California.
8
+ # Copyright (c) 1994-1996 Sun Microsystems, Inc.
9
+ # Copyright (c) 2002 ActiveState Corporation.
10
+ #
11
+ # See the file "license.terms" for information on usage and redistribution
12
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
+ #
14
+
15
+ #-------------------------------------------------------------------------
16
+ # The code below creates the default class bindings for buttons.
17
+ #-------------------------------------------------------------------------
18
+
19
+ if {[tk windowingsystem] eq "aqua"} {
20
+
21
+ bind Radiobutton <Enter> {
22
+ tk::ButtonEnter %W
23
+ }
24
+ bind Radiobutton <1> {
25
+ tk::ButtonDown %W
26
+ }
27
+ bind Radiobutton <ButtonRelease-1> {
28
+ tk::ButtonUp %W
29
+ }
30
+ bind Checkbutton <Enter> {
31
+ tk::ButtonEnter %W
32
+ }
33
+ bind Checkbutton <1> {
34
+ tk::ButtonDown %W
35
+ }
36
+ bind Checkbutton <ButtonRelease-1> {
37
+ tk::ButtonUp %W
38
+ }
39
+ bind Checkbutton <Leave> {
40
+ tk::ButtonLeave %W
41
+ }
42
+ }
43
+ if {"win32" eq [tk windowingsystem]} {
44
+ bind Checkbutton <equal> {
45
+ tk::CheckRadioInvoke %W select
46
+ }
47
+ bind Checkbutton <plus> {
48
+ tk::CheckRadioInvoke %W select
49
+ }
50
+ bind Checkbutton <minus> {
51
+ tk::CheckRadioInvoke %W deselect
52
+ }
53
+ bind Checkbutton <1> {
54
+ tk::CheckRadioDown %W
55
+ }
56
+ bind Checkbutton <ButtonRelease-1> {
57
+ tk::ButtonUp %W
58
+ }
59
+ bind Checkbutton <Enter> {
60
+ tk::CheckRadioEnter %W
61
+ }
62
+ bind Checkbutton <Leave> {
63
+ tk::ButtonLeave %W
64
+ }
65
+
66
+ bind Radiobutton <1> {
67
+ tk::CheckRadioDown %W
68
+ }
69
+ bind Radiobutton <ButtonRelease-1> {
70
+ tk::ButtonUp %W
71
+ }
72
+ bind Radiobutton <Enter> {
73
+ tk::CheckRadioEnter %W
74
+ }
75
+ }
76
+ if {"x11" eq [tk windowingsystem]} {
77
+ bind Checkbutton <Return> {
78
+ if {!$tk_strictMotif} {
79
+ tk::CheckInvoke %W
80
+ }
81
+ }
82
+ bind Radiobutton <Return> {
83
+ if {!$tk_strictMotif} {
84
+ tk::CheckRadioInvoke %W
85
+ }
86
+ }
87
+ bind Checkbutton <1> {
88
+ tk::CheckInvoke %W
89
+ }
90
+ bind Radiobutton <1> {
91
+ tk::CheckRadioInvoke %W
92
+ }
93
+ bind Checkbutton <Enter> {
94
+ tk::CheckEnter %W
95
+ }
96
+ bind Radiobutton <Enter> {
97
+ tk::ButtonEnter %W
98
+ }
99
+ bind Checkbutton <Leave> {
100
+ tk::CheckLeave %W
101
+ }
102
+ }
103
+
104
+ bind Button <space> {
105
+ tk::ButtonInvoke %W
106
+ }
107
+ bind Checkbutton <space> {
108
+ tk::CheckRadioInvoke %W
109
+ }
110
+ bind Radiobutton <space> {
111
+ tk::CheckRadioInvoke %W
112
+ }
113
+ bind Button <<Invoke>> {
114
+ tk::ButtonInvoke %W
115
+ }
116
+ bind Checkbutton <<Invoke>> {
117
+ tk::CheckRadioInvoke %W
118
+ }
119
+ bind Radiobutton <<Invoke>> {
120
+ tk::CheckRadioInvoke %W
121
+ }
122
+
123
+ bind Button <FocusIn> {}
124
+ bind Button <Enter> {
125
+ tk::ButtonEnter %W
126
+ }
127
+ bind Button <Leave> {
128
+ tk::ButtonLeave %W
129
+ }
130
+ bind Button <1> {
131
+ tk::ButtonDown %W
132
+ }
133
+ bind Button <ButtonRelease-1> {
134
+ tk::ButtonUp %W
135
+ }
136
+
137
+ bind Checkbutton <FocusIn> {}
138
+
139
+ bind Radiobutton <FocusIn> {}
140
+ bind Radiobutton <Leave> {
141
+ tk::ButtonLeave %W
142
+ }
143
+
144
+ if {"win32" eq [tk windowingsystem]} {
145
+
146
+ #########################
147
+ # Windows implementation
148
+ #########################
149
+
150
+ # ::tk::ButtonEnter --
151
+ # The procedure below is invoked when the mouse pointer enters a
152
+ # button widget. It records the button we're in and changes the
153
+ # state of the button to active unless the button is disabled.
154
+ #
155
+ # Arguments:
156
+ # w - The name of the widget.
157
+
158
+ proc ::tk::ButtonEnter w {
159
+ variable ::tk::Priv
160
+ if {[$w cget -state] ne "disabled"} {
161
+
162
+ # If the mouse button is down, set the relief to sunken on entry.
163
+ # Overwise, if there's an -overrelief value, set the relief to that.
164
+
165
+ set Priv($w,relief) [$w cget -relief]
166
+ if {$Priv(buttonWindow) eq $w} {
167
+ $w configure -relief sunken -state active
168
+ set Priv($w,prelief) sunken
169
+ } elseif {[set over [$w cget -overrelief]] ne ""} {
170
+ $w configure -relief $over
171
+ set Priv($w,prelief) $over
172
+ }
173
+ }
174
+ set Priv(window) $w
175
+ }
176
+
177
+ # ::tk::ButtonLeave --
178
+ # The procedure below is invoked when the mouse pointer leaves a
179
+ # button widget. It changes the state of the button back to inactive.
180
+ # Restore any modified relief too.
181
+ #
182
+ # Arguments:
183
+ # w - The name of the widget.
184
+
185
+ proc ::tk::ButtonLeave w {
186
+ variable ::tk::Priv
187
+ if {[$w cget -state] ne "disabled"} {
188
+ $w configure -state normal
189
+ }
190
+
191
+ # Restore the original button relief if it was changed by Tk.
192
+ # That is signaled by the existence of Priv($w,prelief).
193
+
194
+ if {[info exists Priv($w,relief)]} {
195
+ if {[info exists Priv($w,prelief)] && \
196
+ $Priv($w,prelief) eq [$w cget -relief]} {
197
+ $w configure -relief $Priv($w,relief)
198
+ }
199
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
200
+ }
201
+
202
+ set Priv(window) ""
203
+ }
204
+
205
+ # ::tk::ButtonDown --
206
+ # The procedure below is invoked when the mouse button is pressed in
207
+ # a button widget. It records the fact that the mouse is in the button,
208
+ # saves the button's relief so it can be restored later, and changes
209
+ # the relief to sunken.
210
+ #
211
+ # Arguments:
212
+ # w - The name of the widget.
213
+
214
+ proc ::tk::ButtonDown w {
215
+ variable ::tk::Priv
216
+
217
+ # Only save the button's relief if it does not yet exist. If there
218
+ # is an overrelief setting, Priv($w,relief) will already have been set,
219
+ # and the current value of the -relief option will be incorrect.
220
+
221
+ if {![info exists Priv($w,relief)]} {
222
+ set Priv($w,relief) [$w cget -relief]
223
+ }
224
+
225
+ if {[$w cget -state] ne "disabled"} {
226
+ set Priv(buttonWindow) $w
227
+ $w configure -relief sunken -state active
228
+ set Priv($w,prelief) sunken
229
+
230
+ # If this button has a repeatdelay set up, get it going with an after
231
+ after cancel $Priv(afterId)
232
+ set delay [$w cget -repeatdelay]
233
+ set Priv(repeated) 0
234
+ if {$delay > 0} {
235
+ set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
236
+ }
237
+ }
238
+ }
239
+
240
+ # ::tk::ButtonUp --
241
+ # The procedure below is invoked when the mouse button is released
242
+ # in a button widget. It restores the button's relief and invokes
243
+ # the command as long as the mouse hasn't left the button.
244
+ #
245
+ # Arguments:
246
+ # w - The name of the widget.
247
+
248
+ proc ::tk::ButtonUp w {
249
+ variable ::tk::Priv
250
+ if {$Priv(buttonWindow) eq $w} {
251
+ set Priv(buttonWindow) ""
252
+
253
+ # Restore the button's relief if it was cached.
254
+
255
+ if {[info exists Priv($w,relief)]} {
256
+ if {[info exists Priv($w,prelief)] && \
257
+ $Priv($w,prelief) eq [$w cget -relief]} {
258
+ $w configure -relief $Priv($w,relief)
259
+ }
260
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
261
+ }
262
+
263
+ # Clean up the after event from the auto-repeater
264
+ after cancel $Priv(afterId)
265
+
266
+ if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} {
267
+ $w configure -state normal
268
+
269
+ # Only invoke the command if it wasn't already invoked by the
270
+ # auto-repeater functionality
271
+ if { $Priv(repeated) == 0 } {
272
+ uplevel #0 [list $w invoke]
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ # ::tk::CheckRadioEnter --
279
+ # The procedure below is invoked when the mouse pointer enters a
280
+ # checkbutton or radiobutton widget. It records the button we're in
281
+ # and changes the state of the button to active unless the button is
282
+ # disabled.
283
+ #
284
+ # Arguments:
285
+ # w - The name of the widget.
286
+
287
+ proc ::tk::CheckRadioEnter w {
288
+ variable ::tk::Priv
289
+ if {[$w cget -state] ne "disabled"} {
290
+ if {$Priv(buttonWindow) eq $w} {
291
+ $w configure -state active
292
+ }
293
+ if {[set over [$w cget -overrelief]] ne ""} {
294
+ set Priv($w,relief) [$w cget -relief]
295
+ set Priv($w,prelief) $over
296
+ $w configure -relief $over
297
+ }
298
+ }
299
+ set Priv(window) $w
300
+ }
301
+
302
+ # ::tk::CheckRadioDown --
303
+ # The procedure below is invoked when the mouse button is pressed in
304
+ # a button widget. It records the fact that the mouse is in the button,
305
+ # saves the button's relief so it can be restored later, and changes
306
+ # the relief to sunken.
307
+ #
308
+ # Arguments:
309
+ # w - The name of the widget.
310
+
311
+ proc ::tk::CheckRadioDown w {
312
+ variable ::tk::Priv
313
+ if {![info exists Priv($w,relief)]} {
314
+ set Priv($w,relief) [$w cget -relief]
315
+ }
316
+ if {[$w cget -state] ne "disabled"} {
317
+ set Priv(buttonWindow) $w
318
+ set Priv(repeated) 0
319
+ $w configure -state active
320
+ }
321
+ }
322
+
323
+ }
324
+
325
+ if {"x11" eq [tk windowingsystem]} {
326
+
327
+ #####################
328
+ # Unix implementation
329
+ #####################
330
+
331
+ # ::tk::ButtonEnter --
332
+ # The procedure below is invoked when the mouse pointer enters a
333
+ # button widget. It records the button we're in and changes the
334
+ # state of the button to active unless the button is disabled.
335
+ #
336
+ # Arguments:
337
+ # w - The name of the widget.
338
+
339
+ proc ::tk::ButtonEnter {w} {
340
+ variable ::tk::Priv
341
+ if {[$w cget -state] ne "disabled"} {
342
+ # On unix the state is active just with mouse-over
343
+ $w configure -state active
344
+
345
+ # If the mouse button is down, set the relief to sunken on entry.
346
+ # Overwise, if there's an -overrelief value, set the relief to that.
347
+
348
+ set Priv($w,relief) [$w cget -relief]
349
+ if {$Priv(buttonWindow) eq $w} {
350
+ $w configure -relief sunken
351
+ set Priv($w,prelief) sunken
352
+ } elseif {[set over [$w cget -overrelief]] ne ""} {
353
+ $w configure -relief $over
354
+ set Priv($w,prelief) $over
355
+ }
356
+ }
357
+ set Priv(window) $w
358
+ }
359
+
360
+ # ::tk::ButtonLeave --
361
+ # The procedure below is invoked when the mouse pointer leaves a
362
+ # button widget. It changes the state of the button back to inactive.
363
+ # Restore any modified relief too.
364
+ #
365
+ # Arguments:
366
+ # w - The name of the widget.
367
+
368
+ proc ::tk::ButtonLeave w {
369
+ variable ::tk::Priv
370
+ if {[$w cget -state] ne "disabled"} {
371
+ $w configure -state normal
372
+ }
373
+
374
+ # Restore the original button relief if it was changed by Tk.
375
+ # That is signaled by the existence of Priv($w,prelief).
376
+
377
+ if {[info exists Priv($w,relief)]} {
378
+ if {[info exists Priv($w,prelief)] && \
379
+ $Priv($w,prelief) eq [$w cget -relief]} {
380
+ $w configure -relief $Priv($w,relief)
381
+ }
382
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
383
+ }
384
+
385
+ set Priv(window) ""
386
+ }
387
+
388
+ # ::tk::ButtonDown --
389
+ # The procedure below is invoked when the mouse button is pressed in
390
+ # a button widget. It records the fact that the mouse is in the button,
391
+ # saves the button's relief so it can be restored later, and changes
392
+ # the relief to sunken.
393
+ #
394
+ # Arguments:
395
+ # w - The name of the widget.
396
+
397
+ proc ::tk::ButtonDown w {
398
+ variable ::tk::Priv
399
+
400
+ # Only save the button's relief if it does not yet exist. If there
401
+ # is an overrelief setting, Priv($w,relief) will already have been set,
402
+ # and the current value of the -relief option will be incorrect.
403
+
404
+ if {![info exists Priv($w,relief)]} {
405
+ set Priv($w,relief) [$w cget -relief]
406
+ }
407
+
408
+ if {[$w cget -state] ne "disabled"} {
409
+ set Priv(buttonWindow) $w
410
+ $w configure -relief sunken
411
+ set Priv($w,prelief) sunken
412
+
413
+ # If this button has a repeatdelay set up, get it going with an after
414
+ after cancel $Priv(afterId)
415
+ set delay [$w cget -repeatdelay]
416
+ set Priv(repeated) 0
417
+ if {$delay > 0} {
418
+ set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
419
+ }
420
+ }
421
+ }
422
+
423
+ # ::tk::ButtonUp --
424
+ # The procedure below is invoked when the mouse button is released
425
+ # in a button widget. It restores the button's relief and invokes
426
+ # the command as long as the mouse hasn't left the button.
427
+ #
428
+ # Arguments:
429
+ # w - The name of the widget.
430
+
431
+ proc ::tk::ButtonUp w {
432
+ variable ::tk::Priv
433
+ if {$w eq $Priv(buttonWindow)} {
434
+ set Priv(buttonWindow) ""
435
+
436
+ # Restore the button's relief if it was cached.
437
+
438
+ if {[info exists Priv($w,relief)]} {
439
+ if {[info exists Priv($w,prelief)] && \
440
+ $Priv($w,prelief) eq [$w cget -relief]} {
441
+ $w configure -relief $Priv($w,relief)
442
+ }
443
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
444
+ }
445
+
446
+ # Clean up the after event from the auto-repeater
447
+ after cancel $Priv(afterId)
448
+
449
+ if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} {
450
+ # Only invoke the command if it wasn't already invoked by the
451
+ # auto-repeater functionality
452
+ if { $Priv(repeated) == 0 } {
453
+ uplevel #0 [list $w invoke]
454
+ }
455
+ }
456
+ }
457
+ }
458
+
459
+ }
460
+
461
+ if {[tk windowingsystem] eq "aqua"} {
462
+
463
+ ####################
464
+ # Mac implementation
465
+ ####################
466
+
467
+ # ::tk::ButtonEnter --
468
+ # The procedure below is invoked when the mouse pointer enters a
469
+ # button widget. It records the button we're in and changes the
470
+ # state of the button to active unless the button is disabled.
471
+ #
472
+ # Arguments:
473
+ # w - The name of the widget.
474
+
475
+ proc ::tk::ButtonEnter {w} {
476
+ variable ::tk::Priv
477
+ if {[$w cget -state] ne "disabled"} {
478
+
479
+ # If there's an -overrelief value, set the relief to that.
480
+
481
+ if {$Priv(buttonWindow) eq $w} {
482
+ $w configure -state active
483
+ } elseif {[set over [$w cget -overrelief]] ne ""} {
484
+ set Priv($w,relief) [$w cget -relief]
485
+ set Priv($w,prelief) $over
486
+ $w configure -relief $over
487
+ }
488
+ }
489
+ set Priv(window) $w
490
+ }
491
+
492
+ # ::tk::ButtonLeave --
493
+ # The procedure below is invoked when the mouse pointer leaves a
494
+ # button widget. It changes the state of the button back to
495
+ # inactive. If we're leaving the button window with a mouse button
496
+ # pressed (Priv(buttonWindow) == $w), restore the relief of the
497
+ # button too.
498
+ #
499
+ # Arguments:
500
+ # w - The name of the widget.
501
+
502
+ proc ::tk::ButtonLeave w {
503
+ variable ::tk::Priv
504
+ if {$w eq $Priv(buttonWindow)} {
505
+ $w configure -state normal
506
+ }
507
+
508
+ # Restore the original button relief if it was changed by Tk.
509
+ # That is signaled by the existence of Priv($w,prelief).
510
+
511
+ if {[info exists Priv($w,relief)]} {
512
+ if {[info exists Priv($w,prelief)] && \
513
+ $Priv($w,prelief) eq [$w cget -relief]} {
514
+ $w configure -relief $Priv($w,relief)
515
+ }
516
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
517
+ }
518
+
519
+ set Priv(window) ""
520
+ }
521
+
522
+ # ::tk::ButtonDown --
523
+ # The procedure below is invoked when the mouse button is pressed in
524
+ # a button widget. It records the fact that the mouse is in the button,
525
+ # saves the button's relief so it can be restored later, and changes
526
+ # the relief to sunken.
527
+ #
528
+ # Arguments:
529
+ # w - The name of the widget.
530
+
531
+ proc ::tk::ButtonDown w {
532
+ variable ::tk::Priv
533
+
534
+ if {[$w cget -state] ne "disabled"} {
535
+ set Priv(buttonWindow) $w
536
+ $w configure -state active
537
+
538
+ # If this button has a repeatdelay set up, get it going with an after
539
+ after cancel $Priv(afterId)
540
+ set Priv(repeated) 0
541
+ if { ![catch {$w cget -repeatdelay} delay] } {
542
+ if {$delay > 0} {
543
+ set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
544
+ }
545
+ }
546
+ }
547
+ }
548
+
549
+ # ::tk::ButtonUp --
550
+ # The procedure below is invoked when the mouse button is released
551
+ # in a button widget. It restores the button's relief and invokes
552
+ # the command as long as the mouse hasn't left the button.
553
+ #
554
+ # Arguments:
555
+ # w - The name of the widget.
556
+
557
+ proc ::tk::ButtonUp w {
558
+ variable ::tk::Priv
559
+ if {$Priv(buttonWindow) eq $w} {
560
+ set Priv(buttonWindow) ""
561
+ $w configure -state normal
562
+
563
+ # Restore the button's relief if it was cached.
564
+
565
+ if {[info exists Priv($w,relief)]} {
566
+ if {[info exists Priv($w,prelief)] && \
567
+ $Priv($w,prelief) eq [$w cget -relief]} {
568
+ $w configure -relief $Priv($w,relief)
569
+ }
570
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
571
+ }
572
+
573
+ # Clean up the after event from the auto-repeater
574
+ after cancel $Priv(afterId)
575
+
576
+ if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} {
577
+ # Only invoke the command if it wasn't already invoked by the
578
+ # auto-repeater functionality
579
+ if { $Priv(repeated) == 0 } {
580
+ uplevel #0 [list $w invoke]
581
+ }
582
+ }
583
+ }
584
+ }
585
+
586
+ }
587
+
588
+ ##################
589
+ # Shared routines
590
+ ##################
591
+
592
+ # ::tk::ButtonInvoke --
593
+ # The procedure below is called when a button is invoked through
594
+ # the keyboard. It simulate a press of the button via the mouse.
595
+ #
596
+ # Arguments:
597
+ # w - The name of the widget.
598
+
599
+ proc ::tk::ButtonInvoke w {
600
+ if {[winfo exists $w] && [$w cget -state] ne "disabled"} {
601
+ set oldRelief [$w cget -relief]
602
+ set oldState [$w cget -state]
603
+ $w configure -state active -relief sunken
604
+ after 100 [list ::tk::ButtonInvokeEnd $w $oldState $oldRelief]
605
+ }
606
+ }
607
+
608
+ # ::tk::ButtonInvokeEnd --
609
+ # The procedure below is called after a button is invoked through
610
+ # the keyboard. It simulate a release of the button via the mouse.
611
+ #
612
+ # Arguments:
613
+ # w - The name of the widget.
614
+ # oldState - Old state to be set back.
615
+ # oldRelief - Old relief to be set back.
616
+
617
+ proc ::tk::ButtonInvokeEnd {w oldState oldRelief} {
618
+ if {[winfo exists $w]} {
619
+ $w configure -state $oldState -relief $oldRelief
620
+ uplevel #0 [list $w invoke]
621
+ }
622
+ }
623
+
624
+ # ::tk::ButtonAutoInvoke --
625
+ #
626
+ # Invoke an auto-repeating button, and set it up to continue to repeat.
627
+ #
628
+ # Arguments:
629
+ # w button to invoke.
630
+ #
631
+ # Results:
632
+ # None.
633
+ #
634
+ # Side effects:
635
+ # May create an after event to call ::tk::ButtonAutoInvoke.
636
+
637
+ proc ::tk::ButtonAutoInvoke {w} {
638
+ variable ::tk::Priv
639
+ after cancel $Priv(afterId)
640
+ set delay [$w cget -repeatinterval]
641
+ if {$Priv(window) eq $w} {
642
+ incr Priv(repeated)
643
+ uplevel #0 [list $w invoke]
644
+ }
645
+ if {$delay > 0} {
646
+ set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
647
+ }
648
+ }
649
+
650
+ # ::tk::CheckRadioInvoke --
651
+ # The procedure below is invoked when the mouse button is pressed in
652
+ # a checkbutton or radiobutton widget, or when the widget is invoked
653
+ # through the keyboard. It invokes the widget if it
654
+ # isn't disabled.
655
+ #
656
+ # Arguments:
657
+ # w - The name of the widget.
658
+ # cmd - The subcommand to invoke (one of invoke, select, or deselect).
659
+
660
+ proc ::tk::CheckRadioInvoke {w {cmd invoke}} {
661
+ if {[$w cget -state] ne "disabled"} {
662
+ uplevel #0 [list $w $cmd]
663
+ }
664
+ }
665
+
666
+ # Special versions of the handlers for checkbuttons on Unix that do the magic
667
+ # to make things work right when the checkbutton indicator is hidden;
668
+ # radiobuttons don't need this complexity.
669
+
670
+ # ::tk::CheckInvoke --
671
+ # The procedure below invokes the checkbutton, like ButtonInvoke, but handles
672
+ # what to do when the checkbutton indicator is missing. Only used on Unix.
673
+ #
674
+ # Arguments:
675
+ # w - The name of the widget.
676
+
677
+ proc ::tk::CheckInvoke {w} {
678
+ variable ::tk::Priv
679
+ if {[$w cget -state] ne "disabled"} {
680
+ # Additional logic to switch the "selected" colors around if necessary
681
+ # (when we're indicator-less).
682
+
683
+ if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} {
684
+ if {[$w cget -selectcolor] eq $Priv($w,aselectcolor)} {
685
+ $w configure -selectcolor $Priv($w,selectcolor)
686
+ } else {
687
+ $w configure -selectcolor $Priv($w,aselectcolor)
688
+ }
689
+ }
690
+ uplevel #0 [list $w invoke]
691
+ }
692
+ }
693
+
694
+ # ::tk::CheckEnter --
695
+ # The procedure below enters the checkbutton, like ButtonEnter, but handles
696
+ # what to do when the checkbutton indicator is missing. Only used on Unix.
697
+ #
698
+ # Arguments:
699
+ # w - The name of the widget.
700
+
701
+ proc ::tk::CheckEnter {w} {
702
+ variable ::tk::Priv
703
+ if {[$w cget -state] ne "disabled"} {
704
+ # On unix the state is active just with mouse-over
705
+ $w configure -state active
706
+
707
+ # If the mouse button is down, set the relief to sunken on entry.
708
+ # Overwise, if there's an -overrelief value, set the relief to that.
709
+
710
+ set Priv($w,relief) [$w cget -relief]
711
+ if {$Priv(buttonWindow) eq $w} {
712
+ $w configure -relief sunken
713
+ set Priv($w,prelief) sunken
714
+ } elseif {[set over [$w cget -overrelief]] ne ""} {
715
+ $w configure -relief $over
716
+ set Priv($w,prelief) $over
717
+ }
718
+
719
+ # Compute what the "selected and active" color should be.
720
+
721
+ if {![$w cget -indicatoron] && [$w cget -selectcolor] ne ""} {
722
+ set Priv($w,selectcolor) [$w cget -selectcolor]
723
+ lassign [winfo rgb $w [$w cget -selectcolor]] r1 g1 b1
724
+ lassign [winfo rgb $w [$w cget -activebackground]] r2 g2 b2
725
+ set Priv($w,aselectcolor) \
726
+ [format "#%04x%04x%04x" [expr {($r1+$r2)/2}] \
727
+ [expr {($g1+$g2)/2}] [expr {($b1+$b2)/2}]]
728
+ # use uplevel to work with other var resolvers
729
+ if {[uplevel #0 [list set [$w cget -variable]]]
730
+ eq [$w cget -onvalue]} {
731
+ $w configure -selectcolor $Priv($w,aselectcolor)
732
+ }
733
+ }
734
+ }
735
+ set Priv(window) $w
736
+ }
737
+
738
+ # ::tk::CheckLeave --
739
+ # The procedure below leaves the checkbutton, like ButtonLeave, but handles
740
+ # what to do when the checkbutton indicator is missing. Only used on Unix.
741
+ #
742
+ # Arguments:
743
+ # w - The name of the widget.
744
+
745
+ proc ::tk::CheckLeave {w} {
746
+ variable ::tk::Priv
747
+ if {[$w cget -state] ne "disabled"} {
748
+ $w configure -state normal
749
+ }
750
+
751
+ # Restore the original button "selected" color; but only if the user
752
+ # has not changed it in the meantime.
753
+
754
+ if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} {
755
+ if {[$w cget -selectcolor] eq $Priv($w,selectcolor)
756
+ || ([info exist Priv($w,aselectcolor)] &&
757
+ [$w cget -selectcolor] eq $Priv($w,aselectcolor))} {
758
+ $w configure -selectcolor $Priv($w,selectcolor)
759
+ }
760
+ }
761
+ unset -nocomplain Priv($w,selectcolor) Priv($w,aselectcolor)
762
+
763
+ # Restore the original button relief if it was changed by Tk. That is
764
+ # signaled by the existence of Priv($w,prelief).
765
+
766
+ if {[info exists Priv($w,relief)]} {
767
+ if {[info exists Priv($w,prelief)] && \
768
+ $Priv($w,prelief) eq [$w cget -relief]} {
769
+ $w configure -relief $Priv($w,relief)
770
+ }
771
+ unset -nocomplain Priv($w,relief) Priv($w,prelief)
772
+ }
773
+
774
+ set Priv(window) ""
775
+ }
776
+
777
+ return
778
+
779
+ # Local Variables:
780
+ # mode: tcl
781
+ # fill-column: 78
782
+ # End:
miniconda3/lib/tk8.6/choosedir.tcl ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # choosedir.tcl --
2
+ #
3
+ # Choose directory dialog implementation for Unix/Mac.
4
+ #
5
+ # Copyright (c) 1998-2000 by Scriptics Corporation.
6
+ # All rights reserved.
7
+
8
+ # Make sure the tk::dialog namespace, in which all dialogs should live, exists
9
+ namespace eval ::tk::dialog {}
10
+ namespace eval ::tk::dialog::file {}
11
+
12
+ # Make the chooseDir namespace inside the dialog namespace
13
+ namespace eval ::tk::dialog::file::chooseDir {
14
+ namespace import -force ::tk::msgcat::*
15
+ }
16
+
17
+ # ::tk::dialog::file::chooseDir:: --
18
+ #
19
+ # Implements the TK directory selection dialog.
20
+ #
21
+ # Arguments:
22
+ # args Options parsed by the procedure.
23
+ #
24
+ proc ::tk::dialog::file::chooseDir:: {args} {
25
+ variable ::tk::Priv
26
+ set dataName __tk_choosedir
27
+ upvar ::tk::dialog::file::$dataName data
28
+ Config $dataName $args
29
+
30
+ if {$data(-parent) eq "."} {
31
+ set w .$dataName
32
+ } else {
33
+ set w $data(-parent).$dataName
34
+ }
35
+
36
+ # (re)create the dialog box if necessary
37
+ #
38
+ if {![winfo exists $w]} {
39
+ ::tk::dialog::file::Create $w TkChooseDir
40
+ } elseif {[winfo class $w] ne "TkChooseDir"} {
41
+ destroy $w
42
+ ::tk::dialog::file::Create $w TkChooseDir
43
+ } else {
44
+ set data(dirMenuBtn) $w.contents.f1.menu
45
+ set data(dirMenu) $w.contents.f1.menu.menu
46
+ set data(upBtn) $w.contents.f1.up
47
+ set data(icons) $w.contents.icons
48
+ set data(ent) $w.contents.f2.ent
49
+ set data(okBtn) $w.contents.f2.ok
50
+ set data(cancelBtn) $w.contents.f2.cancel
51
+ set data(hiddenBtn) $w.contents.f2.hidden
52
+ }
53
+ if {$::tk::dialog::file::showHiddenBtn} {
54
+ $data(hiddenBtn) configure -state normal
55
+ grid $data(hiddenBtn)
56
+ } else {
57
+ $data(hiddenBtn) configure -state disabled
58
+ grid remove $data(hiddenBtn)
59
+ }
60
+
61
+ # When using -mustexist, manage the OK button state for validity
62
+ $data(okBtn) configure -state normal
63
+ if {$data(-mustexist)} {
64
+ $data(ent) configure -validate key \
65
+ -validatecommand [list ::tk::dialog::file::chooseDir::IsOK? $w %P]
66
+ } else {
67
+ $data(ent) configure -validate none
68
+ }
69
+
70
+ # Dialog boxes should be transient with respect to their parent,
71
+ # so that they will always stay on top of their parent window. However,
72
+ # some window managers will create the window as withdrawn if the parent
73
+ # window is withdrawn or iconified. Combined with the grab we put on the
74
+ # window, this can hang the entire application. Therefore we only make
75
+ # the dialog transient if the parent is viewable.
76
+
77
+ if {[winfo viewable [winfo toplevel $data(-parent)]] } {
78
+ wm transient $w $data(-parent)
79
+ }
80
+
81
+ trace add variable data(selectPath) write \
82
+ [list ::tk::dialog::file::SetPath $w]
83
+ $data(dirMenuBtn) configure \
84
+ -textvariable ::tk::dialog::file::${dataName}(selectPath)
85
+
86
+ set data(filter) "*"
87
+ set data(previousEntryText) ""
88
+ ::tk::dialog::file::UpdateWhenIdle $w
89
+
90
+ # Withdraw the window, then update all the geometry information
91
+ # so we know how big it wants to be, then center the window in the
92
+ # display (Motif style) and de-iconify it.
93
+
94
+ ::tk::PlaceWindow $w widget $data(-parent)
95
+ wm title $w $data(-title)
96
+
97
+ # Set a grab and claim the focus too.
98
+
99
+ ::tk::SetFocusGrab $w $data(ent)
100
+ $data(ent) delete 0 end
101
+ $data(ent) insert 0 $data(selectPath)
102
+ $data(ent) selection range 0 end
103
+ $data(ent) icursor end
104
+
105
+ # Wait for the user to respond, then restore the focus and
106
+ # return the index of the selected button. Restore the focus
107
+ # before deleting the window, since otherwise the window manager
108
+ # may take the focus away so we can't redirect it. Finally,
109
+ # restore any grab that was in effect.
110
+
111
+ vwait ::tk::Priv(selectFilePath)
112
+
113
+ ::tk::RestoreFocusGrab $w $data(ent) withdraw
114
+
115
+ # Cleanup traces on selectPath variable
116
+ #
117
+
118
+ foreach trace [trace info variable data(selectPath)] {
119
+ trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1]
120
+ }
121
+ if {[winfo exists $data(dirMenuBtn)]} {
122
+ $data(dirMenuBtn) configure -textvariable {}
123
+ }
124
+
125
+ # Return value to user
126
+ #
127
+
128
+ return $Priv(selectFilePath)
129
+ }
130
+
131
+ # ::tk::dialog::file::chooseDir::Config --
132
+ #
133
+ # Configures the Tk choosedir dialog according to the argument list
134
+ #
135
+ proc ::tk::dialog::file::chooseDir::Config {dataName argList} {
136
+ upvar ::tk::dialog::file::$dataName data
137
+
138
+ # 0: Delete all variable that were set on data(selectPath) the
139
+ # last time the file dialog is used. The traces may cause troubles
140
+ # if the dialog is now used with a different -parent option.
141
+ #
142
+ foreach trace [trace info variable data(selectPath)] {
143
+ trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1]
144
+ }
145
+
146
+ # 1: the configuration specs
147
+ #
148
+ set specs {
149
+ {-mustexist "" "" 0}
150
+ {-initialdir "" "" ""}
151
+ {-parent "" "" "."}
152
+ {-title "" "" ""}
153
+ }
154
+
155
+ # 2: default values depending on the type of the dialog
156
+ #
157
+ if {![info exists data(selectPath)]} {
158
+ # first time the dialog has been popped up
159
+ set data(selectPath) [pwd]
160
+ }
161
+
162
+ # 3: parse the arguments
163
+ #
164
+ tclParseConfigSpec ::tk::dialog::file::$dataName $specs "" $argList
165
+
166
+ if {$data(-title) eq ""} {
167
+ set data(-title) "[mc "Choose Directory"]"
168
+ }
169
+
170
+ # Stub out the -multiple value for the dialog; it doesn't make sense for
171
+ # choose directory dialogs, but we have to have something there because we
172
+ # share so much code with the file dialogs.
173
+ set data(-multiple) 0
174
+
175
+ # 4: set the default directory and selection according to the -initial
176
+ # settings
177
+ #
178
+ if {$data(-initialdir) ne ""} {
179
+ # Ensure that initialdir is an absolute path name.
180
+ if {[file isdirectory $data(-initialdir)]} {
181
+ set old [pwd]
182
+ cd $data(-initialdir)
183
+ set data(selectPath) [pwd]
184
+ cd $old
185
+ } else {
186
+ set data(selectPath) [pwd]
187
+ }
188
+ }
189
+
190
+ if {![winfo exists $data(-parent)]} {
191
+ return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
192
+ "bad window path name \"$data(-parent)\""
193
+ }
194
+ }
195
+
196
+ # Gets called when user presses Return in the "Selection" entry or presses OK.
197
+ #
198
+ proc ::tk::dialog::file::chooseDir::OkCmd {w} {
199
+ upvar ::tk::dialog::file::[winfo name $w] data
200
+
201
+ # This is the brains behind selecting non-existant directories. Here's
202
+ # the flowchart:
203
+ # 1. If the icon list has a selection, join it with the current dir,
204
+ # and return that value.
205
+ # 1a. If the icon list does not have a selection ...
206
+ # 2. If the entry is empty, do nothing.
207
+ # 3. If the entry contains an invalid directory, then...
208
+ # 3a. If the value is the same as last time through here, end dialog.
209
+ # 3b. If the value is different than last time, save it and return.
210
+ # 4. If entry contains a valid directory, then...
211
+ # 4a. If the value is the same as the current directory, end dialog.
212
+ # 4b. If the value is different from the current directory, change to
213
+ # that directory.
214
+
215
+ set selection [$data(icons) selection get]
216
+ if {[llength $selection] != 0} {
217
+ set iconText [$data(icons) get [lindex $selection 0]]
218
+ set iconText [file join $data(selectPath) $iconText]
219
+ Done $w $iconText
220
+ } else {
221
+ set text [$data(ent) get]
222
+ if {$text eq ""} {
223
+ return
224
+ }
225
+ set text [file join {*}[file split [string trim $text]]]
226
+ if {![file exists $text] || ![file isdirectory $text]} {
227
+ # Entry contains an invalid directory. If it's the same as the
228
+ # last time they came through here, reset the saved value and end
229
+ # the dialog. Otherwise, save the value (so we can do this test
230
+ # next time).
231
+ if {$text eq $data(previousEntryText)} {
232
+ set data(previousEntryText) ""
233
+ Done $w $text
234
+ } else {
235
+ set data(previousEntryText) $text
236
+ }
237
+ } else {
238
+ # Entry contains a valid directory. If it is the same as the
239
+ # current directory, end the dialog. Otherwise, change to that
240
+ # directory.
241
+ if {$text eq $data(selectPath)} {
242
+ Done $w $text
243
+ } else {
244
+ set data(selectPath) $text
245
+ }
246
+ }
247
+ }
248
+ return
249
+ }
250
+
251
+ # Change state of OK button to match -mustexist correctness of entry
252
+ #
253
+ proc ::tk::dialog::file::chooseDir::IsOK? {w text} {
254
+ upvar ::tk::dialog::file::[winfo name $w] data
255
+
256
+ set ok [file isdirectory $text]
257
+ $data(okBtn) configure -state [expr {$ok ? "normal" : "disabled"}]
258
+
259
+ # always return 1
260
+ return 1
261
+ }
262
+
263
+ proc ::tk::dialog::file::chooseDir::DblClick {w} {
264
+ upvar ::tk::dialog::file::[winfo name $w] data
265
+ set selection [$data(icons) selection get]
266
+ if {[llength $selection] != 0} {
267
+ set filenameFragment [$data(icons) get [lindex $selection 0]]
268
+ set file $data(selectPath)
269
+ if {[file isdirectory $file]} {
270
+ ::tk::dialog::file::ListInvoke $w [list $filenameFragment]
271
+ return
272
+ }
273
+ }
274
+ }
275
+
276
+ # Gets called when user browses the IconList widget (dragging mouse, arrow
277
+ # keys, etc)
278
+ #
279
+ proc ::tk::dialog::file::chooseDir::ListBrowse {w text} {
280
+ upvar ::tk::dialog::file::[winfo name $w] data
281
+
282
+ if {$text eq ""} {
283
+ return
284
+ }
285
+
286
+ set file [::tk::dialog::file::JoinFile $data(selectPath) $text]
287
+ $data(ent) delete 0 end
288
+ $data(ent) insert 0 $file
289
+ }
290
+
291
+ # ::tk::dialog::file::chooseDir::Done --
292
+ #
293
+ # Gets called when user has input a valid filename. Pops up a
294
+ # dialog box to confirm selection when necessary. Sets the
295
+ # Priv(selectFilePath) variable, which will break the "vwait"
296
+ # loop in tk_chooseDirectory and return the selected filename to the
297
+ # script that calls tk_getOpenFile or tk_getSaveFile
298
+ #
299
+ proc ::tk::dialog::file::chooseDir::Done {w {selectFilePath ""}} {
300
+ upvar ::tk::dialog::file::[winfo name $w] data
301
+ variable ::tk::Priv
302
+
303
+ if {$selectFilePath eq ""} {
304
+ set selectFilePath $data(selectPath)
305
+ }
306
+ if {$data(-mustexist) && ![file isdirectory $selectFilePath]} {
307
+ return
308
+ }
309
+ set Priv(selectFilePath) $selectFilePath
310
+ }
miniconda3/lib/tk8.6/clrpick.tcl ADDED
@@ -0,0 +1,694 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # clrpick.tcl --
2
+ #
3
+ # Color selection dialog for platforms that do not support a
4
+ # standard color selection dialog.
5
+ #
6
+ # Copyright (c) 1996 Sun Microsystems, Inc.
7
+ #
8
+ # See the file "license.terms" for information on usage and redistribution
9
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
+ #
11
+ # ToDo:
12
+ #
13
+ # (1): Find out how many free colors are left in the colormap and
14
+ # don't allocate too many colors.
15
+ # (2): Implement HSV color selection.
16
+ #
17
+
18
+ # Make sure namespaces exist
19
+ namespace eval ::tk {}
20
+ namespace eval ::tk::dialog {}
21
+ namespace eval ::tk::dialog::color {
22
+ namespace import ::tk::msgcat::*
23
+ }
24
+
25
+ # ::tk::dialog::color:: --
26
+ #
27
+ # Create a color dialog and let the user choose a color. This function
28
+ # should not be called directly. It is called by the tk_chooseColor
29
+ # function when a native color selector widget does not exist
30
+ #
31
+ proc ::tk::dialog::color:: {args} {
32
+ variable ::tk::Priv
33
+ set dataName __tk__color
34
+ upvar ::tk::dialog::color::$dataName data
35
+ set w .$dataName
36
+
37
+ # The lines variables track the start and end indices of the line
38
+ # elements in the colorbar canvases.
39
+ set data(lines,red,start) 0
40
+ set data(lines,red,last) -1
41
+ set data(lines,green,start) 0
42
+ set data(lines,green,last) -1
43
+ set data(lines,blue,start) 0
44
+ set data(lines,blue,last) -1
45
+
46
+ # This is the actual number of lines that are drawn in each color strip.
47
+ # Note that the bars may be of any width.
48
+ # However, NUM_COLORBARS must be a number that evenly divides 256.
49
+ # Such as 256, 128, 64, etc.
50
+ set data(NUM_COLORBARS) 16
51
+
52
+ # BARS_WIDTH is the number of pixels wide the color bar portion of the
53
+ # canvas is. This number must be a multiple of NUM_COLORBARS
54
+ set data(BARS_WIDTH) 160
55
+
56
+ # PLGN_WIDTH is the number of pixels wide of the triangular selection
57
+ # polygon. This also results in the definition of the padding on the
58
+ # left and right sides which is half of PLGN_WIDTH. Make this number even.
59
+ set data(PLGN_HEIGHT) 10
60
+
61
+ # PLGN_HEIGHT is the height of the selection polygon and the height of the
62
+ # selection rectangle at the bottom of the color bar. No restrictions.
63
+ set data(PLGN_WIDTH) 10
64
+
65
+ Config $dataName $args
66
+ InitValues $dataName
67
+
68
+ set sc [winfo screen $data(-parent)]
69
+ set winExists [winfo exists $w]
70
+ if {!$winExists || $sc ne [winfo screen $w]} {
71
+ if {$winExists} {
72
+ destroy $w
73
+ }
74
+ toplevel $w -class TkColorDialog -screen $sc
75
+ if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}
76
+ BuildDialog $w
77
+ }
78
+
79
+ # Dialog boxes should be transient with respect to their parent,
80
+ # so that they will always stay on top of their parent window. However,
81
+ # some window managers will create the window as withdrawn if the parent
82
+ # window is withdrawn or iconified. Combined with the grab we put on the
83
+ # window, this can hang the entire application. Therefore we only make
84
+ # the dialog transient if the parent is viewable.
85
+
86
+ if {[winfo viewable [winfo toplevel $data(-parent)]] } {
87
+ wm transient $w $data(-parent)
88
+ }
89
+
90
+ # 5. Withdraw the window, then update all the geometry information
91
+ # so we know how big it wants to be, then center the window in the
92
+ # display (Motif style) and de-iconify it.
93
+
94
+ ::tk::PlaceWindow $w widget $data(-parent)
95
+ wm title $w $data(-title)
96
+
97
+ # 6. Set a grab and claim the focus too.
98
+
99
+ ::tk::SetFocusGrab $w $data(okBtn)
100
+
101
+ # 7. Wait for the user to respond, then restore the focus and
102
+ # return the index of the selected button. Restore the focus
103
+ # before deleting the window, since otherwise the window manager
104
+ # may take the focus away so we can't redirect it. Finally,
105
+ # restore any grab that was in effect.
106
+
107
+ vwait ::tk::Priv(selectColor)
108
+ set result $Priv(selectColor)
109
+ ::tk::RestoreFocusGrab $w $data(okBtn)
110
+ unset data
111
+
112
+ return $result
113
+ }
114
+
115
+ # ::tk::dialog::color::InitValues --
116
+ #
117
+ # Get called during initialization or when user resets NUM_COLORBARS
118
+ #
119
+ proc ::tk::dialog::color::InitValues {dataName} {
120
+ upvar ::tk::dialog::color::$dataName data
121
+
122
+ # IntensityIncr is the difference in color intensity between a colorbar
123
+ # and its neighbors.
124
+ set data(intensityIncr) [expr {256 / $data(NUM_COLORBARS)}]
125
+
126
+ # ColorbarWidth is the width of each colorbar
127
+ set data(colorbarWidth) [expr {$data(BARS_WIDTH) / $data(NUM_COLORBARS)}]
128
+
129
+ # Indent is the width of the space at the left and right side of the
130
+ # colorbar. It is always half the selector polygon width, because the
131
+ # polygon extends into the space.
132
+ set data(indent) [expr {$data(PLGN_WIDTH) / 2}]
133
+
134
+ set data(colorPad) 2
135
+ set data(selPad) [expr {$data(PLGN_WIDTH) / 2}]
136
+
137
+ #
138
+ # minX is the x coordinate of the first colorbar
139
+ #
140
+ set data(minX) $data(indent)
141
+
142
+ #
143
+ # maxX is the x coordinate of the last colorbar
144
+ #
145
+ set data(maxX) [expr {$data(BARS_WIDTH) + $data(indent)-1}]
146
+
147
+ #
148
+ # canvasWidth is the width of the entire canvas, including the indents
149
+ #
150
+ set data(canvasWidth) [expr {$data(BARS_WIDTH) + $data(PLGN_WIDTH)}]
151
+
152
+ # Set the initial color, specified by -initialcolor, or the
153
+ # color chosen by the user the last time.
154
+ set data(selection) $data(-initialcolor)
155
+ set data(finalColor) $data(-initialcolor)
156
+ set rgb [winfo rgb . $data(selection)]
157
+
158
+ set data(red,intensity) [expr {[lindex $rgb 0]/0x100}]
159
+ set data(green,intensity) [expr {[lindex $rgb 1]/0x100}]
160
+ set data(blue,intensity) [expr {[lindex $rgb 2]/0x100}]
161
+ }
162
+
163
+ # ::tk::dialog::color::Config --
164
+ #
165
+ # Parses the command line arguments to tk_chooseColor
166
+ #
167
+ proc ::tk::dialog::color::Config {dataName argList} {
168
+ variable ::tk::Priv
169
+ upvar ::tk::dialog::color::$dataName data
170
+
171
+ # 1: the configuration specs
172
+ #
173
+ if {[info exists Priv(selectColor)] && $Priv(selectColor) ne ""} {
174
+ set defaultColor $Priv(selectColor)
175
+ } else {
176
+ set defaultColor [. cget -background]
177
+ }
178
+
179
+ set specs [list \
180
+ [list -initialcolor "" "" $defaultColor] \
181
+ [list -parent "" "" "."] \
182
+ [list -title "" "" [mc "Color"]] \
183
+ ]
184
+
185
+ # 2: parse the arguments
186
+ #
187
+ tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList
188
+
189
+ if {$data(-title) eq ""} {
190
+ set data(-title) " "
191
+ }
192
+ if {[catch {winfo rgb . $data(-initialcolor)} err]} {
193
+ return -code error -errorcode [list TK LOOKUP COLOR $data(-initialcolor)] \
194
+ $err
195
+ }
196
+
197
+ if {![winfo exists $data(-parent)]} {
198
+ return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
199
+ "bad window path name \"$data(-parent)\""
200
+ }
201
+ }
202
+
203
+ # ::tk::dialog::color::BuildDialog --
204
+ #
205
+ # Build the dialog.
206
+ #
207
+ proc ::tk::dialog::color::BuildDialog {w} {
208
+ upvar ::tk::dialog::color::[winfo name $w] data
209
+
210
+ # TopFrame contains the color strips and the color selection
211
+ #
212
+ set topFrame [frame $w.top -relief raised -bd 1]
213
+
214
+ # StripsFrame contains the colorstrips and the individual RGB entries
215
+ set stripsFrame [frame $topFrame.colorStrip]
216
+
217
+ set maxWidth [::tk::mcmaxamp &Red &Green &Blue]
218
+ set maxWidth [expr {$maxWidth<6 ? 6 : $maxWidth}]
219
+ set colorList {
220
+ red "&Red"
221
+ green "&Green"
222
+ blue "&Blue"
223
+ }
224
+ foreach {color l} $colorList {
225
+ # each f frame contains an [R|G|B] entry and the equiv. color strip.
226
+ set f [frame $stripsFrame.$color]
227
+
228
+ # The box frame contains the label and entry widget for an [R|G|B]
229
+ set box [frame $f.box]
230
+
231
+ ::tk::AmpWidget label $box.label -text "[mc $l]:" \
232
+ -width $maxWidth -anchor ne
233
+ bind $box.label <<AltUnderlined>> [list focus $box.entry]
234
+
235
+ entry $box.entry -textvariable \
236
+ ::tk::dialog::color::[winfo name $w]($color,intensity) \
237
+ -width 4
238
+ pack $box.label -side left -fill y -padx 2 -pady 3
239
+ pack $box.entry -side left -anchor n -pady 0
240
+ pack $box -side left -fill both
241
+
242
+ set height [expr {
243
+ [winfo reqheight $box.entry] -
244
+ 2*([$box.entry cget -highlightthickness] + [$box.entry cget -bd])
245
+ }]
246
+
247
+ canvas $f.color -height $height \
248
+ -width $data(BARS_WIDTH) -relief sunken -bd 2
249
+ canvas $f.sel -height $data(PLGN_HEIGHT) \
250
+ -width $data(canvasWidth) -highlightthickness 0
251
+ pack $f.color -expand yes -fill both
252
+ pack $f.sel -expand yes -fill both
253
+
254
+ pack $f -side top -fill x -padx 0 -pady 2
255
+
256
+ set data($color,entry) $box.entry
257
+ set data($color,col) $f.color
258
+ set data($color,sel) $f.sel
259
+
260
+ bind $data($color,col) <Configure> \
261
+ [list tk::dialog::color::DrawColorScale $w $color 1]
262
+ bind $data($color,col) <Enter> \
263
+ [list tk::dialog::color::EnterColorBar $w $color]
264
+ bind $data($color,col) <Leave> \
265
+ [list tk::dialog::color::LeaveColorBar $w $color]
266
+
267
+ bind $data($color,sel) <Enter> \
268
+ [list tk::dialog::color::EnterColorBar $w $color]
269
+ bind $data($color,sel) <Leave> \
270
+ [list tk::dialog::color::LeaveColorBar $w $color]
271
+
272
+ bind $box.entry <Return> [list tk::dialog::color::HandleRGBEntry $w]
273
+ }
274
+
275
+ pack $stripsFrame -side left -fill both -padx 4 -pady 10
276
+
277
+ # The selFrame contains a frame that demonstrates the currently
278
+ # selected color
279
+ #
280
+ set selFrame [frame $topFrame.sel]
281
+ set lab [::tk::AmpWidget label $selFrame.lab \
282
+ -text [mc "&Selection:"] -anchor sw]
283
+ set ent [entry $selFrame.ent \
284
+ -textvariable ::tk::dialog::color::[winfo name $w](selection) \
285
+ -width 16]
286
+ set f1 [frame $selFrame.f1 -relief sunken -bd 2]
287
+ set data(finalCanvas) [frame $f1.demo -bd 0 -width 100 -height 70]
288
+
289
+ pack $lab $ent -side top -fill x -padx 4 -pady 2
290
+ pack $f1 -expand yes -anchor nw -fill both -padx 6 -pady 10
291
+ pack $data(finalCanvas) -expand yes -fill both
292
+
293
+ bind $ent <Return> [list tk::dialog::color::HandleSelEntry $w]
294
+
295
+ pack $selFrame -side left -fill none -anchor nw
296
+ pack $topFrame -side top -expand yes -fill both -anchor nw
297
+
298
+ # the botFrame frame contains the buttons
299
+ #
300
+ set botFrame [frame $w.bot -relief raised -bd 1]
301
+
302
+ ::tk::AmpWidget button $botFrame.ok -text [mc "&OK"] \
303
+ -command [list tk::dialog::color::OkCmd $w]
304
+ ::tk::AmpWidget button $botFrame.cancel -text [mc "&Cancel"] \
305
+ -command [list tk::dialog::color::CancelCmd $w]
306
+
307
+ set data(okBtn) $botFrame.ok
308
+ set data(cancelBtn) $botFrame.cancel
309
+
310
+ grid x $botFrame.ok x $botFrame.cancel x -sticky ew
311
+ grid configure $botFrame.ok $botFrame.cancel -padx 10 -pady 10
312
+ grid columnconfigure $botFrame {0 4} -weight 1 -uniform space
313
+ grid columnconfigure $botFrame {1 3} -weight 1 -uniform button
314
+ grid columnconfigure $botFrame 2 -weight 2 -uniform space
315
+ pack $botFrame -side bottom -fill x
316
+
317
+ # Accelerator bindings
318
+ bind $lab <<AltUnderlined>> [list focus $ent]
319
+ bind $w <Escape> [list tk::ButtonInvoke $data(cancelBtn)]
320
+ bind $w <Alt-Key> [list tk::AltKeyInDialog $w %A]
321
+
322
+ wm protocol $w WM_DELETE_WINDOW [list tk::dialog::color::CancelCmd $w]
323
+ }
324
+
325
+ # ::tk::dialog::color::SetRGBValue --
326
+ #
327
+ # Sets the current selection of the dialog box
328
+ #
329
+ proc ::tk::dialog::color::SetRGBValue {w color} {
330
+ upvar ::tk::dialog::color::[winfo name $w] data
331
+
332
+ set data(red,intensity) [lindex $color 0]
333
+ set data(green,intensity) [lindex $color 1]
334
+ set data(blue,intensity) [lindex $color 2]
335
+
336
+ RedrawColorBars $w all
337
+
338
+ # Now compute the new x value of each colorbars pointer polygon
339
+ foreach color {red green blue} {
340
+ set x [RgbToX $w $data($color,intensity)]
341
+ MoveSelector $w $data($color,sel) $color $x 0
342
+ }
343
+ }
344
+
345
+ # ::tk::dialog::color::XToRgb --
346
+ #
347
+ # Converts a screen coordinate to intensity
348
+ #
349
+ proc ::tk::dialog::color::XToRgb {w x} {
350
+ upvar ::tk::dialog::color::[winfo name $w] data
351
+
352
+ set x [expr {($x * $data(intensityIncr))/ $data(colorbarWidth)}]
353
+ if {$x > 255} {
354
+ set x 255
355
+ }
356
+ return $x
357
+ }
358
+
359
+ # ::tk::dialog::color::RgbToX
360
+ #
361
+ # Converts an intensity to screen coordinate.
362
+ #
363
+ proc ::tk::dialog::color::RgbToX {w color} {
364
+ upvar ::tk::dialog::color::[winfo name $w] data
365
+
366
+ return [expr {($color * $data(colorbarWidth)/ $data(intensityIncr))}]
367
+ }
368
+
369
+ # ::tk::dialog::color::DrawColorScale --
370
+ #
371
+ # Draw color scale is called whenever the size of one of the color
372
+ # scale canvases is changed.
373
+ #
374
+ proc ::tk::dialog::color::DrawColorScale {w c {create 0}} {
375
+ upvar ::tk::dialog::color::[winfo name $w] data
376
+
377
+ # col: color bar canvas
378
+ # sel: selector canvas
379
+ set col $data($c,col)
380
+ set sel $data($c,sel)
381
+
382
+ # First handle the case that we are creating everything for the first time.
383
+ if {$create} {
384
+ # First remove all the lines that already exist.
385
+ if { $data(lines,$c,last) > $data(lines,$c,start)} {
386
+ for {set i $data(lines,$c,start)} \
387
+ {$i <= $data(lines,$c,last)} {incr i} {
388
+ $sel delete $i
389
+ }
390
+ }
391
+ # Delete the selector if it exists
392
+ if {[info exists data($c,index)]} {
393
+ $sel delete $data($c,index)
394
+ }
395
+
396
+ # Draw the selection polygons
397
+ CreateSelector $w $sel $c
398
+ $sel bind $data($c,index) <Button-1> \
399
+ [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1]
400
+ $sel bind $data($c,index) <B1-Motion> \
401
+ [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
402
+ $sel bind $data($c,index) <ButtonRelease-1> \
403
+ [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
404
+
405
+ set height [winfo height $col]
406
+ # Create an invisible region under the colorstrip to catch mouse clicks
407
+ # that aren't on the selector.
408
+ set data($c,clickRegion) [$sel create rectangle 0 0 \
409
+ $data(canvasWidth) $height -fill {} -outline {}]
410
+
411
+ bind $col <Button-1> \
412
+ [list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)]
413
+ bind $col <B1-Motion> \
414
+ [list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)]
415
+ bind $col <ButtonRelease-1> \
416
+ [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)]
417
+
418
+ $sel bind $data($c,clickRegion) <Button-1> \
419
+ [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)]
420
+ $sel bind $data($c,clickRegion) <B1-Motion> \
421
+ [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
422
+ $sel bind $data($c,clickRegion) <ButtonRelease-1> \
423
+ [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
424
+ } else {
425
+ # l is the canvas index of the first colorbar.
426
+ set l $data(lines,$c,start)
427
+ }
428
+
429
+ # Draw the color bars.
430
+ set highlightW [expr {[$col cget -highlightthickness] + [$col cget -bd]}]
431
+ for {set i 0} { $i < $data(NUM_COLORBARS)} { incr i} {
432
+ set intensity [expr {$i * $data(intensityIncr)}]
433
+ set startx [expr {$i * $data(colorbarWidth) + $highlightW}]
434
+ if {$c eq "red"} {
435
+ set color [format "#%02x%02x%02x" \
436
+ $intensity $data(green,intensity) $data(blue,intensity)]
437
+ } elseif {$c eq "green"} {
438
+ set color [format "#%02x%02x%02x" \
439
+ $data(red,intensity) $intensity $data(blue,intensity)]
440
+ } else {
441
+ set color [format "#%02x%02x%02x" \
442
+ $data(red,intensity) $data(green,intensity) $intensity]
443
+ }
444
+
445
+ if {$create} {
446
+ set index [$col create rect $startx $highlightW \
447
+ [expr {$startx +$data(colorbarWidth)}] \
448
+ [expr {[winfo height $col] + $highlightW}] \
449
+ -fill $color -outline $color]
450
+ } else {
451
+ $col itemconfigure $l -fill $color -outline $color
452
+ incr l
453
+ }
454
+ }
455
+ $sel raise $data($c,index)
456
+
457
+ if {$create} {
458
+ set data(lines,$c,last) $index
459
+ set data(lines,$c,start) [expr {$index - $data(NUM_COLORBARS) + 1}]
460
+ }
461
+
462
+ RedrawFinalColor $w
463
+ }
464
+
465
+ # ::tk::dialog::color::CreateSelector --
466
+ #
467
+ # Creates and draws the selector polygon at the position
468
+ # $data($c,intensity).
469
+ #
470
+ proc ::tk::dialog::color::CreateSelector {w sel c } {
471
+ upvar ::tk::dialog::color::[winfo name $w] data
472
+ set data($c,index) [$sel create polygon \
473
+ 0 $data(PLGN_HEIGHT) \
474
+ $data(PLGN_WIDTH) $data(PLGN_HEIGHT) \
475
+ $data(indent) 0]
476
+ set data($c,x) [RgbToX $w $data($c,intensity)]
477
+ $sel move $data($c,index) $data($c,x) 0
478
+ }
479
+
480
+ # ::tk::dialog::color::RedrawFinalColor
481
+ #
482
+ # Combines the intensities of the three colors into the final color
483
+ #
484
+ proc ::tk::dialog::color::RedrawFinalColor {w} {
485
+ upvar ::tk::dialog::color::[winfo name $w] data
486
+
487
+ set color [format "#%02x%02x%02x" $data(red,intensity) \
488
+ $data(green,intensity) $data(blue,intensity)]
489
+
490
+ $data(finalCanvas) configure -bg $color
491
+ set data(finalColor) $color
492
+ set data(selection) $color
493
+ set data(finalRGB) [list \
494
+ $data(red,intensity) \
495
+ $data(green,intensity) \
496
+ $data(blue,intensity)]
497
+ }
498
+
499
+ # ::tk::dialog::color::RedrawColorBars --
500
+ #
501
+ # Only redraws the colors on the color strips that were not manipulated.
502
+ # Params: color of colorstrip that changed. If color is not [red|green|blue]
503
+ # Then all colorstrips will be updated
504
+ #
505
+ proc ::tk::dialog::color::RedrawColorBars {w colorChanged} {
506
+ upvar ::tk::dialog::color::[winfo name $w] data
507
+
508
+ switch $colorChanged {
509
+ red {
510
+ DrawColorScale $w green
511
+ DrawColorScale $w blue
512
+ }
513
+ green {
514
+ DrawColorScale $w red
515
+ DrawColorScale $w blue
516
+ }
517
+ blue {
518
+ DrawColorScale $w red
519
+ DrawColorScale $w green
520
+ }
521
+ default {
522
+ DrawColorScale $w red
523
+ DrawColorScale $w green
524
+ DrawColorScale $w blue
525
+ }
526
+ }
527
+ RedrawFinalColor $w
528
+ }
529
+
530
+ #----------------------------------------------------------------------
531
+ # Event handlers
532
+ #----------------------------------------------------------------------
533
+
534
+ # ::tk::dialog::color::StartMove --
535
+ #
536
+ # Handles a mousedown button event over the selector polygon.
537
+ # Adds the bindings for moving the mouse while the button is
538
+ # pressed. Sets the binding for the button-release event.
539
+ #
540
+ # Params: sel is the selector canvas window, color is the color of the strip.
541
+ #
542
+ proc ::tk::dialog::color::StartMove {w sel color x delta {dontMove 0}} {
543
+ upvar ::tk::dialog::color::[winfo name $w] data
544
+
545
+ if {!$dontMove} {
546
+ MoveSelector $w $sel $color $x $delta
547
+ }
548
+ }
549
+
550
+ # ::tk::dialog::color::MoveSelector --
551
+ #
552
+ # Moves the polygon selector so that its middle point has the same
553
+ # x value as the specified x. If x is outside the bounds [0,255],
554
+ # the selector is set to the closest endpoint.
555
+ #
556
+ # Params: sel is the selector canvas, c is [red|green|blue]
557
+ # x is a x-coordinate.
558
+ #
559
+ proc ::tk::dialog::color::MoveSelector {w sel color x delta} {
560
+ upvar ::tk::dialog::color::[winfo name $w] data
561
+
562
+ incr x -$delta
563
+
564
+ if { $x < 0 } {
565
+ set x 0
566
+ } elseif { $x > $data(BARS_WIDTH)} {
567
+ set x $data(BARS_WIDTH)
568
+ }
569
+ set diff [expr {$x - $data($color,x)}]
570
+ $sel move $data($color,index) $diff 0
571
+ set data($color,x) [expr {$data($color,x) + $diff}]
572
+
573
+ # Return the x value that it was actually set at
574
+ return $x
575
+ }
576
+
577
+ # ::tk::dialog::color::ReleaseMouse
578
+ #
579
+ # Removes mouse tracking bindings, updates the colorbars.
580
+ #
581
+ # Params: sel is the selector canvas, color is the color of the strip,
582
+ # x is the x-coord of the mouse.
583
+ #
584
+ proc ::tk::dialog::color::ReleaseMouse {w sel color x delta} {
585
+ upvar ::tk::dialog::color::[winfo name $w] data
586
+
587
+ set x [MoveSelector $w $sel $color $x $delta]
588
+
589
+ # Determine exactly what color we are looking at.
590
+ set data($color,intensity) [XToRgb $w $x]
591
+
592
+ RedrawColorBars $w $color
593
+ }
594
+
595
+ # ::tk::dialog::color::ResizeColorbars --
596
+ #
597
+ # Completely redraws the colorbars, including resizing the
598
+ # colorstrips
599
+ #
600
+ proc ::tk::dialog::color::ResizeColorBars {w} {
601
+ upvar ::tk::dialog::color::[winfo name $w] data
602
+
603
+ if {
604
+ ($data(BARS_WIDTH) < $data(NUM_COLORBARS)) ||
605
+ (($data(BARS_WIDTH) % $data(NUM_COLORBARS)) != 0)
606
+ } then {
607
+ set data(BARS_WIDTH) $data(NUM_COLORBARS)
608
+ }
609
+ InitValues [winfo name $w]
610
+ foreach color {red green blue} {
611
+ $data($color,col) configure -width $data(canvasWidth)
612
+ DrawColorScale $w $color 1
613
+ }
614
+ }
615
+
616
+ # ::tk::dialog::color::HandleSelEntry --
617
+ #
618
+ # Handles the return keypress event in the "Selection:" entry
619
+ #
620
+ proc ::tk::dialog::color::HandleSelEntry {w} {
621
+ upvar ::tk::dialog::color::[winfo name $w] data
622
+
623
+ set text [string trim $data(selection)]
624
+ # Check to make sure that the color is valid
625
+ if {[catch {set color [winfo rgb . $text]} ]} {
626
+ set data(selection) $data(finalColor)
627
+ return
628
+ }
629
+
630
+ set R [expr {[lindex $color 0]/0x100}]
631
+ set G [expr {[lindex $color 1]/0x100}]
632
+ set B [expr {[lindex $color 2]/0x100}]
633
+
634
+ SetRGBValue $w "$R $G $B"
635
+ set data(selection) $text
636
+ }
637
+
638
+ # ::tk::dialog::color::HandleRGBEntry --
639
+ #
640
+ # Handles the return keypress event in the R, G or B entry
641
+ #
642
+ proc ::tk::dialog::color::HandleRGBEntry {w} {
643
+ upvar ::tk::dialog::color::[winfo name $w] data
644
+
645
+ foreach c {red green blue} {
646
+ if {[catch {
647
+ set data($c,intensity) [expr {int($data($c,intensity))}]
648
+ }]} {
649
+ set data($c,intensity) 0
650
+ }
651
+
652
+ if {$data($c,intensity) < 0} {
653
+ set data($c,intensity) 0
654
+ }
655
+ if {$data($c,intensity) > 255} {
656
+ set data($c,intensity) 255
657
+ }
658
+ }
659
+
660
+ SetRGBValue $w "$data(red,intensity) \
661
+ $data(green,intensity) $data(blue,intensity)"
662
+ }
663
+
664
+ # mouse cursor enters a color bar
665
+ #
666
+ proc ::tk::dialog::color::EnterColorBar {w color} {
667
+ upvar ::tk::dialog::color::[winfo name $w] data
668
+
669
+ $data($color,sel) itemconfigure $data($color,index) -fill red
670
+ }
671
+
672
+ # mouse leaves enters a color bar
673
+ #
674
+ proc ::tk::dialog::color::LeaveColorBar {w color} {
675
+ upvar ::tk::dialog::color::[winfo name $w] data
676
+
677
+ $data($color,sel) itemconfigure $data($color,index) -fill black
678
+ }
679
+
680
+ # user hits OK button
681
+ #
682
+ proc ::tk::dialog::color::OkCmd {w} {
683
+ variable ::tk::Priv
684
+ upvar ::tk::dialog::color::[winfo name $w] data
685
+
686
+ set Priv(selectColor) $data(finalColor)
687
+ }
688
+
689
+ # user hits Cancel button or destroys window
690
+ #
691
+ proc ::tk::dialog::color::CancelCmd {w} {
692
+ variable ::tk::Priv
693
+ set Priv(selectColor) ""
694
+ }
miniconda3/lib/tk8.6/comdlg.tcl ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # comdlg.tcl --
2
+ #
3
+ # Some functions needed for the common dialog boxes. Probably need to go
4
+ # in a different file.
5
+ #
6
+ # Copyright (c) 1996 Sun Microsystems, Inc.
7
+ #
8
+ # See the file "license.terms" for information on usage and redistribution
9
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
+ #
11
+
12
+ # tclParseConfigSpec --
13
+ #
14
+ # Parses a list of "-option value" pairs. If all options and
15
+ # values are legal, the values are stored in
16
+ # $data($option). Otherwise an error message is returned. When
17
+ # an error happens, the data() array may have been partially
18
+ # modified, but all the modified members of the data(0 array are
19
+ # guaranteed to have valid values. This is different than
20
+ # Tk_ConfigureWidget() which does not modify the value of a
21
+ # widget record if any error occurs.
22
+ #
23
+ # Arguments:
24
+ #
25
+ # w = widget record to modify. Must be the pathname of a widget.
26
+ #
27
+ # specs = {
28
+ # {-commandlineswitch resourceName ResourceClass defaultValue verifier}
29
+ # {....}
30
+ # }
31
+ #
32
+ # flags = a list of flags. Currently supported flags are:
33
+ # DONTSETDEFAULTS = skip default values setting
34
+ #
35
+ # argList = The list of "-option value" pairs.
36
+ #
37
+ proc tclParseConfigSpec {w specs flags argList} {
38
+ upvar #0 $w data
39
+
40
+ # 1: Put the specs in associative arrays for faster access
41
+ #
42
+ foreach spec $specs {
43
+ if {[llength $spec] < 4} {
44
+ return -code error -errorcode {TK VALUE CONFIG_SPEC} \
45
+ "\"spec\" should contain 5 or 4 elements"
46
+ }
47
+ set cmdsw [lindex $spec 0]
48
+ set cmd($cmdsw) ""
49
+ set rname($cmdsw) [lindex $spec 1]
50
+ set rclass($cmdsw) [lindex $spec 2]
51
+ set def($cmdsw) [lindex $spec 3]
52
+ set verproc($cmdsw) [lindex $spec 4]
53
+ }
54
+
55
+ if {[llength $argList] & 1} {
56
+ set cmdsw [lindex $argList end]
57
+ if {![info exists cmd($cmdsw)]} {
58
+ return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \
59
+ "bad option \"$cmdsw\": must be [tclListValidFlags cmd]"
60
+ }
61
+ return -code error -errorcode {TK VALUE_MISSING} \
62
+ "value for \"$cmdsw\" missing"
63
+ }
64
+
65
+ # 2: set the default values
66
+ #
67
+ if {"DONTSETDEFAULTS" ni $flags} {
68
+ foreach cmdsw [array names cmd] {
69
+ set data($cmdsw) $def($cmdsw)
70
+ }
71
+ }
72
+
73
+ # 3: parse the argument list
74
+ #
75
+ foreach {cmdsw value} $argList {
76
+ if {![info exists cmd($cmdsw)]} {
77
+ return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \
78
+ "bad option \"$cmdsw\": must be [tclListValidFlags cmd]"
79
+ }
80
+ set data($cmdsw) $value
81
+ }
82
+
83
+ # Done!
84
+ }
85
+
86
+ proc tclListValidFlags {v} {
87
+ upvar $v cmd
88
+
89
+ set len [llength [array names cmd]]
90
+ set i 1
91
+ set separator ""
92
+ set errormsg ""
93
+ foreach cmdsw [lsort [array names cmd]] {
94
+ append errormsg "$separator$cmdsw"
95
+ incr i
96
+ if {$i == $len} {
97
+ set separator ", or "
98
+ } else {
99
+ set separator ", "
100
+ }
101
+ }
102
+ return $errormsg
103
+ }
104
+
105
+ #----------------------------------------------------------------------
106
+ #
107
+ # Focus Group
108
+ #
109
+ # Focus groups are used to handle the user's focusing actions inside a
110
+ # toplevel.
111
+ #
112
+ # One example of using focus groups is: when the user focuses on an
113
+ # entry, the text in the entry is highlighted and the cursor is put to
114
+ # the end of the text. When the user changes focus to another widget,
115
+ # the text in the previously focused entry is validated.
116
+ #
117
+ #----------------------------------------------------------------------
118
+
119
+
120
+ # ::tk::FocusGroup_Create --
121
+ #
122
+ # Create a focus group. All the widgets in a focus group must be
123
+ # within the same focus toplevel. Each toplevel can have only
124
+ # one focus group, which is identified by the name of the
125
+ # toplevel widget.
126
+ #
127
+ proc ::tk::FocusGroup_Create {t} {
128
+ variable ::tk::Priv
129
+ if {[winfo toplevel $t] ne $t} {
130
+ return -code error -errorcode [list TK LOOKUP TOPLEVEL $t] \
131
+ "$t is not a toplevel window"
132
+ }
133
+ if {![info exists Priv(fg,$t)]} {
134
+ set Priv(fg,$t) 1
135
+ set Priv(focus,$t) ""
136
+ bind $t <FocusIn> [list tk::FocusGroup_In $t %W %d]
137
+ bind $t <FocusOut> [list tk::FocusGroup_Out $t %W %d]
138
+ bind $t <Destroy> [list tk::FocusGroup_Destroy $t %W]
139
+ }
140
+ }
141
+
142
+ # ::tk::FocusGroup_BindIn --
143
+ #
144
+ # Add a widget into the "FocusIn" list of the focus group. The $cmd will be
145
+ # called when the widget is focused on by the user.
146
+ #
147
+ proc ::tk::FocusGroup_BindIn {t w cmd} {
148
+ variable FocusIn
149
+ variable ::tk::Priv
150
+ if {![info exists Priv(fg,$t)]} {
151
+ return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \
152
+ "focus group \"$t\" doesn't exist"
153
+ }
154
+ set FocusIn($t,$w) $cmd
155
+ }
156
+
157
+
158
+ # ::tk::FocusGroup_BindOut --
159
+ #
160
+ # Add a widget into the "FocusOut" list of the focus group. The
161
+ # $cmd will be called when the widget loses the focus (User
162
+ # types Tab or click on another widget).
163
+ #
164
+ proc ::tk::FocusGroup_BindOut {t w cmd} {
165
+ variable FocusOut
166
+ variable ::tk::Priv
167
+ if {![info exists Priv(fg,$t)]} {
168
+ return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \
169
+ "focus group \"$t\" doesn't exist"
170
+ }
171
+ set FocusOut($t,$w) $cmd
172
+ }
173
+
174
+ # ::tk::FocusGroup_Destroy --
175
+ #
176
+ # Cleans up when members of the focus group is deleted, or when the
177
+ # toplevel itself gets deleted.
178
+ #
179
+ proc ::tk::FocusGroup_Destroy {t w} {
180
+ variable FocusIn
181
+ variable FocusOut
182
+ variable ::tk::Priv
183
+
184
+ if {$t eq $w} {
185
+ unset Priv(fg,$t)
186
+ unset Priv(focus,$t)
187
+
188
+ foreach name [array names FocusIn $t,*] {
189
+ unset FocusIn($name)
190
+ }
191
+ foreach name [array names FocusOut $t,*] {
192
+ unset FocusOut($name)
193
+ }
194
+ } else {
195
+ if {[info exists Priv(focus,$t)] && ($Priv(focus,$t) eq $w)} {
196
+ set Priv(focus,$t) ""
197
+ }
198
+ unset -nocomplain FocusIn($t,$w) FocusOut($t,$w)
199
+ }
200
+ }
201
+
202
+ # ::tk::FocusGroup_In --
203
+ #
204
+ # Handles the <FocusIn> event. Calls the FocusIn command for the newly
205
+ # focused widget in the focus group.
206
+ #
207
+ proc ::tk::FocusGroup_In {t w detail} {
208
+ variable FocusIn
209
+ variable ::tk::Priv
210
+
211
+ if {$detail ne "NotifyNonlinear" && $detail ne "NotifyNonlinearVirtual"} {
212
+ # This is caused by mouse moving out&in of the window *or*
213
+ # ordinary keypresses some window managers (ie: CDE [Bug: 2960]).
214
+ return
215
+ }
216
+ if {![info exists FocusIn($t,$w)]} {
217
+ set FocusIn($t,$w) ""
218
+ return
219
+ }
220
+ if {![info exists Priv(focus,$t)]} {
221
+ return
222
+ }
223
+ if {$Priv(focus,$t) eq $w} {
224
+ # This is already in focus
225
+ #
226
+ return
227
+ } else {
228
+ set Priv(focus,$t) $w
229
+ eval $FocusIn($t,$w)
230
+ }
231
+ }
232
+
233
+ # ::tk::FocusGroup_Out --
234
+ #
235
+ # Handles the <FocusOut> event. Checks if this is really a lose
236
+ # focus event, not one generated by the mouse moving out of the
237
+ # toplevel window. Calls the FocusOut command for the widget
238
+ # who loses its focus.
239
+ #
240
+ proc ::tk::FocusGroup_Out {t w detail} {
241
+ variable FocusOut
242
+ variable ::tk::Priv
243
+
244
+ if {$detail ne "NotifyNonlinear" && $detail ne "NotifyNonlinearVirtual"} {
245
+ # This is caused by mouse moving out of the window
246
+ return
247
+ }
248
+ if {![info exists Priv(focus,$t)]} {
249
+ return
250
+ }
251
+ if {![info exists FocusOut($t,$w)]} {
252
+ return
253
+ } else {
254
+ eval $FocusOut($t,$w)
255
+ set Priv(focus,$t) ""
256
+ }
257
+ }
258
+
259
+ # ::tk::FDGetFileTypes --
260
+ #
261
+ # Process the string given by the -filetypes option of the file
262
+ # dialogs. Similar to the C function TkGetFileFilters() on the Mac
263
+ # and Windows platform.
264
+ #
265
+ proc ::tk::FDGetFileTypes {string} {
266
+ foreach t $string {
267
+ if {[llength $t] < 2 || [llength $t] > 3} {
268
+ return -code error -errorcode {TK VALUE FILE_TYPE} \
269
+ "bad file type \"$t\", should be \"typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?\""
270
+ }
271
+ lappend fileTypes([lindex $t 0]) {*}[lindex $t 1]
272
+ }
273
+
274
+ set types {}
275
+ foreach t $string {
276
+ set label [lindex $t 0]
277
+ set exts {}
278
+
279
+ if {[info exists hasDoneType($label)]} {
280
+ continue
281
+ }
282
+
283
+ # Validate each macType. This is to agree with the
284
+ # behaviour of TkGetFileFilters(). This list may be
285
+ # empty.
286
+ foreach macType [lindex $t 2] {
287
+ if {[string length $macType] != 4} {
288
+ return -code error -errorcode {TK VALUE MAC_TYPE} \
289
+ "bad Macintosh file type \"$macType\""
290
+ }
291
+ }
292
+
293
+ set name "$label \("
294
+ set sep ""
295
+ set doAppend 1
296
+ foreach ext $fileTypes($label) {
297
+ if {$ext eq ""} {
298
+ continue
299
+ }
300
+ regsub {^[.]} $ext "*." ext
301
+ if {![info exists hasGotExt($label,$ext)]} {
302
+ if {$doAppend} {
303
+ if {[string length $sep] && [string length $name]>40} {
304
+ set doAppend 0
305
+ append name $sep...
306
+ } else {
307
+ append name $sep$ext
308
+ }
309
+ }
310
+ lappend exts $ext
311
+ set hasGotExt($label,$ext) 1
312
+ }
313
+ set sep ","
314
+ }
315
+ append name "\)"
316
+ lappend types [list $name $exts]
317
+
318
+ set hasDoneType($label) 1
319
+ }
320
+
321
+ return $types
322
+ }
miniconda3/lib/tk8.6/console.tcl ADDED
@@ -0,0 +1,1154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # console.tcl --
2
+ #
3
+ # This code constructs the console window for an application. It
4
+ # can be used by non-unix systems that do not have built-in support
5
+ # for shells.
6
+ #
7
+ # Copyright (c) 1995-1997 Sun Microsystems, Inc.
8
+ # Copyright (c) 1998-2000 Ajuba Solutions.
9
+ # Copyright (c) 2007-2008 Daniel A. Steffen <das@users.sourceforge.net>
10
+ #
11
+ # See the file "license.terms" for information on usage and redistribution
12
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
+ #
14
+
15
+ # TODO: history - remember partially written command
16
+
17
+ namespace eval ::tk::console {
18
+ variable blinkTime 500 ; # msecs to blink braced range for
19
+ variable blinkRange 1 ; # enable blinking of the entire braced range
20
+ variable magicKeys 1 ; # enable brace matching and proc/var recognition
21
+ variable maxLines 600 ; # maximum # of lines buffered in console
22
+ variable showMatches 1 ; # show multiple expand matches
23
+ variable useFontchooser [llength [info command ::tk::fontchooser]]
24
+ variable inPlugin [info exists embed_args]
25
+ variable defaultPrompt ; # default prompt if tcl_prompt1 isn't used
26
+
27
+ if {$inPlugin} {
28
+ set defaultPrompt {subst {[history nextid] % }}
29
+ } else {
30
+ set defaultPrompt {subst {([file tail [pwd]]) [history nextid] % }}
31
+ }
32
+ }
33
+
34
+ # simple compat function for tkcon code added for this console
35
+ interp alias {} EvalAttached {} consoleinterp eval
36
+
37
+ # ::tk::ConsoleInit --
38
+ # This procedure constructs and configures the console windows.
39
+ #
40
+ # Arguments:
41
+ # None.
42
+
43
+ proc ::tk::ConsoleInit {} {
44
+ if {![consoleinterp eval {set tcl_interactive}]} {
45
+ wm withdraw .
46
+ }
47
+
48
+ if {[tk windowingsystem] eq "aqua"} {
49
+ set mod "Cmd"
50
+ } else {
51
+ set mod "Ctrl"
52
+ }
53
+
54
+ if {[catch {menu .menubar} err]} {
55
+ bgerror "INIT: $err"
56
+ }
57
+ AmpMenuArgs .menubar add cascade -label [mc &File] -menu .menubar.file
58
+ AmpMenuArgs .menubar add cascade -label [mc &Edit] -menu .menubar.edit
59
+
60
+ menu .menubar.file -tearoff 0
61
+ AmpMenuArgs .menubar.file add command -label [mc "&Source..."] \
62
+ -command {tk::ConsoleSource}
63
+ AmpMenuArgs .menubar.file add command -label [mc "&Hide Console"] \
64
+ -command {wm withdraw .}
65
+ AmpMenuArgs .menubar.file add command -label [mc "&Clear Console"] \
66
+ -command {.console delete 1.0 "promptEnd linestart"}
67
+ if {[tk windowingsystem] ne "aqua"} {
68
+ AmpMenuArgs .menubar.file add command -label [mc E&xit] -command {exit}
69
+ }
70
+
71
+ menu .menubar.edit -tearoff 0
72
+ AmpMenuArgs .menubar.edit add command -label [mc Cu&t] -accel "$mod+X"\
73
+ -command {event generate .console <<Cut>>}
74
+ AmpMenuArgs .menubar.edit add command -label [mc &Copy] -accel "$mod+C"\
75
+ -command {event generate .console <<Copy>>}
76
+ AmpMenuArgs .menubar.edit add command -label [mc P&aste] -accel "$mod+V"\
77
+ -command {event generate .console <<Paste>>}
78
+
79
+ if {[tk windowingsystem] ne "win32"} {
80
+ AmpMenuArgs .menubar.edit add command -label [mc Cl&ear] \
81
+ -command {event generate .console <<Clear>>}
82
+ } else {
83
+ AmpMenuArgs .menubar.edit add command -label [mc &Delete] \
84
+ -command {event generate .console <<Clear>>} -accel "Del"
85
+
86
+ AmpMenuArgs .menubar add cascade -label [mc &Help] -menu .menubar.help
87
+ menu .menubar.help -tearoff 0
88
+ AmpMenuArgs .menubar.help add command -label [mc &About...] \
89
+ -command tk::ConsoleAbout
90
+ }
91
+
92
+ AmpMenuArgs .menubar.edit add separator
93
+ if {$::tk::console::useFontchooser} {
94
+ if {[tk windowingsystem] eq "aqua"} {
95
+ .menubar.edit add command -label tk_choose_font_marker
96
+ set index [.menubar.edit index tk_choose_font_marker]
97
+ .menubar.edit entryconfigure $index \
98
+ -label [mc "Show Fonts"]\
99
+ -accelerator "$mod-T"\
100
+ -command [list ::tk::console::FontchooserToggle]
101
+ bind Console <<TkFontchooserVisibility>> \
102
+ [list ::tk::console::FontchooserVisibility $index]
103
+ ::tk::console::FontchooserVisibility $index
104
+ } else {
105
+ AmpMenuArgs .menubar.edit add command -label [mc "&Font..."] \
106
+ -command [list ::tk::console::FontchooserToggle]
107
+ }
108
+ bind Console <FocusIn> [list ::tk::console::FontchooserFocus %W 1]
109
+ bind Console <FocusOut> [list ::tk::console::FontchooserFocus %W 0]
110
+ }
111
+ AmpMenuArgs .menubar.edit add command -label [mc "&Increase Font Size"] \
112
+ -accel "$mod++" -command {event generate .console <<Console_FontSizeIncr>>}
113
+ AmpMenuArgs .menubar.edit add command -label [mc "&Decrease Font Size"] \
114
+ -accel "$mod+-" -command {event generate .console <<Console_FontSizeDecr>>}
115
+ AmpMenuArgs .menubar.edit add command -label [mc "Fit To Screen Width"] \
116
+ -command {event generate .console <<Console_FitScreenWidth>>}
117
+
118
+ if {[tk windowingsystem] eq "aqua"} {
119
+ .menubar add cascade -label [mc Window] -menu [menu .menubar.window]
120
+ .menubar add cascade -label [mc Help] -menu [menu .menubar.help]
121
+ }
122
+
123
+ . configure -menu .menubar
124
+
125
+ # See if we can find a better font than the TkFixedFont
126
+ catch {font create TkConsoleFont {*}[font configure TkFixedFont]}
127
+ set families [font families]
128
+ switch -exact -- [tk windowingsystem] {
129
+ aqua { set preferred {Monaco 10} }
130
+ win32 { set preferred {ProFontWindows 8 Consolas 8} }
131
+ default { set preferred {} }
132
+ }
133
+ foreach {family size} $preferred {
134
+ if {$family in $families} {
135
+ font configure TkConsoleFont -family $family -size $size
136
+ break
137
+ }
138
+ }
139
+
140
+ # Provide the right border for the text widget (platform dependent).
141
+ ::ttk::style layout ConsoleFrame {
142
+ Entry.field -sticky news -border 1 -children {
143
+ ConsoleFrame.padding -sticky news
144
+ }
145
+ }
146
+ ::ttk::frame .consoleframe -style ConsoleFrame
147
+
148
+ set con [text .console -yscrollcommand [list .sb set] -setgrid true \
149
+ -borderwidth 0 -highlightthickness 0 -font TkConsoleFont]
150
+ if {[tk windowingsystem] eq "aqua"} {
151
+ scrollbar .sb -command [list $con yview]
152
+ } else {
153
+ ::ttk::scrollbar .sb -command [list $con yview]
154
+ }
155
+ pack .sb -in .consoleframe -fill both -side right -padx 1 -pady 1
156
+ pack $con -in .consoleframe -fill both -expand 1 -side left -padx 1 -pady 1
157
+ pack .consoleframe -fill both -expand 1 -side left
158
+
159
+ ConsoleBind $con
160
+
161
+ $con tag configure stderr -foreground red
162
+ $con tag configure stdin -foreground blue
163
+ $con tag configure prompt -foreground \#8F4433
164
+ $con tag configure proc -foreground \#008800
165
+ $con tag configure var -background \#FFC0D0
166
+ $con tag raise sel
167
+ $con tag configure blink -background \#FFFF00
168
+ $con tag configure find -background \#FFFF00
169
+
170
+ focus $con
171
+
172
+ # Avoid listing this console in [winfo interps]
173
+ if {[info command ::send] eq "::send"} {rename ::send {}}
174
+
175
+ wm protocol . WM_DELETE_WINDOW { wm withdraw . }
176
+ wm title . [mc "Console"]
177
+ flush stdout
178
+ $con mark set output [$con index "end - 1 char"]
179
+ tk::TextSetCursor $con end
180
+ $con mark set promptEnd insert
181
+ $con mark gravity promptEnd left
182
+
183
+ # A variant of ConsolePrompt to avoid a 'puts' call
184
+ set w $con
185
+ set temp [$w index "end - 1 char"]
186
+ $w mark set output end
187
+ if {![consoleinterp eval "info exists tcl_prompt1"]} {
188
+ set string [EvalAttached $::tk::console::defaultPrompt]
189
+ $w insert output $string stdout
190
+ }
191
+ $w mark set output $temp
192
+ ::tk::TextSetCursor $w end
193
+ $w mark set promptEnd insert
194
+ $w mark gravity promptEnd left
195
+
196
+ if {[tk windowingsystem] ne "aqua"} {
197
+ # Subtle work-around to erase the '% ' that tclMain.c prints out
198
+ after idle [subst -nocommand {
199
+ if {[$con get 1.0 output] eq "% "} { $con delete 1.0 output }
200
+ }]
201
+ }
202
+ }
203
+
204
+ # ::tk::ConsoleSource --
205
+ #
206
+ # Prompts the user for a file to source in the main interpreter.
207
+ #
208
+ # Arguments:
209
+ # None.
210
+
211
+ proc ::tk::ConsoleSource {} {
212
+ set filename [tk_getOpenFile -defaultextension .tcl -parent . \
213
+ -title [mc "Select a file to source"] \
214
+ -filetypes [list \
215
+ [list [mc "Tcl Scripts"] .tcl] \
216
+ [list [mc "All Files"] *]]]
217
+ if {$filename ne ""} {
218
+ set cmd [list source -encoding utf-8 $filename]
219
+ if {[catch {consoleinterp eval $cmd} result]} {
220
+ ConsoleOutput stderr "$result\n"
221
+ }
222
+ }
223
+ }
224
+
225
+ # ::tk::ConsoleInvoke --
226
+ # Processes the command line input. If the command is complete it
227
+ # is evaled in the main interpreter. Otherwise, the continuation
228
+ # prompt is added and more input may be added.
229
+ #
230
+ # Arguments:
231
+ # None.
232
+
233
+ proc ::tk::ConsoleInvoke {args} {
234
+ set ranges [.console tag ranges input]
235
+ set cmd ""
236
+ if {[llength $ranges]} {
237
+ set pos 0
238
+ while {[lindex $ranges $pos] ne ""} {
239
+ set start [lindex $ranges $pos]
240
+ set end [lindex $ranges [incr pos]]
241
+ append cmd [.console get $start $end]
242
+ incr pos
243
+ }
244
+ }
245
+ if {$cmd eq ""} {
246
+ ConsolePrompt
247
+ } elseif {[info complete $cmd]} {
248
+ .console mark set output end
249
+ .console tag delete input
250
+ set result [consoleinterp record $cmd]
251
+ if {$result ne ""} {
252
+ puts $result
253
+ }
254
+ ConsoleHistory reset
255
+ ConsolePrompt
256
+ } else {
257
+ ConsolePrompt partial
258
+ }
259
+ .console yview -pickplace insert
260
+ }
261
+
262
+ # ::tk::ConsoleHistory --
263
+ # This procedure implements command line history for the
264
+ # console. In general is evals the history command in the
265
+ # main interpreter to obtain the history. The variable
266
+ # ::tk::HistNum is used to store the current location in the history.
267
+ #
268
+ # Arguments:
269
+ # cmd - Which action to take: prev, next, reset.
270
+
271
+ set ::tk::HistNum 1
272
+ proc ::tk::ConsoleHistory {cmd} {
273
+ variable HistNum
274
+
275
+ switch $cmd {
276
+ prev {
277
+ incr HistNum -1
278
+ if {$HistNum == 0} {
279
+ set cmd {history event [expr {[history nextid] -1}]}
280
+ } else {
281
+ set cmd "history event $HistNum"
282
+ }
283
+ if {[catch {consoleinterp eval $cmd} cmd]} {
284
+ incr HistNum
285
+ return
286
+ }
287
+ .console delete promptEnd end
288
+ .console insert promptEnd $cmd {input stdin}
289
+ .console see end
290
+ }
291
+ next {
292
+ incr HistNum
293
+ if {$HistNum == 0} {
294
+ set cmd {history event [expr {[history nextid] -1}]}
295
+ } elseif {$HistNum > 0} {
296
+ set cmd ""
297
+ set HistNum 1
298
+ } else {
299
+ set cmd "history event $HistNum"
300
+ }
301
+ if {$cmd ne ""} {
302
+ catch {consoleinterp eval $cmd} cmd
303
+ }
304
+ .console delete promptEnd end
305
+ .console insert promptEnd $cmd {input stdin}
306
+ .console see end
307
+ }
308
+ reset {
309
+ set HistNum 1
310
+ }
311
+ }
312
+ }
313
+
314
+ # ::tk::ConsolePrompt --
315
+ # This procedure draws the prompt. If tcl_prompt1 or tcl_prompt2
316
+ # exists in the main interpreter it will be called to generate the
317
+ # prompt. Otherwise, a hard coded default prompt is printed.
318
+ #
319
+ # Arguments:
320
+ # partial - Flag to specify which prompt to print.
321
+
322
+ proc ::tk::ConsolePrompt {{partial normal}} {
323
+ set w .console
324
+ if {$partial eq "normal"} {
325
+ set temp [$w index "end - 1 char"]
326
+ $w mark set output end
327
+ if {[consoleinterp eval "info exists tcl_prompt1"]} {
328
+ consoleinterp eval "eval \[set tcl_prompt1\]"
329
+ } else {
330
+ puts -nonewline [EvalAttached $::tk::console::defaultPrompt]
331
+ }
332
+ } else {
333
+ set temp [$w index output]
334
+ $w mark set output end
335
+ if {[consoleinterp eval "info exists tcl_prompt2"]} {
336
+ consoleinterp eval "eval \[set tcl_prompt2\]"
337
+ } else {
338
+ puts -nonewline "> "
339
+ }
340
+ }
341
+ flush stdout
342
+ $w mark set output $temp
343
+ ::tk::TextSetCursor $w end
344
+ $w mark set promptEnd insert
345
+ $w mark gravity promptEnd left
346
+ ::tk::console::ConstrainBuffer $w $::tk::console::maxLines
347
+ $w see end
348
+ }
349
+
350
+ # Copy selected text from the console
351
+ proc ::tk::console::Copy {w} {
352
+ if {![catch {set data [$w get sel.first sel.last]}]} {
353
+ clipboard clear -displayof $w
354
+ clipboard append -displayof $w $data
355
+ }
356
+ }
357
+ # Copies selected text. If the selection is within the current active edit
358
+ # region then it will be cut, if not it is only copied.
359
+ proc ::tk::console::Cut {w} {
360
+ if {![catch {set data [$w get sel.first sel.last]}]} {
361
+ clipboard clear -displayof $w
362
+ clipboard append -displayof $w $data
363
+ if {[$w compare sel.first >= output]} {
364
+ $w delete sel.first sel.last
365
+ }
366
+ }
367
+ }
368
+ # Paste text from the clipboard
369
+ proc ::tk::console::Paste {w} {
370
+ catch {
371
+ set clip [::tk::GetSelection $w CLIPBOARD]
372
+ set list [split $clip \n\r]
373
+ tk::ConsoleInsert $w [lindex $list 0]
374
+ foreach x [lrange $list 1 end] {
375
+ $w mark set insert {end - 1c}
376
+ tk::ConsoleInsert $w "\n"
377
+ tk::ConsoleInvoke
378
+ tk::ConsoleInsert $w $x
379
+ }
380
+ }
381
+ }
382
+
383
+ # Fit TkConsoleFont to window width
384
+ proc ::tk::console::FitScreenWidth {w} {
385
+ set width [winfo screenwidth $w]
386
+ set cwidth [$w cget -width]
387
+ set s -50
388
+ set fit 0
389
+ array set fi [font configure TkConsoleFont]
390
+ while {$s < 0} {
391
+ set fi(-size) $s
392
+ set f [font create {*}[array get fi]]
393
+ set c [font measure $f "eM"]
394
+ font delete $f
395
+ if {$c * $cwidth < 1.667 * $width} {
396
+ font configure TkConsoleFont -size $s
397
+ break
398
+ }
399
+ incr s 2
400
+ }
401
+ }
402
+
403
+ # ::tk::ConsoleBind --
404
+ # This procedure first ensures that the default bindings for the Text
405
+ # class have been defined. Then certain bindings are overridden for
406
+ # the class.
407
+ #
408
+ # Arguments:
409
+ # None.
410
+
411
+ proc ::tk::ConsoleBind {w} {
412
+ bindtags $w [list $w Console PostConsole [winfo toplevel $w] all]
413
+
414
+ ## Get all Text bindings into Console
415
+ foreach ev [bind Text] {
416
+ bind Console $ev [bind Text $ev]
417
+ }
418
+ ## We really didn't want the newline insertion...
419
+ bind Console <Control-o> {}
420
+ ## ...or any Control-v binding (would block <<Paste>>)
421
+ bind Console <Control-v> {}
422
+
423
+ # For the moment, transpose isn't enabled until the console
424
+ # gets and overhaul of how it handles input -- hobbs
425
+ bind Console <Control-t> {}
426
+
427
+ # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
428
+ # Otherwise, if a widget binding for one of these is defined, the
429
+ # <Keypress> class binding will also fire and insert the character
430
+ # which is wrong.
431
+
432
+ bind Console <Alt-Key> {# nothing }
433
+ bind Console <Meta-Key> {# nothing}
434
+ bind Console <Control-Key> {# nothing}
435
+ if {[tk windowingsystem] eq "aqua"} {
436
+ bind Console <Command-Key> {# nothing}
437
+ bind Console <Mod4-Key> {# nothing}
438
+ }
439
+
440
+ foreach {ev key} {
441
+ <<Console_NextImmediate>> <Control-n>
442
+ <<Console_PrevImmediate>> <Control-p>
443
+ <<Console_PrevSearch>> <Control-r>
444
+ <<Console_NextSearch>> <Control-s>
445
+
446
+ <<Console_Expand>> <Tab>
447
+ <<Console_Expand>> <Escape>
448
+ <<Console_ExpandFile>> <Control-Shift-F>
449
+ <<Console_ExpandProc>> <Control-Shift-P>
450
+ <<Console_ExpandVar>> <Control-Shift-V>
451
+ <<Console_Tab>> <Control-i>
452
+ <<Console_Tab>> <Meta-i>
453
+ <<Console_Eval>> <Return>
454
+ <<Console_Eval>> <KP_Enter>
455
+
456
+ <<Console_Clear>> <Control-l>
457
+ <<Console_KillLine>> <Control-k>
458
+ <<Console_Transpose>> <Control-t>
459
+ <<Console_ClearLine>> <Control-u>
460
+ <<Console_SaveCommand>> <Control-z>
461
+ <<Console_FontSizeIncr>> <Control-plus>
462
+ <<Console_FontSizeDecr>> <Control-minus>
463
+ } {
464
+ event add $ev $key
465
+ bind Console $key {}
466
+ }
467
+ if {[tk windowingsystem] eq "aqua"} {
468
+ foreach {ev key} {
469
+ <<Console_FontSizeIncr>> <Command-plus>
470
+ <<Console_FontSizeDecr>> <Command-minus>
471
+ } {
472
+ event add $ev $key
473
+ bind Console $key {}
474
+ }
475
+ if {$::tk::console::useFontchooser} {
476
+ bind Console <Command-t> [list ::tk::console::FontchooserToggle]
477
+ }
478
+ }
479
+ bind Console <<Console_Expand>> {
480
+ if {[%W compare insert > promptEnd]} {
481
+ ::tk::console::Expand %W
482
+ }
483
+ }
484
+ bind Console <<Console_ExpandFile>> {
485
+ if {[%W compare insert > promptEnd]} {
486
+ ::tk::console::Expand %W path
487
+ }
488
+ }
489
+ bind Console <<Console_ExpandProc>> {
490
+ if {[%W compare insert > promptEnd]} {
491
+ ::tk::console::Expand %W proc
492
+ }
493
+ }
494
+ bind Console <<Console_ExpandVar>> {
495
+ if {[%W compare insert > promptEnd]} {
496
+ ::tk::console::Expand %W var
497
+ }
498
+ }
499
+ bind Console <<Console_Eval>> {
500
+ %W mark set insert {end - 1c}
501
+ tk::ConsoleInsert %W "\n"
502
+ tk::ConsoleInvoke
503
+ break
504
+ }
505
+ bind Console <Delete> {
506
+ if {{} ne [%W tag nextrange sel 1.0 end] \
507
+ && [%W compare sel.first >= promptEnd]} {
508
+ %W delete sel.first sel.last
509
+ } elseif {[%W compare insert >= promptEnd]} {
510
+ %W delete insert
511
+ %W see insert
512
+ }
513
+ }
514
+ bind Console <BackSpace> {
515
+ if {{} ne [%W tag nextrange sel 1.0 end] \
516
+ && [%W compare sel.first >= promptEnd]} {
517
+ %W delete sel.first sel.last
518
+ } elseif {[%W compare insert != 1.0] && \
519
+ [%W compare insert > promptEnd]} {
520
+ %W delete insert-1c
521
+ %W see insert
522
+ }
523
+ }
524
+ bind Console <Control-h> [bind Console <BackSpace>]
525
+
526
+ bind Console <<LineStart>> {
527
+ if {[%W compare insert < promptEnd]} {
528
+ tk::TextSetCursor %W {insert linestart}
529
+ } else {
530
+ tk::TextSetCursor %W promptEnd
531
+ }
532
+ }
533
+ bind Console <<LineEnd>> {
534
+ tk::TextSetCursor %W {insert lineend}
535
+ }
536
+ bind Console <Control-d> {
537
+ if {[%W compare insert < promptEnd]} {
538
+ break
539
+ }
540
+ %W delete insert
541
+ }
542
+ bind Console <<Console_KillLine>> {
543
+ if {[%W compare insert < promptEnd]} {
544
+ break
545
+ }
546
+ if {[%W compare insert == {insert lineend}]} {
547
+ %W delete insert
548
+ } else {
549
+ %W delete insert {insert lineend}
550
+ }
551
+ }
552
+ bind Console <<Console_Clear>> {
553
+ ## Clear console display
554
+ %W delete 1.0 "promptEnd linestart"
555
+ }
556
+ bind Console <<Console_ClearLine>> {
557
+ ## Clear command line (Unix shell staple)
558
+ %W delete promptEnd end
559
+ }
560
+ bind Console <Meta-d> {
561
+ if {[%W compare insert >= promptEnd]} {
562
+ %W delete insert {insert wordend}
563
+ }
564
+ }
565
+ bind Console <Meta-BackSpace> {
566
+ if {[%W compare {insert -1c wordstart} >= promptEnd]} {
567
+ %W delete {insert -1c wordstart} insert
568
+ }
569
+ }
570
+ bind Console <Meta-d> {
571
+ if {[%W compare insert >= promptEnd]} {
572
+ %W delete insert {insert wordend}
573
+ }
574
+ }
575
+ bind Console <Meta-BackSpace> {
576
+ if {[%W compare {insert -1c wordstart} >= promptEnd]} {
577
+ %W delete {insert -1c wordstart} insert
578
+ }
579
+ }
580
+ bind Console <Meta-Delete> {
581
+ if {[%W compare insert >= promptEnd]} {
582
+ %W delete insert {insert wordend}
583
+ }
584
+ }
585
+ bind Console <<PrevLine>> {
586
+ tk::ConsoleHistory prev
587
+ }
588
+ bind Console <<NextLine>> {
589
+ tk::ConsoleHistory next
590
+ }
591
+ bind Console <Insert> {
592
+ catch {tk::ConsoleInsert %W [::tk::GetSelection %W PRIMARY]}
593
+ }
594
+ bind Console <Key> {
595
+ tk::ConsoleInsert %W %A
596
+ }
597
+ bind Console <F9> {
598
+ destroy {*}[winfo children .]
599
+ source -encoding utf-8 [file join $tk_library console.tcl]
600
+ }
601
+ if {[tk windowingsystem] eq "aqua"} {
602
+ bind Console <Command-q> {
603
+ exit
604
+ }
605
+ }
606
+ bind Console <<Cut>> { ::tk::console::Cut %W }
607
+ bind Console <<Copy>> { ::tk::console::Copy %W }
608
+ bind Console <<Paste>> { ::tk::console::Paste %W }
609
+
610
+ bind Console <<Console_FontSizeIncr>> {
611
+ set size [font configure TkConsoleFont -size]
612
+ if {$size < 0} {set sign -1} else {set sign 1}
613
+ set size [expr {(abs($size) + 1) * $sign}]
614
+ font configure TkConsoleFont -size $size
615
+ if {$::tk::console::useFontchooser} {
616
+ tk fontchooser configure -font TkConsoleFont
617
+ }
618
+ }
619
+ bind Console <<Console_FontSizeDecr>> {
620
+ set size [font configure TkConsoleFont -size]
621
+ if {abs($size) < 2} { return }
622
+ if {$size < 0} {set sign -1} else {set sign 1}
623
+ set size [expr {(abs($size) - 1) * $sign}]
624
+ font configure TkConsoleFont -size $size
625
+ if {$::tk::console::useFontchooser} {
626
+ tk fontchooser configure -font TkConsoleFont
627
+ }
628
+ }
629
+ bind Console <<Console_FitScreenWidth>> {
630
+ ::tk::console::FitScreenWidth %W
631
+ }
632
+
633
+ ##
634
+ ## Bindings for doing special things based on certain keys
635
+ ##
636
+ bind PostConsole <parenright> {
637
+ if {"\\" ne [%W get insert-2c]} {
638
+ ::tk::console::MatchPair %W \( \) promptEnd
639
+ }
640
+ }
641
+ bind PostConsole <bracketright> {
642
+ if {"\\" ne [%W get insert-2c]} {
643
+ ::tk::console::MatchPair %W \[ \] promptEnd
644
+ }
645
+ }
646
+ bind PostConsole <braceright> {
647
+ if {"\\" ne [%W get insert-2c]} {
648
+ ::tk::console::MatchPair %W \{ \} promptEnd
649
+ }
650
+ }
651
+ bind PostConsole <quotedbl> {
652
+ if {"\\" ne [%W get insert-2c]} {
653
+ ::tk::console::MatchQuote %W promptEnd
654
+ }
655
+ }
656
+
657
+ bind PostConsole <Key> {
658
+ if {"%A" ne ""} {
659
+ ::tk::console::TagProc %W
660
+ }
661
+ }
662
+ }
663
+
664
+ # ::tk::ConsoleInsert --
665
+ # Insert a string into a text at the point of the insertion cursor.
666
+ # If there is a selection in the text, and it covers the point of the
667
+ # insertion cursor, then delete the selection before inserting. Insertion
668
+ # is restricted to the prompt area.
669
+ #
670
+ # Arguments:
671
+ # w - The text window in which to insert the string
672
+ # s - The string to insert (usually just a single character)
673
+
674
+ proc ::tk::ConsoleInsert {w s} {
675
+ if {$s eq ""} {
676
+ return
677
+ }
678
+ catch {
679
+ if {[$w compare sel.first <= insert] \
680
+ && [$w compare sel.last >= insert]} {
681
+ $w tag remove sel sel.first promptEnd
682
+ $w delete sel.first sel.last
683
+ }
684
+ }
685
+ if {[$w compare insert < promptEnd]} {
686
+ $w mark set insert end
687
+ }
688
+ $w insert insert $s {input stdin}
689
+ $w see insert
690
+ }
691
+
692
+ # ::tk::ConsoleOutput --
693
+ #
694
+ # This routine is called directly by ConsolePutsCmd to cause a string
695
+ # to be displayed in the console.
696
+ #
697
+ # Arguments:
698
+ # dest - The output tag to be used: either "stderr" or "stdout".
699
+ # string - The string to be displayed.
700
+
701
+ proc ::tk::ConsoleOutput {dest string} {
702
+ set w .console
703
+ $w insert output $string $dest
704
+ ::tk::console::ConstrainBuffer $w $::tk::console::maxLines
705
+ $w see insert
706
+ }
707
+
708
+ # ::tk::ConsoleExit --
709
+ #
710
+ # This routine is called by ConsoleEventProc when the main window of
711
+ # the application is destroyed. Don't call exit - that probably already
712
+ # happened. Just delete our window.
713
+ #
714
+ # Arguments:
715
+ # None.
716
+
717
+ proc ::tk::ConsoleExit {} {
718
+ destroy .
719
+ }
720
+
721
+ # ::tk::ConsoleAbout --
722
+ #
723
+ # This routine displays an About box to show Tcl/Tk version info.
724
+ #
725
+ # Arguments:
726
+ # None.
727
+
728
+ proc ::tk::ConsoleAbout {} {
729
+ tk_messageBox -type ok -message "[mc {Tcl for Windows}]
730
+
731
+ Tcl $::tcl_patchLevel
732
+ Tk $::tk_patchLevel"
733
+ }
734
+
735
+ # ::tk::console::Fontchooser* --
736
+ # Let the user select the console font (TIP 324).
737
+
738
+ proc ::tk::console::FontchooserToggle {} {
739
+ if {[tk fontchooser configure -visible]} {
740
+ tk fontchooser hide
741
+ } else {
742
+ tk fontchooser show
743
+ }
744
+ }
745
+ proc ::tk::console::FontchooserVisibility {index} {
746
+ if {[tk fontchooser configure -visible]} {
747
+ .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"]
748
+ } else {
749
+ .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"]
750
+ }
751
+ }
752
+ proc ::tk::console::FontchooserFocus {w isFocusIn} {
753
+ if {$isFocusIn} {
754
+ tk fontchooser configure -parent $w -font TkConsoleFont \
755
+ -command [namespace code [list FontchooserApply]]
756
+ } else {
757
+ tk fontchooser configure -parent $w -font {} -command {}
758
+ }
759
+ }
760
+ proc ::tk::console::FontchooserApply {font args} {
761
+ catch {font configure TkConsoleFont {*}[font actual $font]}
762
+ }
763
+
764
+ # ::tk::console::TagProc --
765
+ #
766
+ # Tags a procedure in the console if it's recognized
767
+ # This procedure is not perfect. However, making it perfect wastes
768
+ # too much CPU time...
769
+ #
770
+ # Arguments:
771
+ # w - console text widget
772
+
773
+ proc ::tk::console::TagProc w {
774
+ if {!$::tk::console::magicKeys} {
775
+ return
776
+ }
777
+ set exp "\[^\\\\\]\[\[ \t\n\r\;{}\"\$\]"
778
+ set i [$w search -backwards -regexp $exp insert-1c promptEnd-1c]
779
+ if {$i eq ""} {
780
+ set i promptEnd
781
+ } else {
782
+ append i +2c
783
+ }
784
+ regsub -all "\[\[\\\\\\?\\*\]" [$w get $i "insert-1c wordend"] {\\\0} c
785
+ if {[llength [EvalAttached [list info commands $c]]]} {
786
+ $w tag add proc $i "insert-1c wordend"
787
+ } else {
788
+ $w tag remove proc $i "insert-1c wordend"
789
+ }
790
+ if {[llength [EvalAttached [list info vars $c]]]} {
791
+ $w tag add var $i "insert-1c wordend"
792
+ } else {
793
+ $w tag remove var $i "insert-1c wordend"
794
+ }
795
+ }
796
+
797
+ # ::tk::console::MatchPair --
798
+ #
799
+ # Blinks a matching pair of characters
800
+ # c2 is assumed to be at the text index 'insert'.
801
+ # This proc is really loopy and took me an hour to figure out given
802
+ # all possible combinations with escaping except for escaped \'s.
803
+ # It doesn't take into account possible commenting... Oh well. If
804
+ # anyone has something better, I'd like to see/use it. This is really
805
+ # only efficient for small contexts.
806
+ #
807
+ # Arguments:
808
+ # w - console text widget
809
+ # c1 - first char of pair
810
+ # c2 - second char of pair
811
+ #
812
+ # Calls: ::tk::console::Blink
813
+
814
+ proc ::tk::console::MatchPair {w c1 c2 {lim 1.0}} {
815
+ if {!$::tk::console::magicKeys} {
816
+ return
817
+ }
818
+ if {{} ne [set ix [$w search -back $c1 insert $lim]]} {
819
+ while {
820
+ [string match {\\} [$w get $ix-1c]] &&
821
+ [set ix [$w search -back $c1 $ix-1c $lim]] ne {}
822
+ } {}
823
+ set i1 insert-1c
824
+ while {$ix ne {}} {
825
+ set i0 $ix
826
+ set j 0
827
+ while {[set i0 [$w search $c2 $i0 $i1]] ne {}} {
828
+ append i0 +1c
829
+ if {[string match {\\} [$w get $i0-2c]]} {
830
+ continue
831
+ }
832
+ incr j
833
+ }
834
+ if {!$j} {
835
+ break
836
+ }
837
+ set i1 $ix
838
+ while {$j && [set ix [$w search -back $c1 $ix $lim]] ne {}} {
839
+ if {[string match {\\} [$w get $ix-1c]]} {
840
+ continue
841
+ }
842
+ incr j -1
843
+ }
844
+ }
845
+ if {[string match {} $ix]} {
846
+ set ix [$w index $lim]
847
+ }
848
+ } else {
849
+ set ix [$w index $lim]
850
+ }
851
+ if {$::tk::console::blinkRange} {
852
+ Blink $w $ix [$w index insert]
853
+ } else {
854
+ Blink $w $ix $ix+1c [$w index insert-1c] [$w index insert]
855
+ }
856
+ }
857
+
858
+ # ::tk::console::MatchQuote --
859
+ #
860
+ # Blinks between matching quotes.
861
+ # Blinks just the quote if it's unmatched, otherwise blinks quoted string
862
+ # The quote to match is assumed to be at the text index 'insert'.
863
+ #
864
+ # Arguments:
865
+ # w - console text widget
866
+ #
867
+ # Calls: ::tk::console::Blink
868
+
869
+ proc ::tk::console::MatchQuote {w {lim 1.0}} {
870
+ if {!$::tk::console::magicKeys} {
871
+ return
872
+ }
873
+ set i insert-1c
874
+ set j 0
875
+ while {[set i [$w search -back \" $i $lim]] ne {}} {
876
+ if {[string match {\\} [$w get $i-1c]]} {
877
+ continue
878
+ }
879
+ if {!$j} {
880
+ set i0 $i
881
+ }
882
+ incr j
883
+ }
884
+ if {$j&1} {
885
+ if {$::tk::console::blinkRange} {
886
+ Blink $w $i0 [$w index insert]
887
+ } else {
888
+ Blink $w $i0 $i0+1c [$w index insert-1c] [$w index insert]
889
+ }
890
+ } else {
891
+ Blink $w [$w index insert-1c] [$w index insert]
892
+ }
893
+ }
894
+
895
+ # ::tk::console::Blink --
896
+ #
897
+ # Blinks between n index pairs for a specified duration.
898
+ #
899
+ # Arguments:
900
+ # w - console text widget
901
+ # i1 - start index to blink region
902
+ # i2 - end index of blink region
903
+ # dur - duration in usecs to blink for
904
+ #
905
+ # Outputs:
906
+ # blinks selected characters in $w
907
+
908
+ proc ::tk::console::Blink {w args} {
909
+ eval [list $w tag add blink] $args
910
+ after $::tk::console::blinkTime [list $w] tag remove blink $args
911
+ }
912
+
913
+ # ::tk::console::ConstrainBuffer --
914
+ #
915
+ # This limits the amount of data in the text widget
916
+ # Called by Prompt and ConsoleOutput
917
+ #
918
+ # Arguments:
919
+ # w - console text widget
920
+ # size - # of lines to constrain to
921
+ #
922
+ # Outputs:
923
+ # may delete data in console widget
924
+
925
+ proc ::tk::console::ConstrainBuffer {w size} {
926
+ if {[$w index end] > $size} {
927
+ $w delete 1.0 [expr {int([$w index end])-$size}].0
928
+ }
929
+ }
930
+
931
+ # ::tk::console::Expand --
932
+ #
933
+ # Arguments:
934
+ # ARGS: w - text widget in which to expand str
935
+ # type - type of expansion (path / proc / variable)
936
+ #
937
+ # Calls: ::tk::console::Expand(Pathname|Procname|Variable)
938
+ #
939
+ # Outputs: The string to match is expanded to the longest possible match.
940
+ # If ::tk::console::showMatches is non-zero and the longest match
941
+ # equaled the string to expand, then all possible matches are
942
+ # output to stdout. Triggers bell if no matches are found.
943
+ #
944
+ # Returns: number of matches found
945
+
946
+ proc ::tk::console::Expand {w {type ""}} {
947
+ set exp "\[^\\\\\]\[\[ \t\n\r\\\{\"\\\\\$\]"
948
+ set tmp [$w search -backwards -regexp $exp insert-1c promptEnd-1c]
949
+ if {$tmp eq ""} {
950
+ set tmp promptEnd
951
+ } else {
952
+ append tmp +2c
953
+ }
954
+ if {[$w compare $tmp >= insert]} {
955
+ return
956
+ }
957
+ set str [$w get $tmp insert]
958
+ switch -glob $type {
959
+ path* {
960
+ set res [ExpandPathname $str]
961
+ }
962
+ proc* {
963
+ set res [ExpandProcname $str]
964
+ }
965
+ var* {
966
+ set res [ExpandVariable $str]
967
+ }
968
+ default {
969
+ set res {}
970
+ foreach t {Pathname Procname Variable} {
971
+ if {![catch {Expand$t $str} res] && ($res ne "")} {
972
+ break
973
+ }
974
+ }
975
+ }
976
+ }
977
+ set len [llength $res]
978
+ if {$len} {
979
+ set repl [lindex $res 0]
980
+ $w delete $tmp insert
981
+ $w insert $tmp $repl {input stdin}
982
+ if {($len > 1) && ($::tk::console::showMatches) && ($repl eq $str)} {
983
+ puts stdout [lsort [lreplace $res 0 0]]
984
+ }
985
+ } else {
986
+ bell
987
+ }
988
+ return [incr len -1]
989
+ }
990
+
991
+ # ::tk::console::ExpandPathname --
992
+ #
993
+ # Expand a file pathname based on $str
994
+ # This is based on UNIX file name conventions
995
+ #
996
+ # Arguments:
997
+ # str - partial file pathname to expand
998
+ #
999
+ # Calls: ::tk::console::ExpandBestMatch
1000
+ #
1001
+ # Returns: list containing longest unique match followed by all the
1002
+ # possible further matches
1003
+
1004
+ proc ::tk::console::ExpandPathname str {
1005
+ set pwd [EvalAttached pwd]
1006
+ if {[catch {EvalAttached [list cd [file dirname $str]]} err opt]} {
1007
+ return -options $opt $err
1008
+ }
1009
+ set dir [file tail $str]
1010
+ ## Check to see if it was known to be a directory and keep the trailing
1011
+ ## slash if so (file tail cuts it off)
1012
+ if {[string match */ $str]} {
1013
+ append dir /
1014
+ }
1015
+ if {[catch {lsort [EvalAttached [list glob $dir*]]} m]} {
1016
+ set match {}
1017
+ } else {
1018
+ if {[llength $m] > 1} {
1019
+ if { $::tcl_platform(platform) eq "windows" } {
1020
+ ## Windows is screwy because it's case insensitive
1021
+ set tmp [ExpandBestMatch [string tolower $m] \
1022
+ [string tolower $dir]]
1023
+ ## Don't change case if we haven't changed the word
1024
+ if {[string length $dir]==[string length $tmp]} {
1025
+ set tmp $dir
1026
+ }
1027
+ } else {
1028
+ set tmp [ExpandBestMatch $m $dir]
1029
+ }
1030
+ if {[string match ?*/* $str]} {
1031
+ set tmp [file dirname $str]/$tmp
1032
+ } elseif {[string match /* $str]} {
1033
+ set tmp /$tmp
1034
+ }
1035
+ regsub -all { } $tmp {\\ } tmp
1036
+ set match [linsert $m 0 $tmp]
1037
+ } else {
1038
+ ## This may look goofy, but it handles spaces in path names
1039
+ eval append match $m
1040
+ if {[file isdir $match]} {
1041
+ append match /
1042
+ }
1043
+ if {[string match ?*/* $str]} {
1044
+ set match [file dirname $str]/$match
1045
+ } elseif {[string match /* $str]} {
1046
+ set match /$match
1047
+ }
1048
+ regsub -all { } $match {\\ } match
1049
+ ## Why is this one needed and the ones below aren't!!
1050
+ set match [list $match]
1051
+ }
1052
+ }
1053
+ EvalAttached [list cd $pwd]
1054
+ return $match
1055
+ }
1056
+
1057
+ # ::tk::console::ExpandProcname --
1058
+ #
1059
+ # Expand a tcl proc name based on $str
1060
+ #
1061
+ # Arguments:
1062
+ # str - partial proc name to expand
1063
+ #
1064
+ # Calls: ::tk::console::ExpandBestMatch
1065
+ #
1066
+ # Returns: list containing longest unique match followed by all the
1067
+ # possible further matches
1068
+
1069
+ proc ::tk::console::ExpandProcname str {
1070
+ set match [EvalAttached [list info commands $str*]]
1071
+ if {[llength $match] == 0} {
1072
+ set ns [EvalAttached \
1073
+ "namespace children \[namespace current\] [list $str*]"]
1074
+ if {[llength $ns]==1} {
1075
+ set match [EvalAttached [list info commands ${ns}::*]]
1076
+ } else {
1077
+ set match $ns
1078
+ }
1079
+ }
1080
+ if {[llength $match] > 1} {
1081
+ regsub -all { } [ExpandBestMatch $match $str] {\\ } str
1082
+ set match [linsert $match 0 $str]
1083
+ } else {
1084
+ regsub -all { } $match {\\ } match
1085
+ }
1086
+ return $match
1087
+ }
1088
+
1089
+ # ::tk::console::ExpandVariable --
1090
+ #
1091
+ # Expand a tcl variable name based on $str
1092
+ #
1093
+ # Arguments:
1094
+ # str - partial tcl var name to expand
1095
+ #
1096
+ # Calls: ::tk::console::ExpandBestMatch
1097
+ #
1098
+ # Returns: list containing longest unique match followed by all the
1099
+ # possible further matches
1100
+
1101
+ proc ::tk::console::ExpandVariable str {
1102
+ if {[regexp {([^\(]*)\((.*)} $str -> ary str]} {
1103
+ ## Looks like they're trying to expand an array.
1104
+ set match [EvalAttached [list array names $ary $str*]]
1105
+ if {[llength $match] > 1} {
1106
+ set vars $ary\([ExpandBestMatch $match $str]
1107
+ foreach var $match {
1108
+ lappend vars $ary\($var\)
1109
+ }
1110
+ return $vars
1111
+ } elseif {[llength $match] == 1} {
1112
+ set match $ary\($match\)
1113
+ }
1114
+ ## Space transformation avoided for array names.
1115
+ } else {
1116
+ set match [EvalAttached [list info vars $str*]]
1117
+ if {[llength $match] > 1} {
1118
+ regsub -all { } [ExpandBestMatch $match $str] {\\ } str
1119
+ set match [linsert $match 0 $str]
1120
+ } else {
1121
+ regsub -all { } $match {\\ } match
1122
+ }
1123
+ }
1124
+ return $match
1125
+ }
1126
+
1127
+ # ::tk::console::ExpandBestMatch --
1128
+ #
1129
+ # Finds the best unique match in a list of names.
1130
+ # The extra $e in this argument allows us to limit the innermost loop a little
1131
+ # further. This improves speed as $l becomes large or $e becomes long.
1132
+ #
1133
+ # Arguments:
1134
+ # l - list to find best unique match in
1135
+ # e - currently best known unique match
1136
+ #
1137
+ # Returns: longest unique match in the list
1138
+
1139
+ proc ::tk::console::ExpandBestMatch {l {e {}}} {
1140
+ set ec [lindex $l 0]
1141
+ if {[llength $l]>1} {
1142
+ set e [expr {[string length $e] - 1}]
1143
+ set ei [expr {[string length $ec] - 1}]
1144
+ foreach l $l {
1145
+ while {$ei>=$e && [string first $ec $l]} {
1146
+ set ec [string range $ec 0 [incr ei -1]]
1147
+ }
1148
+ }
1149
+ }
1150
+ return $ec
1151
+ }
1152
+
1153
+ # now initialize the console
1154
+ ::tk::ConsoleInit
miniconda3/lib/tk8.6/demos/README ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This directory contains a collection of programs to demonstrate
2
+ the features of the Tk toolkit. The programs are all scripts for
3
+ "wish", a windowing shell. If wish has been installed on your path
4
+ then you can invoke any of the programs in this directory just
5
+ by typing its file name to your command shell under Unix. Otherwise
6
+ invoke wish with the file as its first argument, e.g., "wish hello".
7
+ The rest of this file contains a brief description of each program.
8
+ Files with names ending in ".tcl" are procedure packages used by one
9
+ or more of the demo programs; they can't be used as programs by
10
+ themselves so they aren't described below.
11
+
12
+ hello - Creates a single button; if you click on it, a message
13
+ is typed and the application terminates.
14
+
15
+ widget - Contains a collection of demonstrations of the widgets
16
+ currently available in the Tk library. Most of the .tcl
17
+ files are scripts for individual demos available through
18
+ the "widget" program.
19
+
20
+ ixset - A simple Tk-based wrapper for the "xset" program, which
21
+ allows you to interactively query and set various X options
22
+ such as mouse acceleration and bell volume. Thanks to
23
+ Pierre David for contributing this example.
24
+
25
+ rolodex - A mock-up of a simple rolodex application. It has much of
26
+ the user interface for such an application but no back-end
27
+ database. This program was written in response to Tom
28
+ LaStrange's toolkit benchmark challenge.
29
+
30
+ tcolor - A color editor. Allows you to edit colors in several
31
+ different ways, and will also perform automatic updates
32
+ using "send".
33
+
34
+ rmt - Allows you to "hook-up" remotely to any Tk application
35
+ on the display. Select an application with the menu,
36
+ then just type commands: they'll go to that application.
37
+
38
+ timer - Displays a seconds timer with start and stop buttons.
39
+ Control-c and control-q cause it to exit.
40
+
41
+ browse - A simple directory browser. Invoke it with and argument
42
+ giving the name of the directory you'd like to browse.
43
+ Double-click on files or subdirectories to browse them.
44
+ Control-c and control-q cause the program to exit.
miniconda3/lib/tk8.6/demos/anilabel.tcl ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # anilabel.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several animated label widgets.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .anilabel
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Animated Label Demonstration"
16
+ wm iconname $w "anilabel"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "Four animated labels are displayed below; each of the labels on the left is animated by making the text message inside it appear to scroll, and the label on the right is animated by animating the image that it displays."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ # Ensure that this this is an array
27
+ array set animationCallbacks {}
28
+
29
+ ## This callback is the core of how to do animation in Tcl/Tk; all
30
+ ## animations work in basically the same way, with a procedure that
31
+ ## uses the [after] command to reschedule itself at some point in the
32
+ ## future. Of course, the details of how to update the state will vary
33
+ ## according to what is being animated.
34
+ proc RotateLabelText {w interval} {
35
+ global animationCallbacks
36
+
37
+ # Schedule the calling of this procedure again in the future
38
+ set animationCallbacks($w) [after $interval RotateLabelText $w $interval]
39
+
40
+ # We do marquee-like scrolling text by chopping characters off the
41
+ # front of the text and sticking them on the end.
42
+ set text [$w cget -text]
43
+ set newText [string range $text 1 end][string index $text 0]
44
+ $w configure -text $newText
45
+ }
46
+
47
+ ## A helper procedure to start the animation happening.
48
+ proc animateLabelText {w text interval} {
49
+ global animationCallbacks
50
+
51
+ # Install the text into the widget
52
+ $w configure -text $text
53
+
54
+ # Schedule the start of the animation loop
55
+ set animationCallbacks($w) [after $interval RotateLabelText $w $interval]
56
+
57
+ # Make sure that the animation stops and is cleaned up after itself
58
+ # when the animated label is destroyed. Note that at this point we
59
+ # cannot manipulate the widget itself, as that has already died.
60
+ bind $w <Destroy> {
61
+ after cancel $animationCallbacks(%W)
62
+ unset animationCallbacks(%W)
63
+ }
64
+ }
65
+
66
+ ## Next, a similar pair of procedures to animate a GIF loaded into a
67
+ ## photo image.
68
+ proc SelectNextImageFrame {w interval} {
69
+ global animationCallbacks
70
+ set animationCallbacks($w) \
71
+ [after $interval SelectNextImageFrame $w $interval]
72
+ set image [$w cget -image]
73
+
74
+ # The easy way to animate a GIF!
75
+ set idx -1
76
+ scan [$image cget -format] "GIF -index %d" idx
77
+ if {[catch {
78
+ # Note that we get an error if the index is out of range
79
+ $image configure -format "GIF -index [incr idx]"
80
+ }]} then {
81
+ $image configure -format "GIF -index 0"
82
+ }
83
+ }
84
+ proc animateLabelImage {w imageData interval} {
85
+ global animationCallbacks
86
+
87
+ # Create a multi-frame GIF from base-64-encoded data
88
+ set image [image create photo -format GIF -data $imageData]
89
+
90
+ # Install the image into the widget
91
+ $w configure -image $image
92
+
93
+ # Schedule the start of the animation loop
94
+ set animationCallbacks($w) \
95
+ [after $interval SelectNextImageFrame $w $interval]
96
+
97
+ # Make sure that the animation stops and is cleaned up after itself
98
+ # when the animated label is destroyed. Note that at this point we
99
+ # cannot manipulate the widget itself, as that has already died.
100
+ # Also note that this script is in double-quotes; this is always OK
101
+ # because image names are chosen automatically to be simple words.
102
+ bind $w <Destroy> "
103
+ after cancel \$animationCallbacks(%W)
104
+ unset animationCallbacks(%W)
105
+ rename $image {}
106
+ "
107
+ }
108
+
109
+ # Make some widgets to contain the animations
110
+ labelframe $w.left -text "Scrolling Texts"
111
+ labelframe $w.right -text "GIF Image"
112
+ pack $w.left $w.right -side left -padx 10 -pady 10 -expand yes
113
+
114
+ # This method of scrolling text looks far better with a fixed-width font
115
+ label $w.left.l1 -bd 4 -relief ridge -font fixedFont
116
+ label $w.left.l2 -bd 4 -relief groove -font fixedFont
117
+ label $w.left.l3 -bd 4 -relief flat -font fixedFont -width 18
118
+ pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -padx 10 -pady 10 -anchor w
119
+ # Don't need to do very much with this label except turn off the border
120
+ label $w.right.l -bd 0
121
+ pack $w.right.l -side top -expand yes -padx 10 -pady 10
122
+
123
+ # This is a base-64-encoded animated GIF file.
124
+ set tclPoweredData {
125
+ R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM
126
+ zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm
127
+ mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt
128
+ YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP
129
+ dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM
130
+ ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC
131
+ DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0
132
+ qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6
133
+ NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT
134
+ 0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk
135
+ UmRAMgu8OgwQ+uIJgUMVeGXA+IQkzEeHGvD8cIGlDXsLiRjQ+EHroQhea7xY
136
+ 8IQBSgYYDi1IS+OFBCgaDMGVS3fGi5BPJpBaENdQ0EomKGD56IHwO39EXiSC
137
+ Ysgxor5+Xfgq0qByYUpiXmwuoredB2aYH4gWWda0B7SeNENpEJHC1ghi+pS4
138
+ AJpIAwWvKPBi+8YEht5EriEqpFfMlhEdkBNpx0HUhwypx5T4IB1MBg/Ws2sn
139
+ wV3MSQOkzI8fUd48Aw3dOZto71x85hHtHijYv18Gf/3GqCdDCXHNoICBobSo
140
+ IqBqJLyCoH8JPrLgdh88CKCFD0CGmAiGYPgffwceZh6FC2ohIIklnkhehTNY
141
+ 4CIHHGzgwYw01ujBBhvAqKOLLq5AAk9kuSPkkKO40NB+h1gnypJIIvkBf09a
142
+ N5QIRz5p5ZJXJpmlIVhOGQA2TmIJZZhKKmmll2BqyWSXWUrZpQtpatlmk1c2
143
+ KaWRHeTZEJF8SqLDn/hhsOeQgBbqAh6DGqronxeARUIIACH5BAUeAAAALAUA
144
+ LgAFAAUAAAUM4CeKz/OV5YmqaRkCACH5BAUeAAEALAUALgAKAAUAAAUUICCK
145
+ z/OdJVCaa7p+7aOWcDvTZwgAIfkEBR4AAQAsCwAuAAkABQAABRPgA4zP95zA
146
+ eZqoWqqpyqLkZ38hACH5BAUKAAEALAcALgANAA4AAAU7ICA+jwiUJEqeKau+
147
+ r+vGaTmac63v/GP9HM7GQyx+jsgkkoRUHJ3Qx0cK/VQVTKtWwbVKn9suNunc
148
+ WkMAIfkEBQoAAAAsBwA3AAcABQAABRGgIHzk842j+Yjlt5KuO8JmCAAh+QQF
149
+ CgAAACwLADcABwAFAAAFEeAnfN9TjqP5oOWziq05lmUIACH5BAUKAAAALA8A
150
+ NwAHAAUAAAUPoPCJTymS3yiQj4qOcPmEACH5BAUKAAAALBMANwAHAAUAAAUR
151
+ oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j
152
+ Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7
153
+ ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw==
154
+ }
155
+
156
+ # Finally, set up the text scrolling animation
157
+ animateLabelText $w.left.l1 "* Slow Animation *" 300
158
+ animateLabelText $w.left.l2 "* Fast Animation *" 80
159
+ animateLabelText $w.left.l3 "This is a longer scrolling text in a widget that will not show the whole message at once. " 150
160
+ animateLabelImage $w.right.l $tclPoweredData 100
miniconda3/lib/tk8.6/demos/aniwave.tcl ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # aniwave.tcl --
2
+ #
3
+ # This demonstration script illustrates how to adjust canvas item
4
+ # coordinates in a way that does something fairly similar to waveform
5
+ # display.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ set w .aniwave
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Animated Wave Demonstration"
17
+ wm iconname $w "aniwave"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration contains a canvas widget with a line item inside it. The animation routines work by adjusting the coordinates list of the line; a trace on a variable is used so updates to the variable result in a change of position of the line."
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ # Create a canvas large enough to hold the wave. In fact, the wave
28
+ # sticks off both sides of the canvas to prevent visual glitches.
29
+ pack [canvas $w.c -width 300 -height 200 -background black] -padx 10 -pady 10 -expand yes
30
+
31
+ # Ensure that this this is an array
32
+ array set animationCallbacks {}
33
+
34
+ # Creates a coordinates list of a wave. This code does a very sketchy
35
+ # job and relies on Tk's line smoothing to make things look better.
36
+ set waveCoords {}
37
+ for {set x -10} {$x<=300} {incr x 5} {
38
+ lappend waveCoords $x 100
39
+ }
40
+ lappend waveCoords $x 0 [incr x 5] 200
41
+
42
+ # Create a smoothed line and arrange for its coordinates to be the
43
+ # contents of the variable waveCoords.
44
+ $w.c create line $waveCoords -tags wave -width 1 -fill green -smooth 1
45
+ proc waveCoordsTracer {w args} {
46
+ global waveCoords
47
+ # Actual visual update will wait until we have finished
48
+ # processing; Tk does that for us automatically.
49
+ $w.c coords wave $waveCoords
50
+ }
51
+ trace add variable waveCoords write [list waveCoordsTracer $w]
52
+
53
+ # Basic motion handler. Given what direction the wave is travelling
54
+ # in, it advances the y coordinates in the coordinate-list one step in
55
+ # that direction.
56
+ proc basicMotion {} {
57
+ global waveCoords direction
58
+ set oc $waveCoords
59
+ for {set i 1} {$i<[llength $oc]} {incr i 2} {
60
+ if {$direction eq "left"} {
61
+ lset waveCoords $i [lindex $oc \
62
+ [expr {$i+2>[llength $oc] ? 1 : $i+2}]]
63
+ } else {
64
+ lset waveCoords $i \
65
+ [lindex $oc [expr {$i-2<0 ? "end" : $i-2}]]
66
+ }
67
+ }
68
+ }
69
+
70
+ # Oscillation handler. This detects whether to reverse the direction
71
+ # of the wave by checking to see if the peak of the wave has moved off
72
+ # the screen (whose size we know already.)
73
+ proc reverser {} {
74
+ global waveCoords direction
75
+ if {[lindex $waveCoords 1] < 10} {
76
+ set direction "right"
77
+ } elseif {[lindex $waveCoords end] < 10} {
78
+ set direction "left"
79
+ }
80
+ }
81
+
82
+ # Main animation "loop". This calls the two procedures that handle the
83
+ # movement repeatedly by scheduling asynchronous calls back to itself
84
+ # using the [after] command. This procedure is the fundamental basis
85
+ # for all animated effect handling in Tk.
86
+ proc move {} {
87
+ basicMotion
88
+ reverser
89
+
90
+ # Theoretically 100 frames-per-second (==10ms between frames)
91
+ global animationCallbacks
92
+ set animationCallbacks(simpleWave) [after 10 move]
93
+ }
94
+
95
+ # Initialise our remaining animation variables
96
+ set direction "left"
97
+ set animateAfterCallback {}
98
+ # Arrange for the animation loop to stop when the canvas is deleted
99
+ bind $w.c <Destroy> {
100
+ after cancel $animationCallbacks(simpleWave)
101
+ unset animationCallbacks(simpleWave)
102
+ }
103
+ # Start the animation processing
104
+ move
miniconda3/lib/tk8.6/demos/arrow.tcl ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # arrow.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widget that displays a
4
+ # large line with an arrowhead whose shape can be edited interactively.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # arrowSetup --
13
+ # This procedure regenerates all the text and graphics in the canvas
14
+ # window. It's called when the canvas is initially created, and also
15
+ # whenever any of the parameters of the arrow head are changed
16
+ # interactively.
17
+ #
18
+ # Arguments:
19
+ # c - Name of the canvas widget.
20
+
21
+ proc arrowSetup c {
22
+ upvar #0 demo_arrowInfo v
23
+
24
+ # Remember the current box, if there is one.
25
+
26
+ set tags [$c gettags current]
27
+ if {$tags != ""} {
28
+ set cur [lindex $tags [lsearch -glob $tags box?]]
29
+ } else {
30
+ set cur ""
31
+ }
32
+
33
+ # Create the arrow and outline.
34
+
35
+ $c delete all
36
+ eval {$c create line $v(x1) $v(y) $v(x2) $v(y) -arrow last \
37
+ -width [expr {10*$v(width)}] -arrowshape [list \
38
+ [expr {10*$v(a)}] [expr {10*$v(b)}] [expr {10*$v(c)}]]} \
39
+ $v(bigLineStyle)
40
+ set xtip [expr {$v(x2)-10*$v(b)}]
41
+ set deltaY [expr {10*$v(c)+5*$v(width)}]
42
+ $c create line $v(x2) $v(y) $xtip [expr {$v(y)+$deltaY}] \
43
+ [expr {$v(x2)-10*$v(a)}] $v(y) $xtip [expr {$v(y)-$deltaY}] \
44
+ $v(x2) $v(y) -width 2 -capstyle round -joinstyle round
45
+
46
+ # Create the boxes for reshaping the line and arrowhead.
47
+
48
+ eval {$c create rect [expr {$v(x2)-10*$v(a)-5}] [expr {$v(y)-5}] \
49
+ [expr {$v(x2)-10*$v(a)+5}] [expr {$v(y)+5}] \
50
+ -tags {box1 box}} $v(boxStyle)
51
+ eval {$c create rect [expr {$xtip-5}] [expr {$v(y)-$deltaY-5}] \
52
+ [expr {$xtip+5}] [expr {$v(y)-$deltaY+5}] \
53
+ -tags {box2 box}} $v(boxStyle)
54
+ eval {$c create rect [expr {$v(x1)-5}] [expr {$v(y)-5*$v(width)-5}] \
55
+ [expr {$v(x1)+5}] [expr {$v(y)-5*$v(width)+5}] \
56
+ -tags {box3 box}} $v(boxStyle)
57
+ if {$cur != ""} {
58
+ eval $c itemconfigure $cur $v(activeStyle)
59
+ }
60
+
61
+ # Create three arrows in actual size with the same parameters
62
+
63
+ $c create line [expr {$v(x2)+50}] 0 [expr {$v(x2)+50}] 1000 \
64
+ -width 2
65
+ set tmp [expr {$v(x2)+100}]
66
+ $c create line $tmp [expr {$v(y)-125}] $tmp [expr {$v(y)-75}] \
67
+ -width $v(width) \
68
+ -arrow both -arrowshape "$v(a) $v(b) $v(c)"
69
+ $c create line [expr {$tmp-25}] $v(y) [expr {$tmp+25}] $v(y) \
70
+ -width $v(width) \
71
+ -arrow both -arrowshape "$v(a) $v(b) $v(c)"
72
+ $c create line [expr {$tmp-25}] [expr {$v(y)+75}] [expr {$tmp+25}] \
73
+ [expr {$v(y)+125}] -width $v(width) \
74
+ -arrow both -arrowshape "$v(a) $v(b) $v(c)"
75
+
76
+ # Create a bunch of other arrows and text items showing the
77
+ # current dimensions.
78
+
79
+ set tmp [expr {$v(x2)+10}]
80
+ $c create line $tmp [expr {$v(y)-5*$v(width)}] \
81
+ $tmp [expr {$v(y)-$deltaY}] \
82
+ -arrow both -arrowshape $v(smallTips)
83
+ $c create text [expr {$v(x2)+15}] [expr {$v(y)-$deltaY+5*$v(c)}] \
84
+ -text $v(c) -anchor w
85
+ set tmp [expr {$v(x1)-10}]
86
+ $c create line $tmp [expr {$v(y)-5*$v(width)}] \
87
+ $tmp [expr {$v(y)+5*$v(width)}] \
88
+ -arrow both -arrowshape $v(smallTips)
89
+ $c create text [expr {$v(x1)-15}] $v(y) -text $v(width) -anchor e
90
+ set tmp [expr {$v(y)+5*$v(width)+10*$v(c)+10}]
91
+ $c create line [expr {$v(x2)-10*$v(a)}] $tmp $v(x2) $tmp \
92
+ -arrow both -arrowshape $v(smallTips)
93
+ $c create text [expr {$v(x2)-5*$v(a)}] [expr {$tmp+5}] \
94
+ -text $v(a) -anchor n
95
+ set tmp [expr {$tmp+25}]
96
+ $c create line [expr {$v(x2)-10*$v(b)}] $tmp $v(x2) $tmp \
97
+ -arrow both -arrowshape $v(smallTips)
98
+ $c create text [expr {$v(x2)-5*$v(b)}] [expr {$tmp+5}] \
99
+ -text $v(b) -anchor n
100
+
101
+ $c create text $v(x1) 310 -text "-width $v(width)" \
102
+ -anchor w -font {Helvetica 18}
103
+ $c create text $v(x1) 330 -text "-arrowshape {$v(a) $v(b) $v(c)}" \
104
+ -anchor w -font {Helvetica 18}
105
+
106
+ incr v(count)
107
+ }
108
+
109
+ set w .arrow
110
+ catch {destroy $w}
111
+ toplevel $w
112
+ wm title $w "Arrowhead Editor Demonstration"
113
+ wm iconname $w "arrow"
114
+ positionWindow $w
115
+ set c $w.c
116
+
117
+ label $w.msg -font $font -wraplength 5i -justify left -text "This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."
118
+ pack $w.msg -side top
119
+
120
+ ## See Code / Dismiss buttons
121
+ set btns [addSeeDismiss $w.buttons $w]
122
+ pack $btns -side bottom -fill x
123
+
124
+ canvas $c -width 500 -height 350 -relief sunken -borderwidth 2
125
+ pack $c -expand yes -fill both
126
+
127
+ set demo_arrowInfo(a) 8
128
+ set demo_arrowInfo(b) 10
129
+ set demo_arrowInfo(c) 3
130
+ set demo_arrowInfo(width) 2
131
+ set demo_arrowInfo(motionProc) arrowMoveNull
132
+ set demo_arrowInfo(x1) 40
133
+ set demo_arrowInfo(x2) 350
134
+ set demo_arrowInfo(y) 150
135
+ set demo_arrowInfo(smallTips) {5 5 2}
136
+ set demo_arrowInfo(count) 0
137
+ if {[winfo depth $c] > 1} {
138
+ if {[tk windowingsystem] eq "aqua"} {
139
+ set demo_arrowInfo(bigLineStyle) "-fill systemSelectedTextBackgroundColor"
140
+ } else {
141
+ set demo_arrowInfo(bigLineStyle) "-fill LightSeaGreen"
142
+ }
143
+ set demo_arrowInfo(boxStyle) "-fill {} -width 1"
144
+ set demo_arrowInfo(activeStyle) "-fill red -width 1"
145
+ } else {
146
+ # Main widget program sets variable tk_demoDirectory
147
+ set demo_arrowInfo(bigLineStyle) "-fill black \
148
+ -stipple @[file join $tk_demoDirectory images grey.25]"
149
+ set demo_arrowInfo(boxStyle) "-fill {} -outline black -width 1"
150
+ set demo_arrowInfo(activeStyle) "-fill black -outline black -width 1"
151
+ }
152
+ arrowSetup $c
153
+ $c bind box <Enter> "$c itemconfigure current $demo_arrowInfo(activeStyle)"
154
+ $c bind box <Leave> "$c itemconfigure current $demo_arrowInfo(boxStyle)"
155
+ $c bind box <B1-Enter> " "
156
+ $c bind box <B1-Leave> " "
157
+ $c bind box1 <Button-1> {set demo_arrowInfo(motionProc) arrowMove1}
158
+ $c bind box2 <Button-1> {set demo_arrowInfo(motionProc) arrowMove2}
159
+ $c bind box3 <Button-1> {set demo_arrowInfo(motionProc) arrowMove3}
160
+ $c bind box <B1-Motion> "\$demo_arrowInfo(motionProc) $c %x %y"
161
+ bind $c <ButtonRelease-1> "arrowSetup $c"
162
+
163
+ # arrowMove1 --
164
+ # This procedure is called for each mouse motion event on box1 (the
165
+ # one at the vertex of the arrow). It updates the controlling parameters
166
+ # for the line and arrowhead.
167
+ #
168
+ # Arguments:
169
+ # c - The name of the canvas window.
170
+ # x, y - The coordinates of the mouse.
171
+
172
+ proc arrowMove1 {c x y} {
173
+ upvar #0 demo_arrowInfo v
174
+ set newA [expr {($v(x2)+5-round([$c canvasx $x]))/10}]
175
+ if {$newA < 0} {
176
+ set newA 0
177
+ }
178
+ if {$newA > 25} {
179
+ set newA 25
180
+ }
181
+ if {$newA != $v(a)} {
182
+ $c move box1 [expr {10*($v(a)-$newA)}] 0
183
+ set v(a) $newA
184
+ }
185
+ }
186
+
187
+ # arrowMove2 --
188
+ # This procedure is called for each mouse motion event on box2 (the
189
+ # one at the trailing tip of the arrowhead). It updates the controlling
190
+ # parameters for the line and arrowhead.
191
+ #
192
+ # Arguments:
193
+ # c - The name of the canvas window.
194
+ # x, y - The coordinates of the mouse.
195
+
196
+ proc arrowMove2 {c x y} {
197
+ upvar #0 demo_arrowInfo v
198
+ set newB [expr {($v(x2)+5-round([$c canvasx $x]))/10}]
199
+ if {$newB < 0} {
200
+ set newB 0
201
+ }
202
+ if {$newB > 25} {
203
+ set newB 25
204
+ }
205
+ set newC [expr {($v(y)+5-round([$c canvasy $y])-5*$v(width))/10}]
206
+ if {$newC < 0} {
207
+ set newC 0
208
+ }
209
+ if {$newC > 20} {
210
+ set newC 20
211
+ }
212
+ if {($newB != $v(b)) || ($newC != $v(c))} {
213
+ $c move box2 [expr {10*($v(b)-$newB)}] [expr {10*($v(c)-$newC)}]
214
+ set v(b) $newB
215
+ set v(c) $newC
216
+ }
217
+ }
218
+
219
+ # arrowMove3 --
220
+ # This procedure is called for each mouse motion event on box3 (the
221
+ # one that controls the thickness of the line). It updates the
222
+ # controlling parameters for the line and arrowhead.
223
+ #
224
+ # Arguments:
225
+ # c - The name of the canvas window.
226
+ # x, y - The coordinates of the mouse.
227
+
228
+ proc arrowMove3 {c x y} {
229
+ upvar #0 demo_arrowInfo v
230
+ set newWidth [expr {($v(y)+2-round([$c canvasy $y]))/5}]
231
+ if {$newWidth < 0} {
232
+ set newWidth 0
233
+ }
234
+ if {$newWidth > 20} {
235
+ set newWidth 20
236
+ }
237
+ if {$newWidth != $v(width)} {
238
+ $c move box3 0 [expr {5*($v(width)-$newWidth)}]
239
+ set v(width) $newWidth
240
+ }
241
+ }
miniconda3/lib/tk8.6/demos/bind.tcl ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bind.tcl --
2
+ #
3
+ # This demonstration script creates a text widget with bindings set
4
+ # up for hypertext-like effects.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .bind
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Text Demonstration - Tag Bindings"
16
+ wm iconname $w "bind"
17
+ positionWindow $w
18
+
19
+ ## See Code / Dismiss buttons
20
+ set btns [addSeeDismiss $w.buttons $w]
21
+ pack $btns -side bottom -fill x
22
+
23
+ text $w.text -yscrollcommand "$w.scroll set" -setgrid true \
24
+ -width 60 -height 24 -font $font -wrap word
25
+ ttk::scrollbar $w.scroll -command "$w.text yview"
26
+ pack $w.scroll -side right -fill y
27
+ pack $w.text -expand yes -fill both
28
+
29
+ # Set up display styles.
30
+
31
+ if {[winfo depth $w] > 1} {
32
+ set bold "-background #43ce80 -relief raised -borderwidth 1"
33
+ set normal "-background {} -relief flat"
34
+ } else {
35
+ set bold "-foreground white -background black"
36
+ set normal "-foreground {} -background {}"
37
+ }
38
+
39
+ # Add text to widget.
40
+
41
+ $w.text insert 0.0 {\
42
+ The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked. For example, in the text below the descriptions of the canvas demonstrations have been tagged. When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked.
43
+
44
+ }
45
+ $w.text insert end \
46
+ {1. Samples of all the different types of items that can be created in canvas widgets.} d1
47
+ $w.text insert end \n\n
48
+ $w.text insert end \
49
+ {2. A simple two-dimensional plot that allows you to adjust the positions of the data points.} d2
50
+ $w.text insert end \n\n
51
+ $w.text insert end \
52
+ {3. Anchoring and justification modes for text items.} d3
53
+ $w.text insert end \n\n
54
+ $w.text insert end \
55
+ {4. An editor for arrow-head shapes for line items.} d4
56
+ $w.text insert end \n\n
57
+ $w.text insert end \
58
+ {5. A ruler with facilities for editing tab stops.} d5
59
+ $w.text insert end \n\n
60
+ $w.text insert end \
61
+ {6. A grid that demonstrates how canvases can be scrolled.} d6
62
+
63
+ # Create bindings for tags.
64
+
65
+ foreach tag {d1 d2 d3 d4 d5 d6} {
66
+ $w.text tag bind $tag <Enter> "$w.text tag configure $tag $bold"
67
+ $w.text tag bind $tag <Leave> "$w.text tag configure $tag $normal"
68
+ }
69
+ # Main widget program sets variable tk_demoDirectory
70
+ $w.text tag bind d1 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory items.tcl]}
71
+ $w.text tag bind d2 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory plot.tcl]}
72
+ $w.text tag bind d3 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory ctext.tcl]}
73
+ $w.text tag bind d4 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory arrow.tcl]}
74
+ $w.text tag bind d5 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory ruler.tcl]}
75
+ $w.text tag bind d6 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory cscroll.tcl]}
76
+
77
+ $w.text mark set insert 0.0
78
+ $w.text configure -state disabled
miniconda3/lib/tk8.6/demos/bitmap.tcl ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bitmap.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window that displays
4
+ # all of Tk's built-in bitmaps.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # bitmapRow --
13
+ # Create a row of bitmap items in a window.
14
+ #
15
+ # Arguments:
16
+ # w - The window that is to contain the row.
17
+ # args - The names of one or more bitmaps, which will be displayed
18
+ # in a new row across the bottom of w along with their
19
+ # names.
20
+
21
+ proc bitmapRow {w args} {
22
+ frame $w
23
+ pack $w -side top -fill both
24
+ set i 0
25
+ foreach bitmap $args {
26
+ frame $w.$i
27
+ pack $w.$i -side left -fill both -pady .25c -padx .25c
28
+ label $w.$i.bitmap -bitmap $bitmap
29
+ label $w.$i.label -text $bitmap -width 9
30
+ pack $w.$i.label $w.$i.bitmap -side bottom
31
+ incr i
32
+ }
33
+ }
34
+
35
+ set w .bitmap
36
+ catch {destroy $w}
37
+ toplevel $w
38
+ wm title $w "Bitmap Demonstration"
39
+ wm iconname $w "bitmap"
40
+ positionWindow $w
41
+
42
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."
43
+ pack $w.msg -side top
44
+
45
+ ## See Code / Dismiss buttons
46
+ set btns [addSeeDismiss $w.buttons $w]
47
+ pack $btns -side bottom -fill x
48
+
49
+ frame $w.frame
50
+ bitmapRow $w.frame.0 error gray12 gray25 gray50 gray75
51
+ bitmapRow $w.frame.1 hourglass info question questhead warning
52
+ pack $w.frame -side top -expand yes -fill both
miniconda3/lib/tk8.6/demos/browse ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # browse --
6
+ # This script generates a directory browser, which lists the working
7
+ # directory and allows you to open files or subdirectories by
8
+ # double-clicking.
9
+
10
+ package require Tk
11
+
12
+ # Create a scrollbar on the right side of the main window and a listbox
13
+ # on the left side.
14
+
15
+ scrollbar .scroll -command ".list yview"
16
+ pack .scroll -side right -fill y
17
+ listbox .list -yscroll ".scroll set" -relief sunken -width 20 -height 20 \
18
+ -setgrid yes
19
+ pack .list -side left -fill both -expand yes
20
+ wm minsize . 1 1
21
+
22
+ # The procedure below is invoked to open a browser on a given file; if the
23
+ # file is a directory then another instance of this program is invoked; if
24
+ # the file is a regular file then the Mx editor is invoked to display
25
+ # the file.
26
+
27
+ set browseScript [file join [pwd] $argv0]
28
+ proc browse {dir file} {
29
+ global env browseScript
30
+ if {[string compare $dir "."] != 0} {set file $dir/$file}
31
+ switch [file type $file] {
32
+ directory {
33
+ exec [info nameofexecutable] $browseScript $file &
34
+ }
35
+ file {
36
+ if {[info exists env(EDITOR)]} {
37
+ eval exec $env(EDITOR) $file &
38
+ } else {
39
+ exec xedit $file &
40
+ }
41
+ }
42
+ default {
43
+ puts stdout "\"$file\" isn't a directory or regular file"
44
+ }
45
+ }
46
+ }
47
+
48
+ # Fill the listbox with a list of all the files in the directory.
49
+
50
+ if {$argc>0} {set dir [lindex $argv 0]} else {set dir "."}
51
+ foreach i [lsort [glob * .* *.*]] {
52
+ if {[file type $i] eq "directory"} {
53
+ # Safe to do since it is still a directory.
54
+ append i /
55
+ }
56
+ .list insert end $i
57
+ }
58
+
59
+ # Set up bindings for the browser.
60
+
61
+ bind all <Control-c> {destroy .}
62
+ bind .list <Double-Button-1> {foreach i [selection get] {browse $dir $i}}
63
+
64
+ # Local Variables:
65
+ # mode: tcl
66
+ # End:
miniconda3/lib/tk8.6/demos/button.tcl ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # button.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several button widgets.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .button
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Button Demonstration"
16
+ wm iconname $w "button"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "If you click on any of the four buttons below, the background of the button area will change to the color indicated in the button. You can press Tab to move among the buttons, then press Space to invoke the current button."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
24
+
25
+ proc colorrefresh {w col} {
26
+ $w configure -bg $col
27
+ if {[tk windowingsystem] eq "aqua"} {
28
+ # set highlightbackground of all buttons in $w
29
+ set l [list $w]
30
+ while {[llength $l]} {
31
+ set l [concat [lassign $l b] [winfo children $b]]
32
+ if {[winfo class $b] eq "Button"} {
33
+ $b configure -highlightbackground $col
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ button $w.b1 -text "Peach Puff" -width 10 \
40
+ -command [list colorrefresh $w PeachPuff1]
41
+ button $w.b2 -text "Light Blue" -width 10 \
42
+ -command [list colorrefresh $w LightBlue1]
43
+ button $w.b3 -text "Sea Green" -width 10 \
44
+ -command [list colorrefresh $w SeaGreen2]
45
+ button $w.b4 -text "Yellow" -width 10 \
46
+ -command [list colorrefresh $w Yellow1]
47
+ pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2
miniconda3/lib/tk8.6/demos/check.tcl ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # check.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several checkbuttons.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .check
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Checkbutton Demonstration"
16
+ wm iconname $w "check"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "Four checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. The first button also follows the state of the other three. If only some of the three are checked, the first button will display the tri-state mode. Click the \"See Variables\" button to see the current values of the variables."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w [list safety wipers brakes sober]]
24
+ pack $btns -side bottom -fill x
25
+
26
+ checkbutton $w.b0 -text "Safety Check" -variable safety -relief flat \
27
+ -onvalue "all" \
28
+ -offvalue "none" \
29
+ -tristatevalue "partial"
30
+ checkbutton $w.b1 -text "Wipers OK" -variable wipers -relief flat
31
+ checkbutton $w.b2 -text "Brakes OK" -variable brakes -relief flat
32
+ checkbutton $w.b3 -text "Driver Sober" -variable sober -relief flat
33
+ pack $w.b0 -side top -pady 2 -anchor w
34
+ pack $w.b1 $w.b2 $w.b3 -side top -pady 2 -anchor w -padx 15
35
+
36
+ ## This code makes $w.b0 function as a tri-state button; it's not
37
+ ## needed at all for just straight yes/no buttons.
38
+
39
+ set in_check 0
40
+ proc tristate_check {n1 n2 op} {
41
+ global safety wipers brakes sober in_check
42
+ if {$in_check} {
43
+ return
44
+ }
45
+ set in_check 1
46
+ if {$n1 eq "safety"} {
47
+ if {$safety eq "none"} {
48
+ set wipers 0
49
+ set brakes 0
50
+ set sober 0
51
+ } elseif {$safety eq "all"} {
52
+ set wipers 1
53
+ set brakes 1
54
+ set sober 1
55
+ }
56
+ } else {
57
+ if {$wipers == 1 && $brakes == 1 && $sober == 1} {
58
+ set safety all
59
+ } elseif {$wipers == 1 || $brakes == 1 || $sober == 1} {
60
+ set safety partial
61
+ } else {
62
+ set safety none
63
+ }
64
+ }
65
+ set in_check 0
66
+ }
67
+
68
+ trace add variable wipers write tristate_check
69
+ trace add variable brakes write tristate_check
70
+ trace add variable sober write tristate_check
71
+ trace add variable safety write tristate_check
miniconda3/lib/tk8.6/demos/clrpick.tcl ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # clrpick.tcl --
2
+ #
3
+ # This demonstration script prompts the user to select a color.
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .clrpick
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Color Selection Dialog"
15
+ wm iconname $w "colors"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 4i -justify left -text "Press the buttons below to choose the foreground and background colors for the widgets in this window."
19
+ pack $w.msg -side top
20
+
21
+ ## See Code / Dismiss buttons
22
+ set btns [addSeeDismiss $w.buttons $w]
23
+ pack $btns -side bottom -fill x
24
+
25
+ button $w.back -text "Set background color ..." \
26
+ -command \
27
+ "setColor $w $w.back background {-background -highlightbackground}"
28
+ button $w.fore -text "Set foreground color ..." \
29
+ -command \
30
+ "setColor $w $w.back foreground -foreground"
31
+
32
+ pack $w.back $w.fore -side top -anchor c -pady 2m
33
+
34
+ proc setColor {w button name options} {
35
+ grab $w
36
+ set initialColor [$button cget -$name]
37
+ set color [tk_chooseColor -title "Choose a $name color" -parent $w \
38
+ -initialcolor $initialColor]
39
+ if {[string compare $color ""]} {
40
+ setColor_helper $w $options $color
41
+ }
42
+ grab release $w
43
+ }
44
+
45
+ proc setColor_helper {w options color} {
46
+ foreach option $options {
47
+ catch {
48
+ $w config $option $color
49
+ }
50
+ }
51
+ foreach child [winfo children $w] {
52
+ setColor_helper $child $options $color
53
+ }
54
+ }
miniconda3/lib/tk8.6/demos/colors.tcl ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # colors.tcl --
2
+ #
3
+ # This demonstration script creates a listbox widget that displays
4
+ # many of the colors from the X color database. You can click on
5
+ # a color to change the application's palette.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ set w .colors
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Listbox Demonstration (colors)"
17
+ wm iconname $w "Listbox"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing several color names is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by dragging in the listbox window with button 2 pressed. If you double-click button 1 on a color, then the application's color palette will be set to match that color"
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ frame $w.frame -borderwidth 10
28
+ pack $w.frame -side top -expand yes -fill y
29
+
30
+ scrollbar $w.frame.scroll -command "$w.frame.list yview"
31
+ listbox $w.frame.list -yscroll "$w.frame.scroll set" \
32
+ -width 20 -height 16 -setgrid 1
33
+ pack $w.frame.list $w.frame.scroll -side left -fill y -expand 1
34
+
35
+ bind $w.frame.list <Double-Button-1> {
36
+ tk_setPalette [selection get]
37
+ }
38
+ $w.frame.list insert 0 gray60 gray70 gray80 gray85 gray90 gray95 \
39
+ snow1 snow2 snow3 snow4 seashell1 seashell2 \
40
+ seashell3 seashell4 AntiqueWhite1 AntiqueWhite2 AntiqueWhite3 \
41
+ AntiqueWhite4 bisque1 bisque2 bisque3 bisque4 PeachPuff1 \
42
+ PeachPuff2 PeachPuff3 PeachPuff4 NavajoWhite1 NavajoWhite2 \
43
+ NavajoWhite3 NavajoWhite4 LemonChiffon1 LemonChiffon2 \
44
+ LemonChiffon3 LemonChiffon4 cornsilk1 cornsilk2 cornsilk3 \
45
+ cornsilk4 ivory1 ivory2 ivory3 ivory4 honeydew1 honeydew2 \
46
+ honeydew3 honeydew4 LavenderBlush1 LavenderBlush2 \
47
+ LavenderBlush3 LavenderBlush4 MistyRose1 MistyRose2 \
48
+ MistyRose3 MistyRose4 azure1 azure2 azure3 azure4 \
49
+ SlateBlue1 SlateBlue2 SlateBlue3 SlateBlue4 RoyalBlue1 \
50
+ RoyalBlue2 RoyalBlue3 RoyalBlue4 blue1 blue2 blue3 blue4 \
51
+ DodgerBlue1 DodgerBlue2 DodgerBlue3 DodgerBlue4 SteelBlue1 \
52
+ SteelBlue2 SteelBlue3 SteelBlue4 DeepSkyBlue1 DeepSkyBlue2 \
53
+ DeepSkyBlue3 DeepSkyBlue4 SkyBlue1 SkyBlue2 SkyBlue3 \
54
+ SkyBlue4 LightSkyBlue1 LightSkyBlue2 LightSkyBlue3 \
55
+ LightSkyBlue4 SlateGray1 SlateGray2 SlateGray3 SlateGray4 \
56
+ LightSteelBlue1 LightSteelBlue2 LightSteelBlue3 \
57
+ LightSteelBlue4 LightBlue1 LightBlue2 LightBlue3 \
58
+ LightBlue4 LightCyan1 LightCyan2 LightCyan3 LightCyan4 \
59
+ PaleTurquoise1 PaleTurquoise2 PaleTurquoise3 PaleTurquoise4 \
60
+ CadetBlue1 CadetBlue2 CadetBlue3 CadetBlue4 turquoise1 \
61
+ turquoise2 turquoise3 turquoise4 cyan1 cyan2 cyan3 cyan4 \
62
+ DarkSlateGray1 DarkSlateGray2 DarkSlateGray3 \
63
+ DarkSlateGray4 aquamarine1 aquamarine2 aquamarine3 \
64
+ aquamarine4 DarkSeaGreen1 DarkSeaGreen2 DarkSeaGreen3 \
65
+ DarkSeaGreen4 SeaGreen1 SeaGreen2 SeaGreen3 SeaGreen4 \
66
+ PaleGreen1 PaleGreen2 PaleGreen3 PaleGreen4 SpringGreen1 \
67
+ SpringGreen2 SpringGreen3 SpringGreen4 green1 green2 \
68
+ green3 green4 chartreuse1 chartreuse2 chartreuse3 \
69
+ chartreuse4 OliveDrab1 OliveDrab2 OliveDrab3 OliveDrab4 \
70
+ DarkOliveGreen1 DarkOliveGreen2 DarkOliveGreen3 \
71
+ DarkOliveGreen4 khaki1 khaki2 khaki3 khaki4 \
72
+ LightGoldenrod1 LightGoldenrod2 LightGoldenrod3 \
73
+ LightGoldenrod4 LightYellow1 LightYellow2 LightYellow3 \
74
+ LightYellow4 yellow1 yellow2 yellow3 yellow4 gold1 gold2 \
75
+ gold3 gold4 goldenrod1 goldenrod2 goldenrod3 goldenrod4 \
76
+ DarkGoldenrod1 DarkGoldenrod2 DarkGoldenrod3 DarkGoldenrod4 \
77
+ RosyBrown1 RosyBrown2 RosyBrown3 RosyBrown4 IndianRed1 \
78
+ IndianRed2 IndianRed3 IndianRed4 sienna1 sienna2 sienna3 \
79
+ sienna4 burlywood1 burlywood2 burlywood3 burlywood4 wheat1 \
80
+ wheat2 wheat3 wheat4 tan1 tan2 tan3 tan4 chocolate1 \
81
+ chocolate2 chocolate3 chocolate4 firebrick1 firebrick2 \
82
+ firebrick3 firebrick4 brown1 brown2 brown3 brown4 salmon1 \
83
+ salmon2 salmon3 salmon4 LightSalmon1 LightSalmon2 \
84
+ LightSalmon3 LightSalmon4 orange1 orange2 orange3 orange4 \
85
+ DarkOrange1 DarkOrange2 DarkOrange3 DarkOrange4 coral1 \
86
+ coral2 coral3 coral4 tomato1 tomato2 tomato3 tomato4 \
87
+ OrangeRed1 OrangeRed2 OrangeRed3 OrangeRed4 red1 red2 red3 \
88
+ red4 DeepPink1 DeepPink2 DeepPink3 DeepPink4 HotPink1 \
89
+ HotPink2 HotPink3 HotPink4 pink1 pink2 pink3 pink4 \
90
+ LightPink1 LightPink2 LightPink3 LightPink4 PaleVioletRed1 \
91
+ PaleVioletRed2 PaleVioletRed3 PaleVioletRed4 maroon1 \
92
+ maroon2 maroon3 maroon4 VioletRed1 VioletRed2 VioletRed3 \
93
+ VioletRed4 magenta1 magenta2 magenta3 magenta4 orchid1 \
94
+ orchid2 orchid3 orchid4 plum1 plum2 plum3 plum4 \
95
+ MediumOrchid1 MediumOrchid2 MediumOrchid3 MediumOrchid4 \
96
+ DarkOrchid1 DarkOrchid2 DarkOrchid3 DarkOrchid4 purple1 \
97
+ purple2 purple3 purple4 MediumPurple1 MediumPurple2 \
98
+ MediumPurple3 MediumPurple4 thistle1 thistle2 thistle3 \
99
+ thistle4
miniconda3/lib/tk8.6/demos/combo.tcl ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # combo.tcl --
2
+ #
3
+ # This demonstration script creates several combobox widgets.
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .combo
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Combobox Demonstration"
15
+ wm iconname $w "combo"
16
+ positionWindow $w
17
+
18
+ ttk::label $w.msg -font $font -wraplength 5i -justify left -text "Three different\
19
+ combo-boxes are displayed below. You can add characters to the first\
20
+ one by pointing, clicking and typing, just as with an entry; pressing\
21
+ Return will cause the current value to be added to the list that is\
22
+ selectable from the drop-down list, and you can choose other values\
23
+ by pressing the Down key, using the arrow keys to pick another one,\
24
+ and pressing Return again. The second combo-box is fixed to a\
25
+ particular value, and cannot be modified at all. The third one only\
26
+ allows you to select values from its drop-down list of Australian\
27
+ cities."
28
+ pack $w.msg -side top -fill x
29
+
30
+ ## See Code / Dismiss buttons
31
+ set btns [addSeeDismiss $w.buttons $w {firstValue secondValue ozCity}]
32
+ pack $btns -side bottom -fill x
33
+
34
+ ttk::frame $w.f
35
+ pack $w.f -fill both -expand 1
36
+ set w $w.f
37
+
38
+ set australianCities {
39
+ Canberra Sydney Melbourne Perth Adelaide Brisbane
40
+ Hobart Darwin "Alice Springs"
41
+ }
42
+ set secondValue unchangable
43
+ set ozCity Sydney
44
+
45
+ ttk::labelframe $w.c1 -text "Fully Editable"
46
+ ttk::combobox $w.c1.c -textvariable firstValue
47
+ ttk::labelframe $w.c2 -text Disabled
48
+ ttk::combobox $w.c2.c -textvariable secondValue -state disabled
49
+ ttk::labelframe $w.c3 -text "Defined List Only"
50
+ ttk::combobox $w.c3.c -textvariable ozCity -state readonly \
51
+ -values $australianCities
52
+ bind $w.c1.c <Return> {
53
+ if {[%W get] ni [%W cget -values]} {
54
+ %W configure -values [concat [%W cget -values] [list [%W get]]]
55
+ }
56
+ }
57
+
58
+ pack $w.c1 $w.c2 $w.c3 -side top -pady 5 -padx 10
59
+ pack $w.c1.c -pady 5 -padx 10
60
+ pack $w.c2.c -pady 5 -padx 10
61
+ pack $w.c3.c -pady 5 -padx 10
miniconda3/lib/tk8.6/demos/cscroll.tcl ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # cscroll.tcl --
2
+ #
3
+ # This demonstration script creates a simple canvas that can be
4
+ # scrolled in two dimensions.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .cscroll
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Scrollable Canvas Demonstration"
16
+ wm iconname $w "cscroll"
17
+ positionWindow $w
18
+ set c $w.c
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ frame $w.grid
28
+ scrollbar $w.hscroll -orient horizontal -command "$c xview"
29
+ scrollbar $w.vscroll -command "$c yview"
30
+ canvas $c -relief sunken -borderwidth 2 -scrollregion {-11c -11c 50c 20c} \
31
+ -xscrollcommand "$w.hscroll set" \
32
+ -yscrollcommand "$w.vscroll set"
33
+ pack $w.grid -expand yes -fill both -padx 1 -pady 1
34
+ grid rowconfig $w.grid 0 -weight 1 -minsize 0
35
+ grid columnconfig $w.grid 0 -weight 1 -minsize 0
36
+
37
+ grid $c -padx 1 -in $w.grid -pady 1 \
38
+ -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
39
+ grid $w.vscroll -in $w.grid -padx 1 -pady 1 \
40
+ -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
41
+ grid $w.hscroll -in $w.grid -padx 1 -pady 1 \
42
+ -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
43
+
44
+
45
+ set bg [lindex [$c config -bg] 4]
46
+ for {set i 0} {$i < 20} {incr i} {
47
+ set x [expr {-10 + 3*$i}]
48
+ for {set j 0; set y -10} {$j < 10} {incr j; incr y 3} {
49
+ $c create rect ${x}c ${y}c [expr {$x+2}]c [expr {$y+2}]c \
50
+ -fill $bg -tags rect
51
+ $c create text [expr {$x+1}]c [expr {$y+1}]c -text "$i,$j" \
52
+ -anchor center -tags text
53
+ }
54
+ }
55
+
56
+ $c bind all <Enter> "scrollEnter $c"
57
+ $c bind all <Leave> "scrollLeave $c"
58
+ $c bind all <Button-1> "scrollButton $c"
59
+ if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} {
60
+ bind $c <Button-3> "$c scan mark %x %y"
61
+ bind $c <B3-Motion> "$c scan dragto %x %y"
62
+ bind $c <MouseWheel> {
63
+ %W yview scroll [expr {-%D}] units
64
+ }
65
+ bind $c <Option-MouseWheel> {
66
+ %W yview scroll [expr {-10*%D}] units
67
+ }
68
+ bind $c <Shift-MouseWheel> {
69
+ %W xview scroll [expr {-%D}] units
70
+ }
71
+ bind $c <Shift-Option-MouseWheel> {
72
+ %W xview scroll [expr {-10*%D}] units
73
+ }
74
+ } else {
75
+ bind $c <Button-2> "$c scan mark %x %y"
76
+ bind $c <B2-Motion> "$c scan dragto %x %y"
77
+ # We must make sure that positive and negative movements are rounded
78
+ # equally to integers, avoiding the problem that
79
+ # (int)1/-30 = -1,
80
+ # but
81
+ # (int)-1/-30 = 0
82
+ # The following code ensures equal +/- behaviour.
83
+ bind $c <MouseWheel> {
84
+ if {%D >= 0} {
85
+ %W yview scroll [expr {%D/-30}] units
86
+ } else {
87
+ %W yview scroll [expr {(%D-29)/-30}] units
88
+ }
89
+ }
90
+ bind $c <Option-MouseWheel> {
91
+ if {%D >= 0} {
92
+ %W yview scroll [expr {%D/-12}] units
93
+ } else {
94
+ %W yview scroll [expr {(%D-11)/-12}] units
95
+ }
96
+ }
97
+ bind $c <Shift-MouseWheel> {
98
+ if {%D >= 0} {
99
+ %W xview scroll [expr {%D/-30}] units
100
+ } else {
101
+ %W xview scroll [expr {(%D-29)/-30}] units
102
+ }
103
+ }
104
+ bind $c <Shift-Option-MouseWheel> {
105
+ if {%D >= 0} {
106
+ %W xview scroll [expr {%D/-12}] units
107
+ } else {
108
+ %W xview scroll [expr {(%D-11)/-12}] units
109
+ }
110
+ }
111
+ }
112
+
113
+ if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} {
114
+ # Support for mousewheels on Linux/Unix commonly comes through mapping
115
+ # the wheel to the extended buttons. If you have a mousewheel, find
116
+ # Linux configuration info at:
117
+ # https://linuxreviews.org/HOWTO_change_the_mouse_speed_in_X
118
+ bind $c <Button-4> {
119
+ if {!$tk_strictMotif} {
120
+ %W yview scroll -5 units
121
+ }
122
+ }
123
+ bind $c <Shift-Button-4> {
124
+ if {!$tk_strictMotif} {
125
+ %W xview scroll -5 units
126
+ }
127
+ }
128
+ bind $c <Button-5> {
129
+ if {!$tk_strictMotif} {
130
+ %W yview scroll 5 units
131
+ }
132
+ }
133
+ bind $c <Shift-Button-5> {
134
+ if {!$tk_strictMotif} {
135
+ %W xview scroll 5 units
136
+ }
137
+ }
138
+ }
139
+
140
+ proc scrollEnter canvas {
141
+ global oldFill
142
+ set id [$canvas find withtag current]
143
+ if {[lsearch [$canvas gettags current] text] >= 0} {
144
+ set id [expr {$id-1}]
145
+ }
146
+ set oldFill [lindex [$canvas itemconfig $id -fill] 4]
147
+ if {[winfo depth $canvas] > 1} {
148
+ if {[tk windowingsystem] eq "aqua"} {
149
+ $canvas itemconfigure $id -fill systemSelectedTextBackgroundColor
150
+ } else {
151
+ $canvas itemconfigure $id -fill LightSeaGreen
152
+ }
153
+ }
154
+ }
155
+
156
+ proc scrollLeave canvas {
157
+ global oldFill
158
+ set id [$canvas find withtag current]
159
+ if {[lsearch [$canvas gettags current] text] >= 0} {
160
+ set id [expr {$id-1}]
161
+ }
162
+ $canvas itemconfigure $id -fill $oldFill
163
+ }
164
+
165
+ proc scrollButton canvas {
166
+ set id [$canvas find withtag current]
167
+ if {[lsearch [$canvas gettags current] text] < 0} {
168
+ set id [expr {$id+1}]
169
+ }
170
+ puts stdout "You buttoned at [lindex [$canvas itemconf $id -text] 4]"
171
+ }
miniconda3/lib/tk8.6/demos/ctext.tcl ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ctext.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widget with a text
4
+ # item that can be edited and reconfigured in various ways.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .ctext
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Canvas Text Demonstration"
16
+ wm iconname $w "Text"
17
+ positionWindow $w
18
+ set c $w.c
19
+
20
+ label $w.msg -font $font -wraplength 5i -justify left -text "This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification, and on a pie slice to change its angle. The text also supports the following simple bindings for editing:
21
+ 1. You can point, click, and type.
22
+ 2. You can also select with button 1.
23
+ 3. You can copy the selection to the mouse position with button 2.
24
+ 4. Backspace and Control+h delete the selection if there is one;
25
+ otherwise they delete the character just before the insertion cursor.
26
+ 5. Delete deletes the selection if there is one; otherwise it deletes
27
+ the character just after the insertion cursor."
28
+ pack $w.msg -side top
29
+
30
+ ## See Code / Dismiss buttons
31
+ set btns [addSeeDismiss $w.buttons $w]
32
+ pack $btns -side bottom -fill x
33
+
34
+ canvas $c -relief flat -borderwidth 0 -width 500 -height 350
35
+ pack $w.c -side top -expand yes -fill both
36
+
37
+ set textFont {Helvetica 24}
38
+
39
+ $c create rectangle 245 195 255 205 -outline black -fill red
40
+
41
+ # First, create the text item and give it bindings so it can be edited.
42
+
43
+ $c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left]
44
+ $c bind text <Button-1> "textB1Press $c %x %y"
45
+ $c bind text <B1-Motion> "textB1Move $c %x %y"
46
+ $c bind text <Shift-Button-1> "$c select adjust current @%x,%y"
47
+ $c bind text <Shift-B1-Motion> "textB1Move $c %x %y"
48
+ $c bind text <Key> "textInsert $c %A"
49
+ $c bind text <Return> "textInsert $c \\n"
50
+ $c bind text <Control-h> "textBs $c"
51
+ $c bind text <BackSpace> "textBs $c"
52
+ $c bind text <Delete> "textDel $c"
53
+ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
54
+ $c bind text <Button-3> "textPaste $c @%x,%y"
55
+ } else {
56
+ $c bind text <Button-2> "textPaste $c @%x,%y"
57
+ }
58
+
59
+ # Next, create some items that allow the text's anchor position
60
+ # to be edited.
61
+
62
+ proc mkTextConfigBox {w x y option value color} {
63
+ set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \
64
+ -outline black -fill $color -width 1]
65
+ $w bind $item <Button-1> "$w itemconf text $option $value"
66
+ $w addtag config withtag $item
67
+ }
68
+ proc mkTextConfigPie {w x y a option value color} {
69
+ set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \
70
+ -start [expr {$a-15}] -extent 30 -outline black -fill $color \
71
+ -width 1]
72
+ $w bind $item <Button-1> "$w itemconf text $option $value"
73
+ $w addtag config withtag $item
74
+ }
75
+
76
+ set x 50
77
+ set y 50
78
+ set color LightSkyBlue1
79
+ mkTextConfigBox $c $x $y -anchor se $color
80
+ mkTextConfigBox $c [expr {$x+30}] [expr {$y }] -anchor s $color
81
+ mkTextConfigBox $c [expr {$x+60}] [expr {$y }] -anchor sw $color
82
+ mkTextConfigBox $c [expr {$x }] [expr {$y+30}] -anchor e $color
83
+ mkTextConfigBox $c [expr {$x+30}] [expr {$y+30}] -anchor center $color
84
+ mkTextConfigBox $c [expr {$x+60}] [expr {$y+30}] -anchor w $color
85
+ mkTextConfigBox $c [expr {$x }] [expr {$y+60}] -anchor ne $color
86
+ mkTextConfigBox $c [expr {$x+30}] [expr {$y+60}] -anchor n $color
87
+ mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color
88
+ set item [$c create rect \
89
+ [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \
90
+ -outline black -fill red]
91
+ $c bind $item <Button-1> "$c itemconf text -anchor center"
92
+ $c create text [expr {$x+45}] [expr {$y-5}] \
93
+ -text {Text Position} -anchor s -font {Times 20} -fill brown
94
+
95
+ # Now create some items that allow the text's angle to be changed.
96
+
97
+ set x 205
98
+ set y 50
99
+ set color Yellow
100
+ mkTextConfigPie $c $x $y 0 -angle 90 $color
101
+ mkTextConfigPie $c $x $y 30 -angle 120 $color
102
+ mkTextConfigPie $c $x $y 60 -angle 150 $color
103
+ mkTextConfigPie $c $x $y 90 -angle 180 $color
104
+ mkTextConfigPie $c $x $y 120 -angle 210 $color
105
+ mkTextConfigPie $c $x $y 150 -angle 240 $color
106
+ mkTextConfigPie $c $x $y 180 -angle 270 $color
107
+ mkTextConfigPie $c $x $y 210 -angle 300 $color
108
+ mkTextConfigPie $c $x $y 240 -angle 330 $color
109
+ mkTextConfigPie $c $x $y 270 -angle 0 $color
110
+ mkTextConfigPie $c $x $y 300 -angle 30 $color
111
+ mkTextConfigPie $c $x $y 330 -angle 60 $color
112
+ $c create text [expr {$x+45}] [expr {$y-5}] \
113
+ -text {Text Angle} -anchor s -font {Times 20} -fill brown
114
+
115
+ # Lastly, create some items that allow the text's justification to be
116
+ # changed.
117
+
118
+ set x 350
119
+ set y 50
120
+ set color SeaGreen2
121
+ mkTextConfigBox $c $x $y -justify left $color
122
+ mkTextConfigBox $c [expr {$x+30}] $y -justify center $color
123
+ mkTextConfigBox $c [expr {$x+60}] $y -justify right $color
124
+ $c create text [expr {$x+45}] [expr {$y-5}] \
125
+ -text {Justification} -anchor s -font {Times 20} -fill brown
126
+
127
+ $c bind config <Enter> "textEnter $c"
128
+ $c bind config <Leave> "$c itemconf current -fill \$textConfigFill"
129
+
130
+ set textConfigFill {}
131
+
132
+ proc textEnter {w} {
133
+ global textConfigFill
134
+ set textConfigFill [lindex [$w itemconfig current -fill] 4]
135
+ $w itemconfig current -fill black
136
+ }
137
+
138
+ proc textInsert {w string} {
139
+ if {$string == ""} {
140
+ return
141
+ }
142
+ catch {$w dchars text sel.first sel.last}
143
+ $w insert text insert $string
144
+ }
145
+
146
+ proc textPaste {w pos} {
147
+ catch {
148
+ $w insert text $pos [selection get]
149
+ }
150
+ }
151
+
152
+ proc textB1Press {w x y} {
153
+ $w icursor current @$x,$y
154
+ $w focus current
155
+ focus $w
156
+ $w select from current @$x,$y
157
+ }
158
+
159
+ proc textB1Move {w x y} {
160
+ $w select to current @$x,$y
161
+ }
162
+
163
+ proc textBs {w} {
164
+ if {![catch {$w dchars text sel.first sel.last}]} {
165
+ return
166
+ }
167
+ set char [expr {[$w index text insert] - 1}]
168
+ if {$char >= 0} {$w dchar text $char}
169
+ }
170
+
171
+ proc textDel {w} {
172
+ if {![catch {$w dchars text sel.first sel.last}]} {
173
+ return
174
+ }
175
+ $w dchars text insert
176
+ }
miniconda3/lib/tk8.6/demos/dialog1.tcl ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dialog1.tcl --
2
+ #
3
+ # This demonstration script creates a dialog box with a local grab.
4
+
5
+ interp create child
6
+ load {} Tk child
7
+ child eval {
8
+ wm title . child
9
+ wm geometry . +700+30
10
+ pack [text .t -width 30 -height 10]
11
+ }
12
+
13
+ after idle {.dialog1.msg configure -wraplength 4i}
14
+ set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "child" which was created by a child interpreter.} \
15
+ info 0 OK Cancel {Show Code}]
16
+
17
+ switch $i {
18
+ 0 {puts "You pressed OK"}
19
+ 1 {puts "You pressed Cancel"}
20
+ 2 {showCode .dialog1}
21
+ }
22
+
23
+ if {[interp exists child]} {
24
+ interp delete child
25
+ }
miniconda3/lib/tk8.6/demos/dialog2.tcl ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dialog2.tcl --
2
+ #
3
+ # This demonstration script creates a dialog box with a global grab.
4
+
5
+ after idle {
6
+ .dialog2.msg configure -wraplength 4i
7
+ }
8
+ after 100 {
9
+ grab -global .dialog2
10
+ }
11
+ set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab. If you are using an X11 window manager you will be prevented from interacting with anything on your display until you invoke one of the buttons below. This is almost always a bad idea; don't use global grabs with X11 unless you're truly desperate. On macOS systems you will not be able to interact with any window belonging to this process, but interaction with other macOS Applications will still be possible.}\
12
+ warning 0 OK Cancel {Show Code}]
13
+
14
+ switch $i {
15
+ 0 {puts "You pressed OK"}
16
+ 1 {puts "You pressed Cancel"}
17
+ 2 {showCode .dialog2}
18
+ }
miniconda3/lib/tk8.6/demos/en.msg ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ::msgcat::mcset en "Widget Demonstration"
2
+ ::msgcat::mcset en "tkWidgetDemo"
3
+ ::msgcat::mcset en "&File"
4
+ ::msgcat::mcset en "About..."
5
+ ::msgcat::mcset en "&About..."
6
+ ::msgcat::mcset en "<F1>"
7
+ ::msgcat::mcset en "&Quit"
8
+ ::msgcat::mcset en "Meta+Q" ;# Displayed hotkey
9
+ ::msgcat::mcset en "Meta-q" ;# Actual binding sequence
10
+ ::msgcat::mcset en "Ctrl+Q" ;# Displayed hotkey
11
+ ::msgcat::mcset en "Control-q" ;# Actual binding sequence
12
+ ::msgcat::mcset en "Variable values"
13
+ ::msgcat::mcset en "Variable values:"
14
+ ::msgcat::mcset en "OK"
15
+ ::msgcat::mcset en "Run the \"%s\" sample program"
16
+ ::msgcat::mcset en "Dismiss"
17
+ ::msgcat::mcset en "Rerun Demo"
18
+ ::msgcat::mcset en "Demo code: %s"
19
+ ::msgcat::mcset en "About Widget Demo"
20
+ ::msgcat::mcset en "Tk widget demonstration application"
21
+ ::msgcat::mcset en "Copyright © %s"
22
+ ::msgcat::mcset en "
23
+ @@title
24
+ Tk Widget Demonstrations
25
+ @@newline
26
+ @@normal
27
+ @@newline
28
+
29
+ This application provides a front end for several short scripts
30
+ that demonstrate what you can do with Tk widgets. Each of the
31
+ numbered lines below describes a demonstration; you can click on
32
+ it to invoke the demonstration. Once the demonstration window
33
+ appears, you can click the
34
+ @@bold
35
+ See Code
36
+ @@normal
37
+ button to see the Tcl/Tk code that created the demonstration. If
38
+ you wish, you can edit the code and click the
39
+ @@bold
40
+ Rerun Demo
41
+ @@normal
42
+ button in the code window to reinvoke the demonstration with the
43
+ modified code.
44
+ @@newline
45
+ "
46
+ ::msgcat::mcset en "Labels, buttons, checkbuttons, and radiobuttons"
47
+ ::msgcat::mcset en "Labels (text and bitmaps)"
48
+ ::msgcat::mcset en "Labels and UNICODE text"
49
+ ::msgcat::mcset en "Buttons"
50
+ ::msgcat::mcset en "Check-buttons (select any of a group)"
51
+ ::msgcat::mcset en "Radio-buttons (select one of a group)"
52
+ ::msgcat::mcset en "A 15-puzzle game made out of buttons"
53
+ ::msgcat::mcset en "Iconic buttons that use bitmaps"
54
+ ::msgcat::mcset en "Two labels displaying images"
55
+ ::msgcat::mcset en "A simple user interface for viewing images"
56
+ ::msgcat::mcset en "Labelled frames"
57
+ ::msgcat::mcset en "Listboxes"
58
+ ::msgcat::mcset en "The 50 states"
59
+ ::msgcat::mcset en "Colors: change the color scheme for the application"
60
+ ::msgcat::mcset en "A collection of famous and infamous sayings"
61
+ ::msgcat::mcset en "Entries and Spin-boxes"
62
+ ::msgcat::mcset en "Entries without scrollbars"
63
+ ::msgcat::mcset en "Entries with scrollbars"
64
+ ::msgcat::mcset en "Validated entries and password fields"
65
+ ::msgcat::mcset en "Spin-boxes"
66
+ ::msgcat::mcset en "Simple Rolodex-like form"
67
+ ::msgcat::mcset en "Text"
68
+ ::msgcat::mcset en "Basic editable text"
69
+ ::msgcat::mcset en "Text display styles"
70
+ ::msgcat::mcset en "Hypertext (tag bindings)"
71
+ ::msgcat::mcset en "A text widget with embedded windows"
72
+ ::msgcat::mcset en "A search tool built with a text widget"
73
+ ::msgcat::mcset en "Canvases"
74
+ ::msgcat::mcset en "The canvas item types"
75
+ ::msgcat::mcset en "A simple 2-D plot"
76
+ ::msgcat::mcset en "Text items in canvases"
77
+ ::msgcat::mcset en "An editor for arrowheads on canvas lines"
78
+ ::msgcat::mcset en "A ruler with adjustable tab stops"
79
+ ::msgcat::mcset en "A building floor plan"
80
+ ::msgcat::mcset en "A simple scrollable canvas"
81
+ ::msgcat::mcset en "Scales"
82
+ ::msgcat::mcset en "Horizontal scale"
83
+ ::msgcat::mcset en "Vertical scale"
84
+ ::msgcat::mcset en "Paned Windows"
85
+ ::msgcat::mcset en "Horizontal paned window"
86
+ ::msgcat::mcset en "Vertical paned window"
87
+ ::msgcat::mcset en "Menus"
88
+ ::msgcat::mcset en "Menus and cascades (sub-menus)"
89
+ ::msgcat::mcset en "Menu-buttons"
90
+ ::msgcat::mcset en "Common Dialogs"
91
+ ::msgcat::mcset en "Message boxes"
92
+ ::msgcat::mcset en "File selection dialog"
93
+ ::msgcat::mcset en "Color picker"
94
+ ::msgcat::mcset en "Miscellaneous"
95
+ ::msgcat::mcset en "The built-in bitmaps"
96
+ ::msgcat::mcset en "A dialog box with a local grab"
97
+ ::msgcat::mcset en "A dialog box with a global grab"
miniconda3/lib/tk8.6/demos/entry1.tcl ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry1.tcl --
2
+ #
3
+ # This demonstration script creates several entry widgets without
4
+ # scrollbars.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .entry1
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Entry Demonstration (no scrollbars)"
16
+ wm iconname $w "entry1"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse the middle mouse button pressed."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ entry $w.e1
27
+ entry $w.e2
28
+ entry $w.e3
29
+ pack $w.e1 $w.e2 $w.e3 -side top -pady 5 -padx 10 -fill x
30
+
31
+ $w.e1 insert 0 "Initial value"
32
+ $w.e2 insert end "This entry contains a long value, much too long "
33
+ $w.e2 insert end "to fit in the window at one time, so long in fact "
34
+ $w.e2 insert end "that you'll have to scan or scroll to see the end."
miniconda3/lib/tk8.6/demos/entry2.tcl ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry2.tcl --
2
+ #
3
+ # This demonstration script is the same as the entry1.tcl script
4
+ # except that it creates scrollbars for the entries.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .entry2
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Entry Demonstration (with scrollbars)"
16
+ wm iconname $w "entry2"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with the middle mouse button pressed."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ frame $w.frame -borderwidth 10
27
+ pack $w.frame -side top -fill x -expand 1
28
+
29
+ entry $w.frame.e1 -xscrollcommand "$w.frame.s1 set"
30
+ ttk::scrollbar $w.frame.s1 -orient horizontal -command \
31
+ "$w.frame.e1 xview"
32
+ frame $w.frame.spacer1 -width 20 -height 10
33
+ entry $w.frame.e2 -xscrollcommand "$w.frame.s2 set"
34
+ ttk::scrollbar $w.frame.s2 -orient horizontal -command \
35
+ "$w.frame.e2 xview"
36
+ frame $w.frame.spacer2 -width 20 -height 10
37
+ entry $w.frame.e3 -xscrollcommand "$w.frame.s3 set"
38
+ ttk::scrollbar $w.frame.s3 -orient horizontal -command \
39
+ "$w.frame.e3 xview"
40
+ pack $w.frame.e1 $w.frame.s1 $w.frame.spacer1 $w.frame.e2 $w.frame.s2 \
41
+ $w.frame.spacer2 $w.frame.e3 $w.frame.s3 -side top -fill x
42
+
43
+ $w.frame.e1 insert 0 "Initial value"
44
+ $w.frame.e2 insert end "This entry contains a long value, much too long "
45
+ $w.frame.e2 insert end "to fit in the window at one time, so long in fact "
46
+ $w.frame.e2 insert end "that you'll have to scan or scroll to see the end."
miniconda3/lib/tk8.6/demos/entry3.tcl ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry3.tcl --
2
+ #
3
+ # This demonstration script creates several entry widgets whose
4
+ # permitted input is constrained in some way. It also shows off a
5
+ # password entry.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ set w .entry3
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Constrained Entry Demonstration"
17
+ wm iconname $w "entry3"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 5i -justify left -text "Four different\
21
+ entries are displayed below. You can add characters by pointing,\
22
+ clicking and typing, though each is constrained in what it will\
23
+ accept. The first only accepts 32-bit integers or the empty string\
24
+ (checking when focus leaves it) and will flash to indicate any\
25
+ problem. The second only accepts strings with fewer than ten\
26
+ characters and sounds the bell when an attempt to go over the limit\
27
+ is made. The third accepts US phone numbers, mapping letters to\
28
+ their digit equivalent and sounding the bell on encountering an\
29
+ illegal character or if trying to type over a character that is not\
30
+ a digit. The fourth is a password field that accepts up to eight\
31
+ characters (silently ignoring further ones), and displaying them as\
32
+ asterisk characters."
33
+
34
+ ## See Code / Dismiss buttons
35
+ set btns [addSeeDismiss $w.buttons $w]
36
+ pack $btns -side bottom -fill x
37
+
38
+ # focusAndFlash --
39
+ # Error handler for entry widgets that forces the focus onto the
40
+ # widget and makes the widget flash by exchanging the foreground and
41
+ # background colours at intervals of 200ms (i.e. at approximately
42
+ # 2.5Hz).
43
+ #
44
+ # Arguments:
45
+ # W - Name of entry widget to flash
46
+ # fg - Initial foreground colour
47
+ # bg - Initial background colour
48
+ # count - Counter to control the number of times flashed
49
+
50
+ proc focusAndFlash {W fg bg {count 9}} {
51
+ focus -force $W
52
+ if {$count<1} {
53
+ $W configure -foreground $fg -background $bg
54
+ } else {
55
+ if {$count%2} {
56
+ $W configure -foreground $bg -background $fg
57
+ } else {
58
+ $W configure -foreground $fg -background $bg
59
+ }
60
+ after 200 [list focusAndFlash $W $fg $bg [expr {$count-1}]]
61
+ }
62
+ }
63
+
64
+ labelframe $w.l1 -text "Integer Entry"
65
+ # Alternatively try using {string is digit} for arbitrary length numbers,
66
+ # and not just 32-bit ones.
67
+ entry $w.l1.e -validate focus -vcmd {string is integer %P}
68
+ $w.l1.e configure -invalidcommand \
69
+ "focusAndFlash %W [$w.l1.e cget -fg] [$w.l1.e cget -bg]"
70
+ pack $w.l1.e -fill x -expand 1 -padx 1m -pady 1m
71
+
72
+ labelframe $w.l2 -text "Length-Constrained Entry"
73
+ entry $w.l2.e -validate key -invcmd bell -vcmd {expr {[string length %P]<10}}
74
+ pack $w.l2.e -fill x -expand 1 -padx 1m -pady 1m
75
+
76
+ ### PHONE NUMBER ENTRY ###
77
+ # Note that the source to this is quite a bit longer as the behaviour
78
+ # demonstrated is a lot more ambitious than with the others.
79
+
80
+ # Initial content for the third entry widget
81
+ set entry3content "1-(000)-000-0000"
82
+ # Mapping from alphabetic characters to numbers. This is probably
83
+ # wrong, but it is the only mapping I have; the UK doesn't really go
84
+ # for associating letters with digits for some reason.
85
+ set phoneNumberMap {}
86
+ foreach {chars digit} {abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9} {
87
+ foreach char [split $chars ""] {
88
+ lappend phoneNumberMap $char $digit [string toupper $char] $digit
89
+ }
90
+ }
91
+
92
+ # validatePhoneChange --
93
+ # Checks that the replacement (mapped to a digit) of the given
94
+ # character in an entry widget at the given position will leave a
95
+ # valid phone number in the widget.
96
+ #
97
+ # W - The entry widget to validate
98
+ # vmode - The widget's validation mode
99
+ # idx - The index where replacement is to occur
100
+ # char - The character (or string, though that will always be
101
+ # refused) to be overwritten at that point.
102
+
103
+ proc validatePhoneChange {W vmode idx char} {
104
+ global phoneNumberMap entry3content
105
+ if {$idx < 0} {return 1}
106
+ after idle [list $W configure -validate $vmode -invcmd bell]
107
+ if {
108
+ !($idx<3 || $idx==6 || $idx==7 || $idx==11 || $idx>15) &&
109
+ [string match {[0-9A-Za-z]} $char]
110
+ } then {
111
+ $W delete $idx
112
+ $W insert $idx [string map $phoneNumberMap $char]
113
+ after idle [list phoneSkipRight $W -1]
114
+ return 1
115
+ }
116
+ return 0
117
+ }
118
+
119
+ # phoneSkipLeft --
120
+ # Skip over fixed characters in a phone-number string when moving left.
121
+ #
122
+ # Arguments:
123
+ # W - The entry widget containing the phone-number.
124
+
125
+ proc phoneSkipLeft {W} {
126
+ set idx [$W index insert]
127
+ if {$idx == 8} {
128
+ # Skip back two extra characters
129
+ $W icursor [incr idx -2]
130
+ } elseif {$idx == 7 || $idx == 12} {
131
+ # Skip back one extra character
132
+ $W icursor [incr idx -1]
133
+ } elseif {$idx <= 3} {
134
+ # Can't move any further
135
+ bell
136
+ return -code break
137
+ }
138
+ }
139
+
140
+ # phoneSkipRight --
141
+ # Skip over fixed characters in a phone-number string when moving right.
142
+ #
143
+ # Arguments:
144
+ # W - The entry widget containing the phone-number.
145
+ # add - Offset to add to index before calculation (used by validation.)
146
+
147
+ proc phoneSkipRight {W {add 0}} {
148
+ set idx [$W index insert]
149
+ if {$idx+$add == 5} {
150
+ # Skip forward two extra characters
151
+ $W icursor [incr idx 2]
152
+ } elseif {$idx+$add == 6 || $idx+$add == 10} {
153
+ # Skip forward one extra character
154
+ $W icursor [incr idx]
155
+ } elseif {$idx+$add == 15 && !$add} {
156
+ # Can't move any further
157
+ bell
158
+ return -code break
159
+ }
160
+ }
161
+
162
+ labelframe $w.l3 -text "US Phone-Number Entry"
163
+ entry $w.l3.e -validate key -invcmd bell -textvariable entry3content \
164
+ -vcmd {validatePhoneChange %W %v %i %S}
165
+ # Click to focus goes to the first editable character...
166
+ bind $w.l3.e <FocusIn> {
167
+ if {"%d" ne "NotifyAncestor"} {
168
+ %W icursor 3
169
+ after idle {%W selection clear}
170
+ }
171
+ }
172
+ bind $w.l3.e <<PrevChar>> {phoneSkipLeft %W}
173
+ bind $w.l3.e <<NextChar>> {phoneSkipRight %W}
174
+ pack $w.l3.e -fill x -expand 1 -padx 1m -pady 1m
175
+
176
+ labelframe $w.l4 -text "Password Entry"
177
+ entry $w.l4.e -validate key -show "*" -vcmd {expr {[string length %P]<=8}}
178
+ pack $w.l4.e -fill x -expand 1 -padx 1m -pady 1m
179
+
180
+ lower [frame $w.mid]
181
+ grid $w.l1 $w.l2 -in $w.mid -padx 3m -pady 1m -sticky ew
182
+ grid $w.l3 $w.l4 -in $w.mid -padx 3m -pady 1m -sticky ew
183
+ grid columnconfigure $w.mid {0 1} -uniform 1
184
+ pack $w.msg -side top
185
+ pack $w.mid -fill both -expand 1
miniconda3/lib/tk8.6/demos/filebox.tcl ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filebox.tcl --
2
+ #
3
+ # This demonstration script prompts the user to select a file.
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .filebox
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "File Selection Dialogs"
15
+ wm iconname $w "filebox"
16
+ positionWindow $w
17
+
18
+ ttk::frame $w._bg
19
+ place $w._bg -x 0 -y 0 -relwidth 1 -relheight 1
20
+
21
+ ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog."
22
+ pack $w.msg -side top
23
+
24
+ ## See Code / Dismiss buttons
25
+ set btns [addSeeDismiss $w.buttons $w]
26
+ pack $btns -side bottom -fill x
27
+
28
+ foreach i {open save} {
29
+ set f [ttk::frame $w.$i]
30
+ ttk::label $f.lab -text "Select a file to $i: " -anchor e
31
+ ttk::entry $f.ent -width 20
32
+ ttk::button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i"
33
+ pack $f.lab -side left
34
+ pack $f.ent -side left -expand yes -fill x
35
+ pack $f.but -side left
36
+ pack $f -fill x -padx 1c -pady 3
37
+ }
38
+
39
+ if {[tk windowingsystem] eq "x11"} {
40
+ ttk::checkbutton $w.strict -text "Use Motif Style Dialog" \
41
+ -variable tk_strictMotif -onvalue 1 -offvalue 0
42
+ pack $w.strict -anchor c
43
+
44
+ # This binding ensures that we don't run the rest of the demos
45
+ # with motif style interactions
46
+ bind $w.strict <Destroy> {set tk_strictMotif 0}
47
+ }
48
+
49
+ proc fileDialog {w ent operation} {
50
+ # Type names Extension(s) Mac File Type(s)
51
+ #
52
+ #---------------------------------------------------------
53
+ set types {
54
+ {"Text files" {.txt .doc} }
55
+ {"Text files" {} TEXT}
56
+ {"Tcl Scripts" {.tcl} TEXT}
57
+ {"C Source Files" {.c .h} }
58
+ {"All Source Files" {.tcl .c .h} }
59
+ {"Image Files" {.gif} }
60
+ {"Image Files" {.jpeg .jpg} }
61
+ {"Image Files" "" {GIFF JPEG}}
62
+ {"All files" *}
63
+ }
64
+ if {$operation == "open"} {
65
+ global selected_type
66
+ if {![info exists selected_type]} {
67
+ set selected_type "Tcl Scripts"
68
+ }
69
+ set file [tk_getOpenFile -filetypes $types -parent $w \
70
+ -typevariable selected_type]
71
+ puts "You selected filetype \"$selected_type\""
72
+ } else {
73
+ set file [tk_getSaveFile -filetypes $types -parent $w \
74
+ -initialfile Untitled -defaultextension .txt]
75
+ }
76
+ if {[string compare $file ""]} {
77
+ $ent delete 0 end
78
+ $ent insert 0 $file
79
+ $ent xview end
80
+ }
81
+ }
miniconda3/lib/tk8.6/demos/floor.tcl ADDED
@@ -0,0 +1,1372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # floor.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widet that displays the
4
+ # floorplan for DEC's Western Research Laboratory.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # floorDisplay --
13
+ # Recreate the floorplan display in the canvas given by "w". The
14
+ # floor given by "active" is displayed on top with its office structure
15
+ # visible.
16
+ #
17
+ # Arguments:
18
+ # w - Name of the canvas window.
19
+ # active - Number of active floor (1, 2, or 3).
20
+
21
+ proc floorDisplay {w active} {
22
+ global floorLabels floorItems colors activeFloor
23
+
24
+ if {$activeFloor == $active} {
25
+ return
26
+ }
27
+
28
+ $w delete all
29
+ set activeFloor $active
30
+
31
+ # First go through the three floors, displaying the backgrounds for
32
+ # each floor.
33
+
34
+ bg1 $w $colors(bg1) $colors(outline1)
35
+ bg2 $w $colors(bg2) $colors(outline2)
36
+ bg3 $w $colors(bg3) $colors(outline3)
37
+
38
+ # Raise the background for the active floor so that it's on top.
39
+
40
+ $w raise floor$active
41
+
42
+ # Create a dummy item just to mark this point in the display list,
43
+ # so we can insert highlights here.
44
+
45
+ $w create rect 0 100 1 101 -fill {} -outline {} -tags marker
46
+
47
+ # Add the walls and labels for the active floor, along with
48
+ # transparent polygons that define the rooms on the floor.
49
+ # Make sure that the room polygons are on top.
50
+
51
+ catch {unset floorLabels}
52
+ catch {unset floorItems}
53
+ fg$active $w $colors(offices)
54
+ $w raise room
55
+
56
+ # Offset the floors diagonally from each other.
57
+
58
+ $w move floor1 2c 2c
59
+ $w move floor2 1c 1c
60
+
61
+ # Create items for the room entry and its label.
62
+
63
+ $w create window 600 100 -anchor w -window $w.entry
64
+ $w create text 600 100 -anchor e -text "Room: "
65
+
66
+ $w config -scrollregion [$w bbox all]
67
+ }
68
+
69
+ # newRoom --
70
+ # This procedure is invoked whenever the mouse enters a room
71
+ # in the floorplan. It changes tags so that the current room is
72
+ # highlighted.
73
+ #
74
+ # Arguments:
75
+ # w - The name of the canvas window.
76
+
77
+ proc newRoom w {
78
+ global currentRoom floorLabels
79
+
80
+ set id [$w find withtag current]
81
+ if {$id != ""} {
82
+ set currentRoom $floorLabels($id)
83
+ }
84
+ update idletasks
85
+ }
86
+
87
+ # roomChanged --
88
+ # This procedure is invoked whenever the currentRoom variable changes.
89
+ # It highlights the current room and unhighlights any previous room.
90
+ #
91
+ # Arguments:
92
+ # w - The canvas window displaying the floorplan.
93
+ # args - Not used.
94
+
95
+ proc roomChanged {w args} {
96
+ global currentRoom floorItems colors
97
+ $w delete highlight
98
+ if {[catch {set item $floorItems($currentRoom)}]} {
99
+ return
100
+ }
101
+ set new [eval \
102
+ "$w create polygon [$w coords $item] -fill $colors(active) \
103
+ -outline {} -tags highlight"]
104
+ $w raise $new marker
105
+ }
106
+
107
+ # bg1 --
108
+ # This procedure represents part of the floorplan database. When
109
+ # invoked, it instantiates the background information for the first
110
+ # floor.
111
+ #
112
+ # Arguments:
113
+ # w - The canvas window.
114
+ # fill - Fill color to use for the floor's background.
115
+ # outline - Color to use for the floor's outline.
116
+
117
+ proc bg1 {w fill outline} {
118
+ $w create polygon 347 80 349 82 351 84 353 85 363 92 375 99 386 104 \
119
+ 386 129 398 129 398 162 484 162 484 129 559 129 559 133 725 \
120
+ 133 725 129 802 129 802 389 644 389 644 391 559 391 559 327 \
121
+ 508 327 508 311 484 311 484 278 395 278 395 288 400 288 404 \
122
+ 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 \
123
+ 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 \
124
+ 342 331 347 332 351 334 354 336 357 341 359 340 360 335 363 \
125
+ 331 365 326 366 304 366 304 355 258 355 258 387 60 387 60 391 \
126
+ 0 391 0 337 3 337 3 114 8 114 8 25 30 25 30 5 93 5 98 5 104 7 \
127
+ 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 34 221 \
128
+ 22 223 17 227 13 231 8 236 4 242 2 246 0 260 0 283 1 300 5 \
129
+ 321 14 335 22 348 25 365 29 363 39 358 48 352 56 337 70 \
130
+ 344 76 347 80 \
131
+ -tags {floor1 bg} -fill $fill -outline {}
132
+ $w create line 386 129 398 129 -fill $outline -tags {floor1 bg}
133
+ $w create line 258 355 258 387 -fill $outline -tags {floor1 bg}
134
+ $w create line 60 387 60 391 -fill $outline -tags {floor1 bg}
135
+ $w create line 0 337 0 391 -fill $outline -tags {floor1 bg}
136
+ $w create line 60 391 0 391 -fill $outline -tags {floor1 bg}
137
+ $w create line 3 114 3 337 -fill $outline -tags {floor1 bg}
138
+ $w create line 258 387 60 387 -fill $outline -tags {floor1 bg}
139
+ $w create line 484 162 398 162 -fill $outline -tags {floor1 bg}
140
+ $w create line 398 162 398 129 -fill $outline -tags {floor1 bg}
141
+ $w create line 484 278 484 311 -fill $outline -tags {floor1 bg}
142
+ $w create line 484 311 508 311 -fill $outline -tags {floor1 bg}
143
+ $w create line 508 327 508 311 -fill $outline -tags {floor1 bg}
144
+ $w create line 559 327 508 327 -fill $outline -tags {floor1 bg}
145
+ $w create line 644 391 559 391 -fill $outline -tags {floor1 bg}
146
+ $w create line 644 389 644 391 -fill $outline -tags {floor1 bg}
147
+ $w create line 559 129 484 129 -fill $outline -tags {floor1 bg}
148
+ $w create line 484 162 484 129 -fill $outline -tags {floor1 bg}
149
+ $w create line 725 133 559 133 -fill $outline -tags {floor1 bg}
150
+ $w create line 559 129 559 133 -fill $outline -tags {floor1 bg}
151
+ $w create line 725 129 802 129 -fill $outline -tags {floor1 bg}
152
+ $w create line 802 389 802 129 -fill $outline -tags {floor1 bg}
153
+ $w create line 3 337 0 337 -fill $outline -tags {floor1 bg}
154
+ $w create line 559 391 559 327 -fill $outline -tags {floor1 bg}
155
+ $w create line 802 389 644 389 -fill $outline -tags {floor1 bg}
156
+ $w create line 725 133 725 129 -fill $outline -tags {floor1 bg}
157
+ $w create line 8 25 8 114 -fill $outline -tags {floor1 bg}
158
+ $w create line 8 114 3 114 -fill $outline -tags {floor1 bg}
159
+ $w create line 30 25 8 25 -fill $outline -tags {floor1 bg}
160
+ $w create line 484 278 395 278 -fill $outline -tags {floor1 bg}
161
+ $w create line 30 25 30 5 -fill $outline -tags {floor1 bg}
162
+ $w create line 93 5 30 5 -fill $outline -tags {floor1 bg}
163
+ $w create line 98 5 93 5 -fill $outline -tags {floor1 bg}
164
+ $w create line 104 7 98 5 -fill $outline -tags {floor1 bg}
165
+ $w create line 110 10 104 7 -fill $outline -tags {floor1 bg}
166
+ $w create line 116 16 110 10 -fill $outline -tags {floor1 bg}
167
+ $w create line 119 20 116 16 -fill $outline -tags {floor1 bg}
168
+ $w create line 122 28 119 20 -fill $outline -tags {floor1 bg}
169
+ $w create line 123 32 122 28 -fill $outline -tags {floor1 bg}
170
+ $w create line 123 68 123 32 -fill $outline -tags {floor1 bg}
171
+ $w create line 220 68 123 68 -fill $outline -tags {floor1 bg}
172
+ $w create line 386 129 386 104 -fill $outline -tags {floor1 bg}
173
+ $w create line 386 104 375 99 -fill $outline -tags {floor1 bg}
174
+ $w create line 375 99 363 92 -fill $outline -tags {floor1 bg}
175
+ $w create line 353 85 363 92 -fill $outline -tags {floor1 bg}
176
+ $w create line 220 68 220 34 -fill $outline -tags {floor1 bg}
177
+ $w create line 337 70 352 56 -fill $outline -tags {floor1 bg}
178
+ $w create line 352 56 358 48 -fill $outline -tags {floor1 bg}
179
+ $w create line 358 48 363 39 -fill $outline -tags {floor1 bg}
180
+ $w create line 363 39 365 29 -fill $outline -tags {floor1 bg}
181
+ $w create line 365 29 348 25 -fill $outline -tags {floor1 bg}
182
+ $w create line 348 25 335 22 -fill $outline -tags {floor1 bg}
183
+ $w create line 335 22 321 14 -fill $outline -tags {floor1 bg}
184
+ $w create line 321 14 300 5 -fill $outline -tags {floor1 bg}
185
+ $w create line 300 5 283 1 -fill $outline -tags {floor1 bg}
186
+ $w create line 283 1 260 0 -fill $outline -tags {floor1 bg}
187
+ $w create line 260 0 246 0 -fill $outline -tags {floor1 bg}
188
+ $w create line 246 0 242 2 -fill $outline -tags {floor1 bg}
189
+ $w create line 242 2 236 4 -fill $outline -tags {floor1 bg}
190
+ $w create line 236 4 231 8 -fill $outline -tags {floor1 bg}
191
+ $w create line 231 8 227 13 -fill $outline -tags {floor1 bg}
192
+ $w create line 223 17 227 13 -fill $outline -tags {floor1 bg}
193
+ $w create line 221 22 223 17 -fill $outline -tags {floor1 bg}
194
+ $w create line 220 34 221 22 -fill $outline -tags {floor1 bg}
195
+ $w create line 340 360 335 363 -fill $outline -tags {floor1 bg}
196
+ $w create line 335 363 331 365 -fill $outline -tags {floor1 bg}
197
+ $w create line 331 365 326 366 -fill $outline -tags {floor1 bg}
198
+ $w create line 326 366 304 366 -fill $outline -tags {floor1 bg}
199
+ $w create line 304 355 304 366 -fill $outline -tags {floor1 bg}
200
+ $w create line 395 288 400 288 -fill $outline -tags {floor1 bg}
201
+ $w create line 404 288 400 288 -fill $outline -tags {floor1 bg}
202
+ $w create line 409 290 404 288 -fill $outline -tags {floor1 bg}
203
+ $w create line 413 292 409 290 -fill $outline -tags {floor1 bg}
204
+ $w create line 418 297 413 292 -fill $outline -tags {floor1 bg}
205
+ $w create line 421 302 418 297 -fill $outline -tags {floor1 bg}
206
+ $w create line 422 309 421 302 -fill $outline -tags {floor1 bg}
207
+ $w create line 421 318 422 309 -fill $outline -tags {floor1 bg}
208
+ $w create line 421 318 417 325 -fill $outline -tags {floor1 bg}
209
+ $w create line 417 325 411 330 -fill $outline -tags {floor1 bg}
210
+ $w create line 411 330 405 332 -fill $outline -tags {floor1 bg}
211
+ $w create line 405 332 397 333 -fill $outline -tags {floor1 bg}
212
+ $w create line 397 333 344 333 -fill $outline -tags {floor1 bg}
213
+ $w create line 344 333 340 334 -fill $outline -tags {floor1 bg}
214
+ $w create line 340 334 336 336 -fill $outline -tags {floor1 bg}
215
+ $w create line 336 336 335 338 -fill $outline -tags {floor1 bg}
216
+ $w create line 335 338 332 342 -fill $outline -tags {floor1 bg}
217
+ $w create line 331 347 332 342 -fill $outline -tags {floor1 bg}
218
+ $w create line 332 351 331 347 -fill $outline -tags {floor1 bg}
219
+ $w create line 334 354 332 351 -fill $outline -tags {floor1 bg}
220
+ $w create line 336 357 334 354 -fill $outline -tags {floor1 bg}
221
+ $w create line 341 359 336 357 -fill $outline -tags {floor1 bg}
222
+ $w create line 341 359 340 360 -fill $outline -tags {floor1 bg}
223
+ $w create line 395 288 395 278 -fill $outline -tags {floor1 bg}
224
+ $w create line 304 355 258 355 -fill $outline -tags {floor1 bg}
225
+ $w create line 347 80 344 76 -fill $outline -tags {floor1 bg}
226
+ $w create line 344 76 337 70 -fill $outline -tags {floor1 bg}
227
+ $w create line 349 82 347 80 -fill $outline -tags {floor1 bg}
228
+ $w create line 351 84 349 82 -fill $outline -tags {floor1 bg}
229
+ $w create line 353 85 351 84 -fill $outline -tags {floor1 bg}
230
+ }
231
+
232
+ # bg2 --
233
+ # This procedure represents part of the floorplan database. When
234
+ # invoked, it instantiates the background information for the second
235
+ # floor.
236
+ #
237
+ # Arguments:
238
+ # w - The canvas window.
239
+ # fill - Fill color to use for the floor's background.
240
+ # outline - Color to use for the floor's outline.
241
+
242
+ proc bg2 {w fill outline} {
243
+ $w create polygon 559 129 484 129 484 162 398 162 398 129 315 129 \
244
+ 315 133 176 133 176 129 96 129 96 133 3 133 3 339 0 339 0 391 \
245
+ 60 391 60 387 258 387 258 329 350 329 350 311 395 311 395 280 \
246
+ 484 280 484 311 508 311 508 327 558 327 558 391 644 391 644 \
247
+ 367 802 367 802 129 725 129 725 133 559 133 559 129 \
248
+ -tags {floor2 bg} -fill $fill -outline {}
249
+ $w create line 350 311 350 329 -fill $outline -tags {floor2 bg}
250
+ $w create line 398 129 398 162 -fill $outline -tags {floor2 bg}
251
+ $w create line 802 367 802 129 -fill $outline -tags {floor2 bg}
252
+ $w create line 802 129 725 129 -fill $outline -tags {floor2 bg}
253
+ $w create line 725 133 725 129 -fill $outline -tags {floor2 bg}
254
+ $w create line 559 129 559 133 -fill $outline -tags {floor2 bg}
255
+ $w create line 559 133 725 133 -fill $outline -tags {floor2 bg}
256
+ $w create line 484 162 484 129 -fill $outline -tags {floor2 bg}
257
+ $w create line 559 129 484 129 -fill $outline -tags {floor2 bg}
258
+ $w create line 802 367 644 367 -fill $outline -tags {floor2 bg}
259
+ $w create line 644 367 644 391 -fill $outline -tags {floor2 bg}
260
+ $w create line 644 391 558 391 -fill $outline -tags {floor2 bg}
261
+ $w create line 558 327 558 391 -fill $outline -tags {floor2 bg}
262
+ $w create line 558 327 508 327 -fill $outline -tags {floor2 bg}
263
+ $w create line 508 327 508 311 -fill $outline -tags {floor2 bg}
264
+ $w create line 484 311 508 311 -fill $outline -tags {floor2 bg}
265
+ $w create line 484 280 484 311 -fill $outline -tags {floor2 bg}
266
+ $w create line 398 162 484 162 -fill $outline -tags {floor2 bg}
267
+ $w create line 484 280 395 280 -fill $outline -tags {floor2 bg}
268
+ $w create line 395 280 395 311 -fill $outline -tags {floor2 bg}
269
+ $w create line 258 387 60 387 -fill $outline -tags {floor2 bg}
270
+ $w create line 3 133 3 339 -fill $outline -tags {floor2 bg}
271
+ $w create line 3 339 0 339 -fill $outline -tags {floor2 bg}
272
+ $w create line 60 391 0 391 -fill $outline -tags {floor2 bg}
273
+ $w create line 0 339 0 391 -fill $outline -tags {floor2 bg}
274
+ $w create line 60 387 60 391 -fill $outline -tags {floor2 bg}
275
+ $w create line 258 329 258 387 -fill $outline -tags {floor2 bg}
276
+ $w create line 350 329 258 329 -fill $outline -tags {floor2 bg}
277
+ $w create line 395 311 350 311 -fill $outline -tags {floor2 bg}
278
+ $w create line 398 129 315 129 -fill $outline -tags {floor2 bg}
279
+ $w create line 176 133 315 133 -fill $outline -tags {floor2 bg}
280
+ $w create line 176 129 96 129 -fill $outline -tags {floor2 bg}
281
+ $w create line 3 133 96 133 -fill $outline -tags {floor2 bg}
282
+ $w create line 315 133 315 129 -fill $outline -tags {floor2 bg}
283
+ $w create line 176 133 176 129 -fill $outline -tags {floor2 bg}
284
+ $w create line 96 133 96 129 -fill $outline -tags {floor2 bg}
285
+ }
286
+
287
+ # bg3 --
288
+ # This procedure represents part of the floorplan database. When
289
+ # invoked, it instantiates the background information for the third
290
+ # floor.
291
+ #
292
+ # Arguments:
293
+ # w - The canvas window.
294
+ # fill - Fill color to use for the floor's background.
295
+ # outline - Color to use for the floor's outline.
296
+
297
+ proc bg3 {w fill outline} {
298
+ $w create polygon 159 300 107 300 107 248 159 248 159 129 96 129 96 \
299
+ 133 21 133 21 331 0 331 0 391 60 391 60 370 159 370 159 300 \
300
+ -tags {floor3 bg} -fill $fill -outline {}
301
+ $w create polygon 258 370 258 329 350 329 350 311 399 311 399 129 \
302
+ 315 129 315 133 176 133 176 129 159 129 159 370 258 370 \
303
+ -tags {floor3 bg} -fill $fill -outline {}
304
+ $w create line 96 133 96 129 -fill $outline -tags {floor3 bg}
305
+ $w create line 176 129 96 129 -fill $outline -tags {floor3 bg}
306
+ $w create line 176 129 176 133 -fill $outline -tags {floor3 bg}
307
+ $w create line 315 133 176 133 -fill $outline -tags {floor3 bg}
308
+ $w create line 315 133 315 129 -fill $outline -tags {floor3 bg}
309
+ $w create line 399 129 315 129 -fill $outline -tags {floor3 bg}
310
+ $w create line 399 311 399 129 -fill $outline -tags {floor3 bg}
311
+ $w create line 399 311 350 311 -fill $outline -tags {floor3 bg}
312
+ $w create line 350 329 350 311 -fill $outline -tags {floor3 bg}
313
+ $w create line 350 329 258 329 -fill $outline -tags {floor3 bg}
314
+ $w create line 258 370 258 329 -fill $outline -tags {floor3 bg}
315
+ $w create line 60 370 258 370 -fill $outline -tags {floor3 bg}
316
+ $w create line 60 370 60 391 -fill $outline -tags {floor3 bg}
317
+ $w create line 60 391 0 391 -fill $outline -tags {floor3 bg}
318
+ $w create line 0 391 0 331 -fill $outline -tags {floor3 bg}
319
+ $w create line 21 331 0 331 -fill $outline -tags {floor3 bg}
320
+ $w create line 21 331 21 133 -fill $outline -tags {floor3 bg}
321
+ $w create line 96 133 21 133 -fill $outline -tags {floor3 bg}
322
+ $w create line 107 300 159 300 159 248 107 248 107 300 \
323
+ -fill $outline -tags {floor3 bg}
324
+ }
325
+
326
+ # fg1 --
327
+ # This procedure represents part of the floorplan database. When
328
+ # invoked, it instantiates the foreground information for the first
329
+ # floor (office outlines and numbers).
330
+ #
331
+ # Arguments:
332
+ # w - The canvas window.
333
+ # color - Color to use for drawing foreground information.
334
+
335
+ proc fg1 {w color} {
336
+ global floorLabels floorItems
337
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor1 room}]
338
+ set floorLabels($i) 101
339
+ set {floorItems(101)} $i
340
+ $w create text 358 209 -text 101 -fill $color -anchor c -tags {floor1 label}
341
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor1 room}]
342
+ set floorLabels($i) {Pub Lift1}
343
+ set {floorItems(Pub Lift1)} $i
344
+ $w create text 323 223 -text {Pub Lift1} -fill $color -anchor c -tags {floor1 label}
345
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor1 room}]
346
+ set floorLabels($i) {Priv Lift1}
347
+ set {floorItems(Priv Lift1)} $i
348
+ $w create text 323 188 -text {Priv Lift1} -fill $color -anchor c -tags {floor1 label}
349
+ set i [$w create polygon 42 389 42 337 1 337 1 389 -fill {} -outline {} -tags {floor1 room}]
350
+ set floorLabels($i) 110
351
+ set {floorItems(110)} $i
352
+ $w create text 21.5 363 -text 110 -fill $color -anchor c -tags {floor1 label}
353
+ set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -fill {} -outline {} -tags {floor1 room}]
354
+ set floorLabels($i) 109
355
+ set {floorItems(109)} $i
356
+ $w create text 67 363 -text 109 -fill $color -anchor c -tags {floor1 label}
357
+ set i [$w create polygon 51 300 51 253 6 253 6 300 -fill {} -outline {} -tags {floor1 room}]
358
+ set floorLabels($i) 111
359
+ set {floorItems(111)} $i
360
+ $w create text 28.5 276.5 -text 111 -fill $color -anchor c -tags {floor1 label}
361
+ set i [$w create polygon 98 248 98 309 79 309 79 248 -fill {} -outline {} -tags {floor1 room}]
362
+ set floorLabels($i) 117B
363
+ set {floorItems(117B)} $i
364
+ $w create text 88.5 278.5 -text 117B -fill $color -anchor c -tags {floor1 label}
365
+ set i [$w create polygon 51 251 51 204 6 204 6 251 -fill {} -outline {} -tags {floor1 room}]
366
+ set floorLabels($i) 112
367
+ set {floorItems(112)} $i
368
+ $w create text 28.5 227.5 -text 112 -fill $color -anchor c -tags {floor1 label}
369
+ set i [$w create polygon 6 156 51 156 51 203 6 203 -fill {} -outline {} -tags {floor1 room}]
370
+ set floorLabels($i) 113
371
+ set {floorItems(113)} $i
372
+ $w create text 28.5 179.5 -text 113 -fill $color -anchor c -tags {floor1 label}
373
+ set i [$w create polygon 85 169 79 169 79 192 85 192 -fill {} -outline {} -tags {floor1 room}]
374
+ set floorLabels($i) 117A
375
+ set {floorItems(117A)} $i
376
+ $w create text 82 180.5 -text 117A -fill $color -anchor c -tags {floor1 label}
377
+ set i [$w create polygon 77 302 77 168 53 168 53 302 -fill {} -outline {} -tags {floor1 room}]
378
+ set floorLabels($i) 117
379
+ set {floorItems(117)} $i
380
+ $w create text 65 235 -text 117 -fill $color -anchor c -tags {floor1 label}
381
+ set i [$w create polygon 51 155 51 115 6 115 6 155 -fill {} -outline {} -tags {floor1 room}]
382
+ set floorLabels($i) 114
383
+ set {floorItems(114)} $i
384
+ $w create text 28.5 135 -text 114 -fill $color -anchor c -tags {floor1 label}
385
+ set i [$w create polygon 95 115 53 115 53 168 95 168 -fill {} -outline {} -tags {floor1 room}]
386
+ set floorLabels($i) 115
387
+ set {floorItems(115)} $i
388
+ $w create text 74 141.5 -text 115 -fill $color -anchor c -tags {floor1 label}
389
+ set i [$w create polygon 87 113 87 27 10 27 10 113 -fill {} -outline {} -tags {floor1 room}]
390
+ set floorLabels($i) 116
391
+ set {floorItems(116)} $i
392
+ $w create text 48.5 70 -text 116 -fill $color -anchor c -tags {floor1 label}
393
+ set i [$w create polygon 89 91 128 91 128 113 89 113 -fill {} -outline {} -tags {floor1 room}]
394
+ set floorLabels($i) 118
395
+ set {floorItems(118)} $i
396
+ $w create text 108.5 102 -text 118 -fill $color -anchor c -tags {floor1 label}
397
+ set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -fill {} -outline {} -tags {floor1 room}]
398
+ set floorLabels($i) 120
399
+ set {floorItems(120)} $i
400
+ $w create text 189.5 111.5 -text 120 -fill $color -anchor c -tags {floor1 label}
401
+ set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -fill {} -outline {} -tags {floor1 room}]
402
+ set floorLabels($i) 122
403
+ set {floorItems(122)} $i
404
+ $w create text 131 207.5 -text 122 -fill $color -anchor c -tags {floor1 label}
405
+ set i [$w create polygon 138 169 154 169 154 191 138 191 -fill {} -outline {} -tags {floor1 room}]
406
+ set floorLabels($i) 121
407
+ set {floorItems(121)} $i
408
+ $w create text 146 180 -text 121 -fill $color -anchor c -tags {floor1 label}
409
+ set i [$w create polygon 99 300 126 300 126 309 99 309 -fill {} -outline {} -tags {floor1 room}]
410
+ set floorLabels($i) 106A
411
+ set {floorItems(106A)} $i
412
+ $w create text 112.5 304.5 -text 106A -fill $color -anchor c -tags {floor1 label}
413
+ set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -fill {} -outline {} -tags {floor1 room}]
414
+ set floorLabels($i) 105
415
+ set {floorItems(105)} $i
416
+ $w create text 124.5 278.5 -text 105 -fill $color -anchor c -tags {floor1 label}
417
+ set i [$w create polygon 174 309 174 300 152 300 152 309 -fill {} -outline {} -tags {floor1 room}]
418
+ set floorLabels($i) 106B
419
+ set {floorItems(106B)} $i
420
+ $w create text 163 304.5 -text 106B -fill $color -anchor c -tags {floor1 label}
421
+ set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -fill {} -outline {} -tags {floor1 room}]
422
+ set floorLabels($i) 104
423
+ set {floorItems(104)} $i
424
+ $w create text 184 278.5 -text 104 -fill $color -anchor c -tags {floor1 label}
425
+ set i [$w create polygon 138 385 138 337 91 337 91 385 -fill {} -outline {} -tags {floor1 room}]
426
+ set floorLabels($i) 108
427
+ set {floorItems(108)} $i
428
+ $w create text 114.5 361 -text 108 -fill $color -anchor c -tags {floor1 label}
429
+ set i [$w create polygon 256 337 140 337 140 385 256 385 -fill {} -outline {} -tags {floor1 room}]
430
+ set floorLabels($i) 107
431
+ set {floorItems(107)} $i
432
+ $w create text 198 361 -text 107 -fill $color -anchor c -tags {floor1 label}
433
+ set i [$w create polygon 300 353 300 329 260 329 260 353 -fill {} -outline {} -tags {floor1 room}]
434
+ set floorLabels($i) Smoking
435
+ set {floorItems(Smoking)} $i
436
+ $w create text 280 341 -text Smoking -fill $color -anchor c -tags {floor1 label}
437
+ set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -fill {} -outline {} -tags {floor1 room}]
438
+ set floorLabels($i) 123
439
+ set {floorItems(123)} $i
440
+ $w create text 245.5 190.5 -text 123 -fill $color -anchor c -tags {floor1 label}
441
+ set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -fill {} -outline {} -tags {floor1 room}]
442
+ set floorLabels($i) 103
443
+ set {floorItems(103)} $i
444
+ $w create text 259 287 -text 103 -fill $color -anchor c -tags {floor1 label}
445
+ set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -fill {} -outline {} -tags {floor1 room}]
446
+ set floorLabels($i) 124
447
+ set {floorItems(124)} $i
448
+ $w create text 356 150 -text 124 -fill $color -anchor c -tags {floor1 label}
449
+ set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -fill {} -outline {} -tags {floor1 room}]
450
+ set floorLabels($i) 125
451
+ set {floorItems(125)} $i
452
+ $w create text 392 217.5 -text 125 -fill $color -anchor c -tags {floor1 label}
453
+ set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -fill {} -outline {} -tags {floor1 room}]
454
+ set floorLabels($i) 126
455
+ set {floorItems(126)} $i
456
+ $w create text 436.5 185.5 -text 126 -fill $color -anchor c -tags {floor1 label}
457
+ set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -fill {} -outline {} -tags {floor1 room}]
458
+ set floorLabels($i) 127
459
+ set {floorItems(127)} $i
460
+ $w create text 436.5 231 -text 127 -fill $color -anchor c -tags {floor1 label}
461
+ set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -fill {} -outline {} -tags {floor1 room}]
462
+ set floorLabels($i) MShower
463
+ set {floorItems(MShower)} $i
464
+ $w create text 488.5 184 -text MShower -fill $color -anchor c -tags {floor1 label}
465
+ set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -fill {} -outline {} -tags {floor1 room}]
466
+ set floorLabels($i) Closet
467
+ set {floorItems(Closet)} $i
468
+ $w create text 502.5 190 -text Closet -fill $color -anchor c -tags {floor1 label}
469
+ set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -fill {} -outline {} -tags {floor1 room}]
470
+ set floorLabels($i) WShower
471
+ set {floorItems(WShower)} $i
472
+ $w create text 494.5 230 -text WShower -fill $color -anchor c -tags {floor1 label}
473
+ set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -fill {} -outline {} -tags {floor1 room}]
474
+ set floorLabels($i) 130
475
+ set {floorItems(130)} $i
476
+ $w create text 638.5 205 -text 130 -fill $color -anchor c -tags {floor1 label}
477
+ set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -fill {} -outline {} -tags {floor1 room}]
478
+ set floorLabels($i) 102
479
+ set {floorItems(102)} $i
480
+ $w create text 367.5 278.5 -text 102 -fill $color -anchor c -tags {floor1 label}
481
+ set i [$w create polygon 397 255 486 255 486 276 397 276 -fill {} -outline {} -tags {floor1 room}]
482
+ set floorLabels($i) 128
483
+ set {floorItems(128)} $i
484
+ $w create text 441.5 265.5 -text 128 -fill $color -anchor c -tags {floor1 label}
485
+ set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -fill {} -outline {} -tags {floor1 room}]
486
+ set floorLabels($i) 129
487
+ set {floorItems(129)} $i
488
+ $w create text 535.5 293 -text 129 -fill $color -anchor c -tags {floor1 label}
489
+ set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -fill {} -outline {} -tags {floor1 room}]
490
+ set floorLabels($i) 133
491
+ set {floorItems(133)} $i
492
+ $w create text 628.5 335 -text 133 -fill $color -anchor c -tags {floor1 label}
493
+ set i [$w create polygon 742 387 742 281 800 281 800 387 -fill {} -outline {} -tags {floor1 room}]
494
+ set floorLabels($i) 132
495
+ set {floorItems(132)} $i
496
+ $w create text 771 334 -text 132 -fill $color -anchor c -tags {floor1 label}
497
+ set i [$w create polygon 800 168 800 280 699 280 699 168 -fill {} -outline {} -tags {floor1 room}]
498
+ set floorLabels($i) 134
499
+ set {floorItems(134)} $i
500
+ $w create text 749.5 224 -text 134 -fill $color -anchor c -tags {floor1 label}
501
+ set i [$w create polygon 726 131 726 166 800 166 800 131 -fill {} -outline {} -tags {floor1 room}]
502
+ set floorLabels($i) 135
503
+ set {floorItems(135)} $i
504
+ $w create text 763 148.5 -text 135 -fill $color -anchor c -tags {floor1 label}
505
+ set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -fill {} -outline {} -tags {floor1 room}]
506
+ set floorLabels($i) {Ramona Stair}
507
+ set {floorItems(Ramona Stair)} $i
508
+ $w create text 368 323 -text {Ramona Stair} -fill $color -anchor c -tags {floor1 label}
509
+ set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -fill {} -outline {} -tags {floor1 room}]
510
+ set floorLabels($i) {University Stair}
511
+ set {floorItems(University Stair)} $i
512
+ $w create text 155 77.5 -text {University Stair} -fill $color -anchor c -tags {floor1 label}
513
+ set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -fill {} -outline {} -tags {floor1 room}]
514
+ set floorLabels($i) {Plaza Stair}
515
+ set {floorItems(Plaza Stair)} $i
516
+ $w create text 317.5 28.5 -text {Plaza Stair} -fill $color -anchor c -tags {floor1 label}
517
+ set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -fill {} -outline {} -tags {floor1 room}]
518
+ set floorLabels($i) {Plaza Deck}
519
+ set {floorItems(Plaza Deck)} $i
520
+ $w create text 303 81 -text {Plaza Deck} -fill $color -anchor c -tags {floor1 label}
521
+ set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -fill {} -outline {} -tags {floor1 room}]
522
+ set floorLabels($i) 106
523
+ set {floorItems(106)} $i
524
+ $w create text 131.5 318.5 -text 106 -fill $color -anchor c -tags {floor1 label}
525
+ set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -fill {} -outline {} -tags {floor1 room}]
526
+ set floorLabels($i) 119
527
+ set {floorItems(119)} $i
528
+ $w create text 143.5 133 -text 119 -fill $color -anchor c -tags {floor1 label}
529
+ $w create line 155 191 155 189 -fill $color -tags {floor1 wall}
530
+ $w create line 155 177 155 169 -fill $color -tags {floor1 wall}
531
+ $w create line 96 129 96 169 -fill $color -tags {floor1 wall}
532
+ $w create line 78 169 176 169 -fill $color -tags {floor1 wall}
533
+ $w create line 176 247 176 129 -fill $color -tags {floor1 wall}
534
+ $w create line 340 206 307 206 -fill $color -tags {floor1 wall}
535
+ $w create line 340 187 340 170 -fill $color -tags {floor1 wall}
536
+ $w create line 340 210 340 201 -fill $color -tags {floor1 wall}
537
+ $w create line 340 247 340 224 -fill $color -tags {floor1 wall}
538
+ $w create line 340 241 307 241 -fill $color -tags {floor1 wall}
539
+ $w create line 376 246 376 170 -fill $color -tags {floor1 wall}
540
+ $w create line 307 247 307 170 -fill $color -tags {floor1 wall}
541
+ $w create line 376 170 307 170 -fill $color -tags {floor1 wall}
542
+ $w create line 315 129 315 170 -fill $color -tags {floor1 wall}
543
+ $w create line 147 129 176 129 -fill $color -tags {floor1 wall}
544
+ $w create line 202 133 176 133 -fill $color -tags {floor1 wall}
545
+ $w create line 398 129 315 129 -fill $color -tags {floor1 wall}
546
+ $w create line 258 352 258 387 -fill $color -tags {floor1 wall}
547
+ $w create line 60 387 60 391 -fill $color -tags {floor1 wall}
548
+ $w create line 0 337 0 391 -fill $color -tags {floor1 wall}
549
+ $w create line 60 391 0 391 -fill $color -tags {floor1 wall}
550
+ $w create line 3 114 3 337 -fill $color -tags {floor1 wall}
551
+ $w create line 258 387 60 387 -fill $color -tags {floor1 wall}
552
+ $w create line 52 237 52 273 -fill $color -tags {floor1 wall}
553
+ $w create line 52 189 52 225 -fill $color -tags {floor1 wall}
554
+ $w create line 52 140 52 177 -fill $color -tags {floor1 wall}
555
+ $w create line 395 306 395 311 -fill $color -tags {floor1 wall}
556
+ $w create line 531 254 398 254 -fill $color -tags {floor1 wall}
557
+ $w create line 475 178 475 238 -fill $color -tags {floor1 wall}
558
+ $w create line 502 162 398 162 -fill $color -tags {floor1 wall}
559
+ $w create line 398 129 398 188 -fill $color -tags {floor1 wall}
560
+ $w create line 383 188 376 188 -fill $color -tags {floor1 wall}
561
+ $w create line 408 188 408 194 -fill $color -tags {floor1 wall}
562
+ $w create line 398 227 398 254 -fill $color -tags {floor1 wall}
563
+ $w create line 408 227 398 227 -fill $color -tags {floor1 wall}
564
+ $w create line 408 222 408 227 -fill $color -tags {floor1 wall}
565
+ $w create line 408 206 408 210 -fill $color -tags {floor1 wall}
566
+ $w create line 408 208 475 208 -fill $color -tags {floor1 wall}
567
+ $w create line 484 278 484 311 -fill $color -tags {floor1 wall}
568
+ $w create line 484 311 508 311 -fill $color -tags {floor1 wall}
569
+ $w create line 508 327 508 311 -fill $color -tags {floor1 wall}
570
+ $w create line 559 327 508 327 -fill $color -tags {floor1 wall}
571
+ $w create line 644 391 559 391 -fill $color -tags {floor1 wall}
572
+ $w create line 644 389 644 391 -fill $color -tags {floor1 wall}
573
+ $w create line 514 205 475 205 -fill $color -tags {floor1 wall}
574
+ $w create line 496 189 496 187 -fill $color -tags {floor1 wall}
575
+ $w create line 559 129 484 129 -fill $color -tags {floor1 wall}
576
+ $w create line 484 162 484 129 -fill $color -tags {floor1 wall}
577
+ $w create line 725 133 559 133 -fill $color -tags {floor1 wall}
578
+ $w create line 559 129 559 133 -fill $color -tags {floor1 wall}
579
+ $w create line 725 149 725 167 -fill $color -tags {floor1 wall}
580
+ $w create line 725 129 802 129 -fill $color -tags {floor1 wall}
581
+ $w create line 802 389 802 129 -fill $color -tags {floor1 wall}
582
+ $w create line 739 167 802 167 -fill $color -tags {floor1 wall}
583
+ $w create line 396 188 408 188 -fill $color -tags {floor1 wall}
584
+ $w create line 0 337 9 337 -fill $color -tags {floor1 wall}
585
+ $w create line 58 337 21 337 -fill $color -tags {floor1 wall}
586
+ $w create line 43 391 43 337 -fill $color -tags {floor1 wall}
587
+ $w create line 105 337 75 337 -fill $color -tags {floor1 wall}
588
+ $w create line 91 387 91 337 -fill $color -tags {floor1 wall}
589
+ $w create line 154 337 117 337 -fill $color -tags {floor1 wall}
590
+ $w create line 139 387 139 337 -fill $color -tags {floor1 wall}
591
+ $w create line 227 337 166 337 -fill $color -tags {floor1 wall}
592
+ $w create line 258 337 251 337 -fill $color -tags {floor1 wall}
593
+ $w create line 258 328 302 328 -fill $color -tags {floor1 wall}
594
+ $w create line 302 355 302 311 -fill $color -tags {floor1 wall}
595
+ $w create line 395 311 302 311 -fill $color -tags {floor1 wall}
596
+ $w create line 484 278 395 278 -fill $color -tags {floor1 wall}
597
+ $w create line 395 294 395 278 -fill $color -tags {floor1 wall}
598
+ $w create line 473 278 473 275 -fill $color -tags {floor1 wall}
599
+ $w create line 473 256 473 254 -fill $color -tags {floor1 wall}
600
+ $w create line 533 257 531 254 -fill $color -tags {floor1 wall}
601
+ $w create line 553 276 551 274 -fill $color -tags {floor1 wall}
602
+ $w create line 698 276 553 276 -fill $color -tags {floor1 wall}
603
+ $w create line 559 391 559 327 -fill $color -tags {floor1 wall}
604
+ $w create line 802 389 644 389 -fill $color -tags {floor1 wall}
605
+ $w create line 741 314 741 389 -fill $color -tags {floor1 wall}
606
+ $w create line 698 280 698 167 -fill $color -tags {floor1 wall}
607
+ $w create line 707 280 698 280 -fill $color -tags {floor1 wall}
608
+ $w create line 802 280 731 280 -fill $color -tags {floor1 wall}
609
+ $w create line 741 280 741 302 -fill $color -tags {floor1 wall}
610
+ $w create line 698 167 727 167 -fill $color -tags {floor1 wall}
611
+ $w create line 725 137 725 129 -fill $color -tags {floor1 wall}
612
+ $w create line 514 254 514 175 -fill $color -tags {floor1 wall}
613
+ $w create line 496 175 514 175 -fill $color -tags {floor1 wall}
614
+ $w create line 502 175 502 162 -fill $color -tags {floor1 wall}
615
+ $w create line 475 166 475 162 -fill $color -tags {floor1 wall}
616
+ $w create line 496 176 496 175 -fill $color -tags {floor1 wall}
617
+ $w create line 491 189 496 189 -fill $color -tags {floor1 wall}
618
+ $w create line 491 205 491 189 -fill $color -tags {floor1 wall}
619
+ $w create line 487 238 475 238 -fill $color -tags {floor1 wall}
620
+ $w create line 487 240 487 238 -fill $color -tags {floor1 wall}
621
+ $w create line 487 252 487 254 -fill $color -tags {floor1 wall}
622
+ $w create line 315 133 304 133 -fill $color -tags {floor1 wall}
623
+ $w create line 256 133 280 133 -fill $color -tags {floor1 wall}
624
+ $w create line 78 247 270 247 -fill $color -tags {floor1 wall}
625
+ $w create line 307 247 294 247 -fill $color -tags {floor1 wall}
626
+ $w create line 214 133 232 133 -fill $color -tags {floor1 wall}
627
+ $w create line 217 247 217 266 -fill $color -tags {floor1 wall}
628
+ $w create line 217 309 217 291 -fill $color -tags {floor1 wall}
629
+ $w create line 217 309 172 309 -fill $color -tags {floor1 wall}
630
+ $w create line 154 309 148 309 -fill $color -tags {floor1 wall}
631
+ $w create line 175 300 175 309 -fill $color -tags {floor1 wall}
632
+ $w create line 151 300 175 300 -fill $color -tags {floor1 wall}
633
+ $w create line 151 247 151 309 -fill $color -tags {floor1 wall}
634
+ $w create line 78 237 78 265 -fill $color -tags {floor1 wall}
635
+ $w create line 78 286 78 309 -fill $color -tags {floor1 wall}
636
+ $w create line 106 309 78 309 -fill $color -tags {floor1 wall}
637
+ $w create line 130 309 125 309 -fill $color -tags {floor1 wall}
638
+ $w create line 99 309 99 247 -fill $color -tags {floor1 wall}
639
+ $w create line 127 299 99 299 -fill $color -tags {floor1 wall}
640
+ $w create line 127 309 127 299 -fill $color -tags {floor1 wall}
641
+ $w create line 155 191 137 191 -fill $color -tags {floor1 wall}
642
+ $w create line 137 169 137 191 -fill $color -tags {floor1 wall}
643
+ $w create line 78 171 78 169 -fill $color -tags {floor1 wall}
644
+ $w create line 78 190 78 218 -fill $color -tags {floor1 wall}
645
+ $w create line 86 192 86 169 -fill $color -tags {floor1 wall}
646
+ $w create line 86 192 78 192 -fill $color -tags {floor1 wall}
647
+ $w create line 52 301 3 301 -fill $color -tags {floor1 wall}
648
+ $w create line 52 286 52 301 -fill $color -tags {floor1 wall}
649
+ $w create line 52 252 3 252 -fill $color -tags {floor1 wall}
650
+ $w create line 52 203 3 203 -fill $color -tags {floor1 wall}
651
+ $w create line 3 156 52 156 -fill $color -tags {floor1 wall}
652
+ $w create line 8 25 8 114 -fill $color -tags {floor1 wall}
653
+ $w create line 63 114 3 114 -fill $color -tags {floor1 wall}
654
+ $w create line 75 114 97 114 -fill $color -tags {floor1 wall}
655
+ $w create line 108 114 129 114 -fill $color -tags {floor1 wall}
656
+ $w create line 129 114 129 89 -fill $color -tags {floor1 wall}
657
+ $w create line 52 114 52 128 -fill $color -tags {floor1 wall}
658
+ $w create line 132 89 88 89 -fill $color -tags {floor1 wall}
659
+ $w create line 88 25 88 89 -fill $color -tags {floor1 wall}
660
+ $w create line 88 114 88 89 -fill $color -tags {floor1 wall}
661
+ $w create line 218 89 144 89 -fill $color -tags {floor1 wall}
662
+ $w create line 147 111 147 129 -fill $color -tags {floor1 wall}
663
+ $w create line 162 111 147 111 -fill $color -tags {floor1 wall}
664
+ $w create line 162 109 162 111 -fill $color -tags {floor1 wall}
665
+ $w create line 162 96 162 89 -fill $color -tags {floor1 wall}
666
+ $w create line 218 89 218 94 -fill $color -tags {floor1 wall}
667
+ $w create line 218 89 218 119 -fill $color -tags {floor1 wall}
668
+ $w create line 8 25 88 25 -fill $color -tags {floor1 wall}
669
+ $w create line 258 337 258 328 -fill $color -tags {floor1 wall}
670
+ $w create line 113 129 96 129 -fill $color -tags {floor1 wall}
671
+ $w create line 302 355 258 355 -fill $color -tags {floor1 wall}
672
+ $w create line 386 104 386 129 -fill $color -tags {floor1 wall}
673
+ $w create line 377 100 386 104 -fill $color -tags {floor1 wall}
674
+ $w create line 365 94 377 100 -fill $color -tags {floor1 wall}
675
+ $w create line 350 83 365 94 -fill $color -tags {floor1 wall}
676
+ $w create line 337 70 350 83 -fill $color -tags {floor1 wall}
677
+ $w create line 337 70 323 56 -fill $color -tags {floor1 wall}
678
+ $w create line 312 49 323 56 -fill $color -tags {floor1 wall}
679
+ $w create line 295 40 312 49 -fill $color -tags {floor1 wall}
680
+ $w create line 282 37 295 40 -fill $color -tags {floor1 wall}
681
+ $w create line 260 34 282 37 -fill $color -tags {floor1 wall}
682
+ $w create line 253 34 260 34 -fill $color -tags {floor1 wall}
683
+ $w create line 386 128 386 104 -fill $color -tags {floor1 wall}
684
+ $w create line 113 152 156 152 -fill $color -tags {floor1 wall}
685
+ $w create line 113 152 156 152 -fill $color -tags {floor1 wall}
686
+ $w create line 113 152 113 129 -fill $color -tags {floor1 wall}
687
+ }
688
+
689
+ # fg2 --
690
+ # This procedure represents part of the floorplan database. When
691
+ # invoked, it instantiates the foreground information for the second
692
+ # floor (office outlines and numbers).
693
+ #
694
+ # Arguments:
695
+ # w - The canvas window.
696
+ # color - Color to use for drawing foreground information.
697
+
698
+ proc fg2 {w color} {
699
+ global floorLabels floorItems
700
+ set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -fill {} -outline {} -tags {floor2 room}]
701
+ set floorLabels($i) 238
702
+ set {floorItems(238)} $i
703
+ $w create text 774 195 -text 238 -fill $color -anchor c -tags {floor2 label}
704
+ set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -fill {} -outline {} -tags {floor2 room}]
705
+ set floorLabels($i) 237
706
+ set {floorItems(237)} $i
707
+ $w create text 763 148.5 -text 237 -fill $color -anchor c -tags {floor2 label}
708
+ set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -fill {} -outline {} -tags {floor2 room}]
709
+ set floorLabels($i) 246
710
+ set {floorItems(246)} $i
711
+ $w create text 600 264 -text 246 -fill $color -anchor c -tags {floor2 label}
712
+ set i [$w create polygon 694 279 643 279 643 314 694 314 -fill {} -outline {} -tags {floor2 room}]
713
+ set floorLabels($i) 247
714
+ set {floorItems(247)} $i
715
+ $w create text 668.5 296.5 -text 247 -fill $color -anchor c -tags {floor2 label}
716
+ set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -fill {} -outline {} -tags {floor2 room}]
717
+ set floorLabels($i) 202
718
+ set {floorItems(202)} $i
719
+ $w create text 285.5 260 -text 202 -fill $color -anchor c -tags {floor2 label}
720
+ set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -fill {} -outline {} -tags {floor2 room}]
721
+ set floorLabels($i) 206
722
+ set {floorItems(206)} $i
723
+ $w create text 143 267 -text 206 -fill $color -anchor c -tags {floor2 label}
724
+ set i [$w create polygon 51 277 6 277 6 338 51 338 -fill {} -outline {} -tags {floor2 room}]
725
+ set floorLabels($i) 212
726
+ set {floorItems(212)} $i
727
+ $w create text 28.5 307.5 -text 212 -fill $color -anchor c -tags {floor2 label}
728
+ set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -fill {} -outline {} -tags {floor2 room}]
729
+ set floorLabels($i) 245
730
+ set {floorItems(245)} $i
731
+ $w create text 521.5 300.5 -text 245 -fill $color -anchor c -tags {floor2 label}
732
+ set i [$w create polygon 560 389 599 389 599 326 560 326 -fill {} -outline {} -tags {floor2 room}]
733
+ set floorLabels($i) 244
734
+ set {floorItems(244)} $i
735
+ $w create text 579.5 357.5 -text 244 -fill $color -anchor c -tags {floor2 label}
736
+ set i [$w create polygon 601 389 601 326 643 326 643 389 -fill {} -outline {} -tags {floor2 room}]
737
+ set floorLabels($i) 243
738
+ set {floorItems(243)} $i
739
+ $w create text 622 357.5 -text 243 -fill $color -anchor c -tags {floor2 label}
740
+ set i [$w create polygon 688 316 645 316 645 365 688 365 -fill {} -outline {} -tags {floor2 room}]
741
+ set floorLabels($i) 242
742
+ set {floorItems(242)} $i
743
+ $w create text 666.5 340.5 -text 242 -fill $color -anchor c -tags {floor2 label}
744
+ set i [$w create polygon 802 367 759 367 759 226 802 226 -fill {} -outline {} -tags {floor2 room}]
745
+ set floorLabels($i) {Barbecue Deck}
746
+ set {floorItems(Barbecue Deck)} $i
747
+ $w create text 780.5 296.5 -text {Barbecue Deck} -fill $color -anchor c -tags {floor2 label}
748
+ set i [$w create polygon 755 262 755 314 717 314 717 262 -fill {} -outline {} -tags {floor2 room}]
749
+ set floorLabels($i) 240
750
+ set {floorItems(240)} $i
751
+ $w create text 736 288 -text 240 -fill $color -anchor c -tags {floor2 label}
752
+ set i [$w create polygon 755 316 689 316 689 365 755 365 -fill {} -outline {} -tags {floor2 room}]
753
+ set floorLabels($i) 241
754
+ set {floorItems(241)} $i
755
+ $w create text 722 340.5 -text 241 -fill $color -anchor c -tags {floor2 label}
756
+ set i [$w create polygon 755 206 717 206 717 261 755 261 -fill {} -outline {} -tags {floor2 room}]
757
+ set floorLabels($i) 239
758
+ set {floorItems(239)} $i
759
+ $w create text 736 233.5 -text 239 -fill $color -anchor c -tags {floor2 label}
760
+ set i [$w create polygon 695 277 643 277 643 206 695 206 -fill {} -outline {} -tags {floor2 room}]
761
+ set floorLabels($i) 248
762
+ set {floorItems(248)} $i
763
+ $w create text 669 241.5 -text 248 -fill $color -anchor c -tags {floor2 label}
764
+ set i [$w create polygon 676 135 676 185 724 185 724 135 -fill {} -outline {} -tags {floor2 room}]
765
+ set floorLabels($i) 236
766
+ set {floorItems(236)} $i
767
+ $w create text 700 160 -text 236 -fill $color -anchor c -tags {floor2 label}
768
+ set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -fill {} -outline {} -tags {floor2 room}]
769
+ set floorLabels($i) 235
770
+ set {floorItems(235)} $i
771
+ $w create text 651.5 160 -text 235 -fill $color -anchor c -tags {floor2 label}
772
+ set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -fill {} -outline {} -tags {floor2 room}]
773
+ set floorLabels($i) 234
774
+ set {floorItems(234)} $i
775
+ $w create text 606 160 -text 234 -fill $color -anchor c -tags {floor2 label}
776
+ set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -fill {} -outline {} -tags {floor2 room}]
777
+ set floorLabels($i) 233
778
+ set {floorItems(233)} $i
779
+ $w create text 552.5 158 -text 233 -fill $color -anchor c -tags {floor2 label}
780
+ set i [$w create polygon 476 249 557 249 557 205 476 205 -fill {} -outline {} -tags {floor2 room}]
781
+ set floorLabels($i) 230
782
+ set {floorItems(230)} $i
783
+ $w create text 516.5 227 -text 230 -fill $color -anchor c -tags {floor2 label}
784
+ set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -fill {} -outline {} -tags {floor2 room}]
785
+ set floorLabels($i) 232
786
+ set {floorItems(232)} $i
787
+ $w create text 500.5 158 -text 232 -fill $color -anchor c -tags {floor2 label}
788
+ set i [$w create polygon 476 186 495 186 495 204 476 204 -fill {} -outline {} -tags {floor2 room}]
789
+ set floorLabels($i) 229
790
+ set {floorItems(229)} $i
791
+ $w create text 485.5 195 -text 229 -fill $color -anchor c -tags {floor2 label}
792
+ set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -fill {} -outline {} -tags {floor2 room}]
793
+ set floorLabels($i) 227
794
+ set {floorItems(227)} $i
795
+ $w create text 436.5 185.5 -text 227 -fill $color -anchor c -tags {floor2 label}
796
+ set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -fill {} -outline {} -tags {floor2 room}]
797
+ set floorLabels($i) 228
798
+ set {floorItems(228)} $i
799
+ $w create text 436.5 231 -text 228 -fill $color -anchor c -tags {floor2 label}
800
+ set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -fill {} -outline {} -tags {floor2 room}]
801
+ set floorLabels($i) 226
802
+ set {floorItems(226)} $i
803
+ $w create text 392 217.5 -text 226 -fill $color -anchor c -tags {floor2 label}
804
+ set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -fill {} -outline {} -tags {floor2 room}]
805
+ set floorLabels($i) 225
806
+ set {floorItems(225)} $i
807
+ $w create text 356.5 150 -text 225 -fill $color -anchor c -tags {floor2 label}
808
+ set i [$w create polygon 234 198 306 198 306 249 234 249 -fill {} -outline {} -tags {floor2 room}]
809
+ set floorLabels($i) 224
810
+ set {floorItems(224)} $i
811
+ $w create text 270 223.5 -text 224 -fill $color -anchor c -tags {floor2 label}
812
+ set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -fill {} -outline {} -tags {floor2 room}]
813
+ set floorLabels($i) 223
814
+ set {floorItems(223)} $i
815
+ $w create text 292 157 -text 223 -fill $color -anchor c -tags {floor2 label}
816
+ set i [$w create polygon 268 179 221 179 221 135 268 135 -fill {} -outline {} -tags {floor2 room}]
817
+ set floorLabels($i) 222
818
+ set {floorItems(222)} $i
819
+ $w create text 244.5 157 -text 222 -fill $color -anchor c -tags {floor2 label}
820
+ set i [$w create polygon 177 179 219 179 219 135 177 135 -fill {} -outline {} -tags {floor2 room}]
821
+ set floorLabels($i) 221
822
+ set {floorItems(221)} $i
823
+ $w create text 198 157 -text 221 -fill $color -anchor c -tags {floor2 label}
824
+ set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -fill {} -outline {} -tags {floor2 room}]
825
+ set floorLabels($i) 204
826
+ set {floorItems(204)} $i
827
+ $w create text 324 301.5 -text 204 -fill $color -anchor c -tags {floor2 label}
828
+ set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -fill {} -outline {} -tags {floor2 room}]
829
+ set floorLabels($i) 205
830
+ set {floorItems(205)} $i
831
+ $w create text 265.5 307 -text 205 -fill $color -anchor c -tags {floor2 label}
832
+ set i [$w create polygon 256 385 256 340 212 340 212 385 -fill {} -outline {} -tags {floor2 room}]
833
+ set floorLabels($i) 207
834
+ set {floorItems(207)} $i
835
+ $w create text 234 362.5 -text 207 -fill $color -anchor c -tags {floor2 label}
836
+ set i [$w create polygon 210 340 164 340 164 385 210 385 -fill {} -outline {} -tags {floor2 room}]
837
+ set floorLabels($i) 208
838
+ set {floorItems(208)} $i
839
+ $w create text 187 362.5 -text 208 -fill $color -anchor c -tags {floor2 label}
840
+ set i [$w create polygon 115 340 162 340 162 385 115 385 -fill {} -outline {} -tags {floor2 room}]
841
+ set floorLabels($i) 209
842
+ set {floorItems(209)} $i
843
+ $w create text 138.5 362.5 -text 209 -fill $color -anchor c -tags {floor2 label}
844
+ set i [$w create polygon 89 228 89 156 53 156 53 228 -fill {} -outline {} -tags {floor2 room}]
845
+ set floorLabels($i) 217
846
+ set {floorItems(217)} $i
847
+ $w create text 71 192 -text 217 -fill $color -anchor c -tags {floor2 label}
848
+ set i [$w create polygon 89 169 97 169 97 190 89 190 -fill {} -outline {} -tags {floor2 room}]
849
+ set floorLabels($i) 217A
850
+ set {floorItems(217A)} $i
851
+ $w create text 93 179.5 -text 217A -fill $color -anchor c -tags {floor2 label}
852
+ set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -fill {} -outline {} -tags {floor2 room}]
853
+ set floorLabels($i) 216
854
+ set {floorItems(216)} $i
855
+ $w create text 71 145.5 -text 216 -fill $color -anchor c -tags {floor2 label}
856
+ set i [$w create polygon 51 179 51 135 6 135 6 179 -fill {} -outline {} -tags {floor2 room}]
857
+ set floorLabels($i) 215
858
+ set {floorItems(215)} $i
859
+ $w create text 28.5 157 -text 215 -fill $color -anchor c -tags {floor2 label}
860
+ set i [$w create polygon 51 227 6 227 6 180 51 180 -fill {} -outline {} -tags {floor2 room}]
861
+ set floorLabels($i) 214
862
+ set {floorItems(214)} $i
863
+ $w create text 28.5 203.5 -text 214 -fill $color -anchor c -tags {floor2 label}
864
+ set i [$w create polygon 51 275 6 275 6 229 51 229 -fill {} -outline {} -tags {floor2 room}]
865
+ set floorLabels($i) 213
866
+ set {floorItems(213)} $i
867
+ $w create text 28.5 252 -text 213 -fill $color -anchor c -tags {floor2 label}
868
+ set i [$w create polygon 114 340 67 340 67 385 114 385 -fill {} -outline {} -tags {floor2 room}]
869
+ set floorLabels($i) 210
870
+ set {floorItems(210)} $i
871
+ $w create text 90.5 362.5 -text 210 -fill $color -anchor c -tags {floor2 label}
872
+ set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -fill {} -outline {} -tags {floor2 room}]
873
+ set floorLabels($i) 211
874
+ set {floorItems(211)} $i
875
+ $w create text 33 364.5 -text 211 -fill $color -anchor c -tags {floor2 label}
876
+ set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -fill {} -outline {} -tags {floor2 room}]
877
+ set floorLabels($i) 203
878
+ set {floorItems(203)} $i
879
+ $w create text 367.5 292.5 -text 203 -fill $color -anchor c -tags {floor2 label}
880
+ set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -fill {} -outline {} -tags {floor2 room}]
881
+ set floorLabels($i) 220
882
+ set {floorItems(220)} $i
883
+ $w create text 132.5 208.5 -text 220 -fill $color -anchor c -tags {floor2 label}
884
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor2 room}]
885
+ set floorLabels($i) {Priv Lift2}
886
+ set {floorItems(Priv Lift2)} $i
887
+ $w create text 323 188 -text {Priv Lift2} -fill $color -anchor c -tags {floor2 label}
888
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor2 room}]
889
+ set floorLabels($i) {Pub Lift 2}
890
+ set {floorItems(Pub Lift 2)} $i
891
+ $w create text 323 223 -text {Pub Lift 2} -fill $color -anchor c -tags {floor2 label}
892
+ set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor2 room}]
893
+ set floorLabels($i) 218
894
+ set {floorItems(218)} $i
895
+ $w create text 136 149.5 -text 218 -fill $color -anchor c -tags {floor2 label}
896
+ set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor2 room}]
897
+ set floorLabels($i) 219
898
+ set {floorItems(219)} $i
899
+ $w create text 132.5 180 -text 219 -fill $color -anchor c -tags {floor2 label}
900
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor2 room}]
901
+ set floorLabels($i) 201
902
+ set {floorItems(201)} $i
903
+ $w create text 358 209 -text 201 -fill $color -anchor c -tags {floor2 label}
904
+ $w create line 641 186 678 186 -fill $color -tags {floor2 wall}
905
+ $w create line 757 350 757 367 -fill $color -tags {floor2 wall}
906
+ $w create line 634 133 634 144 -fill $color -tags {floor2 wall}
907
+ $w create line 634 144 627 144 -fill $color -tags {floor2 wall}
908
+ $w create line 572 133 572 144 -fill $color -tags {floor2 wall}
909
+ $w create line 572 144 579 144 -fill $color -tags {floor2 wall}
910
+ $w create line 398 129 398 162 -fill $color -tags {floor2 wall}
911
+ $w create line 174 197 175 197 -fill $color -tags {floor2 wall}
912
+ $w create line 175 197 175 227 -fill $color -tags {floor2 wall}
913
+ $w create line 757 206 757 221 -fill $color -tags {floor2 wall}
914
+ $w create line 396 188 408 188 -fill $color -tags {floor2 wall}
915
+ $w create line 727 189 725 189 -fill $color -tags {floor2 wall}
916
+ $w create line 747 167 802 167 -fill $color -tags {floor2 wall}
917
+ $w create line 747 167 747 189 -fill $color -tags {floor2 wall}
918
+ $w create line 755 189 739 189 -fill $color -tags {floor2 wall}
919
+ $w create line 769 224 757 224 -fill $color -tags {floor2 wall}
920
+ $w create line 802 224 802 129 -fill $color -tags {floor2 wall}
921
+ $w create line 802 129 725 129 -fill $color -tags {floor2 wall}
922
+ $w create line 725 189 725 129 -fill $color -tags {floor2 wall}
923
+ $w create line 725 186 690 186 -fill $color -tags {floor2 wall}
924
+ $w create line 676 133 676 186 -fill $color -tags {floor2 wall}
925
+ $w create line 627 144 627 186 -fill $color -tags {floor2 wall}
926
+ $w create line 629 186 593 186 -fill $color -tags {floor2 wall}
927
+ $w create line 579 144 579 186 -fill $color -tags {floor2 wall}
928
+ $w create line 559 129 559 133 -fill $color -tags {floor2 wall}
929
+ $w create line 725 133 559 133 -fill $color -tags {floor2 wall}
930
+ $w create line 484 162 484 129 -fill $color -tags {floor2 wall}
931
+ $w create line 559 129 484 129 -fill $color -tags {floor2 wall}
932
+ $w create line 526 129 526 186 -fill $color -tags {floor2 wall}
933
+ $w create line 540 186 581 186 -fill $color -tags {floor2 wall}
934
+ $w create line 528 186 523 186 -fill $color -tags {floor2 wall}
935
+ $w create line 511 186 475 186 -fill $color -tags {floor2 wall}
936
+ $w create line 496 190 496 186 -fill $color -tags {floor2 wall}
937
+ $w create line 496 205 496 202 -fill $color -tags {floor2 wall}
938
+ $w create line 475 205 527 205 -fill $color -tags {floor2 wall}
939
+ $w create line 558 205 539 205 -fill $color -tags {floor2 wall}
940
+ $w create line 558 205 558 249 -fill $color -tags {floor2 wall}
941
+ $w create line 558 249 475 249 -fill $color -tags {floor2 wall}
942
+ $w create line 662 206 642 206 -fill $color -tags {floor2 wall}
943
+ $w create line 695 206 675 206 -fill $color -tags {floor2 wall}
944
+ $w create line 695 278 642 278 -fill $color -tags {floor2 wall}
945
+ $w create line 642 291 642 206 -fill $color -tags {floor2 wall}
946
+ $w create line 695 291 695 206 -fill $color -tags {floor2 wall}
947
+ $w create line 716 208 716 206 -fill $color -tags {floor2 wall}
948
+ $w create line 757 206 716 206 -fill $color -tags {floor2 wall}
949
+ $w create line 757 221 757 224 -fill $color -tags {floor2 wall}
950
+ $w create line 793 224 802 224 -fill $color -tags {floor2 wall}
951
+ $w create line 757 262 716 262 -fill $color -tags {floor2 wall}
952
+ $w create line 716 220 716 264 -fill $color -tags {floor2 wall}
953
+ $w create line 716 315 716 276 -fill $color -tags {floor2 wall}
954
+ $w create line 757 315 703 315 -fill $color -tags {floor2 wall}
955
+ $w create line 757 325 757 224 -fill $color -tags {floor2 wall}
956
+ $w create line 757 367 644 367 -fill $color -tags {floor2 wall}
957
+ $w create line 689 367 689 315 -fill $color -tags {floor2 wall}
958
+ $w create line 647 315 644 315 -fill $color -tags {floor2 wall}
959
+ $w create line 659 315 691 315 -fill $color -tags {floor2 wall}
960
+ $w create line 600 325 600 391 -fill $color -tags {floor2 wall}
961
+ $w create line 627 325 644 325 -fill $color -tags {floor2 wall}
962
+ $w create line 644 391 644 315 -fill $color -tags {floor2 wall}
963
+ $w create line 615 325 575 325 -fill $color -tags {floor2 wall}
964
+ $w create line 644 391 558 391 -fill $color -tags {floor2 wall}
965
+ $w create line 563 325 558 325 -fill $color -tags {floor2 wall}
966
+ $w create line 558 391 558 314 -fill $color -tags {floor2 wall}
967
+ $w create line 558 327 508 327 -fill $color -tags {floor2 wall}
968
+ $w create line 558 275 484 275 -fill $color -tags {floor2 wall}
969
+ $w create line 558 302 558 275 -fill $color -tags {floor2 wall}
970
+ $w create line 508 327 508 311 -fill $color -tags {floor2 wall}
971
+ $w create line 484 311 508 311 -fill $color -tags {floor2 wall}
972
+ $w create line 484 275 484 311 -fill $color -tags {floor2 wall}
973
+ $w create line 475 208 408 208 -fill $color -tags {floor2 wall}
974
+ $w create line 408 206 408 210 -fill $color -tags {floor2 wall}
975
+ $w create line 408 222 408 227 -fill $color -tags {floor2 wall}
976
+ $w create line 408 227 398 227 -fill $color -tags {floor2 wall}
977
+ $w create line 398 227 398 254 -fill $color -tags {floor2 wall}
978
+ $w create line 408 188 408 194 -fill $color -tags {floor2 wall}
979
+ $w create line 383 188 376 188 -fill $color -tags {floor2 wall}
980
+ $w create line 398 188 398 162 -fill $color -tags {floor2 wall}
981
+ $w create line 398 162 484 162 -fill $color -tags {floor2 wall}
982
+ $w create line 475 162 475 254 -fill $color -tags {floor2 wall}
983
+ $w create line 398 254 475 254 -fill $color -tags {floor2 wall}
984
+ $w create line 484 280 395 280 -fill $color -tags {floor2 wall}
985
+ $w create line 395 311 395 275 -fill $color -tags {floor2 wall}
986
+ $w create line 307 197 293 197 -fill $color -tags {floor2 wall}
987
+ $w create line 278 197 233 197 -fill $color -tags {floor2 wall}
988
+ $w create line 233 197 233 249 -fill $color -tags {floor2 wall}
989
+ $w create line 307 179 284 179 -fill $color -tags {floor2 wall}
990
+ $w create line 233 249 278 249 -fill $color -tags {floor2 wall}
991
+ $w create line 269 179 269 133 -fill $color -tags {floor2 wall}
992
+ $w create line 220 179 220 133 -fill $color -tags {floor2 wall}
993
+ $w create line 155 191 110 191 -fill $color -tags {floor2 wall}
994
+ $w create line 90 190 98 190 -fill $color -tags {floor2 wall}
995
+ $w create line 98 169 98 190 -fill $color -tags {floor2 wall}
996
+ $w create line 52 133 52 165 -fill $color -tags {floor2 wall}
997
+ $w create line 52 214 52 177 -fill $color -tags {floor2 wall}
998
+ $w create line 52 226 52 262 -fill $color -tags {floor2 wall}
999
+ $w create line 52 274 52 276 -fill $color -tags {floor2 wall}
1000
+ $w create line 234 275 234 339 -fill $color -tags {floor2 wall}
1001
+ $w create line 226 339 258 339 -fill $color -tags {floor2 wall}
1002
+ $w create line 211 387 211 339 -fill $color -tags {floor2 wall}
1003
+ $w create line 214 339 177 339 -fill $color -tags {floor2 wall}
1004
+ $w create line 258 387 60 387 -fill $color -tags {floor2 wall}
1005
+ $w create line 3 133 3 339 -fill $color -tags {floor2 wall}
1006
+ $w create line 165 339 129 339 -fill $color -tags {floor2 wall}
1007
+ $w create line 117 339 80 339 -fill $color -tags {floor2 wall}
1008
+ $w create line 68 339 59 339 -fill $color -tags {floor2 wall}
1009
+ $w create line 0 339 46 339 -fill $color -tags {floor2 wall}
1010
+ $w create line 60 391 0 391 -fill $color -tags {floor2 wall}
1011
+ $w create line 0 339 0 391 -fill $color -tags {floor2 wall}
1012
+ $w create line 60 387 60 391 -fill $color -tags {floor2 wall}
1013
+ $w create line 258 329 258 387 -fill $color -tags {floor2 wall}
1014
+ $w create line 350 329 258 329 -fill $color -tags {floor2 wall}
1015
+ $w create line 395 311 350 311 -fill $color -tags {floor2 wall}
1016
+ $w create line 398 129 315 129 -fill $color -tags {floor2 wall}
1017
+ $w create line 176 133 315 133 -fill $color -tags {floor2 wall}
1018
+ $w create line 176 129 96 129 -fill $color -tags {floor2 wall}
1019
+ $w create line 3 133 96 133 -fill $color -tags {floor2 wall}
1020
+ $w create line 66 387 66 339 -fill $color -tags {floor2 wall}
1021
+ $w create line 115 387 115 339 -fill $color -tags {floor2 wall}
1022
+ $w create line 163 387 163 339 -fill $color -tags {floor2 wall}
1023
+ $w create line 234 275 276 275 -fill $color -tags {floor2 wall}
1024
+ $w create line 288 275 309 275 -fill $color -tags {floor2 wall}
1025
+ $w create line 298 275 298 329 -fill $color -tags {floor2 wall}
1026
+ $w create line 341 283 350 283 -fill $color -tags {floor2 wall}
1027
+ $w create line 321 275 341 275 -fill $color -tags {floor2 wall}
1028
+ $w create line 375 275 395 275 -fill $color -tags {floor2 wall}
1029
+ $w create line 315 129 315 170 -fill $color -tags {floor2 wall}
1030
+ $w create line 376 170 307 170 -fill $color -tags {floor2 wall}
1031
+ $w create line 307 250 307 170 -fill $color -tags {floor2 wall}
1032
+ $w create line 376 245 376 170 -fill $color -tags {floor2 wall}
1033
+ $w create line 340 241 307 241 -fill $color -tags {floor2 wall}
1034
+ $w create line 340 245 340 224 -fill $color -tags {floor2 wall}
1035
+ $w create line 340 210 340 201 -fill $color -tags {floor2 wall}
1036
+ $w create line 340 187 340 170 -fill $color -tags {floor2 wall}
1037
+ $w create line 340 206 307 206 -fill $color -tags {floor2 wall}
1038
+ $w create line 293 250 307 250 -fill $color -tags {floor2 wall}
1039
+ $w create line 271 179 238 179 -fill $color -tags {floor2 wall}
1040
+ $w create line 226 179 195 179 -fill $color -tags {floor2 wall}
1041
+ $w create line 176 129 176 179 -fill $color -tags {floor2 wall}
1042
+ $w create line 182 179 176 179 -fill $color -tags {floor2 wall}
1043
+ $w create line 174 169 176 169 -fill $color -tags {floor2 wall}
1044
+ $w create line 162 169 90 169 -fill $color -tags {floor2 wall}
1045
+ $w create line 96 169 96 129 -fill $color -tags {floor2 wall}
1046
+ $w create line 175 227 90 227 -fill $color -tags {floor2 wall}
1047
+ $w create line 90 190 90 227 -fill $color -tags {floor2 wall}
1048
+ $w create line 52 179 3 179 -fill $color -tags {floor2 wall}
1049
+ $w create line 52 228 3 228 -fill $color -tags {floor2 wall}
1050
+ $w create line 52 276 3 276 -fill $color -tags {floor2 wall}
1051
+ $w create line 155 177 155 169 -fill $color -tags {floor2 wall}
1052
+ $w create line 110 191 110 169 -fill $color -tags {floor2 wall}
1053
+ $w create line 155 189 155 197 -fill $color -tags {floor2 wall}
1054
+ $w create line 350 283 350 329 -fill $color -tags {floor2 wall}
1055
+ $w create line 162 197 155 197 -fill $color -tags {floor2 wall}
1056
+ $w create line 341 275 341 283 -fill $color -tags {floor2 wall}
1057
+ }
1058
+
1059
+ # fg3 --
1060
+ # This procedure represents part of the floorplan database. When
1061
+ # invoked, it instantiates the foreground information for the third
1062
+ # floor (office outlines and numbers).
1063
+ #
1064
+ # Arguments:
1065
+ # w - The canvas window.
1066
+ # color - Color to use for drawing foreground information.
1067
+
1068
+ proc fg3 {w color} {
1069
+ global floorLabels floorItems
1070
+ set i [$w create polygon 89 228 89 180 70 180 70 228 -fill {} -outline {} -tags {floor3 room}]
1071
+ set floorLabels($i) 316
1072
+ set {floorItems(316)} $i
1073
+ $w create text 79.5 204 -text 316 -fill $color -anchor c -tags {floor3 label}
1074
+ set i [$w create polygon 115 368 162 368 162 323 115 323 -fill {} -outline {} -tags {floor3 room}]
1075
+ set floorLabels($i) 309
1076
+ set {floorItems(309)} $i
1077
+ $w create text 138.5 345.5 -text 309 -fill $color -anchor c -tags {floor3 label}
1078
+ set i [$w create polygon 164 323 164 368 211 368 211 323 -fill {} -outline {} -tags {floor3 room}]
1079
+ set floorLabels($i) 308
1080
+ set {floorItems(308)} $i
1081
+ $w create text 187.5 345.5 -text 308 -fill $color -anchor c -tags {floor3 label}
1082
+ set i [$w create polygon 256 368 212 368 212 323 256 323 -fill {} -outline {} -tags {floor3 room}]
1083
+ set floorLabels($i) 307
1084
+ set {floorItems(307)} $i
1085
+ $w create text 234 345.5 -text 307 -fill $color -anchor c -tags {floor3 label}
1086
+ set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -fill {} -outline {} -tags {floor3 room}]
1087
+ set floorLabels($i) 305
1088
+ set {floorItems(305)} $i
1089
+ $w create text 270.5 301.5 -text 305 -fill $color -anchor c -tags {floor3 label}
1090
+ set i [$w create polygon 251 219 251 203 244 203 244 219 -fill {} -outline {} -tags {floor3 room}]
1091
+ set floorLabels($i) 324B
1092
+ set {floorItems(324B)} $i
1093
+ $w create text 247.5 211 -text 324B -fill $color -anchor c -tags {floor3 label}
1094
+ set i [$w create polygon 251 249 244 249 244 232 251 232 -fill {} -outline {} -tags {floor3 room}]
1095
+ set floorLabels($i) 324A
1096
+ set {floorItems(324A)} $i
1097
+ $w create text 247.5 240.5 -text 324A -fill $color -anchor c -tags {floor3 label}
1098
+ set i [$w create polygon 223 135 223 179 177 179 177 135 -fill {} -outline {} -tags {floor3 room}]
1099
+ set floorLabels($i) 320
1100
+ set {floorItems(320)} $i
1101
+ $w create text 200 157 -text 320 -fill $color -anchor c -tags {floor3 label}
1102
+ set i [$w create polygon 114 368 114 323 67 323 67 368 -fill {} -outline {} -tags {floor3 room}]
1103
+ set floorLabels($i) 310
1104
+ set {floorItems(310)} $i
1105
+ $w create text 90.5 345.5 -text 310 -fill $color -anchor c -tags {floor3 label}
1106
+ set i [$w create polygon 23 277 23 321 68 321 68 277 -fill {} -outline {} -tags {floor3 room}]
1107
+ set floorLabels($i) 312
1108
+ set {floorItems(312)} $i
1109
+ $w create text 45.5 299 -text 312 -fill $color -anchor c -tags {floor3 label}
1110
+ set i [$w create polygon 23 229 68 229 68 275 23 275 -fill {} -outline {} -tags {floor3 room}]
1111
+ set floorLabels($i) 313
1112
+ set {floorItems(313)} $i
1113
+ $w create text 45.5 252 -text 313 -fill $color -anchor c -tags {floor3 label}
1114
+ set i [$w create polygon 68 227 23 227 23 180 68 180 -fill {} -outline {} -tags {floor3 room}]
1115
+ set floorLabels($i) 314
1116
+ set {floorItems(314)} $i
1117
+ $w create text 45.5 203.5 -text 314 -fill $color -anchor c -tags {floor3 label}
1118
+ set i [$w create polygon 95 179 95 135 23 135 23 179 -fill {} -outline {} -tags {floor3 room}]
1119
+ set floorLabels($i) 315
1120
+ set {floorItems(315)} $i
1121
+ $w create text 59 157 -text 315 -fill $color -anchor c -tags {floor3 label}
1122
+ set i [$w create polygon 99 226 99 204 91 204 91 226 -fill {} -outline {} -tags {floor3 room}]
1123
+ set floorLabels($i) 316B
1124
+ set {floorItems(316B)} $i
1125
+ $w create text 95 215 -text 316B -fill $color -anchor c -tags {floor3 label}
1126
+ set i [$w create polygon 91 202 99 202 99 180 91 180 -fill {} -outline {} -tags {floor3 room}]
1127
+ set floorLabels($i) 316A
1128
+ set {floorItems(316A)} $i
1129
+ $w create text 95 191 -text 316A -fill $color -anchor c -tags {floor3 label}
1130
+ set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -fill {} -outline {} -tags {floor3 room}]
1131
+ set floorLabels($i) 319
1132
+ set {floorItems(319)} $i
1133
+ $w create text 141.5 209 -text 319 -fill $color -anchor c -tags {floor3 label}
1134
+ set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -fill {} -outline {} -tags {floor3 room}]
1135
+ set floorLabels($i) 311
1136
+ set {floorItems(311)} $i
1137
+ $w create text 29.5 361 -text 311 -fill $color -anchor c -tags {floor3 label}
1138
+ set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor3 room}]
1139
+ set floorLabels($i) 318
1140
+ set {floorItems(318)} $i
1141
+ $w create text 132.5 180 -text 318 -fill $color -anchor c -tags {floor3 label}
1142
+ set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor3 room}]
1143
+ set floorLabels($i) 317
1144
+ set {floorItems(317)} $i
1145
+ $w create text 136 149.5 -text 317 -fill $color -anchor c -tags {floor3 label}
1146
+ set i [$w create polygon 274 194 274 221 306 221 306 194 -fill {} -outline {} -tags {floor3 room}]
1147
+ set floorLabels($i) 323
1148
+ set {floorItems(323)} $i
1149
+ $w create text 290 207.5 -text 323 -fill $color -anchor c -tags {floor3 label}
1150
+ set i [$w create polygon 306 222 274 222 274 249 306 249 -fill {} -outline {} -tags {floor3 room}]
1151
+ set floorLabels($i) 325
1152
+ set {floorItems(325)} $i
1153
+ $w create text 290 235.5 -text 325 -fill $color -anchor c -tags {floor3 label}
1154
+ set i [$w create polygon 263 179 224 179 224 135 263 135 -fill {} -outline {} -tags {floor3 room}]
1155
+ set floorLabels($i) 321
1156
+ set {floorItems(321)} $i
1157
+ $w create text 243.5 157 -text 321 -fill $color -anchor c -tags {floor3 label}
1158
+ set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -fill {} -outline {} -tags {floor3 room}]
1159
+ set floorLabels($i) 322
1160
+ set {floorItems(322)} $i
1161
+ $w create text 293.5 163.5 -text 322 -fill $color -anchor c -tags {floor3 label}
1162
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor3 room}]
1163
+ set floorLabels($i) {Pub Lift3}
1164
+ set {floorItems(Pub Lift3)} $i
1165
+ $w create text 323 223 -text {Pub Lift3} -fill $color -anchor c -tags {floor3 label}
1166
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor3 room}]
1167
+ set floorLabels($i) {Priv Lift3}
1168
+ set {floorItems(Priv Lift3)} $i
1169
+ $w create text 323 188 -text {Priv Lift3} -fill $color -anchor c -tags {floor3 label}
1170
+ set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -fill {} -outline {} -tags {floor3 room}]
1171
+ set floorLabels($i) 303
1172
+ set {floorItems(303)} $i
1173
+ $w create text 373.5 292.5 -text 303 -fill $color -anchor c -tags {floor3 label}
1174
+ set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -fill {} -outline {} -tags {floor3 room}]
1175
+ set floorLabels($i) 324
1176
+ set {floorItems(324)} $i
1177
+ $w create text 262 226 -text 324 -fill $color -anchor c -tags {floor3 label}
1178
+ set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -fill {} -outline {} -tags {floor3 room}]
1179
+ set floorLabels($i) 304
1180
+ set {floorItems(304)} $i
1181
+ $w create text 324 301.5 -text 304 -fill $color -anchor c -tags {floor3 label}
1182
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor3 room}]
1183
+ set floorLabels($i) 301
1184
+ set {floorItems(301)} $i
1185
+ $w create text 358 209 -text 301 -fill $color -anchor c -tags {floor3 label}
1186
+ set i [$w create polygon 397 246 377 246 377 185 397 185 -fill {} -outline {} -tags {floor3 room}]
1187
+ set floorLabels($i) 327
1188
+ set {floorItems(327)} $i
1189
+ $w create text 387 215.5 -text 327 -fill $color -anchor c -tags {floor3 label}
1190
+ set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -fill {} -outline {} -tags {floor3 room}]
1191
+ set floorLabels($i) 326
1192
+ set {floorItems(326)} $i
1193
+ $w create text 356.5 150 -text 326 -fill $color -anchor c -tags {floor3 label}
1194
+ set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -fill {} -outline {} -tags {floor3 room}]
1195
+ set floorLabels($i) 302
1196
+ set {floorItems(302)} $i
1197
+ $w create text 319.5 261 -text 302 -fill $color -anchor c -tags {floor3 label}
1198
+ set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -fill {} -outline {} -tags {floor3 room}]
1199
+ set floorLabels($i) 306
1200
+ set {floorItems(306)} $i
1201
+ $w create text 200.5 284.5 -text 306 -fill $color -anchor c -tags {floor3 label}
1202
+ $w create line 341 275 341 283 -fill $color -tags {floor3 wall}
1203
+ $w create line 162 197 155 197 -fill $color -tags {floor3 wall}
1204
+ $w create line 396 247 399 247 -fill $color -tags {floor3 wall}
1205
+ $w create line 399 129 399 311 -fill $color -tags {floor3 wall}
1206
+ $w create line 258 202 243 202 -fill $color -tags {floor3 wall}
1207
+ $w create line 350 283 350 329 -fill $color -tags {floor3 wall}
1208
+ $w create line 251 231 243 231 -fill $color -tags {floor3 wall}
1209
+ $w create line 243 220 251 220 -fill $color -tags {floor3 wall}
1210
+ $w create line 243 250 243 202 -fill $color -tags {floor3 wall}
1211
+ $w create line 155 197 155 190 -fill $color -tags {floor3 wall}
1212
+ $w create line 110 192 110 169 -fill $color -tags {floor3 wall}
1213
+ $w create line 155 192 110 192 -fill $color -tags {floor3 wall}
1214
+ $w create line 155 177 155 169 -fill $color -tags {floor3 wall}
1215
+ $w create line 176 197 176 227 -fill $color -tags {floor3 wall}
1216
+ $w create line 69 280 69 274 -fill $color -tags {floor3 wall}
1217
+ $w create line 21 276 69 276 -fill $color -tags {floor3 wall}
1218
+ $w create line 69 262 69 226 -fill $color -tags {floor3 wall}
1219
+ $w create line 21 228 69 228 -fill $color -tags {floor3 wall}
1220
+ $w create line 21 179 75 179 -fill $color -tags {floor3 wall}
1221
+ $w create line 69 179 69 214 -fill $color -tags {floor3 wall}
1222
+ $w create line 90 220 90 227 -fill $color -tags {floor3 wall}
1223
+ $w create line 90 204 90 202 -fill $color -tags {floor3 wall}
1224
+ $w create line 90 203 100 203 -fill $color -tags {floor3 wall}
1225
+ $w create line 90 187 90 179 -fill $color -tags {floor3 wall}
1226
+ $w create line 90 227 176 227 -fill $color -tags {floor3 wall}
1227
+ $w create line 100 179 100 227 -fill $color -tags {floor3 wall}
1228
+ $w create line 100 179 87 179 -fill $color -tags {floor3 wall}
1229
+ $w create line 96 179 96 129 -fill $color -tags {floor3 wall}
1230
+ $w create line 162 169 96 169 -fill $color -tags {floor3 wall}
1231
+ $w create line 173 169 176 169 -fill $color -tags {floor3 wall}
1232
+ $w create line 182 179 176 179 -fill $color -tags {floor3 wall}
1233
+ $w create line 176 129 176 179 -fill $color -tags {floor3 wall}
1234
+ $w create line 195 179 226 179 -fill $color -tags {floor3 wall}
1235
+ $w create line 224 133 224 179 -fill $color -tags {floor3 wall}
1236
+ $w create line 264 179 264 133 -fill $color -tags {floor3 wall}
1237
+ $w create line 238 179 264 179 -fill $color -tags {floor3 wall}
1238
+ $w create line 273 207 273 193 -fill $color -tags {floor3 wall}
1239
+ $w create line 273 235 273 250 -fill $color -tags {floor3 wall}
1240
+ $w create line 273 224 273 219 -fill $color -tags {floor3 wall}
1241
+ $w create line 273 193 307 193 -fill $color -tags {floor3 wall}
1242
+ $w create line 273 222 307 222 -fill $color -tags {floor3 wall}
1243
+ $w create line 273 250 307 250 -fill $color -tags {floor3 wall}
1244
+ $w create line 384 247 376 247 -fill $color -tags {floor3 wall}
1245
+ $w create line 340 206 307 206 -fill $color -tags {floor3 wall}
1246
+ $w create line 340 187 340 170 -fill $color -tags {floor3 wall}
1247
+ $w create line 340 210 340 201 -fill $color -tags {floor3 wall}
1248
+ $w create line 340 247 340 224 -fill $color -tags {floor3 wall}
1249
+ $w create line 340 241 307 241 -fill $color -tags {floor3 wall}
1250
+ $w create line 376 247 376 170 -fill $color -tags {floor3 wall}
1251
+ $w create line 307 250 307 170 -fill $color -tags {floor3 wall}
1252
+ $w create line 376 170 307 170 -fill $color -tags {floor3 wall}
1253
+ $w create line 315 129 315 170 -fill $color -tags {floor3 wall}
1254
+ $w create line 376 283 366 283 -fill $color -tags {floor3 wall}
1255
+ $w create line 376 283 376 275 -fill $color -tags {floor3 wall}
1256
+ $w create line 399 275 376 275 -fill $color -tags {floor3 wall}
1257
+ $w create line 341 275 320 275 -fill $color -tags {floor3 wall}
1258
+ $w create line 341 283 350 283 -fill $color -tags {floor3 wall}
1259
+ $w create line 298 275 298 329 -fill $color -tags {floor3 wall}
1260
+ $w create line 308 275 298 275 -fill $color -tags {floor3 wall}
1261
+ $w create line 243 322 243 275 -fill $color -tags {floor3 wall}
1262
+ $w create line 243 275 284 275 -fill $color -tags {floor3 wall}
1263
+ $w create line 258 322 226 322 -fill $color -tags {floor3 wall}
1264
+ $w create line 212 370 212 322 -fill $color -tags {floor3 wall}
1265
+ $w create line 214 322 177 322 -fill $color -tags {floor3 wall}
1266
+ $w create line 163 370 163 322 -fill $color -tags {floor3 wall}
1267
+ $w create line 165 322 129 322 -fill $color -tags {floor3 wall}
1268
+ $w create line 84 322 117 322 -fill $color -tags {floor3 wall}
1269
+ $w create line 71 322 64 322 -fill $color -tags {floor3 wall}
1270
+ $w create line 115 322 115 370 -fill $color -tags {floor3 wall}
1271
+ $w create line 66 322 66 370 -fill $color -tags {floor3 wall}
1272
+ $w create line 52 322 21 322 -fill $color -tags {floor3 wall}
1273
+ $w create line 21 331 0 331 -fill $color -tags {floor3 wall}
1274
+ $w create line 21 331 21 133 -fill $color -tags {floor3 wall}
1275
+ $w create line 96 133 21 133 -fill $color -tags {floor3 wall}
1276
+ $w create line 176 129 96 129 -fill $color -tags {floor3 wall}
1277
+ $w create line 315 133 176 133 -fill $color -tags {floor3 wall}
1278
+ $w create line 315 129 399 129 -fill $color -tags {floor3 wall}
1279
+ $w create line 399 311 350 311 -fill $color -tags {floor3 wall}
1280
+ $w create line 350 329 258 329 -fill $color -tags {floor3 wall}
1281
+ $w create line 258 322 258 370 -fill $color -tags {floor3 wall}
1282
+ $w create line 60 370 258 370 -fill $color -tags {floor3 wall}
1283
+ $w create line 60 370 60 391 -fill $color -tags {floor3 wall}
1284
+ $w create line 0 391 0 331 -fill $color -tags {floor3 wall}
1285
+ $w create line 60 391 0 391 -fill $color -tags {floor3 wall}
1286
+ $w create line 307 250 307 242 -fill $color -tags {floor3 wall}
1287
+ $w create line 273 250 307 250 -fill $color -tags {floor3 wall}
1288
+ $w create line 258 250 243 250 -fill $color -tags {floor3 wall}
1289
+ }
1290
+
1291
+ # Below is the "main program" that creates the floorplan demonstration.
1292
+
1293
+ set w .floor
1294
+ global c currentRoom colors activeFloor
1295
+ catch {destroy $w}
1296
+ toplevel $w
1297
+ wm title $w "Floorplan Canvas Demonstration"
1298
+ wm iconname $w "Floorplan"
1299
+ wm geometry $w +20+20
1300
+ wm minsize $w 100 100
1301
+
1302
+ label $w.msg -font $font -wraplength 8i -justify left -text "This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."
1303
+ pack $w.msg -side top
1304
+
1305
+ ## See Code / Dismiss buttons
1306
+ set btns [addSeeDismiss $w.buttons $w]
1307
+ pack $btns -side bottom -fill x
1308
+
1309
+ set f [frame $w.frame]
1310
+ pack $f -side top -fill both -expand yes
1311
+ set h [ttk::scrollbar $f.hscroll -orient horizontal]
1312
+ set v [ttk::scrollbar $f.vscroll -orient vertical]
1313
+ set f1 [frame $f.f1 -borderwidth 2 -relief sunken]
1314
+ set c [canvas $f1.c -width 900 -height 500 -highlightthickness 0 \
1315
+ -xscrollcommand [list $h set] \
1316
+ -yscrollcommand [list $v set]]
1317
+ pack $c -expand yes -fill both
1318
+ grid $f1 -padx 1 -pady 1 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
1319
+ grid $v -padx 1 -pady 1 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
1320
+ grid $h -padx 1 -pady 1 -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
1321
+ grid rowconfig $f 0 -weight 1 -minsize 0
1322
+ grid columnconfig $f 0 -weight 1 -minsize 0
1323
+ pack $f -expand yes -fill both -padx 1 -pady 1
1324
+
1325
+ $v configure -command [list $c yview]
1326
+ $h configure -command [list $c xview]
1327
+
1328
+ # Create an entry for displaying and typing in current room.
1329
+
1330
+ entry $c.entry -width 10 -textvariable currentRoom
1331
+
1332
+ # Choose colors, then fill in the floorplan.
1333
+
1334
+ if {[winfo depth $c] > 1} {
1335
+ set colors(bg1) #a9c1da
1336
+ set colors(outline1) #77889a
1337
+ set colors(bg2) #9ab0c6
1338
+ set colors(outline2) #687786
1339
+ set colors(bg3) #8ba0b3
1340
+ set colors(outline3) #596673
1341
+ set colors(offices) Black
1342
+ set colors(active) #c4d1df
1343
+ } else {
1344
+ set colors(bg1) white
1345
+ set colors(outline1) black
1346
+ set colors(bg2) white
1347
+ set colors(outline2) black
1348
+ set colors(bg3) white
1349
+ set colors(outline3) black
1350
+ set colors(offices) Black
1351
+ set colors(active) black
1352
+ }
1353
+ set activeFloor ""
1354
+ floorDisplay $c 3
1355
+
1356
+ # Set up event bindings for canvas:
1357
+
1358
+ $c bind floor1 <Button-1> "floorDisplay $c 1"
1359
+ $c bind floor2 <Button-1> "floorDisplay $c 2"
1360
+ $c bind floor3 <Button-1> "floorDisplay $c 3"
1361
+ $c bind room <Enter> "newRoom $c"
1362
+ $c bind room <Leave> {set currentRoom ""}
1363
+ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
1364
+ bind $c <Button-3> "$c scan mark %x %y"
1365
+ bind $c <B3-Motion> "$c scan dragto %x %y"
1366
+ } else {
1367
+ bind $c <Button-2> "$c scan mark %x %y"
1368
+ bind $c <B2-Motion> "$c scan dragto %x %y"
1369
+ }
1370
+ bind $c <Destroy> "unset currentRoom"
1371
+ set currentRoom ""
1372
+ trace add variable currentRoom write "roomChanged $c"
miniconda3/lib/tk8.6/demos/fontchoose.tcl ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fontchoose.tcl --
2
+ #
3
+ # Show off the stock font selector dialog
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .fontchoose
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Font Selection Dialog"
15
+ wm iconname $w "fontchooser"
16
+ positionWindow $w
17
+
18
+ catch {font create FontchooseDemoFont {*}[font actual TkDefaultFont]}
19
+
20
+ # The font chooser needs to be configured and then shown.
21
+ proc SelectFont {parent} {
22
+ tk fontchooser configure -font FontchooseDemoFont \
23
+ -command ApplyFont -parent $parent
24
+ tk fontchooser show
25
+ }
26
+
27
+ proc ApplyFont {font} {
28
+ font configure FontchooseDemoFont {*}[font actual $font]
29
+ }
30
+
31
+ # When the visibility of the fontchooser changes, the following event is fired
32
+ # to the parent widget.
33
+ #
34
+ bind $w <<TkFontchooserVisibility>> {
35
+ if {[tk fontchooser configure -visible]} {
36
+ %W.f.font state disabled
37
+ } else {
38
+ %W.f.font state !disabled
39
+ }
40
+ }
41
+
42
+
43
+ set f [ttk::frame $w.f -relief sunken -padding 2]
44
+
45
+ text $f.msg -font FontchooseDemoFont -width 40 -height 6 -borderwidth 0 \
46
+ -yscrollcommand [list $f.vs set]
47
+ ttk::scrollbar $f.vs -command [list $f.msg yview]
48
+
49
+ $f.msg insert end "Press the buttons below to choose a new font for the\
50
+ text shown in this window.\n" {}
51
+
52
+ ttk::button $f.font -text "Set font ..." -command [list SelectFont $w]
53
+
54
+ grid $f.msg $f.vs -sticky news
55
+ grid $f.font - -sticky e
56
+ grid columnconfigure $f 0 -weight 1
57
+ grid rowconfigure $f 0 -weight 1
58
+
59
+ ## See Code / Dismiss buttons
60
+ set btns [addSeeDismiss $w.buttons $w]
61
+
62
+ grid $f -sticky news
63
+ grid $btns -sticky ew
64
+ grid columnconfigure $w 0 -weight 1
65
+ grid rowconfigure $w 0 -weight 1
66
+ update idletasks
67
+ grid propagate $f 0
miniconda3/lib/tk8.6/demos/form.tcl ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # form.tcl --
2
+ #
3
+ # This demonstration script creates a simple form with a bunch
4
+ # of entry widgets.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .form
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Form Demonstration"
16
+ wm iconname $w "form"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ foreach i {f1 f2 f3 f4 f5} {
27
+ frame $w.$i -bd 2
28
+ entry $w.$i.entry -relief sunken -width 40
29
+ label $w.$i.label
30
+ pack $w.$i.entry -side right
31
+ pack $w.$i.label -side left
32
+ }
33
+ $w.f1.label config -text Name:
34
+ $w.f2.label config -text Address:
35
+ $w.f5.label config -text Phone:
36
+ pack $w.msg $w.f1 $w.f2 $w.f3 $w.f4 $w.f5 -side top -fill x
37
+ bind $w <Return> "destroy $w"
38
+ focus $w.f1.entry
miniconda3/lib/tk8.6/demos/goldberg.tcl ADDED
@@ -0,0 +1,1834 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##+#################################################################
2
+ #
3
+ # TkGoldberg.tcl
4
+ # by Keith Vetter, March 13, 2003
5
+ #
6
+ # "Man will always find a difficult means to perform a simple task"
7
+ # Rube Goldberg
8
+ #
9
+ # Reproduced here with permission.
10
+ #
11
+ ##+#################################################################
12
+ #
13
+ # Keith Vetter 2003-03-21: this started out as a simple little program
14
+ # but was so much fun that it grew and grew. So I apologize about the
15
+ # size but I just couldn't resist sharing it.
16
+ #
17
+ # This is a whizzlet that does a Rube Goldberg type animation, the
18
+ # design of which comes from an New Years e-card from IncrediMail.
19
+ # That version had nice sound effects which I eschewed. On the other
20
+ # hand, that version was in black and white (actually dark blue and
21
+ # light blue) and this one is fully colorized.
22
+ #
23
+ # One thing I learned from this project is that drawing filled complex
24
+ # objects on a canvas is really hard. More often than not I had to
25
+ # draw each item twice--once with the desired fill color but no
26
+ # outline, and once with no fill but with the outline. Another trick
27
+ # is erasing by drawing with the background color. Having a flood fill
28
+ # command would have been extremely helpful.
29
+ #
30
+ # Two wiki pages were extremely helpful: Drawing rounded rectangles
31
+ # which I generalized into Drawing rounded polygons, and regular
32
+ # polygons which allowed me to convert ovals and arcs into polygons
33
+ # which could then be rotated (see Canvas Rotation). I also wrote
34
+ # Named Colors to aid in the color selection.
35
+ #
36
+ # I could comment on the code, but it's just 26 state machines with
37
+ # lots of canvas create and move calls.
38
+
39
+ if {![info exists widgetDemo]} {
40
+ error "This script should be run from the \"widget\" demo."
41
+ }
42
+
43
+ package require Tk
44
+
45
+ set w .goldberg
46
+ catch {destroy $w}
47
+ toplevel $w
48
+ wm title $w "Tk Goldberg (demonstration)"
49
+ wm iconname $w "goldberg"
50
+ wm resizable $w 0 0
51
+ #positionWindow $w
52
+
53
+ label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a\
54
+ demonstration of just how complex you can make your animations\
55
+ become. Click the ball to start things moving!\n\n\"Man will always\
56
+ find a difficult means to perform a simple task\"\n - Rube Goldberg"
57
+ pack $w.msg -side top
58
+
59
+ ###--- End of Boilerplate ---###
60
+
61
+ # Ensure that this this is an array
62
+ array set animationCallbacks {}
63
+ bind $w <Destroy> {
64
+ if {"%W" eq [winfo toplevel %W]} {
65
+ unset S C speed
66
+ }
67
+ }
68
+
69
+ set S(title) "Tk Goldberg"
70
+ set S(speed) 5
71
+ set S(cnt) 0
72
+ set S(message) "\\nWelcome\\nto\\nTcl/Tk"
73
+ array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500}
74
+
75
+ set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5
76
+ set S(mode) $::MSTART
77
+
78
+ # Colors for everything
79
+ set C(fg) black
80
+ set C(bg) cornflowerblue
81
+
82
+ set C(0) white; set C(1a) darkgreen; set C(1b) yellow
83
+ set C(2) red; set C(3a) green; set C(3b) darkblue
84
+ set C(4) $C(fg); set C(5a) brown; set C(5b) white
85
+ set C(6) magenta; set C(7) green; set C(8) $C(fg)
86
+ set C(9) blue4; set C(10a) white; set C(10b) cyan
87
+ set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2
88
+ set C(13a) yellow; set C(13b) red; set C(14) white
89
+ set C(15a) green; set C(15b) yellow; set C(16) gray65
90
+ set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50
91
+ set C(20) cyan; set C(21) gray65; set C(22) $C(20)
92
+ set C(23a) blue; set C(23b) red; set C(23c) yellow
93
+ set C(24a) red; set C(24b) white;
94
+ set C(24c) black; set C(26) $C(0);
95
+
96
+ proc DoDisplay {w} {
97
+ global S C
98
+
99
+ ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5
100
+ pack [frame $w.screen -bd 2 -relief raised] \
101
+ -side left -fill both -expand 1
102
+
103
+ canvas $w.c -width 860 -height 730 -bg $C(bg) -highlightthickness 0
104
+ $w.c config -scrollregion {0 0 1000 1000} ;# Kludge: move everything up
105
+ $w.c yview moveto .05
106
+ pack $w.c -in $w.screen -side top -fill both -expand 1
107
+
108
+ bind $w.c <Button-3> [list $w.pause invoke]
109
+ bind $w.c <Destroy> {
110
+ after cancel $animationCallbacks(goldberg)
111
+ unset animationCallbacks(goldberg)
112
+ }
113
+ DoCtrlFrame $w
114
+ DoDetailFrame $w
115
+ if {[tk windowingsystem] ne "aqua"} {
116
+ ttk::button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2
117
+ } else {
118
+ button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg)
119
+ }
120
+ place $w.show -in $w.c -relx 1 -rely 0 -anchor ne
121
+ update
122
+ }
123
+
124
+ proc DoCtrlFrame {w} {
125
+ global S
126
+ ttk::button $w.start -text "Start" -command [list DoButton $w 0]
127
+ ttk::checkbutton $w.pause -text "Pause" -command [list DoButton $w 1] \
128
+ -variable S(pause)
129
+ ttk::button $w.step -text "Single Step" -command [list DoButton $w 2]
130
+ ttk::button $w.bstep -text "Big Step" -command [list DoButton $w 4]
131
+ ttk::button $w.reset -text "Reset" -command [list DoButton $w 3]
132
+ ttk::labelframe $w.details
133
+ raise $w.details
134
+ set S(details) 0
135
+ ttk::checkbutton $w.details.cb -text "Details" -variable S(details)
136
+ ttk::labelframe $w.message -text "Message"
137
+ ttk::entry $w.message.e -textvariable S(message) -justify center
138
+ ttk::labelframe $w.speed -text "Speed: 0"
139
+ ttk::scale $w.speed.scale -orient horizontal -from 1 -to 10 -variable S(speed)
140
+ ttk::button $w.about -text About -command [list About $w]
141
+
142
+ grid $w.start -in $w.ctrl -row 0 -sticky ew
143
+ grid rowconfigure $w.ctrl 1 -minsize 10
144
+ grid $w.pause -in $w.ctrl -row 2 -sticky ew
145
+ grid $w.step -in $w.ctrl -sticky ew -pady 2
146
+ grid $w.bstep -in $w.ctrl -sticky ew
147
+ grid $w.reset -in $w.ctrl -sticky ew -pady 2
148
+ grid rowconfigure $w.ctrl 10 -minsize 18
149
+ grid $w.details -in $w.ctrl -row 11 -sticky ew
150
+ grid rowconfigure $w.ctrl 11 -minsize 20
151
+ $w.details configure -labelwidget $w.details.cb
152
+ grid [ttk::frame $w.details.b -height 1] ;# Work around minor bug
153
+ raise $w.details
154
+ raise $w.details.cb
155
+ grid rowconfigure $w.ctrl 50 -weight 1
156
+ trace add variable ::S(mode) write [list ActiveGUI $w]
157
+ trace add variable ::S(details) write [list ActiveGUI $w]
158
+ trace add variable ::S(speed) write [list ActiveGUI $w]
159
+
160
+ grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 5
161
+ grid $w.message.e -sticky nsew
162
+ grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5}
163
+ pack $w.speed.scale -fill both -expand 1
164
+ grid $w.about -in $w.ctrl -row 100 -sticky ew
165
+ bind $w.reset <Button-3> {set S(mode) -1} ;# Debugging
166
+
167
+ ## See Code / Dismiss buttons hack!
168
+ set btns [addSeeDismiss $w.ctrl.buttons $w]
169
+ grid [ttk::separator $w.ctrl.sep] -sticky ew -pady 4
170
+ set i 0
171
+ foreach b [winfo children $btns] {
172
+ if {[winfo class $b] eq "TButton"} {
173
+ grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew
174
+ foreach b3 [$b configure] {
175
+ set b3 [lindex $b3 0]
176
+ # Some options are read-only; ignore those errors
177
+ catch {$b2 configure $b3 [$b cget $b3]}
178
+ }
179
+ }
180
+ }
181
+ destroy $btns
182
+ }
183
+
184
+ proc DoDetailFrame {w} {
185
+ set w2 $w.details.f
186
+ ttk::frame $w2
187
+
188
+ ttk::label $w2.l -textvariable S(cnt) -background white
189
+ grid $w2.l - - - -sticky ew -row 0
190
+ for {set i 1} {1} {incr i} {
191
+ if {[info procs "Move$i"] eq ""} break
192
+ ttk::label $w2.l$i -text $i -anchor e -width 2 -background white
193
+ ttk::label $w2.ll$i -textvariable STEP($i) -width 5 -background white
194
+ set row [expr {($i + 1) / 2}]
195
+ set col [expr {(($i + 1) & 1) * 2}]
196
+ grid $w2.l$i -sticky ew -row $row -column $col
197
+ grid $w2.ll$i -sticky ew -row $row -column [incr col]
198
+ }
199
+ grid columnconfigure $w2 1 -weight 1
200
+ }
201
+
202
+ # Map or unmap the ctrl window
203
+ proc ShowCtrl {w} {
204
+ if {[winfo ismapped $w.ctrl]} {
205
+ pack forget $w.ctrl
206
+ $w.show config -text "\xbb"
207
+ } else {
208
+ pack $w.ctrl -side right -fill both -ipady 5
209
+ $w.show config -text "\xab"
210
+ }
211
+ }
212
+
213
+ proc DrawAll {w} {
214
+ ResetStep
215
+ $w.c delete all
216
+ for {set i 0} {1} {incr i} {
217
+ set p "Draw$i"
218
+ if {[info procs $p] eq ""} break
219
+ $p $w
220
+ }
221
+ }
222
+
223
+ proc ActiveGUI {w var1 var2 op} {
224
+ global S MGO MSTART MDONE
225
+ array set z {0 disabled 1 normal}
226
+
227
+ set m $S(mode)
228
+ set S(pause) [expr {$m == 2}]
229
+ $w.start config -state $z([expr {$m != $MGO}])
230
+ $w.pause config -state $z([expr {$m != $MSTART && $m != $MDONE}])
231
+ $w.step config -state $z([expr {$m != $MGO && $m != $MDONE}])
232
+ $w.bstep config -state $z([expr {$m != $MGO && $m != $MDONE}])
233
+ $w.reset config -state $z([expr {$m != $MSTART}])
234
+
235
+ if {$S(details)} {
236
+ grid $w.details.f -sticky ew
237
+ } else {
238
+ grid forget $w.details.f
239
+ }
240
+ set S(speed) [expr {round($S(speed))}]
241
+ $w.speed config -text "Speed: $S(speed)"
242
+ }
243
+
244
+ proc Start {} {
245
+ global S MGO
246
+ set S(mode) $MGO
247
+ }
248
+
249
+ proc DoButton {w what} {
250
+ global S MDONE MGO MSSTEP MBSTEP MPAUSE
251
+
252
+ if {$what == 0} { ;# Start
253
+ if {$S(mode) == $MDONE} {
254
+ Reset $w
255
+ }
256
+ set S(mode) $MGO
257
+ } elseif {$what == 1} { ;# Pause
258
+ set S(mode) [expr {$S(pause) ? $MPAUSE : $MGO}]
259
+ } elseif {$what == 2} { ;# Step
260
+ set S(mode) $MSSTEP
261
+ } elseif {$what == 3} { ;# Reset
262
+ Reset $w
263
+ } elseif {$what == 4} { ;# Big step
264
+ set S(mode) $MBSTEP
265
+ }
266
+ }
267
+
268
+ proc Go {w {who {}}} {
269
+ global S speed animationCallbacks MGO MPAUSE MSSTEP MBSTEP
270
+
271
+ set now [clock clicks -milliseconds]
272
+ catch {after cancel $animationCallbacks(goldberg)}
273
+ if {$who ne ""} { ;# Start here for debugging
274
+ set S(active) $who
275
+ set S(mode) $MGO
276
+ }
277
+ if {$S(mode) == -1} return ;# Debugging
278
+ set n 0
279
+ if {$S(mode) != $MPAUSE} { ;# Not paused
280
+ set n [NextStep $w] ;# Do the next move
281
+ }
282
+ if {$S(mode) == $MSSTEP} { ;# Single step
283
+ set S(mode) $MPAUSE
284
+ }
285
+ if {$S(mode) == $MBSTEP && $n} { ;# Big step
286
+ set S(mode) $MSSTEP
287
+ }
288
+
289
+ set elapsed [expr {[clock click -milliseconds] - $now}]
290
+ set delay [expr {$speed($S(speed)) - $elapsed}]
291
+ if {$delay <= 0} {
292
+ set delay 1
293
+ }
294
+ set animationCallbacks(goldberg) [after $delay [list Go $w]]
295
+ }
296
+
297
+ # NextStep: drives the next step of the animation
298
+ proc NextStep {w} {
299
+ global S MSTART MDONE
300
+ set rval 0 ;# Return value
301
+
302
+ if {$S(mode) != $MSTART && $S(mode) != $MDONE} {
303
+ incr S(cnt)
304
+ }
305
+ set alive {}
306
+ foreach {who} $S(active) {
307
+ set n ["Move$who" $w]
308
+ if {$n & 1} { ;# This guy still alive
309
+ lappend alive $who
310
+ }
311
+ if {$n & 2} { ;# Next guy is active
312
+ lappend alive [expr {$who + 1}]
313
+ set rval 1
314
+ }
315
+ if {$n & 4} { ;# End of puzzle flag
316
+ set S(mode) $MDONE ;# Done mode
317
+ set S(active) {} ;# No more animation
318
+ return 1
319
+ }
320
+ }
321
+ set S(active) $alive
322
+ return $rval
323
+ }
324
+ proc About {w} {
325
+ set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind\
326
+ permission of the author)\n\n\"Man will always find a difficult\
327
+ means to perform a simple task.\"\nRube Goldberg"
328
+ tk_messageBox -parent $w -message $msg -title About
329
+ }
330
+ ################################################################
331
+ #
332
+ # All the drawing and moving routines
333
+ #
334
+
335
+ # START HERE! banner
336
+ proc Draw0 {w} {
337
+ set color $::C(0)
338
+ set xy {579 119}
339
+ $w.c create text $xy -text "START HERE!" -fill $color -anchor w \
340
+ -tag I0 -font {{Times Roman} 12 italic bold}
341
+ set xy {719 119 763 119}
342
+ $w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \
343
+ -arrowshape {18 18 5}
344
+ $w.c bind I0 <Button-1> Start
345
+ }
346
+ proc Move0 {w {step {}}} {
347
+ set step [GetStep 0 $step]
348
+
349
+ if {$::S(mode) > $::MSTART} { ;# Start the ball rolling
350
+ MoveAbs $w I0 {-100 -100} ;# Hide the banner
351
+ return 2
352
+ }
353
+
354
+ set pos {
355
+ {673 119} {678 119} {683 119} {688 119}
356
+ {693 119} {688 119} {683 119} {678 119}
357
+ }
358
+ set step [expr {$step % [llength $pos]}]
359
+ MoveAbs $w I0 [lindex $pos $step]
360
+ return 1
361
+ }
362
+
363
+ # Dropping ball
364
+ proc Draw1 {w} {
365
+ set color $::C(1a)
366
+ set color2 $::C(1b)
367
+ set xy {844 133 800 133 800 346 820 346 820 168 844 168 844 133}
368
+ $w.c create poly $xy -width 3 -fill $color -outline {}
369
+ set xy {771 133 685 133 685 168 751 168 751 346 771 346 771 133}
370
+ $w.c create poly $xy -width 3 -fill $color -outline {}
371
+
372
+ set xy [box 812 122 9]
373
+ $w.c create oval $xy -tag I1 -fill $color2 -outline {}
374
+ $w.c bind I1 <Button-1> Start
375
+ }
376
+ proc Move1 {w {step {}}} {
377
+ set step [GetStep 1 $step]
378
+ set pos {
379
+ {807 122} {802 122} {797 123} {793 124} {789 129} {785 153}
380
+ {785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503}
381
+ {824 585 y} {838 587} {848 593} {857 601} {-100 -100}
382
+ }
383
+ if {$step >= [llength $pos]} {
384
+ return 0
385
+ }
386
+ set where [lindex $pos $step]
387
+ MoveAbs $w I1 $where
388
+
389
+ if {[lindex $where 2] eq "y"} {
390
+ Move15a $w
391
+ }
392
+ if {[lindex $where 2] eq "x"} {
393
+ return 3
394
+ }
395
+ return 1
396
+ }
397
+
398
+ # Lighting the match
399
+ proc Draw2 {w} {
400
+ set color red
401
+ set color $::C(2)
402
+ set xy {750 369 740 392 760 392} ;# Fulcrum
403
+ $w.c create poly $xy -fill $::C(fg) -outline $::C(fg)
404
+ set xy {628 335 660 383} ;# Strike box
405
+ $w.c create rect $xy -fill {} -outline $::C(fg)
406
+ for {set y 0} {$y < 3} {incr y} {
407
+ set yy [expr {335+$y*16}]
408
+ $w.c create bitmap 628 $yy -bitmap gray25 -anchor nw \
409
+ -foreground $::C(fg)
410
+ $w.c create bitmap 644 $yy -bitmap gray25 -anchor nw \
411
+ -foreground $::C(fg)
412
+ }
413
+
414
+ set xy {702 366 798 366} ;# Lever
415
+ $w.c create line $xy -fill $::C(fg) -width 6 -tag I2_0
416
+ set xy {712 363 712 355} ;# R strap
417
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_1
418
+ set xy {705 363 705 355} ;# L strap
419
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_2
420
+ set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick
421
+ $w.c create line $xy -fill $::C(fg) -tag I2_3
422
+
423
+ #set xy {662 352 680 365} ;# Match head
424
+ set xy {
425
+ 671 352 677.4 353.9 680 358.5 677.4 363.1 671 365 664.6 363.1
426
+ 662 358.5 664.6 353.9
427
+ }
428
+ $w.c create poly $xy -fill $color -outline $color -tag I2_4
429
+ }
430
+ proc Move2 {w {step {}}} {
431
+ set step [GetStep 2 $step]
432
+
433
+ set stages {0 0 1 2 0 2 1 0 1 2 0 2 1}
434
+ set xy(0) {
435
+ 686 333 692 323 682 316 674 309 671 295 668 307 662 318 662 328
436
+ 671 336
437
+ }
438
+ set xy(1) {687 331 698 322 703 295 680 320 668 297 663 311 661 327 671 335}
439
+ set xy(2) {
440
+ 686 331 704 322 688 300 678 283 678 283 674 298 666 309 660 324
441
+ 672 336
442
+ }
443
+
444
+ if {$step >= [llength $stages]} {
445
+ $w.c delete I2
446
+ return 0
447
+ }
448
+
449
+ if {$step == 0} { ;# Rotate the match
450
+ set beta 20
451
+ lassign [Anchor $w I2_0 s] Ox Oy ;# Where to pivot
452
+ for {set i 0} {[$w.c find withtag I2_$i] ne ""} {incr i} {
453
+ RotateItem $w I2_$i $Ox $Oy $beta
454
+ }
455
+ $w.c create poly -tag I2 -smooth 1 -fill $::C(2) ;# For the flame
456
+ return 1
457
+ }
458
+ $w.c coords I2 $xy([lindex $stages $step])
459
+ return [expr {$step == 7 ? 3 : 1}]
460
+ }
461
+
462
+ # Weight and pulleys
463
+ proc Draw3 {w} {
464
+ set color $::C(3a)
465
+ set color2 $::C(3b)
466
+
467
+ set xy {602 296 577 174 518 174}
468
+ foreach {x y} $xy { ;# 3 Pulleys
469
+ $w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) \
470
+ -width 3
471
+ $w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg)
472
+ }
473
+
474
+ set xy {750 309 670 309} ;# Wall to flame
475
+ $w.c create line $xy -tag I3_s -width 3 -fill $::C(fg) -smooth 1
476
+ set xy {670 309 650 309} ;# Flame to pulley 1
477
+ $w.c create line $xy -tag I3_0 -width 3 -fill $::C(fg)
478
+ set xy {650 309 600 309} ;# Flame to pulley 1
479
+ $w.c create line $xy -tag I3_1 -width 3 -fill $::C(fg)
480
+ set xy {589 296 589 235} ;# Pulley 1 half way to 2
481
+ $w.c create line $xy -tag I3_2 -width 3 -fill $::C(fg)
482
+ set xy {589 235 589 174} ;# Pulley 1 other half to 2
483
+ $w.c create line $xy -width 3 -fill $::C(fg)
484
+ set xy {577 161 518 161} ;# Across the top
485
+ $w.c create line $xy -width 3 -fill $::C(fg)
486
+ set xy {505 174 505 205} ;# Down to weight
487
+ $w.c create line $xy -tag I3_w -width 3 -fill $::C(fg)
488
+
489
+ # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle
490
+ set xy {515 207 495 207}
491
+ foreach {x1 y1 x2 y2} $xy {
492
+ $w.c create oval [box $x1 $y1 6] -tag I3_ -fill $color2 \
493
+ -outline $color2
494
+ $w.c create oval [box $x2 $y2 6] -tag I3_ -fill $color2 \
495
+ -outline $color2
496
+ incr y1 -6; incr y2 6
497
+ $w.c create rect $x1 $y1 $x2 $y2 -tag I3_ -fill $color2 \
498
+ -outline $color2
499
+ }
500
+ set xy {492 220 518 263}
501
+ set xy [RoundRect $w $xy 15]
502
+ $w.c create poly $xy -smooth 1 -tag I3_ -fill $color2 -outline $color2
503
+ set xy {500 217 511 217}
504
+ $w.c create line $xy -tag I3_ -fill $color2 -width 10
505
+
506
+ set xy {502 393 522 393 522 465} ;# Bottom weight target
507
+ $w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 10
508
+ }
509
+ proc Move3 {w {step {}}} {
510
+ set step [GetStep 3 $step]
511
+
512
+ set pos {{505 247} {505 297} {505 386.5} {505 386.5}}
513
+ set rope(0) {750 309 729 301 711 324 690 300}
514
+ set rope(1) {750 309 737 292 736 335 717 315 712 320}
515
+ set rope(2) {750 309 737 309 740 343 736 351 725 340}
516
+ set rope(3) {750 309 738 321 746 345 742 356}
517
+
518
+ if {$step >= [llength $pos]} {
519
+ return 0
520
+ }
521
+
522
+ $w.c delete "I3_$step" ;# Delete part of the rope
523
+ MoveAbs $w I3_ [lindex $pos $step] ;# Move weight down
524
+ $w.c coords I3_s $rope($step) ;# Flapping rope end
525
+ $w.c coords I3_w [concat 505 174 [lindex $pos $step]]
526
+ if {$step == 2} {
527
+ $w.c move I3__ 0 30
528
+ return 2
529
+ }
530
+ return 1
531
+ }
532
+
533
+ # Cage and door
534
+ proc Draw4 {w} {
535
+ set color $::C(4)
536
+ lassign {527 356 611 464} x0 y0 x1 y1
537
+
538
+ for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars
539
+ $w.c create line $x0 $y $x1 $y -fill $color -width 1
540
+ }
541
+ for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars
542
+ $w.c create line $x $y0 $x $y1 -fill $color -width 1
543
+ }
544
+
545
+ set xy {518 464 518 428} ;# Swing gate
546
+ $w.c create line $xy -tag I4 -fill $color -width 3
547
+ }
548
+ proc Move4 {w {step {}}} {
549
+ set step [GetStep 4 $step]
550
+
551
+ set angles {-10 -20 -30 -30}
552
+ if {$step >= [llength $angles]} {
553
+ return 0
554
+ }
555
+ RotateItem $w I4 518 464 [lindex $angles $step]
556
+ $w.c raise I4
557
+ return [expr {$step == 3 ? 3 : 1}]
558
+ }
559
+
560
+ # Mouse
561
+ proc Draw5 {w} {
562
+ set color $::C(5a)
563
+ set color2 $::C(5b)
564
+ set xy {377 248 410 248 410 465 518 465} ;# Mouse course
565
+ lappend xy 518 428 451 428 451 212 377 212
566
+ $w.c create poly $xy -fill $color2 -outline $::C(fg) -width 3
567
+
568
+ set xy {
569
+ 534.5 445.5 541 440 552 436 560 436 569 440 574 446 575 452 574 454
570
+ 566 456 554 456 545 456 537 454 530 452
571
+ }
572
+ $w.c create poly $xy -tag {I5 I5_0} -fill $color
573
+ set xy {573 452 592 458 601 460 613 456} ;# Tail
574
+ $w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 3
575
+ set xy [box 540 446 2] ;# Eye
576
+ set xy {540 444 541 445 541 447 540 448 538 447 538 445}
577
+ #.c create oval $xy -tag {I5 I5_2} -fill $::C(bg) -outline {}
578
+ $w.c create poly $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} -smooth 1
579
+ set xy {538 454 535 461} ;# Front leg
580
+ $w.c create line $xy -tag {I5 I5_3} -fill $color -width 2
581
+ set xy {566 455 569 462} ;# Back leg
582
+ $w.c create line $xy -tag {I5 I5_4} -fill $color -width 2
583
+ set xy {544 455 545 460} ;# 2nd front leg
584
+ $w.c create line $xy -tag {I5 I5_5} -fill $color -width 2
585
+ set xy {560 455 558 460} ;# 2nd back leg
586
+ $w.c create line $xy -tag {I5 I5_6} -fill $color -width 2
587
+ }
588
+ proc Move5 {w {step {}}} {
589
+ set step [GetStep 5 $step]
590
+
591
+ set pos {
592
+ {553 452} {533 452} {513 452} {493 452} {473 452}
593
+ {463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394}
594
+ {422 374} {422 354} {422 334} {422 314} {422 294}
595
+ {422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237}
596
+ }
597
+ if {$step >= [llength $pos]} {
598
+ return 0
599
+ }
600
+
601
+ lassign [lindex $pos $step] x y beta next
602
+ MoveAbs $w I5 [list $x $y]
603
+ if {$beta ne ""} {
604
+ lassign [Centroid $w I5_0] Ox Oy
605
+ foreach id {0 1 2 3 4 5 6} {
606
+ RotateItem $w I5_$id $Ox $Oy $beta
607
+ }
608
+ }
609
+ if {$next eq "x"} {
610
+ return 3
611
+ }
612
+ return 1
613
+ }
614
+
615
+ # Dropping gumballs
616
+ array set XY6 {
617
+ -1 {366 207} -2 {349 204} -3 {359 193} -4 {375 192} -5 {340 190}
618
+ -6 {349 177} -7 {366 177} -8 {380 176} -9 {332 172} -10 {342 161}
619
+ -11 {357 164} -12 {372 163} -13 {381 149} -14 {364 151} -15 {349 146}
620
+ -16 {333 148} 0 {357 219}
621
+ 1 {359 261} 2 {359 291} 3 {359 318} 4 {361 324} 5 {365 329} 6 {367 334}
622
+ 7 {367 340} 8 {366 346} 9 {364 350} 10 {361 355} 11 {359 370} 12 {359 391}
623
+ 13,0 {360 456} 13,1 {376 456} 13,2 {346 456} 13,3 {330 456}
624
+ 13,4 {353 444} 13,5 {368 443} 13,6 {339 442} 13,7 {359 431}
625
+ 13,8 {380 437} 13,9 {345 428} 13,10 {328 434} 13,11 {373 424}
626
+ 13,12 {331 420} 13,13 {360 417} 13,14 {345 412} 13,15 {376 410}
627
+ 13,16 {360 403}
628
+ }
629
+ proc Draw6 {w} {
630
+ set color $::C(6)
631
+ set xy {324 130 391 204} ;# Ball holder
632
+ set xy [RoundRect $w $xy 10]
633
+ $w.c create poly $xy -smooth 1 -outline $::C(fg) -width 3 -fill $color
634
+ set xy {339 204 376 253} ;# Below the ball holder
635
+ $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color \
636
+ -tag I6c
637
+ set xy [box 346 339 28]
638
+ $w.c create oval $xy -fill $color -outline {} ;# Rotor
639
+ $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \
640
+ -start 80 -extent 205
641
+ $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \
642
+ -start -41 -extent 85
643
+
644
+ set xy [box 346 339 15] ;# Center of rotor
645
+ $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) -tag I6m
646
+ set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor
647
+ $w.c create poly $xy -fill $color -outline {}
648
+ $w.c create line $xy -fill $::C(fg) -width 2
649
+
650
+ set xy {353 240 367 300} ;# Poke bottom hole
651
+ $w.c create rect $xy -fill $color -outline {}
652
+ set xy {341 190 375 210} ;# Poke another hole
653
+ $w.c create rect $xy -fill $color -outline {}
654
+
655
+ set xy {368 356 368 403 389 403 389 464 320 464 320 403 352 403 352 366}
656
+ $w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor
657
+ $w.c create line $xy -fill $::C(fg) -width 2
658
+ set xy [box 275 342 7] ;# On/off rotor
659
+ $w.c create oval $xy -outline $::C(fg) -fill $::C(fg)
660
+ set xy {276 334 342 325} ;# Fan belt top
661
+ $w.c create line $xy -fill $::C(fg) -width 3
662
+ set xy {276 349 342 353} ;# Fan belt bottom
663
+ $w.c create line $xy -fill $::C(fg) -width 3
664
+
665
+ set xy {337 212 337 247} ;# What the mouse pushes
666
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_
667
+ set xy {392 212 392 247}
668
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_
669
+ set xy {337 230 392 230}
670
+ $w.c create line $xy -fill $::C(fg) -width 7 -tag I6_
671
+
672
+ set who -1 ;# All the balls
673
+ set colors {red cyan orange green blue darkblue}
674
+ lappend colors {*}$colors {*}$colors
675
+
676
+ for {set i 0} {$i < 17} {incr i} {
677
+ set loc [expr {-1 * $i}]
678
+ set color [lindex $colors $i]
679
+ $w.c create oval [box {*}$::XY6($loc) 5] -fill $color \
680
+ -outline $color -tag I6_b$i
681
+ }
682
+ Draw6a $w 12 ;# The wheel
683
+ }
684
+ proc Draw6a {w beta} {
685
+ $w.c delete I6_0
686
+ lassign {346 339} Ox Oy
687
+ for {set i 0} {$i < 4} {incr i} {
688
+ set b [expr {$beta + $i * 45}]
689
+ lassign [RotateC 28 0 0 0 $b] x y
690
+ set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \
691
+ [expr {$Ox-$x}] [expr {$Oy-$y}]]
692
+ $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2
693
+ }
694
+ }
695
+ proc Move6 {w {step {}}} {
696
+ set step [GetStep 6 $step]
697
+ if {$step > 62} {
698
+ return 0
699
+ }
700
+
701
+ if {$step < 2} { ;# Open gate for balls to drop
702
+ $w.c move I6_ -7 0
703
+ if {$step == 1} { ;# Poke a hole
704
+ set xy {348 226 365 240}
705
+ $w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {}
706
+ }
707
+ return 1
708
+ }
709
+
710
+ set s [expr {$step - 1}] ;# Do the gumball drop dance
711
+ for {set i 0} {$i <= int(($s-1) / 3)} {incr i} {
712
+ set tag "I6_b$i"
713
+ if {[$w.c find withtag $tag] eq ""} break
714
+ set loc [expr {$s - 3 * $i}]
715
+
716
+ if {[info exists ::XY6($loc,$i)]} {
717
+ MoveAbs $w $tag $::XY6($loc,$i)
718
+ } elseif {[info exists ::XY6($loc)]} {
719
+ MoveAbs $w $tag $::XY6($loc)
720
+ }
721
+ }
722
+ if {($s % 3) == 1} {
723
+ set first [expr {($s + 2) / 3}]
724
+ for {set i $first} {1} {incr i} {
725
+ set tag "I6_b$i"
726
+ if {[$w.c find withtag $tag] eq ""} break
727
+ set loc [expr {$first - $i}]
728
+ MoveAbs $w $tag $::XY6($loc)
729
+ }
730
+ }
731
+ if {$s >= 3} { ;# Rotate the motor
732
+ set idx [expr {$s % 3}]
733
+ #Draw6a $w [lindex {12 35 64} $idx]
734
+ Draw6a $w [expr {12 + $s * 15}]
735
+ }
736
+ return [expr {$s == 3 ? 3 : 1}]
737
+ }
738
+
739
+ # On/off switch
740
+ proc Draw7 {w} {
741
+ set color $::C(7)
742
+ set xy {198 306 277 374} ;# Box
743
+ $w.c create rect $xy -outline $::C(fg) -width 2 -fill $color -tag I7z
744
+ $w.c lower I7z
745
+ set xy {275 343 230 349}
746
+ $w.c create line $xy -tag I7 -fill $::C(fg) -arrow last \
747
+ -arrowshape {23 23 8} -width 6
748
+ set xy {225 324} ;# On button
749
+ $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg)
750
+ set xy {218 323} ;# On text
751
+ set font {{Times Roman} 8}
752
+ $w.c create text $xy -text "on" -anchor e -fill $::C(fg) -font $font
753
+ set xy {225 350} ;# Off button
754
+ $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg)
755
+ set xy {218 349} ;# Off button
756
+ $w.c create text $xy -text "off" -anchor e -fill $::C(fg) -font $font
757
+ }
758
+ proc Move7 {w {step {}}} {
759
+ set step [GetStep 7 $step]
760
+ set numsteps 30
761
+ if {$step > $numsteps} {
762
+ return 0
763
+ }
764
+ set beta [expr {30.0 / $numsteps}]
765
+ RotateItem $w I7 275 343 $beta
766
+
767
+ return [expr {$step == $numsteps ? 3 : 1}]
768
+ }
769
+
770
+ # Electricity to the fan
771
+ proc Draw8 {w} {
772
+ Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3
773
+ }
774
+ proc Move8 {w {step {}}} {
775
+ set step [GetStep 8 $step]
776
+
777
+ if {$step > 3} {
778
+ return 0
779
+ }
780
+ if {$step == 0} {
781
+ Sparkle $w [Anchor $w I8_s s] I8
782
+ return 1
783
+
784
+ } elseif {$step == 1} {
785
+ MoveAbs $w I8 [Anchor $w I8_s c]
786
+ } elseif {$step == 2} {
787
+ MoveAbs $w I8 [Anchor $w I8_s n]
788
+ } else {
789
+ $w.c delete I8
790
+ }
791
+ return [expr {$step == 2 ? 3 : 1}]
792
+ }
793
+
794
+ # Fan
795
+ proc Draw9 {w} {
796
+ set color $::C(9)
797
+ set xy {266 194 310 220}
798
+ $w.c create oval $xy -outline $color -fill $color
799
+ set xy {280 209 296 248}
800
+ $w.c create oval $xy -outline $color -fill $color
801
+ set xy {288 249 252 249 260 240 280 234 296 234 316 240 324 249 288 249}
802
+ $w.c create poly $xy -fill $color -smooth 1
803
+
804
+ set xy {248 205 265 214 264 205 265 196} ;# Spinner
805
+ $w.c create poly $xy -fill $color
806
+
807
+ set xy {255 206 265 234} ;# Fan blades
808
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0
809
+ set xy {255 176 265 204}
810
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0
811
+ set xy {255 206 265 220}
812
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1
813
+ set xy {255 190 265 204}
814
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1
815
+ }
816
+ proc Move9 {w {step {}}} {
817
+ set step [GetStep 9 $step]
818
+
819
+ if {$step & 1} {
820
+ $w.c itemconfig I9_0 -width 4
821
+ $w.c itemconfig I9_1 -width 1
822
+ $w.c lower I9_1 I9_0
823
+ } else {
824
+ $w.c itemconfig I9_0 -width 1
825
+ $w.c itemconfig I9_1 -width 4
826
+ $w.c lower I9_0 I9_1
827
+ }
828
+ if {$step == 0} {
829
+ return 3
830
+ }
831
+ return 1
832
+ }
833
+
834
+ # Boat
835
+ proc Draw10 {w} {
836
+ set color $::C(10a)
837
+ set color2 $::C(10b)
838
+ set xy {191 230 233 230 233 178 191 178} ;# Sail
839
+ $w.c create poly $xy -fill $color -width 3 -outline $::C(fg) -tag I10
840
+ set xy [box 209 204 31] ;# Front
841
+ $w.c create arc $xy -outline {} -fill $color -style pie \
842
+ -start 120 -extent 120 -tag I10
843
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
844
+ -start 120 -extent 120 -tag I10
845
+ set xy [box 249 204 31] ;# Back
846
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 3 -style pie \
847
+ -start 120 -extent 120 -tag I10
848
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
849
+ -start 120 -extent 120 -tag I10
850
+
851
+ set xy {200 171 200 249} ;# Mast
852
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I10
853
+ set xy {159 234 182 234} ;# Bow sprit
854
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I10
855
+ set xy {180 234 180 251 220 251} ;# Hull
856
+ $w.c create line $xy -fill $::C(fg) -width 6 -tag I10
857
+
858
+ set xy {92 255 221 255} ;# Waves
859
+ Sine $w {*}$xy 2 25 -fill $color2 -width 1 -tag I10w
860
+
861
+ set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water
862
+ set xy [concat $xy 222 266 222 277 99 277]
863
+ $w.c create poly $xy -fill $color2 -outline $color2
864
+ set xy {222 266 222 277 97 277 97 266} ;# Water bottom
865
+ $w.c create line $xy -fill $::C(fg) -width 3
866
+
867
+ set xy [box 239 262 17]
868
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
869
+ -start 95 -extent 103
870
+ set xy [box 76 266 21]
871
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 190
872
+ }
873
+ proc Move10 {w {step {}}} {
874
+ set step [GetStep 10 $step]
875
+ set pos {
876
+ {195 212} {193 212} {190 212} {186 212} {181 212} {176 212}
877
+ {171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212}
878
+ {137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212}
879
+ }
880
+
881
+ if {$step >= [llength $pos]} {
882
+ return 0
883
+ }
884
+ set where [lindex $pos $step]
885
+ MoveAbs $w I10 $where
886
+
887
+ if {[lindex $where 2] eq "x"} {
888
+ return 3
889
+ }
890
+ return 1
891
+ }
892
+
893
+ # 2nd ball drop
894
+ proc Draw11 {w} {
895
+ set color $::C(11a)
896
+ set color2 $::C(11b)
897
+ set xy {23 264 55 591} ;# Color the down tube
898
+ $w.c create rect $xy -fill $color -outline {}
899
+ set xy [box 71 460 48] ;# Color the outer loop
900
+ $w.c create oval $xy -fill $color -outline {}
901
+
902
+ set xy {55 264 55 458} ;# Top right side
903
+ $w.c create line $xy -fill $::C(fg) -width 3
904
+ set xy {55 504 55 591} ;# Bottom right side
905
+ $w.c create line $xy -fill $::C(fg) -width 3
906
+ set xy [box 71 460 48] ;# Outer loop
907
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
908
+ -start 110 -extent -290 -tag I11i
909
+ set xy [box 71 460 16] ;# Inner loop
910
+ $w.c create oval $xy -outline $::C(fg) -fill {} -width 3 -tag I11i
911
+ $w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 3
912
+
913
+ set xy {23 264 23 591} ;# Left side
914
+ $w.c create line $xy -fill $::C(fg) -width 3
915
+ set xy [box 1 266 23] ;# Top left curve
916
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 90
917
+
918
+ set xy [box 75 235 9] ;# The ball
919
+ $w.c create oval $xy -fill $color2 -outline {} -width 3 -tag I11
920
+ }
921
+ proc Move11 {w {step {}}} {
922
+ set step [GetStep 11 $step]
923
+ set pos {
924
+ {75 235} {70 235} {65 237} {56 240} {46 247} {38 266} {38 296}
925
+ {38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423}
926
+ {-100 -100} {38 505} {38 527 x} {38 591}
927
+ }
928
+
929
+ if {$step >= [llength $pos]} {
930
+ return 0
931
+ }
932
+ set where [lindex $pos $step]
933
+ MoveAbs $w I11 $where
934
+ if {[lindex $where 2] eq "x"} {
935
+ return 3
936
+ }
937
+ return 1
938
+ }
939
+
940
+ # Hand
941
+ proc Draw12 {w} {
942
+ set xy {20 637 20 617 20 610 20 590 40 590 40 590 60 590 60 610 60 610}
943
+ lappend xy 60 610 65 620 60 631 ;# Thumb
944
+ lappend xy 60 631 60 637 60 662 60 669 52 669 56 669 50 669 50 662 50 637
945
+
946
+ set y0 637 ;# Bumps for fingers
947
+ set y1 645
948
+ for {set x 50} {$x > 20} {incr x -10} {
949
+ set x1 [expr {$x - 5}]
950
+ set x2 [expr {$x - 10}]
951
+ lappend xy $x $y0 $x1 $y1 $x2 $y0
952
+ }
953
+ $w.c create poly $xy -fill $::C(12) -outline $::C(fg) -smooth 1 -tag I12 \
954
+ -width 3
955
+ }
956
+ proc Move12 {w {step {}}} {
957
+ set step [GetStep 12 $step]
958
+ set pos {{42.5 641 x}}
959
+ if {$step >= [llength $pos]} {
960
+ return 0
961
+ }
962
+
963
+ set where [lindex $pos $step]
964
+ MoveAbs $w I12 $where
965
+ if {[lindex $where 2] eq "x"} {
966
+ return 3
967
+ }
968
+ return 1
969
+ }
970
+
971
+ # Fax
972
+ proc Draw13 {w} {
973
+ set color $::C(13a)
974
+ set xy {86 663 149 663 149 704 50 704 50 681 64 681 86 671}
975
+ set xy2 {784 663 721 663 721 704 820 704 820 681 806 681 784 671}
976
+ set radii {2 9 9 8 5 5 2}
977
+
978
+ RoundPoly $w.c $xy $radii -width 3 -outline $::C(fg) -fill $color
979
+ RoundPoly $w.c $xy2 $radii -width 3 -outline $::C(fg) -fill $color
980
+
981
+ set xy {56 677}
982
+ $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \
983
+ -tag I13
984
+ set xy {809 677}
985
+ $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \
986
+ -tag I13R
987
+
988
+ set xy {112 687} ;# Label
989
+ $w.c create text $xy -text "FAX" -fill $::C(fg) \
990
+ -font {{Times Roman} 12 bold}
991
+ set xy {762 687}
992
+ $w.c create text $xy -text "FAX" -fill $::C(fg) \
993
+ -font {{Times Roman} 12 bold}
994
+
995
+ set xy {138 663 148 636 178 636} ;# Paper guide
996
+ $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3
997
+ set xy {732 663 722 636 692 636}
998
+ $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3
999
+
1000
+ Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3
1001
+ }
1002
+ proc Move13 {w {step {}}} {
1003
+ set step [GetStep 13 $step]
1004
+ set numsteps 7
1005
+
1006
+ if {$step == $numsteps+2} {
1007
+ MoveAbs $w I13_star {-100 -100}
1008
+ $w.c itemconfig I13R -fill $::C(13b) -width 2
1009
+ return 2
1010
+ }
1011
+ if {$step == 0} { ;# Button down
1012
+ $w.c delete I13
1013
+ Sparkle $w {-100 -100} I13_star ;# Create off screen
1014
+ return 1
1015
+ }
1016
+ lassign [Anchor $w I13_s w] x0 y0
1017
+ lassign [Anchor $w I13_s e] x1 y1
1018
+ set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}]
1019
+ MoveAbs $w I13_star [list $x $y0]
1020
+ return 1
1021
+ }
1022
+
1023
+ # Paper in fax
1024
+ proc Draw14 {w} {
1025
+ set color $::C(14)
1026
+ set xy {102 661 113 632 130 618} ;# Left paper edge
1027
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_0
1028
+ set xy {148 629 125 640 124 662} ;# Right paper edge
1029
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_1
1030
+ Draw14a $w L
1031
+
1032
+ set xy {
1033
+ 768.0 662.5 767.991316225 662.433786215 767.926187912 662.396880171
1034
+ }
1035
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_0
1036
+ $w.c lower I14R_0
1037
+ # NB. these numbers are VERY sensitive, you must start with final size
1038
+ # and shrink down to get the values
1039
+ set xy {
1040
+ 745.947897349 662.428358855 745.997829056 662.452239237 746.0 662.5
1041
+ }
1042
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_1
1043
+ $w.c lower I14R_1
1044
+ }
1045
+ proc Draw14a {w side} {
1046
+ set color $::C(14)
1047
+ set xy [$w.c coords I14${side}_0]
1048
+ set xy2 [$w.c coords I14${side}_1]
1049
+ lassign $xy x0 y0 x1 y1 x2 y2
1050
+ lassign $xy2 x3 y3 x4 y4 x5 y5
1051
+ set zz [concat \
1052
+ $x0 $y0 $x0 $y0 $xy $x2 $y2 $x2 $y2 \
1053
+ $x3 $y3 $x3 $y3 $xy2 $x5 $y5 $x5 $y5]
1054
+ $w.c delete I14$side
1055
+ $w.c create poly $zz -tag I14$side -smooth 1 -fill $color -outline $color \
1056
+ -width 3
1057
+ $w.c lower I14$side
1058
+ }
1059
+ proc Move14 {w {step {}}} {
1060
+ set step [GetStep 14 $step]
1061
+
1062
+ # Paper going down
1063
+ set sc [expr {.9 - .05*$step}]
1064
+ if {$sc < .3} {
1065
+ $w.c delete I14L
1066
+ return 0
1067
+ }
1068
+
1069
+ lassign [$w.c coords I14L_0] Ox Oy
1070
+ $w.c scale I14L_0 $Ox $Oy $sc $sc
1071
+ lassign [lrange [$w.c coords I14L_1] end-1 end] Ox Oy
1072
+ $w.c scale I14L_1 $Ox $Oy $sc $sc
1073
+ Draw14a $w L
1074
+
1075
+ # Paper going up
1076
+ set sc [expr {.35 + .05*$step}]
1077
+ set sc [expr {1 / $sc}]
1078
+
1079
+ lassign [$w.c coords I14R_0] Ox Oy
1080
+ $w.c scale I14R_0 $Ox $Oy $sc $sc
1081
+ lassign [lrange [$w.c coords I14R_1] end-1 end] Ox Oy
1082
+ $w.c scale I14R_1 $Ox $Oy $sc $sc
1083
+ Draw14a $w R
1084
+
1085
+ return [expr {$step == 10 ? 3 : 1}]
1086
+ }
1087
+
1088
+ # Light beam
1089
+ proc Draw15 {w} {
1090
+ set color $::C(15a)
1091
+ set xy {824 599 824 585 820 585 829 585}
1092
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I15a
1093
+ set xy {789 599 836 643}
1094
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1095
+ set xy {778 610 788 632}
1096
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1097
+ set xy {766 617 776 625}
1098
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1099
+
1100
+ set xy {633 600 681 640}
1101
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1102
+ set xy {635 567 657 599}
1103
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 2
1104
+ set xy {765 557 784 583}
1105
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 2
1106
+
1107
+ Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3
1108
+ }
1109
+ proc Move15a {w} {
1110
+ set color $::C(15b)
1111
+ $w.c scale I15a 824 599 1 .3 ;# Button down
1112
+ set xy {765 621 681 621}
1113
+ $w.c create line $xy -dash "-" -width 3 -fill $color -tag I15
1114
+ }
1115
+ proc Move15 {w {step {}}} {
1116
+ set step [GetStep 15 $step]
1117
+ set numsteps 6
1118
+
1119
+ if {$step == $numsteps+2} {
1120
+ MoveAbs $w I15_star {-100 -100}
1121
+ return 2
1122
+ }
1123
+ if {$step == 0} { ;# Break the light beam
1124
+ Sparkle $w {-100 -100} I15_star
1125
+ set xy {765 621 745 621}
1126
+ $w.c coords I15 $xy
1127
+ return 1
1128
+ }
1129
+ lassign [Anchor $w I15_s w] x0 y0
1130
+ lassign [Anchor $w I15_s e] x1 y1
1131
+ set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}]
1132
+ MoveAbs $w I15_star [list $x $y0]
1133
+ return 1
1134
+ }
1135
+
1136
+ # Bell
1137
+ proc Draw16 {w} {
1138
+ set color $::C(16)
1139
+ set xy {722 485 791 556}
1140
+ $w.c create rect $xy -fill {} -outline $::C(fg) -width 3
1141
+ set xy [box 752 515 25] ;# Bell
1142
+ $w.c create oval $xy -fill $color -outline black -tag I16b -width 2
1143
+ set xy [box 752 515 5] ;# Bell button
1144
+ $w.c create oval $xy -fill black -outline black -tag I16b
1145
+
1146
+ set xy {784 523 764 549} ;# Clapper
1147
+ $w.c create line $xy -width 3 -tag I16c -fill $::C(fg)
1148
+ set xy [box 784 523 4]
1149
+ $w.c create oval $xy -fill $::C(fg) -outline $::C(fg) -tag I16d
1150
+ }
1151
+ proc Move16 {w {step {}}} {
1152
+ set step [GetStep 16 $step]
1153
+
1154
+ # Note: we never stop
1155
+ lassign {760 553} Ox Oy
1156
+ if {$step & 1} {
1157
+ set beta 12
1158
+ $w.c move I16b 3 0
1159
+ } else {
1160
+ set beta -12
1161
+ $w.c move I16b -3 0
1162
+ }
1163
+ RotateItem $w I16c $Ox $Oy $beta
1164
+ RotateItem $w I16d $Ox $Oy $beta
1165
+
1166
+ return [expr {$step == 1 ? 3 : 1}]
1167
+ }
1168
+
1169
+ # Cat
1170
+ proc Draw17 {w} {
1171
+ set color $::C(17)
1172
+
1173
+ set xy {584 556 722 556}
1174
+ $w.c create line $xy -fill $::C(fg) -width 3
1175
+ set xy {584 485 722 485}
1176
+ $w.c create line $xy -fill $::C(fg) -width 3
1177
+
1178
+ set xy {664 523 717 549} ;# Body
1179
+ $w.c create arc $xy -outline $::C(fg) -fill $color -width 3 \
1180
+ -style chord -start 128 -extent -260 -tag I17
1181
+
1182
+ set xy {709 554 690 543} ;# Paw
1183
+ $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17
1184
+ set xy {657 544 676 555}
1185
+ $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17
1186
+
1187
+ set xy [box 660 535 15] ;# Lower face
1188
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
1189
+ -start 150 -extent 240 -tag I17_
1190
+ $w.c create arc $xy -outline {} -fill $color -width 1 -style chord \
1191
+ -start 150 -extent 240 -tag I17_
1192
+ set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears
1193
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1194
+ $w.c create poly $xy -fill $color -outline {} -width 1 -tag {I17_ I17_c}
1195
+ set xy {652 542 628 539} ;# Whiskers
1196
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1197
+ set xy {652 543 632 545}
1198
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1199
+ set xy {652 546 632 552}
1200
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1201
+
1202
+ set xy {668 543 687 538}
1203
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
1204
+ set xy {668 544 688 546}
1205
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
1206
+ set xy {668 547 688 553}
1207
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
1208
+
1209
+ set xy {649 530 654 538 659 530} ;# Left eye
1210
+ $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
1211
+ set xy {671 530 666 538 661 530} ;# Right eye
1212
+ $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
1213
+ set xy {655 543 660 551 665 543} ;# Mouth
1214
+ $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
1215
+ }
1216
+ proc Move17 {w {step {}}} {
1217
+ set step [GetStep 17 $step]
1218
+
1219
+ if {$step == 0} {
1220
+ $w.c delete I17 ;# Delete most of the cat
1221
+ set xy {655 543 660 535 665 543} ;# Mouth
1222
+ $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_
1223
+ set xy [box 654 530 4] ;# Left eye
1224
+ $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_
1225
+ set xy [box 666 530 4] ;# Right eye
1226
+ $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_
1227
+
1228
+ $w.c move I17_ 0 -20 ;# Move face up
1229
+ set xy {652 528 652 554} ;# Front leg
1230
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1231
+ set xy {670 528 670 554} ;# 2nd front leg
1232
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1233
+
1234
+ set xy {
1235
+ 675 506 694 489 715 513 715 513 715 513 716 525 716 525 716 525
1236
+ 706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517
1237
+ 677 512
1238
+ } ;# Body
1239
+ $w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \
1240
+ -outline $::C(fg) -width 3 -smooth 1 -tag I17_
1241
+ set xy {716 514 716 554} ;# Back leg
1242
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1243
+ set xy {694 532 694 554} ;# 2nd back leg
1244
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1245
+ set xy {715 514 718 506 719 495 716 488};# Tail
1246
+ $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_
1247
+
1248
+ $w.c raise I17w ;# Make whiskers visible
1249
+ $w.c move I17_ -5 0 ;# Move away from wall a bit
1250
+ return 2
1251
+ }
1252
+ return 0
1253
+ }
1254
+
1255
+ # Sling shot
1256
+ proc Draw18 {w} {
1257
+ set color $::C(18)
1258
+ set xy {721 506 627 506} ;# Sling hold
1259
+ $w.c create line $xy -width 4 -fill $::C(fg) -tag I18
1260
+
1261
+ set xy {607 500 628 513} ;# Sling rock
1262
+ $w.c create oval $xy -fill $color -outline {} -tag I18a
1263
+
1264
+ set xy {526 513 606 507 494 502} ;# Sling band
1265
+ $w.c create line $xy -fill $::C(fg) -width 4 -tag I18b
1266
+ set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling
1267
+ $w.c create line $xy -fill $::C(fg) -width 6
1268
+ }
1269
+ proc Move18 {w {step {}}} {
1270
+ set step [GetStep 18 $step]
1271
+
1272
+ set pos {
1273
+ {587 506} {537 506} {466 506} {376 506} {266 506 x} {136 506}
1274
+ {16 506} {-100 -100}
1275
+ }
1276
+
1277
+ set b(0) {490 502 719 507 524 512} ;# Band collapsing
1278
+ set b(1) {
1279
+ 491 503 524 557 563 505 559 496 546 506 551 525 553 536 538 534
1280
+ 532 519 529 499
1281
+ }
1282
+ set b(2) {491 503 508 563 542 533 551 526 561 539 549 550 530 500}
1283
+ set b(3) {491 503 508 563 530 554 541 562 525 568 519 544 530 501}
1284
+
1285
+ if {$step >= [llength $pos]} {
1286
+ return 0
1287
+ }
1288
+
1289
+ if {$step == 0} {
1290
+ $w.c delete I18
1291
+ $w.c itemconfig I18b -smooth 1
1292
+ }
1293
+ if {[info exists b($step)]} {
1294
+ $w.c coords I18b $b($step)
1295
+ }
1296
+
1297
+ set where [lindex $pos $step]
1298
+ MoveAbs $w I18a $where
1299
+ if {[lindex $where 2] eq "x"} {
1300
+ return 3
1301
+ }
1302
+ return 1
1303
+ }
1304
+
1305
+ # Water pipe
1306
+ proc Draw19 {w} {
1307
+ set color $::C(19)
1308
+ set xx {249 181 155 118 86 55 22 0}
1309
+ foreach {x1 x2} $xx {
1310
+ $w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19
1311
+ $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1;# Pipe top
1312
+ $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1;# Pipe bottom
1313
+ }
1314
+ $w.c raise I11i
1315
+
1316
+ set xy [box 168 460 16] ;# Bulge by the joint
1317
+ $w.c create oval $xy -fill $color -outline {}
1318
+ $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \
1319
+ -start 21 -extent 136
1320
+ $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \
1321
+ -start -21 -extent -130
1322
+
1323
+ set xy {249 447 255 473} ;# First joint 26x6
1324
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1325
+
1326
+ set xy [box 257 433 34] ;# Bend up
1327
+ $w.c create arc $xy -outline {} -fill $color -width 1 \
1328
+ -style pie -start 0 -extent -91
1329
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1330
+ -style arc -start 0 -extent -90
1331
+ set xy [box 257 433 20]
1332
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
1333
+ -style pie -start 0 -extent -92
1334
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1335
+ -style arc -start 0 -extent -90
1336
+ set xy [box 257 421 34] ;# Bend left
1337
+ $w.c create arc $xy -outline {} -fill $color -width 1 \
1338
+ -style pie -start 1 -extent 91
1339
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1340
+ -style arc -start 0 -extent 90
1341
+ set xy [box 257 421 20]
1342
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
1343
+ -style pie -start 0 -extent 90
1344
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1345
+ -style arc -start 0 -extent 90
1346
+ set xy [box 243 421 34] ;# Bend down
1347
+ $w.c create arc $xy -outline {} -fill $color -width 1 \
1348
+ -style pie -start 90 -extent 90
1349
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1350
+ -style arc -start 90 -extent 90
1351
+ set xy [box 243 421 20]
1352
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
1353
+ -style pie -start 90 -extent 90
1354
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1355
+ -style arc -start 90 -extent 90
1356
+
1357
+ set xy {270 427 296 433} ;# 2nd joint bottom
1358
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1359
+ set xy {270 421 296 427} ;# 2nd joint top
1360
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1361
+ set xy {249 382 255 408} ;# Third joint right
1362
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1363
+ set xy {243 382 249 408} ;# Third joint left
1364
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1365
+ set xy {203 420 229 426} ;# Last joint
1366
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1367
+
1368
+ set xy [box 168 460 6] ;# Handle joint
1369
+ $w.c create oval $xy -fill $::C(fg) -outline {} -tag I19a
1370
+ set xy {168 460 168 512} ;# Handle bar
1371
+ $w.c create line $xy -fill $::C(fg) -width 5 -tag I19b
1372
+ }
1373
+ proc Move19 {w {step {}}} {
1374
+ set step [GetStep 19 $step]
1375
+
1376
+ set angles {30 30 30}
1377
+ if {$step == [llength $angles]} {
1378
+ return 2
1379
+ }
1380
+
1381
+ RotateItem $w I19b {*}[Centroid $w I19a] [lindex $angles $step]
1382
+ return 1
1383
+ }
1384
+
1385
+ # Water pouring
1386
+ proc Draw20 {w} {
1387
+ }
1388
+ proc Move20 {w {step {}}} {
1389
+ set step [GetStep 20 $step]
1390
+
1391
+ set pos {451 462 473 484 496 504 513 523 532}
1392
+ set freq {20 40 40 40 40 40 40 40 40}
1393
+ set pos {
1394
+ {451 20} {462 40} {473 40} {484 40} {496 40} {504 40} {513 40}
1395
+ {523 40} {532 40 x}
1396
+ }
1397
+ if {$step >= [llength $pos]} {
1398
+ return 0
1399
+ }
1400
+
1401
+ $w.c delete I20
1402
+ set where [lindex $pos $step]
1403
+ lassign $where y f
1404
+ H2O $w $y $f
1405
+ if {[lindex $where 2] eq "x"} {
1406
+ return 3
1407
+ }
1408
+ return 1
1409
+ }
1410
+ proc H2O {w y f} {
1411
+ set color $::C(20)
1412
+ $w.c delete I20
1413
+
1414
+ Sine $w 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color \
1415
+ -smooth 1
1416
+ $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \
1417
+ -tag {I20 I20a}
1418
+ $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \
1419
+ -tag {I20 I20b}
1420
+ $w.c move I20a 8 0
1421
+ $w.c move I20b 16 0
1422
+ }
1423
+
1424
+ # Bucket
1425
+ proc Draw21 {w} {
1426
+ set color $::C(21)
1427
+ set xy {217 451 244 490} ;# Right handle
1428
+ $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a
1429
+ set xy {201 467 182 490} ;# Left handle
1430
+ $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a
1431
+
1432
+ set xy {245 490 237 535} ;# Right side
1433
+ set xy2 {189 535 181 490} ;# Left side
1434
+ $w.c create poly [concat $xy $xy2] -fill $color -outline {} \
1435
+ -tag {I21 I21f}
1436
+ $w.c create line $xy -fill $::C(fg) -width 2 -tag I21
1437
+ $w.c create line $xy2 -fill $::C(fg) -width 2 -tag I21
1438
+
1439
+ set xy {182 486 244 498} ;# Top
1440
+ $w.c create oval $xy -fill $color -outline {} -width 2 -tag {I21 I21f}
1441
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 2 -tag {I21 I21t}
1442
+ set xy {189 532 237 540} ;# Bottom
1443
+ $w.c create oval $xy -fill $color -outline $::C(fg) -width 2 \
1444
+ -tag {I21 I21b}
1445
+ }
1446
+ proc Move21 {w {step {}}} {
1447
+ set step [GetStep 21 $step]
1448
+
1449
+ set numsteps 30
1450
+ if {$step >= $numsteps} {
1451
+ return 0
1452
+ }
1453
+
1454
+ lassign [$w.c coords I21b] x1 y1 x2 y2
1455
+ #lassign [$w.c coords I21t] X1 Y1 X2 Y2
1456
+ lassign {183 492 243 504} X1 Y1 X2 Y2
1457
+
1458
+ set f [expr {$step / double($numsteps)}]
1459
+ set y2 [expr {$y2 - 3}]
1460
+ set xx1 [expr {$x1 + ($X1 - $x1) * $f}]
1461
+ set yy1 [expr {$y1 + ($Y1 - $y1) * $f}]
1462
+ set xx2 [expr {$x2 + ($X2 - $x2) * $f}]
1463
+ set yy2 [expr {$y2 + ($Y2 - $y2) * $f}]
1464
+ #H2O $w $yy1 40
1465
+
1466
+ $w.c itemconfig I21b -fill $::C(20)
1467
+ $w.c delete I21w
1468
+ $w.c create poly $x2 $y2 $x1 $y1 $xx1 $yy1 $xx2 $yy1 -tag {I21 I21w} \
1469
+ -outline {} -fill $::C(20)
1470
+ $w.c lower I21w I21
1471
+ $w.c raise I21b
1472
+ $w.c lower I21f
1473
+
1474
+ return [expr {$step == $numsteps-1 ? 3 : 1}]
1475
+ }
1476
+
1477
+ # Bucket drop
1478
+ proc Draw22 {w} {
1479
+ }
1480
+ proc Move22 {w {step {}}} {
1481
+ set step [GetStep 22 $step]
1482
+ set pos {{213 513} {213 523} {213 543 x} {213 583} {213 593}}
1483
+
1484
+ if {$step == 0} {$w.c itemconfig I21f -fill $::C(22)}
1485
+ if {$step >= [llength $pos]} {
1486
+ return 0
1487
+ }
1488
+ set where [lindex $pos $step]
1489
+ MoveAbs $w I21 $where
1490
+ H2O $w [lindex $where 1] 40
1491
+ $w.c delete I21_a ;# Delete handles
1492
+
1493
+ if {[lindex $where 2] eq "x"} {
1494
+ return 3
1495
+ }
1496
+ return 1
1497
+ }
1498
+
1499
+ # Blow dart
1500
+ proc Draw23 {w} {
1501
+ set color $::C(23a)
1502
+ set color2 $::C(23b)
1503
+ set color3 $::C(23c)
1504
+
1505
+ set xy {185 623 253 650} ;# Block
1506
+ $w.c create rect $xy -fill black -outline $::C(fg) -width 2 -tag I23a
1507
+ set xy {187 592 241 623} ;# Balloon
1508
+ $w.c create oval $xy -outline {} -fill $color -tag I23b
1509
+ $w.c create arc $xy -outline $::C(fg) -width 3 -tag I23b \
1510
+ -style arc -start 12 -extent 336
1511
+ set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle
1512
+ $w.c create poly $xy -outline {} -fill $color -tag I23b
1513
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I23b
1514
+
1515
+ set xy {285 611 250 603} ;# Dart body
1516
+ $w.c create oval $xy -fill $color2 -outline $::C(fg) -width 3 -tag I23d
1517
+ set xy {249 596 249 618 264 607 249 596} ;# Dart tail
1518
+ $w.c create poly $xy -fill $color3 -outline $::C(fg) -width 3 -tag I23d
1519
+ set xy {249 607 268 607} ;# Dart detail
1520
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d
1521
+ set xy {285 607 305 607} ;# Dart needle
1522
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d
1523
+ }
1524
+ proc Move23 {w {step {}}} {
1525
+ set step [GetStep 23 $step]
1526
+
1527
+ set pos {
1528
+ {277 607} {287 607} {307 607 x} {347 607} {407 607} {487 607}
1529
+ {587 607} {687 607} {787 607} {-100 -100}
1530
+ }
1531
+
1532
+ if {$step >= [llength $pos]} {
1533
+ return 0
1534
+ }
1535
+ if {$step <= 1} {
1536
+ $w.c scale I23b {*}[Anchor $w I23a n] .9 .5
1537
+ }
1538
+ set where [lindex $pos $step]
1539
+ MoveAbs $w I23d $where
1540
+
1541
+ if {[lindex $where 2] eq "x"} {
1542
+ return 3
1543
+ }
1544
+ return 1
1545
+ }
1546
+
1547
+ # Balloon
1548
+ proc Draw24 {w} {
1549
+ set color $::C(24a)
1550
+ set xy {366 518 462 665} ;# Balloon
1551
+ $w.c create oval $xy -fill $color -outline $::C(fg) -width 3 -tag I24
1552
+ set xy {414 666 414 729} ;# String
1553
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I24
1554
+ set xy {410 666 404 673 422 673 418 666} ;# Nozzle
1555
+ $w.c create poly $xy -fill $color -outline $::C(fg) -width 3 -tag I24
1556
+
1557
+ set xy {387 567 390 549 404 542} ;# Reflections
1558
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1559
+ set xy {395 568 399 554 413 547}
1560
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1561
+ set xy {403 570 396 555 381 553}
1562
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1563
+ set xy {408 564 402 547 386 545}
1564
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1565
+ }
1566
+ proc Move24 {w {step {}}} {
1567
+ global S
1568
+ set step [GetStep 24 $step]
1569
+
1570
+ if {$step > 4} {
1571
+ return 0
1572
+ } elseif {$step == 4} {
1573
+ return 2
1574
+ }
1575
+
1576
+ if {$step == 0} {
1577
+ $w.c delete I24 ;# Exploding balloon
1578
+ set xy {
1579
+ 347 465 361 557 271 503 272 503 342 574 259 594 259 593 362 626
1580
+ 320 737 320 740 398 691 436 738 436 739 476 679 528 701 527 702
1581
+ 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508
1582
+ 431 441 431 440 400 502 347 465 347 465
1583
+ }
1584
+ $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \
1585
+ -width 10 -smooth 1
1586
+ set msg [subst $S(message)]
1587
+ $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \
1588
+ -fill $::C(24c) \
1589
+ -justify center -font {{Times Roman} 18 bold}
1590
+ return 1
1591
+ }
1592
+
1593
+ $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold]
1594
+ $w.c move I24 0 -60
1595
+ $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25
1596
+ return 1
1597
+ }
1598
+
1599
+ # Displaying the message
1600
+ proc Move25 {w {step {}}} {
1601
+ global S
1602
+ set step [GetStep 25 $step]
1603
+ if {$step == 0} {
1604
+ set ::XY(25) [clock clicks -milliseconds]
1605
+ return 1
1606
+ }
1607
+ set elapsed [expr {[clock clicks -milliseconds] - $::XY(25)}]
1608
+ if {$elapsed < 5000} {
1609
+ return 1
1610
+ }
1611
+ return 2
1612
+ }
1613
+
1614
+ # Collapsing balloon
1615
+ proc Move26 {w {step {}}} {
1616
+ global S
1617
+ set step [GetStep 26 $step]
1618
+
1619
+ if {$step >= 3} {
1620
+ $w.c delete I24 I26
1621
+ $w.c create text 430 755 -anchor s -tag I26 \
1622
+ -fill $::C(26) \
1623
+ -text "click to continue" -font {{Times Roman} 24 bold}
1624
+ bind $w.c <Button-1> [list Reset $w]
1625
+ return 4
1626
+ }
1627
+
1628
+ $w.c scale I24 {*}[Centroid $w I24] .8 .8
1629
+ $w.c move I24 0 60
1630
+ $w.c itemconfig I24t -font [list {Times Roman} [expr {30 - 6*$step}] bold]
1631
+ return 1
1632
+ }
1633
+
1634
+ ################################################################
1635
+ #
1636
+ # Helper functions
1637
+ #
1638
+
1639
+ proc box {x y r} {
1640
+ return [list [expr {$x-$r}] [expr {$y-$r}] [expr {$x+$r}] [expr {$y+$r}]]
1641
+ }
1642
+
1643
+ proc MoveAbs {w item xy} {
1644
+ lassign $xy x y
1645
+ lassign [Centroid $w $item] Ox Oy
1646
+ set dx [expr {$x - $Ox}]
1647
+ set dy [expr {$y - $Oy}]
1648
+ $w.c move $item $dx $dy
1649
+ }
1650
+
1651
+ proc RotateItem {w item Ox Oy beta} {
1652
+ set xy [$w.c coords $item]
1653
+ set xy2 {}
1654
+ foreach {x y} $xy {
1655
+ lappend xy2 {*}[RotateC $x $y $Ox $Oy $beta]
1656
+ }
1657
+ $w.c coords $item $xy2
1658
+ }
1659
+
1660
+ proc RotateC {x y Ox Oy beta} {
1661
+ # rotates vector (Ox,Oy)->(x,y) by beta degrees clockwise
1662
+
1663
+ set x [expr {$x - $Ox}] ;# Shift to origin
1664
+ set y [expr {$y - $Oy}]
1665
+
1666
+ set beta [expr {$beta * atan(1) * 4 / 180.0}] ;# Radians
1667
+ set xx [expr {$x * cos($beta) - $y * sin($beta)}] ;# Rotate
1668
+ set yy [expr {$x * sin($beta) + $y * cos($beta)}]
1669
+
1670
+ set xx [expr {$xx + $Ox}] ;# Shift back
1671
+ set yy [expr {$yy + $Oy}]
1672
+
1673
+ return [list $xx $yy]
1674
+ }
1675
+
1676
+ proc Reset {w} {
1677
+ global S
1678
+ DrawAll $w
1679
+ bind $w.c <Button-1> {}
1680
+ set S(mode) $::MSTART
1681
+ set S(active) 0
1682
+ }
1683
+
1684
+ # Each Move## keeps its state info in STEP, this retrieves and increments it
1685
+ proc GetStep {who step} {
1686
+ global STEP
1687
+ if {$step ne ""} {
1688
+ set STEP($who) $step
1689
+ } elseif {![info exists STEP($who)] || $STEP($who) eq ""} {
1690
+ set STEP($who) 0
1691
+ } else {
1692
+ incr STEP($who)
1693
+ }
1694
+ return $STEP($who)
1695
+ }
1696
+
1697
+ proc ResetStep {} {
1698
+ global STEP
1699
+ set ::S(cnt) 0
1700
+ foreach a [array names STEP] {
1701
+ set STEP($a) ""
1702
+ }
1703
+ }
1704
+
1705
+ proc Sine {w x0 y0 x1 y1 amp freq args} {
1706
+ set PI [expr {4 * atan(1)}]
1707
+ set step 2
1708
+ set xy {}
1709
+ if {$y0 == $y1} { ;# Horizontal
1710
+ for {set x $x0} {$x <= $x1} {incr x $step} {
1711
+ set beta [expr {($x - $x0) * 2 * $PI / $freq}]
1712
+ set y [expr {$y0 + $amp * sin($beta)}]
1713
+ lappend xy $x $y
1714
+ }
1715
+ } else {
1716
+ for {set y $y0} {$y <= $y1} {incr y $step} {
1717
+ set beta [expr {($y - $y0) * 2 * $PI / $freq}]
1718
+ set x [expr {$x0 + $amp * sin($beta)}]
1719
+ lappend xy $x $y
1720
+ }
1721
+ }
1722
+ return [$w.c create line $xy {*}$args]
1723
+ }
1724
+
1725
+ proc RoundRect {w xy radius args} {
1726
+ lassign $xy x0 y0 x3 y3
1727
+ set r [winfo pixels $w.c $radius]
1728
+ set d [expr {2 * $r}]
1729
+
1730
+ # Make sure that the radius of the curve is less than 3/8 size of the box!
1731
+ set maxr 0.75
1732
+ if {$d > $maxr * ($x3 - $x0)} {
1733
+ set d [expr {$maxr * ($x3 - $x0)}]
1734
+ }
1735
+ if {$d > $maxr * ($y3 - $y0)} {
1736
+ set d [expr {$maxr * ($y3 - $y0)}]
1737
+ }
1738
+
1739
+ set x1 [expr { $x0 + $d }]
1740
+ set x2 [expr { $x3 - $d }]
1741
+ set y1 [expr { $y0 + $d }]
1742
+ set y2 [expr { $y3 - $d }]
1743
+
1744
+ set xy [list $x0 $y0 $x1 $y0 $x2 $y0 $x3 $y0 $x3 $y1 $x3 $y2]
1745
+ lappend xy $x3 $y3 $x2 $y3 $x1 $y3 $x0 $y3 $x0 $y2 $x0 $y1
1746
+ return $xy
1747
+ }
1748
+
1749
+ proc RoundPoly {canv xy radii args} {
1750
+ set lenXY [llength $xy]
1751
+ set lenR [llength $radii]
1752
+ if {$lenXY != 2*$lenR} {
1753
+ error "wrong number of vertices and radii"
1754
+ }
1755
+
1756
+ set knots {}
1757
+ lassign [lrange $xy end-1 end] x0 y0
1758
+ lassign $xy x1 y1
1759
+ lappend xy {*}[lrange $xy 0 1]
1760
+
1761
+ for {set i 0} {$i < $lenXY} {incr i 2} {
1762
+ set radius [lindex $radii [expr {$i/2}]]
1763
+ set r [winfo pixels $canv $radius]
1764
+
1765
+ lassign [lrange $xy [expr {$i + 2}] [expr {$i + 3}]] x2 y2
1766
+ set z [_RoundPoly2 $x0 $y0 $x1 $y1 $x2 $y2 $r]
1767
+ lappend knots {*}$z
1768
+
1769
+ lassign [list $x1 $y1] x0 y0
1770
+ lassign [list $x2 $y2] x1 y1
1771
+ }
1772
+ set n [$canv create polygon $knots -smooth 1 {*}$args]
1773
+ return $n
1774
+ }
1775
+
1776
+ proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} {
1777
+ set d [expr {2 * $radius}]
1778
+ set maxr 0.75
1779
+
1780
+ set v1x [expr {$x0 - $x1}]
1781
+ set v1y [expr {$y0 - $y1}]
1782
+ set v2x [expr {$x2 - $x1}]
1783
+ set v2y [expr {$y2 - $y1}]
1784
+
1785
+ set vlen1 [expr {sqrt($v1x*$v1x + $v1y*$v1y)}]
1786
+ set vlen2 [expr {sqrt($v2x*$v2x + $v2y*$v2y)}]
1787
+ if {$d > $maxr * $vlen1} {
1788
+ set d [expr {$maxr * $vlen1}]
1789
+ }
1790
+ if {$d > $maxr * $vlen2} {
1791
+ set d [expr {$maxr * $vlen2}]
1792
+ }
1793
+
1794
+ lappend xy [expr {$x1 + $d * $v1x/$vlen1}] [expr {$y1 + $d * $v1y/$vlen1}]
1795
+ lappend xy $x1 $y1
1796
+ lappend xy [expr {$x1 + $d * $v2x/$vlen2}] [expr {$y1 + $d * $v2y/$vlen2}]
1797
+
1798
+ return $xy
1799
+ }
1800
+
1801
+ proc Sparkle {w Oxy tag} {
1802
+ set xy {299 283 298 302 295 314 271 331 239 310 242 292 256 274 281 273}
1803
+ foreach {x y} $xy {
1804
+ $w.c create line 271 304 $x $y -fill white -width 3 -tag $tag
1805
+ }
1806
+ MoveAbs $w $tag $Oxy
1807
+ }
1808
+
1809
+ proc Centroid {w item} {
1810
+ return [Anchor $w $item c]
1811
+ }
1812
+
1813
+ proc Anchor {w item where} {
1814
+ lassign [$w.c bbox $item] x1 y1 x2 y2
1815
+ if {[string match *n* $where]} {
1816
+ set y $y1
1817
+ } elseif {[string match *s* $where]} {
1818
+ set y $y2
1819
+ } else {
1820
+ set y [expr {($y1 + $y2) / 2.0}]
1821
+ }
1822
+ if {[string match *w* $where]} {
1823
+ set x $x1
1824
+ } elseif {[string match *e* $where]} {
1825
+ set x $x2
1826
+ } else {
1827
+ set x [expr {($x1 + $x2) / 2.0}]
1828
+ }
1829
+ return [list $x $y]
1830
+ }
1831
+
1832
+ DoDisplay $w
1833
+ Reset $w
1834
+ Go $w ;# Start everything going