︙ | | | ︙ | |
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
|
component tree
component hsb
component vsb
option -leftdir -default "" -configuremethod SetDirOption
option -rightdir -default "" -configuremethod SetDirOption
variable AfterId
variable IdleQueue
variable IdleQueueArr
variable leftMark ""
variable rightMark ""
constructor {args} {
install tree using ttk::treeview $win.tree -height 20 \
-columns {type status leftfull leftname leftsize leftdate rightfull rightname rightsize rightdate} \
-displaycolumns {leftname leftsize leftdate rightname rightsize rightdate}
if {[tk windowingsystem] ne "aqua"} {
install vsb using ttk::scrollbar $win.vsb -orient vertical \
-command "$tree yview"
install hsb using ttk::scrollbar $win.hsb -orient horizontal \
-command "$tree xview"
} else {
install vsb using scrollbar $win.vsb -orient vertical \
-command "$tree yview"
install hsb using scrollbar $win.hsb -orient horizontal \
-command "$tree xview"
}
$tree configure -yscroll "$vsb set" -xscroll "$hsb set"
set AfterId ""
set IdleQueue {}
$tree heading \#0 -text "Structure"
$tree heading leftname -text "Name"
$tree heading leftsize -text "Size"
$tree heading leftdate -text "Date"
$tree heading rightname -text "Name"
$tree heading rightsize -text "Size"
|
|
|
<
<
<
<
<
<
|
|
|
|
<
<
>
>
|
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
|
component tree
component hsb
component vsb
option -leftdir -default "" -configuremethod SetDirOption
option -rightdir -default "" -configuremethod SetDirOption
variable AfterId ""
variable IdleQueue {}
variable IdleQueueArr
variable leftMark ""
variable rightMark ""
constructor {args} {
install tree using ttk::treeview $win.tree -height 20 \
-columns {type status leftfull leftname leftsize leftdate rightfull rightname rightsize rightdate} \
-displaycolumns {leftname leftsize leftdate rightname rightsize rightdate}
install vsb using scrollbar $win.vsb -orient vertical \
-command "$tree yview"
install hsb using scrollbar $win.hsb -orient horizontal \
-command "$tree xview"
set AfterId ""
set IdleQueue {}
$tree configure -yscroll "$vsb set" -xscroll "$hsb set"
$tree heading \#0 -text "Structure"
$tree heading leftname -text "Name"
$tree heading leftsize -text "Size"
$tree heading leftdate -text "Date"
$tree heading rightname -text "Name"
$tree heading rightsize -text "Size"
|
︙ | | | ︙ | |
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
$tree tag configure new -foreground green
$tree tag configure old -foreground blue
$tree tag configure change -foreground red
bind $tree <<TreeviewOpen>> "[mymethod UpdateDirNode] \[%W focus\]"
bind $tree <Button-3> "[mymethod ContextMenu] %x %y %X %Y"
bind $tree <Double-ButtonPress-1> "[mymethod DoubleClick] %x %y"
grid $tree $vsb -sticky nsew
grid $hsb -sticky nsew
grid columnconfigure $win 0 -weight 1
grid rowconfigure $win 0 -weight 1
$self configurelist $args
|
>
|
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
$tree tag configure new -foreground green
$tree tag configure old -foreground blue
$tree tag configure change -foreground red
bind $tree <<TreeviewOpen>> "[mymethod UpdateDirNode] \[%W focus\]"
bind $tree <Button-3> "[mymethod ContextMenu] %x %y %X %Y"
bind $tree <Double-ButtonPress-1> "[mymethod DoubleClick] %x %y"
bind $tree <Key-Return> [mymethod KeyReturn]
grid $tree $vsb -sticky nsew
grid $hsb -sticky nsew
grid columnconfigure $win 0 -weight 1
grid rowconfigure $win 0 -weight 1
$self configurelist $args
|
︙ | | | ︙ | |
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
set rf [$tree set $node rightfull]
set type [$tree set $node type]
# On a file that exists on both sides, start a file diff
if {$type eq "file" && $lf ne "" && $rf ne ""} {
newDiff $lf $rf
# Stop the default bindings from running
break
}
}
# Bring up a context menu on a file.
method ContextMenu {x y X Y} {
#global dirdiff Pref
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
set rf [$tree set $node rightfull]
set type [$tree set $node type]
# On a file that exists on both sides, start a file diff
if {$type eq "file" && $lf ne "" && $rf ne ""} {
newDiff $lf $rf
# Stop the default bindings from running
return -code break
}
}
# React on Return key
method KeyReturn {} {
set node [$tree focus]
if {$node eq ""} return
set lf [$tree set $node leftfull]
set rf [$tree set $node rightfull]
set type [$tree set $node type]
# On a file that exists on both sides, start a file diff
if {$type eq "file" && $lf ne "" && $rf ne ""} {
newDiff $lf $rf
# Stop the default bindings from running
return -code break
}
}
# Bring up a context menu on a file.
method ContextMenu {x y X Y} {
#global dirdiff Pref
|
︙ | | | ︙ | |
626
627
628
629
630
631
632
633
634
635
636
637
638
639
|
set values [list $type unknown \
$df1 "" "" "" \
$df2 "" "" ""]
} else {
set values [list $type unknown \
$df1 [file tail $df1] $size1 $time1 \
$df2 [file tail $df2] $size2 $time2]
}
set id [$tree insert $node end -text $name \
-values $values]
if {$type eq "directory"} {
## Make it so that this node is openable
$tree insert $id 0 -text dummy ;# a dummy
$tree item $id -text $name/
|
>
>
>
|
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
|
set values [list $type unknown \
$df1 "" "" "" \
$df2 "" "" ""]
} else {
set values [list $type unknown \
$df1 [file tail $df1] $size1 $time1 \
$df2 [file tail $df2] $size2 $time2]
}
if {$type ne "directory"} {
set name ""
}
set id [$tree insert $node end -text $name \
-values $values]
if {$type eq "directory"} {
## Make it so that this node is openable
$tree insert $id 0 -text dummy ;# a dummy
$tree item $id -text $name/
|
︙ | | | ︙ | |
734
735
736
737
738
739
740
741
742
743
744
745
746
747
|
}
$self SetNodeStatus $node $status
}
}
snit::widget DirDiff {
hulltype toplevel
component tree
constructor {args} {
lappend ::diff(diffWindows) $win
wm title $win "Eskil Dir"
wm protocol $win WM_DELETE_WINDOW [list cleanupAndExit $win]
|
>
|
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
|
}
$self SetNodeStatus $node $status
}
}
snit::widget DirDiff {
hulltype toplevel
widgetclass Toplevel
component tree
constructor {args} {
lappend ::diff(diffWindows) $win
wm title $win "Eskil Dir"
wm protocol $win WM_DELETE_WINDOW [list cleanupAndExit $win]
|
︙ | | | ︙ | |
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
|
menu $win.m.mo.mc
$win.m.mo.mc add radiobutton -variable Pref(dir,comparelevel) -value 0 \
-label "Do not check contents"
$win.m.mo.mc add radiobutton -variable Pref(dir,comparelevel) -value 1 \
-label "Normal compare"
$win.m.mo.mc add radiobutton -variable Pref(dir,comparelevel) -value 2 \
-label "Binary compare"
$win.m.mo.mc add checkbutton -variable Pref(dir,ignorekey) \
-label "Ignore \$Keyword:\$"
$win.m add cascade -label "Tools" -underline 0 -menu $win.m.mt
menu $win.m.mt
$win.m.mt add command -label "New Diff Window" -underline 0 \
-command makeDiffWin
|
|
|
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
menu $win.m.mo.mc
$win.m.mo.mc add radiobutton -variable Pref(dir,comparelevel) -value 0 \
-label "Do not check contents"
$win.m.mo.mc add radiobutton -variable Pref(dir,comparelevel) -value 1 \
-label "Normal compare"
$win.m.mo.mc add radiobutton -variable Pref(dir,comparelevel) -value 2 \
-label "Exact compare"
$win.m.mo.mc add checkbutton -variable Pref(dir,ignorekey) \
-label "Ignore \$Keyword:\$"
$win.m add cascade -label "Tools" -underline 0 -menu $win.m.mt
menu $win.m.mt
$win.m.mt add command -label "New Diff Window" -underline 0 \
-command makeDiffWin
|
︙ | | | ︙ | |
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
|
pack $win.bu2 -padx 6
pack $win.e2 -in $win.fe2 -side left -fill x -expand 1
grid $win.fe1 $win.bu $win.fe2 -sticky we
grid $tree - - -sticky news
grid $win.bu -padx 6
grid rowconfigure $win 2 -weight 1
grid columnconfigure $win {0 2} -weight 1
}
method DoDirCompare {} {
$tree configure -leftdir $::dirdiff(leftDir) \
-rightdir $::dirdiff(rightDir)
}
# Go up one level in directory hierarchy.
# 0 = both
method UpDir {{n 0}} {
global dirdiff Pref
switch $n {
0 {
set dirdiff(leftDir) [file dirname $dirdiff(leftDir)]
set dirdiff(rightDir) [file dirname $dirdiff(rightDir)]
.dirdiff.e1 xview end
.dirdiff.e2 xview end
}
1 {
set dirdiff(leftDir) [file dirname $dirdiff(leftDir)]
.dirdiff.e1 xview end
}
2 {
set dirdiff(rightDir) [file dirname $dirdiff(rightDir)]
.dirdiff.e2 xview end
}
}
$self DoDirCompare
}
}
# Transfer preferences from dialog to real settings
|
|
|
|
|
|
|
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
|
pack $win.bu2 -padx 6
pack $win.e2 -in $win.fe2 -side left -fill x -expand 1
grid $win.fe1 $win.bu $win.fe2 -sticky we
grid $tree - - -sticky news
grid $win.bu -padx 6
grid rowconfigure $win 1 -weight 1
grid columnconfigure $win {0 2} -weight 1
}
method DoDirCompare {} {
$tree configure -leftdir $::dirdiff(leftDir) \
-rightdir $::dirdiff(rightDir)
}
# Go up one level in directory hierarchy.
# 0 = both
method UpDir {{n 0}} {
global dirdiff Pref
switch $n {
0 {
set dirdiff(leftDir) [file dirname $dirdiff(leftDir)]
set dirdiff(rightDir) [file dirname $dirdiff(rightDir)]
$win.e1 xview end
$win.e2 xview end
}
1 {
set dirdiff(leftDir) [file dirname $dirdiff(leftDir)]
$win.e1 xview end
}
2 {
set dirdiff(rightDir) [file dirname $dirdiff(rightDir)]
$win.e2 xview end
}
}
$self DoDirCompare
}
}
# Transfer preferences from dialog to real settings
|
︙ | | | ︙ | |
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
|
set check [labelframe $top.check -text "Check" -padx 3 -pady 3]
radiobutton $check.rb1 -variable TmpPref(dir,comparelevel) -value 0 \
-text "Do not check contents"
radiobutton $check.rb2 -variable TmpPref(dir,comparelevel) -value 1 \
-text "Normal compare"
radiobutton $check.rb3 -variable TmpPref(dir,comparelevel) -value 2 \
-text "Binary compare"
grid $check.rb1 -sticky w -padx 3 -pady 3
grid $check.rb2 -sticky w -padx 3 -pady 3
grid $check.rb3 -sticky w -padx 3 -pady 3
grid columnconfigure $check {0 1 2} -uniform a -weight 1
set opts [labelframe $top.opts -text "Options" -padx 3 -pady 3]
checkbutton $opts.cb1 -variable TmpPref(dir,ignorekey) \
|
|
|
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
|
set check [labelframe $top.check -text "Check" -padx 3 -pady 3]
radiobutton $check.rb1 -variable TmpPref(dir,comparelevel) -value 0 \
-text "Do not check contents"
radiobutton $check.rb2 -variable TmpPref(dir,comparelevel) -value 1 \
-text "Normal compare"
radiobutton $check.rb3 -variable TmpPref(dir,comparelevel) -value 2 \
-text "Exact compare"
grid $check.rb1 -sticky w -padx 3 -pady 3
grid $check.rb2 -sticky w -padx 3 -pady 3
grid $check.rb3 -sticky w -padx 3 -pady 3
grid columnconfigure $check {0 1 2} -uniform a -weight 1
set opts [labelframe $top.opts -text "Options" -padx 3 -pady 3]
checkbutton $opts.cb1 -variable TmpPref(dir,ignorekey) \
|
︙ | | | ︙ | |
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
|
grid $top.l2 $top.e2 -sticky we
grid columnconfigure $top 1 -weight 1
grid rowconfigure $top 2 -weight 1
}
proc makeDirDiffWin {{redraw 0}} {
DirDiff .dirdiff
}
|
>
|
|
>
>
|
>
>
>
|
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
|
grid $top.l2 $top.e2 -sticky we
grid columnconfigure $top 1 -weight 1
grid rowconfigure $top 2 -weight 1
}
proc makeDirDiffWin {{redraw 0}} {
if {![info exists ::dirdiff(leftDir)]} {
set ::dirdiff(leftDir) ""
}
if {![info exists ::dirdiff(rightDir)]} {
set ::dirdiff(rightDir) ""
}
destroy .dirdiff
DirDiff .dirdiff
}
|