-
Notifications
You must be signed in to change notification settings - Fork 16
/
vtcl.tcl
executable file
·791 lines (657 loc) · 21.1 KB
/
vtcl.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
#!/bin/sh
# the next line restarts using wish\
exec wish "$0" "$@"
##############################################################################
#
# Visual TCL - A cross-platform application development environment
#
# Copyright (C) 1996-1998 Stewart Allen
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##############################################################################
#
## for Tcl/Tk 8.4
if {![llength [info commands tkTextInsert]]} {
::tk::unsupported::ExposePrivateCommand tkTextInsert
}
namespace eval ::vTcl {}
set vTcl(sourcing) 0
proc vTcl:log {msg} {
global vTcl tcl_platform
if {![info exists vTcl(LOG_FD_W)]} {
## If we can't open the log files in HOME, try in the vTcl directory.
if {[catch {open $vTcl(LOG_FILE) "w"} vTcl(LOG_FD_W)] \
|| [catch {open $vTcl(LOG_FILE) "r"} vTcl(LOG_FD_R)]} {
vTcl:error "Cannot open vTcl log file."
vTcl:exit
}
catch {fconfigure $vTcl(LOG_FD_R) -buffering line}
}
puts $vTcl(LOG_FD_W) "$msg"
flush $vTcl(LOG_FD_W)
# tkcon_puts $msg
}
proc vTcl:splash_status {string {nodots {}}} {
global statusMsg
if {$nodots == {}} { append string ... }
set statusMsg $string
update
}
proc vTcl:splash {} {
global vTcl
toplevel .x -bd 3 -relief raised
wm withdraw .x
set sw [winfo screenwidth .]
set sh [winfo screenheight .]
image create photo "title" \
-file [file join $vTcl(VTCL_HOME) images title.gif]
wm overrideredirect .x 1
label .x.l -image title -bd 1 -relief sunken -background black
pack .x.l -side top -expand 1 -fill both
entry .x.status -relief flat -background black -foreground white \
-textvar statusMsg -font "Helvetica 12"
pack .x.status -side bottom -expand 1 -fill both
set x [expr {($sw - 200)/2}]
set y [expr {($sh - 250)/2}]
wm geometry .x +$x+$y
wm deiconify .x
update idletasks
after 3000 {catch {destroy .x}}
}
proc vTcl:load_lib {lib} {
global vTcl
vTcl:splash_status "Loading library [file tail $lib]"
set file [file join $vTcl(LIB_DIR) $lib]
if {[file exists $file] == 0} {
vTcl:log "Missing Libary: $lib"
return 0
} else {
uplevel #0 [list source $file]
return 1
}
}
proc vTcl:load_widgets {} {
global vTcl
vTcl:splash_status "Loading widgets"
#
# Query for the list of libs to load.
# Either from prefs or defaults to all available libraries.
#
set toload [vTcl::project::getLibrariesToLoad]
#
# Make sure lib_core loads before all other widget libraries.
#
::vTcl::lremove toload *lib_core.tcl
set toload [linsert $toload 0 lib_core.tcl]
foreach i $toload {
set lib [lindex [split [file root $i] _] end]
if {[vTcl:load_lib $i]} {
set libname [lindex [split [lindex [file split $i] end] .] 0]
## If we don't have the library, don't load the widgets for it.
if {![vTcl:$libname:init]} { continue }
lappend vTcl(w,libs) $libname
vTcl:LoadWidgets [file join $vTcl(VTCL_HOME) lib Widgets $lib]
}
}
}
proc vTcl:load_libs {libs} {
global vTcl
foreach i $libs {
vTcl:load_lib $i
}
}
proc ::vTcl::load_bwidgets {} {
vTcl:splash_status "Loading BWidgets"
uplevel #0 {
set dir [file join $vTcl(LIB_DIR) bwidget]
source [file join $dir pkgIndex.tcl]
}
}
#
# Get a locally provided 'tablelist' module
#
proc ::vTcl::load_tablelist {} {
vTcl:splash_status "Loading Tablelist"
uplevel #0 {
set dir [file join $vTcl(LIB_DIR) tablelist]
source [file join $dir pkgIndex.tcl]
}
}
proc vTcl:setup {} {
global tk_strictMotif env vTcl tcl_platform __vtlog
# set vTcl(version) 1.60 # Clamped off,2016-02-19/hph
#+
# Newstyle versioning:
#
# M.R.m(.p)
#
# i.e.: M, R, m & p can be any number of digits
# but at least 3 positions must be present.
# M cannot be '0',
# An optional 4th field 'p' denotes a patchlevel
# not for production; such a version lives on GitHub
# i.e.
# - for major vTcl version 9 is written: 9.0.0
# - for an upcoming version 8.7 it is 8.7.0
# (a.s.o.)
# - a version 8.6.3.65 is a patchlevel
#
# Attn.: This must match with the regex in lib/file.tcl!
# Or vTcl will mourn on load with:
# "This ist not a vTcl project"
#-
set vTcl(version) 8.6.0.5
if {$env(VTCL_HOME) == ""} {
set vTcl(VTCL_HOME) [pwd]
} else {
set vTcl(VTCL_HOME) $env(VTCL_HOME)
}
## See if we can write to a file in HOME. If not, use VTCL_HOME
if {$env(HOME) == "" || [catch {open [file join $env(HOME) .tmp] w} fp]} {
set vTcl(CONF_FILE) [file join $vTcl(VTCL_HOME) .vtclrc]
set vTcl(LIB_FILE) [file join $vTcl(VTCL_HOME) .vtcllibs]
set vTcl(LOG_FILE) [file join $vTcl(VTCL_HOME) .vtclog]
} else {
set vTcl(CONF_FILE) [file join $env(HOME) .vtclrc]
set vTcl(LIB_FILE) [file join $env(HOME) .vtcllibs]
set vTcl(LOG_FILE) [file join $env(HOME) .vtclog]
}
catch {
close $fp
file delete -force [file join $env(HOME) .tmp]
}
set vTcl(LIB_DIR) [file join $vTcl(VTCL_HOME) lib]
set vTcl(LIB_WIDG) [glob -nocomplain [file join $vTcl(LIB_DIR) lib_*.tcl]]
set LIBS "globals.tcl about.tcl propmgr.tcl balloon.tcl
attrbar.tcl bgerror.tcl bind.tcl command.tcl color.tcl
tkcon.tcl compound.tcl compounds.tcl do.tcl
dragsize.tcl dump.tcl edit.tcl file.tcl handle.tcl
input.tcl loadwidg.tcl font.tcl images.tcl menu.tcl
misc.tcl name.tcl prefs.tcl proc.tcl tclet.tcl
tops.tcl tree.tcl var.tcl vtclib.tcl
widget.tcl help.tcl menus.tcl new.tcl ttd/ttd.tcl
toolbar.tcl taborder.tcl copyattr.tcl "
# UKo 2000-12-10: initiate some variables
set vTcl(libs) {}
set vTcl(classes) {}
set vTcl(options) {}
set tk_strictMotif 1
wm withdraw .
vTcl:splash
::vTcl::load_bwidgets
#for scrolled Bands widget
source [ file join $vTcl(LIB_DIR) kpwidgets sbands.tcl ]
namespace import kpwidgets::*
vTcl:load_libs $LIBS
## load preferences
if {[file exists $vTcl(CONF_FILE)]} {
catch {uplevel #0 [list source $vTcl(CONF_FILE)]}
catch {set vTcl(w,def_mgr) $vTcl(pr,manager)}
}
vTcl:load_widgets
# ::vTcl::load_bwidgets
::vTcl::load_tablelist
# initializes the stock images database
vTcl:image:init_stock
# initializes the stock fonts database
vTcl:font:init_stock
# initializes the project
vTcl::project::initModule main
# make sure TkCon doesn't see command line arguments here
set argc $::argc
set argv $::argv
set ::argc 0
set ::argv {}
vTcl:setup_gui
set ::argc $argc
set ::argv $argv
update idletasks
set vTcl(start,procs) [lsort [info procs]]
set vTcl(start,globals) [lsort [info globals]]
vTcl:setup_meta
}
proc vTcl:setup_meta {} {
global vTcl tcl_platform
proc exit {args} {}
proc init {argc argv} {}
proc main {argc argv} {}
vTcl:proclist:show $vTcl(pr,show_func)
vTcl:toplist:show $vTcl(pr,show_top)
}
proc vTcl:setup_gui {} {
global vTcl tcl_platform tk_version
rename exit vTcl:exit
vTcl:splash_status "Setting Up Workspace"
##
## We use our own version of Bwidgets with some bug fixes.
## Will submit them the bugs when time permits. (C.Cavin/somewhere ~2000)
##
package require -exact BWidget 1.3.1
package require -exact Tablelist 5.15
if {$tcl_platform(platform) == "macintosh"} {
set vTcl(pr,balloon) 0
set vTcl(balloon,on) 0
}
if {$vTcl(pr,font_dlg) == ""} {
switch $tcl_platform(platform) {
windows {
set vTcl(pr,font_dlg) {{MS Sans Serif} 8}
}
default {
set vTcl(pr,font_dlg) {Helvetica 12}
}
}
}
if {$vTcl(pr,font_fixed) == ""} {
set vTcl(pr,font_fixed) {Courier 10}
}
if {$tcl_platform(platform) == "unix"} {
option add *vTcl*Scrollbar.width 10
option add *vTcl*Scrollbar.highlightThickness 0
option add *vTcl*Scrollbar.elementBorderWidth 2
option add *vTcl*Scrollbar.borderWidth 2
option add *Scrollbar.width 10
option add *vTcl*font {Helvetica 12}
option add *ScrolledWindow.size 14
}
if {$tcl_platform(platform) == "windows"} {
option add *Button.padY 0
}
option add *vTcl*font $vTcl(pr,font_dlg)
option add *vTcl*Text*font $vTcl(pr,font_fixed)
option add *NoteBook.font $vTcl(pr,font_dlg)
option add *__tk__messagebox*font $vTcl(pr,font_dlg)
if {[info exists vTcl(pr,bgcolor)] && ![lempty $vTcl(pr,bgcolor)]} {
## On some systems, the . window has an empty {} background option,
## and this makes the tk_setPalette code fail
. configure -background gray
tk_setPalette $vTcl(pr,bgcolor)
option add *vTcl*background $vTcl(pr,bgcolor)
}
option add *vTcl*Entry.background $vTcl(pr,entrybgcolor)
option add *vTcl*Listbox.background $vTcl(pr,listboxbgcolor)
vTcl:setup_bind_tree .
vTcl:load_images
Window show .vTcl
foreach l $vTcl(w,libs) {
vTcl:widget:lib:$l
}
vTcl:toolbar_reflow
foreach i $vTcl(gui,showlist) {
Window show $i
}
vTcl:clear_wtree
vTcl:define_bindings
vTcl:cmp_sys_menu
raise .vTcl
}
proc vTclWindow.vTcl {args} {
global vTcl tcl_platform tcl_version
if {[winfo exists .vTcl]} {return}
toplevel $vTcl(gui,main)
wm title $vTcl(gui,main) "Visual Tcl"
wm resizable $vTcl(gui,main) 0 0
wm group $vTcl(gui,main) $vTcl(gui,main)
wm command $vTcl(gui,main) "$vTcl(VTCL_HOME)/vtcl"
wm iconname $vTcl(gui,main) "Visual Tcl"
if {$tcl_platform(platform) == "macintosh"} {
wm geometry $vTcl(gui,main) +0+20
} else {
wm geometry $vTcl(gui,main) +0+0
}
catch {
regsub -all {[0-9]+x[0-9]+} $vTcl(geometry,.vTcl) "" \
vTcl(geometry,.vTcl)
wm geometry .vTcl $vTcl(geometry,.vTcl)
}
wm protocol .vTcl WM_DELETE_WINDOW {vTcl:quit}
set tmp $vTcl(gui,main).menu
frame $tmp -relief flat
frame .vTcl.stat -relief flat
pack $tmp -side top -expand 1 -fill x
.vTcl conf -menu .vTcl.m
foreach menu {file edit mode compound options window widget} {
if {$tcl_version >= 8} {
vTcl:menu:insert .vTcl.m.$menu $menu .vTcl.m
} else {
menubutton $tmp.$menu -text [vTcl:upper_first $menu] \
-menu $tmp.$menu.m -anchor w
vTcl:menu:insert $tmp.$menu.m $menu
pack $tmp.$menu -side left
}
}
vTcl:menu:insert .vTcl.m.help help .vTcl.m
# RIGHT CLICK MENU
set vTcl(gui,rc_menu) .vTcl.menu_rc
menu $vTcl(gui,rc_menu) -tearoff 0
set vTcl(gui,rc_widget_menu) .vTcl.menu_rc.widgets
menu $vTcl(gui,rc_widget_menu) -tearoff 0
$vTcl(gui,rc_menu) add cascade -label "Widget" \
-menu $vTcl(gui,rc_widget_menu)
$vTcl(gui,rc_menu) add command -label "Set Insert" -command {
vTcl:set_insert
}
$vTcl(gui,rc_menu) add command -label "Set Alias..." -command {
vTcl:set_alias $vTcl(w,widget)
}
$vTcl(gui,rc_menu) add separator
$vTcl(gui,rc_menu) add command -label "Select Toplevel" -command {
vTcl:select_toplevel
}
$vTcl(gui,rc_menu) add command -label "Select Parent" -command {
vTcl:select_parent
}
$vTcl(gui,rc_menu) add separator
$vTcl(gui,rc_menu) add command -label "Tab order" -command {
vTcl:taborder
}
$vTcl(gui,rc_menu) add command -label "Copy/Paste attributes" -command {
vTcl:copyattr
}
$vTcl(gui,rc_menu) add command -label "Stop Paste attributes" -command {
vTcl:copyattr:quit
}
$vTcl(gui,rc_menu) add separator
$vTcl(gui,rc_menu) add comm -label "Cut" -comm {
vTcl:cut
} -accel "Ctrl+X"
$vTcl(gui,rc_menu) add comm -label "Copy" -comm {
vTcl:copy
} -accel "Ctrl+C"
$vTcl(gui,rc_menu) add comm -label "Paste" -comm {
vTcl:paste -mouse
} -accel "Ctrl+V"
$vTcl(gui,rc_menu) add comm -label "Delete" -comm {
vTcl:delete "" $vTcl(w,widget)
} -accel "Del"
$vTcl(gui,rc_menu) add separator
$vTcl(gui,rc_menu) add comm -label "Hide" -comm {
vTcl:hide
} -accel "Ctrl+H"
$vTcl(gui,rc_menu) add command -label "Copy Widgetname" -command {
vTcl:copy_widgetname
}
$vTcl(gui,rc_menu) add separator
$vTcl(gui,rc_menu) add command -label "Bindings..." -command {
vTcl:show_bindings
}
# MINI-ATTRIBUTE AREA
vTcl:attrbar
vTcl:set_manager $vTcl(w,def_mgr)
# STATUS AREA
label .vTcl.stat.sl \
-relief groove -bd 2 -text "Status" -anchor w -width 35 \
-textvariable vTcl(status)
label .vTcl.stat.mo \
-width 6 -relief groove -bd 2 -textvariable vTcl(mode)
bind .vTcl.stat.mo <Button-1> {
%W configure -relief sunken
}
bind .vTcl.stat.mo <ButtonRelease-1> {
if {[%W cget -relief] == "sunken"} {
vTcl:switch_mode
}
%W configure -relief groove
}
vTcl:set_balloon .vTcl.stat.mo "application mode"
frame .vTcl.stat.f -relief sunken -bd 1 -width 150 -height 15
frame .vTcl.stat.f.bar -relief raised -bd 1 -bg #ff4444
pack .vTcl.stat.sl -side left -expand 1 -fill both
pack .vTcl.stat.mo -side left -padx 2
pack .vTcl.stat.f -side left -padx 2 -fill y
pack .vTcl.stat -side top -fill both
vTcl:setup_vTcl:bind .vTcl
## Create a hidden entry widget that holds the name of the current widget.
## We use this for copying the widget name and using it globally.
entry .vTcl.widgetname -textvariable vTcl(w,widget)
## Make the menu flat
.vTcl.m configure -relief flat
}
proc vTcl:vtcl:remap {w} {
global vTcl
if {![vTcl:streq $w ".vTcl"]} { return }
if {![info exists vTcl(tops,unmapped)]} { return }
foreach i $vTcl(tops,unmapped) {
if {![winfo exists $i]} { continue }
vTcl:show_top $i
}
wm deiconify .vTcl.toolbar
set vTcl(tops,unmapped) ""
}
proc vTcl:vtcl:unmap {w} {
global vTcl
if {![vTcl:streq $w ".vTcl"]} { return }
if {[vTcl:streq [wm state $w] "normal"]} { return }
set vTcl(tops,unmapped) ""
foreach i $vTcl(tops) {
if {![winfo exists $i]} { continue }
if {[wm state $i] != "withdrawn"} {
vTcl:hide_top $i
lappend vTcl(tops,unmapped) $i
}
}
}
proc vTcl:define_bindings {} {
global vTcl
vTcl:status "creating bindings"
foreach i {a b} {
bind vTcl($i) <Control-z> { vTcl:pop_action }
bind vTcl($i) <Control-r> { vTcl:redo_action }
bind vTcl($i) <Control-x> { vTcl:cut %W }
bind vTcl($i) <Control-c> { vTcl:copy %W }
bind vTcl($i) <Control-v> { vTcl:paste {} %W }
bind vTcl($i) <Control-q> { vTcl:quit }
bind vTcl($i) <Control-n> { vTcl:new }
bind vTcl($i) <Control-o> { vTcl:open }
bind vTcl($i) <Control-s> { vTcl:save }
bind vTcl($i) <Control-w> { vTcl:close }
bind vTcl($i) <Control-h> { vTcl:hide }
bind vTcl($i) <Key-Delete> { vTcl:delete %W $vTcl(w,widget) }
bind vTcl($i) <Alt-a> { vTcl:set_alias $vTcl(w,widget) }
bind vTcl($i) <Alt-f> { vTcl:proclist:show flip }
bind vTcl($i) <Alt-o> { vTcl:toplist:show flip }
bind vTcl($i) <Alt-t> { vTcl:setup_unbind_tree . }
bind vTcl($i) <Alt-e> { vTcl:setup_bind_tree . }
bind vTcl($i) <Alt-b> { vTcl:show_bindings }
bind vTcl($i) <Alt-w> { vTcl:show_wtree }
bind vTcl($i) <Alt-c> { vTcl:name_compound $vTcl(w,widget) }
}
bind vTcl(c) <Configure> {
if {$vTcl(w,widget) == "%W"} {
vTcl:update_widget_info %W
}
after idle "vTcl:place_handles \"$vTcl(w,widget)\""
}
bind Text <Control-Key-c> {tk_textCopy %W}
bind Text <Control-Key-x> {tk_textCut %W}
bind Text <Control-Key-v> {tk_textPaste %W}
bind Text <Key-Tab> {
tkTextInsert %W $vTcl(tab)
focus %W
break
}
#
# handles auto-indent and syntax coloring
#
bind Text <Key-Return> {
# exclude user inserted text widgets from vTcl bindings
if {(! [string match .vTcl* %W]) ||
[info exists %W.nosyntax] } {
tkTextInsert %W "\n"
focus %W
break
}
vTcl:syntax_color %W
set pos [%W index "insert linestart"]
# change by Nelson 3.9.2003: better auto indent
set nos [%W search -regexp "\[^#\ \]|$" $pos]
# set nos [%W search -regexp -nocase "\[a-z0-9\]" $pos]
if {$nos != ""} {
set ct [%W get $pos $nos]
tkTextInsert %W "\n${ct}"
focus %W
break
} else {
tkTextInsert %W "\n"
focus %W
break
}
}
bind Text <KeyRelease> {
# exclude user inserted text widgets from vTcl bindings
if {(! [string match .vTcl* %W]) ||
[info exists %W.nosyntax] } {
break
}
if {"%K"=="Up" ||
"%K"=="Down" ||
"%K"=="Right" ||
"%K"=="Left"||
"%K"=="space"||
"%K"=="End"||
"%K"=="Home"||
[regexp {[]\")\}]} %A]} {
scan [%W index insert] %%d pos
vTcl:syntax_color %W $pos $pos
focus %W
break
}
}
bind vTcl(b) <Button-3> {vTcl:right_click %W %X %Y %x %y}
bind vTcl(b) <Double-Button-1> {vTcl:widget_dblclick %W %X %Y %x %y}
bind vTcl(b) <Button-1> {vTcl:bind_button_1 %W %X %Y %x %y}
bind vTcl(b) <Button-2> {vTcl:bind_button_2 %W %X %Y %x %y}
bind vTcl(b) <Control-Button-1> {vTcl:bind_button_2 %W %X %Y %x %y}
bind vTcl(b) <B1-Motion> {vTcl:bind_motion %W %X %Y}
bind vTcl(b) <B2-Motion> {vTcl:bind_motion %W %X %Y}
bind vTcl(b) <Control-B1-Motion> {vTcl:bind_motion %W %X %Y}
bind vTcl(b) <ButtonRelease-1> {vTcl:bind_release %W %X %Y %x %y}
bind vTcl(b) <ButtonRelease-2> {vTcl:bind_release %W %X %Y %x %y}
bind vTcl(b) <Up> {
vTcl:widget_delta $vTcl(w,widget) 0 -$vTcl(key,y) 0 0
}
bind vTcl(b) <Down> {
vTcl:widget_delta $vTcl(w,widget) 0 $vTcl(key,y) 0 0
}
bind vTcl(b) <Left> {
vTcl:widget_delta $vTcl(w,widget) -$vTcl(key,x) 0 0 0
}
bind vTcl(b) <Right> {
vTcl:widget_delta $vTcl(w,widget) $vTcl(key,x) 0 0 0
}
bind vTcl(b) <Shift-Up> {
vTcl:widget_delta $vTcl(w,widget) 0 0 0 -$vTcl(key,h)
}
bind vTcl(b) <Shift-Down> {
vTcl:widget_delta $vTcl(w,widget) 0 0 0 $vTcl(key,h)
}
bind vTcl(b) <Shift-Left> {
vTcl:widget_delta $vTcl(w,widget) 0 0 -$vTcl(key,w) 0
}
bind vTcl(b) <Shift-Right> {
vTcl:widget_delta $vTcl(w,widget) 0 0 $vTcl(key,w) 0
}
bind vTcl(b) <Alt-h> {
if {$vTcl(h,exist)} {
vTcl:destroy_handles
} else {
vTcl:create_handles $vTcl(w,widget)
}
}
#
# If we iconify or deiconify vTcl, take the top windows with us.
#
bind .vTcl <Unmap> { vTcl:vtcl:unmap %W }
bind .vTcl <Map> { vTcl:vtcl:remap %W }
vTcl:status "Status"
}
proc vTcl:main {argc argv} {
global env vTcl tcl_version tcl_platform
catch {package require Unsafe} ; #for running in Netscape
catch {package require dde} ; #for windows
catch {package require Tk} ; #for dynamic loading tk
if {$tcl_version < 8.3} {
wm deiconify .
wm title . "Time to upgrade TCL/TK"
frame .f -relief groove -bd 2
pack .f -expand 1 -fill both -padx 2 -pady 2
label .f.l1 -text "This version of Tk is too old..."
label .f.l2 -text "Tcl8.3 and Tk8.3 or newer required"
button .f.b -text "Close" -command {exit}
pack .f.l1 .f.l2 -side top -padx 5
pack .f.b -side top -pady 5
return
}
if {$tcl_platform(platform) == "macintosh"} {
set vTcl(VTCL_HOME) $env(HOME)
}
# if {$tcl_platform(platform) == "unix"} {
# set vTcl(VTCL_HOME) $env(HOME)
# }
if {![info exists env(VTCL_HOME)]} {
set home [file dirname [info script]]
switch [file pathtype $home] {
absolute {set env(VTCL_HOME) $home}
relative {set env(VTCL_HOME) [file join [pwd] $home]}
volumerelative {
set curdir [pwd]
cd $home
set env(VTCL_HOME) [file join [pwd] [file dirname \
[file join [lrange [file split $home] 1 end]]]]
cd $curdir
}
}
}
if {![file isdir $env(VTCL_HOME)]} { set vTcl(VTCL_HOME) [pwd] }
vTcl:setup
## init the bindings editor
::widgets_bindings::init
vTcl:splash_status " vTcl Loaded" -nodots
after 1000 {if {[winfo exists .x]} {destroy .x}}
## load file passed in command line, get rid of splash window right here
if {$argc > 0 && [lindex $argv end] != ""} {
set file [lindex $argv end]
if {[file exists $file]} {
destroy .x
vTcl:open $file
} elseif {[file exists [file join [pwd] $file]]} {
destroy .x
vTcl:open [file join [pwd] $file]
}
}
if [info exists vTcl(pr,autoloadcomp)] {
if {$vTcl(pr,autoloadcomp)} {
set loaded [vTcl:load_compounds $vTcl(pr,autoloadcompfile)]
if {$loaded == ""} {
## if user cancels, we unselect the "autoload compounds" option
## so (s)he is not prompted again
set vTcl(pr,autoloadcomp) 0
} else {
## user changed the compounds file, save the setting
set vTcl(pr,autoloadcompfile) $loaded
}
}
}
if {[info exists vTcl(pr,dontshowtips)] && !$vTcl(pr,dontshowtips)} {
Window show .vTcl.tip
}
#
# Show vTcl news.
#
if {!$vTcl(pr,dontshownews)} {
set vTcl(tmp,newsAfter) [after 5000 ::vTcl::news::get_news]
}
}
vTcl:main $argc $argv