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
|
#!/bin/sh
#
# diff.tcl
#
# Purpose
# Graphical frontend to diff
#
# Usage
# diff.tcl [options] [file1] [file2]
#
# [options] All options but the ones listed below
# are passed to diff.
# [file1],[file2] Files to be compared
# If no files are given, the program is
# started anyway and you can select files
# from within.
# If only one file is given, the program
# looks for an RCS directory next to the
# file, and if found, runs in RCS mode.
#
# Options for diff.tcl:
#
# -nodiff : Normally, if there are enough information on the
# command line to run diff, diff.tcl will do so unless
# this option is specified.
#
# -noparse : Diff.tcl can perform analysis of changed blocks to
# -line : improve display. See online help for details.
# -block : The default is -block, but this can be slow if there
# are large change blocks.
#
# -char : The analysis of changes can be done on either
# -word : character or word basis. -char is the default.
#
# -2nd : Turn on or off second stage parsing.
# -no2nd : It is on by default.
#
# -conflict : Treat file as a merge conflict file and enter merge
# mode.
# -o <file> : Specify merge result output file.
#
# -print <file> : Generate postscript and exit.
#
# Author Peter Spjuth 980612
#
# Revised By Date Remark
#
# 1.0 DC-PS 980612 New Version.
# 1.1 DC-PS 980807 Parsing of change blocks added
|
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/bin/sh
#
# diff.tcl
#
# Purpose
# Graphical frontend to diff
#
# Usage
# Do 'diff.tcl' for interactive mode
# Do 'diff.tcl -h' for command line usage
#
# Author Peter Spjuth 980612
#
# Revised By Date Remark
#
# 1.0 DC-PS 980612 New Version.
# 1.1 DC-PS 980807 Parsing of change blocks added
|
︙ | | | ︙ | |
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# 1.7 DA-PS 000427 Restricted parsing of large blocks.
# Fixed bug with spaces in file names.
# Regular screen updates during processing.
# Added CVS support.
# 1.8 DA-PS 001115 Highlight current diff.
# New -conflict flag to handle merge conflicts.
#
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"
set debug 1
set diffver "Version 1.8.3 2001-04-26"
set tmpcnt 0
set tmpfiles {}
set thisscript [file join [pwd] [info script]]
set thisdir [file dirname $thisscript]
if {$tcl_platform(platform) == "windows"} {
cd $thisdir
|
>
>
|
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# 1.7 DA-PS 000427 Restricted parsing of large blocks.
# Fixed bug with spaces in file names.
# Regular screen updates during processing.
# Added CVS support.
# 1.8 DA-PS 001115 Highlight current diff.
# New -conflict flag to handle merge conflicts.
#
#-----------------------------------------------
# $Revision$
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"
set debug 1
set diffver "Version 1.8.4 2001-05-04"
set tmpcnt 0
set tmpfiles {}
set thisscript [file join [pwd] [info script]]
set thisdir [file dirname $thisscript]
if {$tcl_platform(platform) == "windows"} {
cd $thisdir
|
︙ | | | ︙ | |
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
if {$::diffexe != "diff"} {
file delete $::diffexe
}
cleartmp
exit
}
proc myform {lineNo text} {
return [format "%3d: %s\n" $lineNo $text]
}
proc myforml {lineNo} {
return [format "%3d: \n" $lineNo]
}
proc maxabs {a b} {
return [expr {abs($a) > abs($b) ? $a : $b}]
}
proc tmpfile {} {
|
<
<
<
|
>
|
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
if {$::diffexe != "diff"} {
file delete $::diffexe
}
cleartmp
exit
}
# Format a line number
proc myforml {lineNo} {
if {![string is integer -strict $lineNo]} {return "$lineNo\n"}
return [format "%3d: \n" $lineNo]
}
proc maxabs {a b} {
return [expr {abs($a) > abs($b) ? $a : $b}]
}
proc tmpfile {} {
|
︙ | | | ︙ | |
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
} else {
insert 1 $doingLine1 $line1 change
insert 2 $doingLine2 $line2 change
}
incr doingLine1
incr doingLine2
}
# Process one of the change/add/delete blocks reported by diff.
# ch1 is a file channel for the left file
# ch2 is a file channel for the right file
# n1/n2 is the number of lines involved
# line1/line2 says on what lines this block starts
proc dotext {ch1 ch2 n1 n2 line1 line2} {
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
} else {
insert 1 $doingLine1 $line1 change
insert 2 $doingLine2 $line2 change
}
incr doingLine1
incr doingLine2
}
# Returns number of lines used to display the blocks
proc insertMatchingBlocks {block1 block2} {
global doingLine1 doingLine2
set apa [compareblocks $block1 $block2]
set t1 0
set t2 0
foreach c $apa {
if {$c == "c"} {
set textline1 [lindex $block1 $t1]
set textline2 [lindex $block2 $t2]
insertMatchingLines $textline1 $textline2
incr t1
incr t2
}
if {$c == "d"} {
set bepa [lindex $block1 $t1]
.ft1.tl insert end [myforml $doingLine1] \
"hl$::HighLightCount change"
.ft1.tt insert end "$bepa\n" new1
emptyline 2
incr doingLine1
incr t1
}
if {$c == "a"} {
set bepa [lindex $block2 $t2]
.ft2.tl insert end [myforml $doingLine2] \
"hl$::HighLightCount change"
.ft2.tt insert end "$bepa\n" new2
emptyline 1
incr doingLine2
incr t2
}
}
return [llength $apa]
}
# Process one of the change/add/delete blocks reported by diff.
# ch1 is a file channel for the left file
# ch2 is a file channel for the right file
# n1/n2 is the number of lines involved
# line1/line2 says on what lines this block starts
proc dotext {ch1 ch2 n1 n2 line1 line2} {
|
︙ | | | ︙ | |
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
|
lappend block1 $apa
}
set block2 {}
for {set t 0} {$t < $n2} {incr t} {
gets $ch2 apa
lappend block2 $apa
}
set apa [compareblocks $block1 $block2]
set t1 0
set t2 0
foreach c $apa {
if {$c == "c"} {
set textline1 [lindex $block1 $t1]
set textline2 [lindex $block2 $t2]
insertMatchingLines $textline1 $textline2
incr t1
incr t2
}
if {$c == "d"} {
set bepa [lindex $block1 $t1]
.ft1.tl insert end [myforml $doingLine1] \
"hl$::HighLightCount change"
.ft1.tt insert end "$bepa\n" new1
emptyline 2
incr doingLine1
incr t1
}
if {$c == "a"} {
set bepa [lindex $block2 $t2]
.ft2.tl insert end [myforml $doingLine2] \
"hl$::HighLightCount change"
.ft2.tt insert end "$bepa\n" new2
emptyline 1
incr doingLine2
incr t2
}
}
lappend changesList $mapMax [llength $apa] change \
$line1 $n1 $line2 $n2
incr mapMax [llength $apa]
} else {
for {set t 0} {$t < $n1} {incr t} {
gets $ch1 apa
insert 1 $doingLine1 $apa $tag1
incr doingLine1
}
for {set t 0} {$t < $n2} {incr t} {
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
lappend block1 $apa
}
set block2 {}
for {set t 0} {$t < $n2} {incr t} {
gets $ch2 apa
lappend block2 $apa
}
set apa [insertMatchingBlocks $block1 $block2]
lappend changesList $mapMax $apa change \
$line1 $n1 $line2 $n2
incr mapMax $apa
} else {
for {set t 0} {$t < $n1} {incr t} {
gets $ch1 apa
insert 1 $doingLine1 $apa $tag1
incr doingLine1
}
for {set t 0} {$t < $n2} {incr t} {
|
︙ | | | ︙ | |
886
887
888
889
890
891
892
893
894
895
896
897
898
899
|
proc cleanupConflict {} {
global diff Pref
cleartmp
set diff(rightFile) $diff(conflictFile)
set diff(leftFile) $diff(conflictFile)
}
# Prepare for RCS/CVS diff. Checkout copies of the versions needed.
proc prepareRCS {} {
global diff Pref
set revs {}
set opts {}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
|
proc cleanupConflict {} {
global diff Pref
cleartmp
set diff(rightFile) $diff(conflictFile)
set diff(leftFile) $diff(conflictFile)
}
proc displayOnePatch {leftLines rightLines leftLine rightLine} {
emptyline 1
emptyline 2
set leftlen [llength $leftLines]
set rightlen [llength $rightLines]
set leftc 0
set rightc 0
set lblock {}
set lblockl 0
set rblock {}
set rblockl 0
while {$leftc < $leftlen || $rightc < $rightlen} {
foreach {lline lmode lstr} [lindex $leftLines $leftc] break
foreach {rline rmode rstr} [lindex $rightLines $rightc] break
# Fix the case where one side's block is empty.
# That means that each line not marked should show up on both sides.
if {$leftc >= $leftlen} {
set lline $leftLine
incr leftLine
set lmode ""
set lstr $rstr
}
if {$rightc >= $rightlen} {
set rline $rightLine
incr rightLine
set rmode ""
set rstr $lstr
}
# Treat the combination "-" and "+" as a "!"
if {$lmode == "-" && $rmode == "+"} {
set lmode "!"
set rmode "!"
}
if {$lmode == "-" && [llength $lblock] > 0} {
set lmode "!"
}
if {$rmode == "+" && [llength $rblock] > 0} {
set rmode "!"
}
# If we are in a change block, gather up all lines
if {$lmode == "!" || $rmode == "!"} {
if {$lmode == "!"} {
if {[llength $lblock] == 0} {
set lblockl $lline
}
lappend lblock $lstr
incr leftc
}
if {$rmode == "!"} {
if {[llength $rblock] == 0} {
set rblockl $rline
}
lappend rblock $rstr
incr rightc
}
continue
}
# No change block anymore. If one just ended, display it.
if {[llength $lblock] > 0 || [llength $rblock] > 0} {
set ::doingLine1 $lblockl
set ::doingLine2 $rblockl
insertMatchingBlocks $lblock $rblock
set lblock {}
set rblock {}
}
if {$lmode == "" && $rmode == ""} {
insert 1 $lline $lstr
insert 2 $rline $rstr
incr leftc
incr rightc
continue
}
if {$lmode == "-"} {
insert 1 $lline $lstr new1
emptyline 2
incr leftc
continue
}
if {$rmode == "+"} {
insert 2 $rline $rstr new2
emptyline 1
incr rightc
continue
}
}
}
# Read a patch file and display it
proc displayPatch {} {
global diff Pref
set ch [open $diff(patchFile) r]
set style ""
set divider "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
set leftLine 1
set rightLine 1
set leftLines {}
set rightLines {}
set state none
while {[gets $ch line] != -1} {
if {[string match ======* $line]} {
if {$state != "none"} {
displayOnePatch $leftLines $rightLines $leftLine $rightLine
}
set leftLines {}
set rightLines {}
set state none
continue
}
# Detect the first line in a c style diff
if {$state == "none" && [regexp {^\*\*\*} $line]} {
set state newfile
set style c
set leftRE {^\*\*\*\s+(.*)$}
set rightRE {^---\s+(.*)$}
}
# Detect the first line in a u style diff
if {$state == "none" && [regexp {^---} $line]} {
set state newfile
set style u
set leftRE {^---\s+(.*)$}
set rightRE {^\+\+\+\s+(.*)$}
}
if {$state == "newfile" && [regexp $leftRE $line -> sub]} {
emptyline 1
insert 1 "" $divider
insert 1 "" $sub
insert 1 "" $divider
continue
}
if {$state == "newfile" && [regexp $rightRE $line -> sub]} {
emptyline 2
insert 2 "" $divider
insert 2 "" $sub
insert 2 "" $divider
continue
}
# A new section in a u style diff
if {[regexp {^@@\s+-(\d+),\d+\s+\+(\d+),} $line -> sub1 sub2]} {
if {$state == "both"} {
displayOnePatch $leftLines $rightLines $leftLine $rightLine
}
set state both
set leftLine $sub1
set rightLine $sub2
set leftLines {}
set rightLines {}
continue
}
# A new section in a c style diff
if {[regexp {^\*\*\*\*\*} $line]} {
if {$state == "right"} {
displayOnePatch $leftLines $rightLines $leftLine $rightLine
}
set leftLines {}
set rightLines {}
set state left
continue
}
# We are in the left part of a c style diff
if {$state == "left"} {
if {[regexp {^\*\*\*\s*(\d*)} $line -> sub]} {
if {$sub != ""} {
set leftLine $sub
}
continue
}
if {[regexp {^---\s*(\d*)} $line -> sub]} {
if {$sub != ""} {
set rightLine $sub
}
set state right
continue
}
if {![regexp {^[\s!+-]} $line]} continue
lappend leftLines [list $leftLine \
[string trim [string range $line 0 1]] \
[string range $line 2 end]]
incr leftLine
continue
}
# We are in the right part of a c style diff
if {$state == "right"} {
if {![regexp {^[\s!+-]} $line]} continue
lappend rightLines [list $rightLine \
[string trim [string range $line 0 1]] \
[string range $line 2 end]]
incr rightLine
continue
}
# We are in a u style diff
if {$state == "both"} {
if {![regexp {^[\s+-]} $line]} continue
set sig [string trim [string index $line 0]]
set str [string range $line 1 end]
if {$sig == ""} {
lappend leftLines [list $leftLine "" $str]
lappend rightLines [list $leftLine "" $str]
incr leftLine
incr rightLine
} elseif {$sig == "-"} {
lappend leftLines [list $leftLine "-" $str]
incr leftLine
} else {
lappend rightLines [list $leftLine "+" $str]
incr rightLine
}
continue
}
}
close $ch
set diff(leftLabel) "Patch $diff(patchFile): old"
set diff(rightLabel) "Patch $diff(patchFile): new"
update idletasks
}
# Prepare for RCS/CVS diff. Checkout copies of the versions needed.
proc prepareRCS {} {
global diff Pref
set revs {}
set opts {}
|
︙ | | | ︙ | |
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
|
foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} {
$w configure -state normal
$w delete 1.0 end
}
set changesList {}
set mapMax 0
highLightChange -1
update idletasks
if {$diff(mode) == "RCS" || $diff(mode) == "CVS"} {
prepareRCS
} elseif {[string match "conflict*" $diff(mode)]} {
prepareConflict
}
# Run diff and parse the result.
set differr [catch {eval exec \$::diffexe $Pref(dopt) $Pref(ignore) \
|
>
>
>
>
>
>
>
>
>
>
>
|
|
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
|
foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} {
$w configure -state normal
$w delete 1.0 end
}
set changesList {}
set mapMax 0
set ::HighLightCount 0
highLightChange -1
update idletasks
if {$diff(mode) == "patch"} {
displayPatch
drawMap -1
foreach w {.ft1.tl .ft2.tl} {
$w configure -state disabled
}
update idletasks
.ft2.tl see 1.0
normalCursor
return
} elseif {$diff(mode) == "RCS" || $diff(mode) == "CVS"} {
prepareRCS
} elseif {[string match "conflict*" $diff(mode)]} {
prepareConflict
}
# Run diff and parse the result.
set differr [catch {eval exec \$::diffexe $Pref(dopt) $Pref(ignore) \
|
︙ | | | ︙ | |
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
|
if {$::tcl_platform(platform) == "windows" && $Pref(crlf)} {
fconfigure $ch1 -translation crlf
fconfigure $ch2 -translation crlf
}
set doingLine1 1
set doingLine2 1
set t 0
set ::HighLightCount 0
foreach i $result {
if {![regexp {(.*)([acd])(.*)} $i -> l c r]} {
.ft1.tt insert 1.0 "No regexp match for $i\n"
} else {
if {[regexp {([0-9]+),([0-9]+)} $l apa start stop]} {
set n1 [expr {$stop - $start + 1}]
set line1 $start
|
<
|
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
|
if {$::tcl_platform(platform) == "windows" && $Pref(crlf)} {
fconfigure $ch1 -translation crlf
fconfigure $ch2 -translation crlf
}
set doingLine1 1
set doingLine2 1
set t 0
foreach i $result {
if {![regexp {(.*)([acd])(.*)} $i -> l c r]} {
.ft1.tt insert 1.0 "No regexp match for $i\n"
} else {
if {[regexp {([0-9]+),([0-9]+)} $l apa start stop]} {
set n1 [expr {$stop - $start + 1}]
set line1 $start
|
︙ | | | ︙ | |
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
|
set diff(mode) "conflict"
set Pref(ignore) " "
set diff(conflictFile) $diff(rightFile)
set diff(mergeFile) ""
doDiff
}
}
proc openRCS {} {
global diff
if {[doOpenRight]} {
set diff(mode) "RCS"
set diff(RCSFile) $diff(rightFile)
set diff(leftLabel) "RCS"
|
>
>
>
>
>
>
>
>
>
>
|
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
|
set diff(mode) "conflict"
set Pref(ignore) " "
set diff(conflictFile) $diff(rightFile)
set diff(mergeFile) ""
doDiff
}
}
proc openPatch {} {
global diff
if {[doOpenLeft]} {
set diff(mode) "patch"
set Pref(ignore) " "
set diff(patchFile) $diff(leftFile)
doDiff
}
}
proc openRCS {} {
global diff
if {[doOpenRight]} {
set diff(mode) "RCS"
set diff(RCSFile) $diff(rightFile)
set diff(leftLabel) "RCS"
|
︙ | | | ︙ | |
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
|
set gray 1.0
set line ""
set lines {}
foreach {key value index} $tdump {
if {$key == "tagon"} {
if {$value == "change"} {
set gray $::grayLevel1
} else {
set gray $::grayLevel2
}
} elseif {$key == "tagoff"} {
set gray 1.0
} elseif {$key == "text"} {
append line $value
if {[string index $value end] == "\n"} {
set line [string trim [string trim $line] :]
if {$line == ""} {
lappend lines ""
} else {
|
|
>
|
>
|
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
|
set gray 1.0
set line ""
set lines {}
foreach {key value index} $tdump {
if {$key == "tagon"} {
if {$value == "change"} {
set gray $::grayLevel1
} elseif {[string match "new*" $value]} {
set gray $::grayLevel2
}
} elseif {$key == "tagoff"} {
if {$value == "change" || [string match "new*" $value]} {
set gray 1.0
}
} elseif {$key == "text"} {
append line $value
if {[string index $value end] == "\n"} {
set line [string trim [string trim $line] :]
if {$line == ""} {
lappend lines ""
} else {
|
︙ | | | ︙ | |
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
|
text {
set value [fixTextBlock $value $index]
if {[string index $value end] == "\n"} {
set newline 1
set value [string trimright $value "\n"]
}
set len [string length $value]
while {$chars + $len > 85} {
set wrap [expr {85 - $chars}]
set val1 [string range $value 0 [expr {$wrap - 1}]]
set value [string range $value $wrap end]
append line $val1
append line [linewrap $gray]
set chars 5
incr wrapc
set len [string length $value]
|
|
|
|
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
|
text {
set value [fixTextBlock $value $index]
if {[string index $value end] == "\n"} {
set newline 1
set value [string trimright $value "\n"]
}
set len [string length $value]
while {$chars + $len > 84} {
set wrap [expr {84 - $chars}]
set val1 [string range $value 0 [expr {$wrap - 1}]]
set value [string range $value $wrap end]
append line $val1
append line [linewrap $gray]
set chars 5
incr wrapc
set len [string length $value]
|
︙ | | | ︙ | |
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
|
puts $ch [lindex $wraplines2 $i2]
}
puts -nonewline $ch "\f"
}
close $ch
catch {exec enscript -c -B -e -p $tmpFile2 $tmpFile}
catch {exec mpage -bA4 -a2 $tmpFile2 > $tmpFile3}
normalCursor
if {!$quiet} {
destroy .dp
toplevel .dp
wm title .dp "Diff Print"
button .dp.b -text Close -command {destroy .dp}
|
>
>
>
>
|
>
>
>
>
>
|
>
>
>
|
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
|
puts $ch [lindex $wraplines2 $i2]
}
puts -nonewline $ch "\f"
}
close $ch
if {$::tcl_platform(platform) == "windows" &&\
![info exists env(ENSCRIPT_LIBRARY)]} {
set ::env(ENSCRIPT_LIBRARY) [pwd]
}
if {[catch {exec enscript -c -B -e -p $tmpFile2 $tmpFile} result]} {
if {[string index $result 0] != "\["} {
tk_messageBox -message "Enscript error: $result"
return
}
}
if {[catch {exec mpage -bA4 -a2 $tmpFile2 > $tmpFile3} result]} {
tk_messageBox -message "Mpage error: $result"
return
}
normalCursor
if {!$quiet} {
destroy .dp
toplevel .dp
wm title .dp "Diff Print"
button .dp.b -text Close -command {destroy .dp}
|
︙ | | | ︙ | |
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
|
regsub -all "\t" $text " " text
.balloon.t$x configure -width [string length $text]
}
wm geometry .balloon +${wx}+${wy}
update
wm withdraw .balloon
puts "[winfo width .balloon] [winfo rootx .] [winfo width .]"
# Is the balloon within the diff window?
set wid [winfo width .balloon]
if {$wid + $wx > [winfo rootx .] + [winfo width .]} {
# No.
# Center on diff window
set wx [expr {([winfo width .] - $wid) / 2 + [winfo rootx .]}]
# Is the balloon not within the screen?
if {$wx + $wid > [winfo screenwidth .]} {
# Center in screen
set wx [expr {([winfo screenwidth .] - $wid) / 2}]
}
wm geometry .balloon +$wx+$wy
}
# Does the balloon fit within the screen?
if {$wid > [winfo screenwidth .]} {
# Add a row and fill screen width
.balloon.t1 configure -height 2
.balloon.t2 configure -height 2
update idletasks
wm geometry .balloon \
[winfo screenwidth .]x[winfo reqheight .balloon]+0+$wy
set apa {
set h [.balloon.t1 cget -height]
incr h
.balloon.t1 configure -height $h
.balloon.t2 configure -height $h
update idletasks
wm geometry .balloon \
[winfo screenwidth .]x[winfo reqheight .balloon]
}
bind .balloon <Button-1> $apa
bind . <Button-1> $apa
}
wm deiconify .balloon
}
proc unzoomRow {} {
destroy .balloon
bind . <Button-1> ""
}
|
<
>
>
<
|
>
>
|
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
|
regsub -all "\t" $text " " text
.balloon.t$x configure -width [string length $text]
}
wm geometry .balloon +${wx}+${wy}
update
wm withdraw .balloon
# Is the balloon within the diff window?
set wid [winfo width .balloon]
if {$wid + $wx > [winfo rootx .] + [winfo width .]} {
# No.
# Center on diff window
set wx [expr {([winfo width .] - $wid) / 2 + [winfo rootx .]}]
if {$wx < 0} {set wx 0}
# Is the balloon not within the screen?
if {$wx + $wid > [winfo screenwidth .]} {
# Center in screen
set wx [expr {([winfo screenwidth .] - $wid) / 2}]
if {$wx < 0} {set wx 0}
}
}
# Does the balloon fit within the screen?
if {$wid > [winfo screenwidth .]} {
# Add a row and fill screen width
.balloon.t1 configure -height 2
.balloon.t2 configure -height 2
update idletasks
wm geometry .balloon \
[winfo screenwidth .]x[winfo reqheight .balloon]
set wx 0
set apa {
set h [.balloon.t1 cget -height]
incr h
.balloon.t1 configure -height $h
.balloon.t2 configure -height $h
update idletasks
wm geometry .balloon \
[winfo screenwidth .]x[winfo reqheight .balloon]
}
bind .balloon <Button-1> $apa
bind . <Button-1> $apa
}
wm deiconify .balloon
wm geometry .balloon +$wx+$wy
}
proc unzoomRow {} {
destroy .balloon
bind . <Button-1> ""
}
|
︙ | | | ︙ | |
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
|
}
.mf.m add separator
.mf.m add command -label "Open Both" -underline 0 -command {openBoth 0}
.mf.m add command -label "Open Both (forget)" -command {openBoth 1}
.mf.m add command -label "Open Left File" -command openLeft
.mf.m add command -label "Open Right File" -command openRight
.mf.m add command -label "Open Conflict File" -command openConflict
if {$tcl_platform(platform) == "unix"} {
.mf.m add command -label "RCSDiff" -underline 0 -command openRCS
.mf.m add command -label "CVSDiff" -underline 0 -command openCVS
.mf.m add separator
.mf.m add command -label "Print" -underline 0 -command doPrint
}
.mf.m add separator
.mf.m add command -label "Quit" -command cleanupAndExit
menubutton .mo -text Options -underline 0 -menu .mo.m
menu .mo.m
.mo.m add cascade -label Font -underline 0 -menu .mo.mf
.mo.m add cascade -label Ignore -underline 0 -menu .mo.mi
|
>
>
|
|
<
|
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
|
}
.mf.m add separator
.mf.m add command -label "Open Both" -underline 0 -command {openBoth 0}
.mf.m add command -label "Open Both (forget)" -command {openBoth 1}
.mf.m add command -label "Open Left File" -command openLeft
.mf.m add command -label "Open Right File" -command openRight
.mf.m add command -label "Open Conflict File" -command openConflict
.mf.m add command -label "Open Patch File" -command openPatch
if {$tcl_platform(platform) == "unix"} {
.mf.m add command -label "RCSDiff" -underline 0 -command openRCS
.mf.m add command -label "CVSDiff" -underline 0 -command openCVS
}
.mf.m add separator
.mf.m add command -label "Print" -underline 0 -command doPrint
.mf.m add separator
.mf.m add command -label "Quit" -command cleanupAndExit
menubutton .mo -text Options -underline 0 -menu .mo.m
menu .mo.m
.mo.m add cascade -label Font -underline 0 -menu .mo.mf
.mo.m add cascade -label Ignore -underline 0 -menu .mo.mi
|
︙ | | | ︙ | |
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
|
.he.t insert end {3: } change {NET '/I$1/N$1456' } "" {IC2-13 } new1 {IC2-12 } "" {2: } change {NET '/I$1/N$1456' IC2-12
}
.he.t insert end {4: NET '/I$1/N$1457' IC2-11 IC6-7 3: NET '/I$1/N$1457' IC2-11 IC6-7
}
.he.t insert end {5: } change {NET '/I$1/N$1458' } "" {IC2-10} change { } "" {4: } change {NET '/I$1/N$1458' } "" {IC2-9} change "\n"
}
proc parseCommandLine {} {
global diff Pref
global argv argc tcl_platform
set diff(leftOK) 0
set diff(rightOK) 0
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
|
.he.t insert end {3: } change {NET '/I$1/N$1456' } "" {IC2-13 } new1 {IC2-12 } "" {2: } change {NET '/I$1/N$1456' IC2-12
}
.he.t insert end {4: NET '/I$1/N$1457' IC2-11 IC6-7 3: NET '/I$1/N$1457' IC2-11 IC6-7
}
.he.t insert end {5: } change {NET '/I$1/N$1458' } "" {IC2-10} change { } "" {4: } change {NET '/I$1/N$1458' } "" {IC2-9} change "\n"
}
proc printUsage {} {
puts {Usage: diff.tcl [options] [file1] [file2]
[options] All options but the ones listed below
are passed to diff.
[file1],[file2] Files to be compared
If no files are given, the program is
started anyway and you can select files
from within.
If only one file is given, the program
looks for an RCS/CVS directory next to the
file, and if found, runs in RCS mode.
Options:
-nodiff : Normally, if there are enough information on the
command line to run diff, diff.tcl will do so unless
this option is specified.
-noparse : Diff.tcl can perform analysis of changed blocks to
-line : improve display. See online help for details.
-block : The default is -block, but this can be slow if there
are large change blocks.
-char : The analysis of changes can be done on either
-word : character or word basis. -char is the default.
-2nd : Turn on or off second stage parsing.
-no2nd : It is on by default.
-conflict : Treat file as a merge conflict file and enter merge
mode.
-o <file> : Specify merge result output file.
-print <file> : Generate postscript and exit.
}
}
proc parseCommandLine {} {
global diff Pref
global argv argc tcl_platform
set diff(leftOK) 0
set diff(rightOK) 0
|
︙ | | | ︙ | |
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
|
set Pref(dopt) "$Pref(dopt) -r$arg"
}
set nextArg ""
continue
}
if {$arg == "-w"} {
set Pref(ignore) "-w"
} elseif {$arg == "-b"} {
set Pref(ignore) "-b"
} elseif {$arg == "-noignore"} {
set Pref(ignore) " "
} elseif {$arg == "-noparse"} {
set Pref(parse) 0
} elseif {$arg == "-line"} {
|
>
>
>
|
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
|
set Pref(dopt) "$Pref(dopt) -r$arg"
}
set nextArg ""
continue
}
if {$arg == "-w"} {
set Pref(ignore) "-w"
} elseif {$arg == "-h"} {
printUsage
exit
} elseif {$arg == "-b"} {
set Pref(ignore) "-b"
} elseif {$arg == "-noignore"} {
set Pref(ignore) " "
} elseif {$arg == "-noparse"} {
set Pref(parse) 0
} elseif {$arg == "-line"} {
|
︙ | | | ︙ | |
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
|
after idle doDiff
}
} else {
set diff(leftDir) $fulldir
set diff(leftFile) $fullname
set diff(leftLabel) $fullname
set diff(leftOK) 1
}
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set diff(leftDir) $fulldir
set diff(leftFile) $fullname
set diff(leftLabel) $fullname
|
>
>
>
>
>
>
>
>
>
>
|
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
|
after idle doDiff
}
} else {
set diff(leftDir) $fulldir
set diff(leftFile) $fullname
set diff(leftLabel) $fullname
set diff(leftOK) 1
if {[string match "*.diff" $fullname]} {
set diff(mode) "patch"
set diff(patchFile) $fullname
set autobrowse 0
if {$noautodiff} {
enableRedo
} else {
after idle doDiff
}
}
}
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set diff(leftDir) $fulldir
set diff(leftFile) $fullname
set diff(leftLabel) $fullname
|
︙ | | | ︙ | |