Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Some code cleanup. Use -translation crlf on windows. Added line numbers when printing. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
61405d781bcacd95a219f32fa27c6ba9 |
User & Date: | spjutp 2000-07-25 11:33:51.000 |
Context
2000-07-25
| ||
11:39 | Added right mouse menu with file copy. Improved command line parsing. check-in: ac0f283357 user: spjutp tags: trunk | |
11:33 | Some code cleanup. Use -translation crlf on windows. Added line numbers when printing. check-in: 61405d781b user: spjutp tags: trunk | |
2000-06-26
| ||
15:50 | Added FreeWrap support. Bug fix in accessing CVS revisions. check-in: cba3aa052f user: spjutp tags: trunk | |
Changes
Changes to src/eskil.tcl.
1 2 3 4 5 6 7 8 9 10 11 | #!/bin/sh # # diff.tcl # # Purpose # Graphical frontend to diff # # Usage # diff.tcl [options] [file1] [file2] # # [options] All options but the ones listed below | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/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. |
︙ | ︙ | |||
156 157 158 159 160 161 162 | set mid2 [string range $s2 $t [expr {$t + $len1 - 1}]] set right2 [string range $s2 [expr {$t + $len1}] end] set res2 [list $left2 $mid2 $right2] set res1 [list "" $s1 ""] return } } | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | set mid2 [string range $s2 $t [expr {$t + $len1 - 1}]] set right2 [string range $s2 [expr {$t + $len1}] end] set res2 [list $left2 $mid2 $right2] set res1 [list "" $s1 ""] return } } #Is s2 a substring of s1 ? if {$len2 < $len1} { set t [string first $s2 $s1] if {$t != -1} { set left1 [string range $s1 0 [expr {$t - 1}]] set mid1 [string range $s1 $t [expr {$t + $len2 - 1}]] set right1 [string range $s1 [expr {$t + $len2}] end] |
︙ | ︙ | |||
224 225 226 227 228 229 230 | set found1 $t set found2 $i set minlen $foundlen set u [expr {$t + $minlen}] } } } | | | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | set found1 $t set found2 $i set minlen $foundlen set u [expr {$t + $minlen}] } } } if {$foundlen == -1} { set res1 [list $s1] set res2 [list $s2] } else { set left1 [string range $s1 0 [expr {$found1 - 1}]] set mid1 [string range $s1 $found1 [expr {$found1 + $foundlen - 1}]] set right1 [string range $s1 [expr {$found1 + $foundlen}] end] |
︙ | ︙ | |||
286 287 288 289 290 291 292 | set len2 [string length $apa2] set len [expr {$len1 < $len2 ? $len1 : $len2}] for {set t 0; set s 0; set flag 0} {$t < $len} {incr t} { if {[set c [string index $apa1 $t]] != [string index $apa2 $t]} { incr flag 2 break } | | > > | | > | | | | > > > > | | 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 | set len2 [string length $apa2] set len [expr {$len1 < $len2 ? $len1 : $len2}] for {set t 0; set s 0; set flag 0} {$t < $len} {incr t} { if {[set c [string index $apa1 $t]] != [string index $apa2 $t]} { incr flag 2 break } if {$c == " "} { set s $t set flag 1 } } if {$Pref(lineparsewords) == 0 || $test != 0} { incr leftp1 $t incr leftp2 $t } else { if {$flag < 2} { set s $len } elseif {$flag == 3} { incr s } incr leftp1 $s incr leftp2 $s } #Check for matching right chars/words. #t1 and t2 will be the indicies of the last difference set len1 [string length $mid1] set len2 [string length $mid2] set t1 [expr {$len1 - 1}] set t2 [expr {$len2 - 1}] set s1 $t1 set s2 $t2 set flag 0 for {} {$t1 >= $leftp1 && $t2 >= $leftp2} {incr t1 -1; incr t2 -1} { if {[set c [string index $mid1 $t1]] != [string index $mid2 $t2]} { incr flag 2 break } if {$c == " "} { set s1 $t1 set s2 $t2 set flag 1 } } if {$Pref(lineparsewords) == 1 && $test == 0} { if {$flag >= 2} { if {$flag == 3} { incr s1 -1 incr s2 -1 } set t1 $s1 set t2 $s2 } } #Make the result if {$leftp1 > $t1} { set res1 [list $line1] } else { set right1 [string range $line1 [expr {$t1 + 1}] end] set mid1 [string range $line1 $leftp1 $t1] set left1 [string range $line1 0 [expr {$leftp1 - 1}]] |
︙ | ︙ | |||
400 401 402 403 404 405 406 | #Collect statistics set result {} set scores {} foreach line1 $block1 { set bestscore -100000 set bestline 0 set i 0 | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | #Collect statistics set result {} set scores {} foreach line1 $block1 { set bestscore -100000 set bestline 0 set i 0 foreach line2 $block2 { set x [compareLines2 $line1 $line2] if {$x > $bestscore} { set bestscore $x set bestline $i } incr i } |
︙ | ︙ | |||
482 483 484 485 486 487 488 | if {$next == 1} continue } } } } set apa {} | | | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | if {$next == 1} continue } } } } set apa {} set t1 0 set t2 0 while {$t1 < $size1 || $t2 < $size2} { if {$t1 < $size1} { set r [lindex $result $t1] if {$r < $t2 || $t2 >= $size2} { lappend apa $dsym incr t1 |
︙ | ︙ | |||
510 511 512 513 514 515 516 | return $apa } #Decide how to display change blocks proc compareblocks {block1 block2} { set size1 [llength $block1] set size2 [llength $block2] | | | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | return $apa } #Decide how to display change blocks proc compareblocks {block1 block2} { set size1 [llength $block1] set size2 [llength $block2] if {$size1 * $size2 > 1000} { puts "Diff warning: Analyzing a large block. ($size1 $size2)" update idletasks } #Swap if block1 is bigger if {$size1 > $size2} { |
︙ | ︙ | |||
537 538 539 540 541 542 543 | #Collect statistics set scores {} set j 0 foreach line1 $block1 { set bestscore -100000 set bestline 0 set i 0 | | | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | #Collect statistics set scores {} set j 0 foreach line1 $block1 { set bestscore -100000 set bestline 0 set i 0 foreach line2 $block2 { set x [compareLines2 $line1 $line2] if {$x > $bestscore} { set bestscore $x set bestline $i } incr i } |
︙ | ︙ | |||
613 614 615 616 617 618 619 | set result($i) -1 } } } } set apa {} | | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | set result($i) -1 } } } } set apa {} set t1 0 set t2 0 while {$t1 < $size1 || $t2 < $size2} { if {$t1 < $size1} { set r $result($t1) if {$r < $t2 || $t2 >= $size2} { lappend apa $dsym incr t1 |
︙ | ︙ | |||
688 689 690 691 692 693 694 | .ft2.tt insert end $i2 set dotag 1 } } .ft1.tt insert end "\n" .ft2.tt insert end "\n" } else { | | | | | | | | | | | | 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 | .ft2.tt insert end $i2 set dotag 1 } } .ft1.tt insert end "\n" .ft2.tt insert end "\n" } 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} { global doingLine1 doingLine2 Pref mapList mapMax if {$n1 == 0 && $n2 == 0} { #All blocks have been processed. Continue until end of file. if {$Pref(onlydiffs) == 1} return while {[gets $ch2 apa] != -1} { insert 2 $doingLine2 $apa incr doingLine2 incr mapMax } while {[gets $ch1 apa] != -1} { insert 1 $doingLine1 $apa incr doingLine1 } return } if {$n1 == 0} {set tag2 new2} else {set tag2 change} if {$n2 == 0} {set tag1 new1} else {set tag1 change} #Display all equal lines before next diff if {$Pref(onlydiffs) == 1 && $doingLine1 < $line1} { emptyline 1 emptyline 2 incr mapMax } while {$doingLine1 < $line1} { gets $ch1 apa gets $ch2 bepa if {$Pref(onlydiffs) == 0} { insert 1 $doingLine1 $apa insert 2 $doingLine2 $bepa incr mapMax } incr doingLine1 incr doingLine2 } if {$doingLine2 != $line2} { .ft1.tt insert end "**Bad alignment here!! $doingLine2 $line2**\n" .ft2.tt insert end "**Bad alignment here!! $doingLine2 $line2**\n" .ft1.tl insert end "\n" .ft2.tl insert end "\n" } #Process the block if {$n1 == $n2 && ($n1 == 1 || $Pref(parse) < 2)} { for {set t 0} {$t < $n1} {incr t} { gets $ch1 line1 |
︙ | ︙ | |||
785 786 787 788 789 790 791 | incr t1 incr t2 } if {$c == "d"} { set bepa [lindex $block1 $t1] .ft1.tl insert end [myforml $doingLine1] change .ft1.tt insert end "$bepa\n" new1 | | | | | | | | 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | incr t1 incr t2 } if {$c == "d"} { set bepa [lindex $block1 $t1] .ft1.tl insert end [myforml $doingLine1] 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] change .ft2.tt insert end "$bepa\n" new2 emptyline 1 incr doingLine2 incr t2 } } lappend mapList $mapMax incr mapMax [llength $apa] lappend mapList $mapMax change } 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} { gets $ch2 apa insert 2 $doingLine2 $apa $tag2 incr doingLine2 } if {$n1 < $n2} { for {set t $n1} {$t < $n2} {incr t} { emptyline 1 } lappend mapList $mapMax incr mapMax $n2 lappend mapList $mapMax $tag2 } elseif {$n2 < $n1} { for {set t $n2} {$t < $n1} {incr t} { emptyline 2 } lappend mapList $mapMax incr mapMax $n1 lappend mapList $mapMax $tag1 } } } |
︙ | ︙ | |||
845 846 847 848 849 850 851 | set c2 [.ft2.tt tag nextrange change $i] # Below, the 'list' command is not used because I want the list # "flattened" before the sort. set apa [lsort -dictionary "$n1 $c1 $n2 $c2"] if {[llength $apa] != 0} { | | | | | | | | | | | | 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 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 | set c2 [.ft2.tt tag nextrange change $i] # Below, the 'list' command is not used because I want the list # "flattened" before the sort. set apa [lsort -dictionary "$n1 $c1 $n2 $c2"] if {[llength $apa] != 0} { set apa [lindex $apa 0] } else { set apa end } foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { $w yview $apa } } #Scroll windows to previous diff proc findPrev {} { set i [.ft1.tt index @0,0] set n1 [.ft1.tt tag prevrange new1 $i] set c1 [.ft1.tt tag prevrange change $i] set i [.ft2.tt index @0,0] set n2 [.ft2.tt tag prevrange new2 $i] set c2 [.ft2.tt tag prevrange change $i] # Below, the 'list' command is not used because I want the list # "flattened" before the sort. set apa [lsort -decreasing -dictionary "$n1 $c1 $n2 $c2"] if {[llength $apa] != 0} { set apa [lindex $apa 1] } else { set apa 1.0 } foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { $w yview $apa } } proc enableRedo {} { .mf.m entryconfigure 1 -state normal } proc disableRedo {} { .mf.m entryconfigure 1 -state disabled } proc busyCursor {} { global oldcursor oldcursor2 if {![info exists oldcursor]} { set oldcursor [. cget -cursor] set oldcursor2 [.ft1.tt cget -cursor] } . config -cursor watch foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { $w config -cursor watch } } proc normalCursor {} { global oldcursor oldcursor2 . config -cursor $oldcursor foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { $w config -cursor $oldcursor2 } } proc prepareRCS {} { global leftFile rightFile RCSFile leftLabel rightLabel Pref RCSmode set revs {} |
︙ | ︙ | |||
935 936 937 938 939 940 941 | 0 { set leftFile [tmpfile] set rightLabel $RCSFile set rightFile $RCSFile if {$RCSmode == 2} { set leftLabel "$RCSFile (CVS)" | | > | > | | > | > | 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 | 0 { set leftFile [tmpfile] set rightLabel $RCSFile set rightFile $RCSFile if {$RCSmode == 2} { set leftLabel "$RCSFile (CVS)" catch {exec cvs update -p \ [file nativename $RCSFile] > $leftFile} } else { set leftLabel "$RCSFile (RCS)" catch {exec co -p [file nativename $RCSFile] > $leftFile} } } 1 { set r [lindex $revs 0] set leftFile [tmpfile] set rightLabel $RCSFile set rightFile $RCSFile if {$RCSmode == 2} { set leftLabel "$RCSFile (CVS $r)" catch {exec cvs update -p -r $r \ [file nativename $RCSFile] > $leftFile} } else { set leftLabel "$RCSFile (RCS $r)" catch {exec co -p$r [file nativename $RCSFile] > $leftFile} } } default { set r1 [lindex $revs 0] set r2 [lindex $revs 1] set leftFile [tmpfile] set rightFile [tmpfile] if {$RCSmode == 2} { set leftLabel "$RCSFile (CVS $r1)" set rightLabel "$RCSFile (CVS $r2)" catch {exec cvs update -p -r $r1 \ [file nativename $RCSFile] > $leftFile} catch {exec cvs update -p -r $r2 \ [file nativename $RCSFile] > $rightFile} } else { set leftLabel "$RCSFile (RCS $r1)" set rightLabel "$RCSFile (RCS $r2)" catch {exec co -p$r1 [file nativename $RCSFile] > $leftFile} catch {exec co -p$r2 [file nativename $RCSFile] > $rightFile} } } |
︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 | } else { enableRedo } busyCursor foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { | | | | | 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 | } else { enableRedo } busyCursor foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { $w configure -state normal $w delete 1.0 end } set mapList {} set mapMax 0 update idletasks if {$RCSmode} { prepareRCS } set differr [catch {eval exec $::diffexe $Pref(dopt) $Pref(ignore) \ \$leftFile \$rightFile} diffres] set apa [split $diffres "\n"] set result {} foreach i $apa { if {[string match {[0-9]*} $i]} { lappend result $i } } |
︙ | ︙ | |||
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | } } else { set eqLabel " " } set ch1 [open $leftFile] set ch2 [open $rightFile] set doingLine1 1 set doingLine2 1 set t 0 foreach i $result { if {![regexp {(.*)([acd])(.*)} $i apa l c r]} { .ft1.tt insert 1.0 "No regexp match for $i\n" } else { | > > > > | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | } } else { set eqLabel " " } set ch1 [open $leftFile] set ch2 [open $rightFile] if {$::tcl_platform(platform) == "windows"} { fconfigure $ch1 -translation crlf fconfigure $ch2 -translation crlf } set doingLine1 1 set doingLine2 1 set t 0 foreach i $result { if {![regexp {(.*)([acd])(.*)} $i apa l c r]} { .ft1.tt insert 1.0 "No regexp match for $i\n" } else { |
︙ | ︙ | |||
1065 1066 1067 1068 1069 1070 1071 | set n2 1 set line2 $r } switch $c { a { # lucka i left, new i right dotext $ch1 $ch2 0 $n2 [expr {$line1 + 1}] $line2 | | | | | 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 | set n2 1 set line2 $r } switch $c { a { # lucka i left, new i right dotext $ch1 $ch2 0 $n2 [expr {$line1 + 1}] $line2 } c { dotext $ch1 $ch2 $n1 $n2 $line1 $line2 } d { # lucka i right, new i left dotext $ch1 $ch2 $n1 0 $line1 [expr {$line2 + 1}] } } } if {[incr t] >= 10} { update idletasks .ft2.tl see end update idletasks set t 0 } } |
︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 | if {$RCSmode} { cleanupRCS } drawMap -1 foreach w {.ft1.tl .ft2.tl} { | | > > > | | | 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 | if {$RCSmode} { cleanupRCS } drawMap -1 foreach w {.ft1.tl .ft2.tl} { $w configure -state disabled } update idletasks .ft2.tl see 1.0 normalCursor } # This is the entrypoint to do a diff via DDE or Send proc remoteDiff {file1 file2} { global leftFile rightFile leftOK rightOK global leftDir rightDir leftLabel rightLabel set leftDir [file dirname $file1] set leftFile $file1 set leftLabel $file1 set leftOK 1 set rightDir [file dirname $file2] set rightFile $file2 set rightLabel $file2 set rightOK 1 set RCSmode 0 wm deiconify . raise . update doDiff } proc doOpenLeft {{forget 0}} { global leftFile leftDir rightDir leftOK leftLabel if {!$forget && [info exists leftDir]} { set initDir $leftDir } elseif {[info exists rightDir]} { set initDir $rightDir } else { set initDir [pwd] } set apa [tk_getOpenFile -title "Select left file" -initialdir $initDir] if {$apa != ""} { set leftDir [file dirname $apa] set leftFile $apa set leftLabel $apa set leftOK 1 return 1 } return 0 } |
︙ | ︙ | |||
1226 1227 1228 1229 1230 1231 1232 | doDiff } } } proc drawMap {newh} { global mapList mapMax Pref | | | | 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | doDiff } } } proc drawMap {newh} { global mapList mapMax Pref set oldh [map cget -height] if {$oldh == $newh} return map blank if {![info exists mapList] || $mapList == ""} return set w [winfo width .c] set h [winfo height .c] set x2 [expr {$w - 1}] map configure -width $w -height $h |
︙ | ︙ | |||
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | } if {$gray == "1.0"} { return $res } else { return "\0bggray\{$gray\}$res\0bggray\{1.0\}" } } #Handle wrapping of a too long line for printing proc linewrap {gray} { if {$gray == "1.0"} { return "\n " } else { return "\0bggray\{1.0\}\n \0bggray\{$gray\}" | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 | } if {$gray == "1.0"} { return $res } else { return "\0bggray\{$gray\}$res\0bggray\{1.0\}" } } # Process the line numbers from the line number widget into a list # of "linestarters" proc processLineno {w} { set tdump [$w dump -tag -text 1.0 end] set gray 1.0 set line "" set lines {} foreach {key value index} $tdump { if {$key == "tagon"} { if {$value == "change"} { set gray 0.6 } else { set gray 0.8 } } 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 { lappend lines [formatLineno $line $gray] } set line "" } } } return $lines } #Handle wrapping of a too long line for printing proc linewrap {gray} { if {$gray == "1.0"} { return "\n " } else { return "\0bggray\{1.0\}\n \0bggray\{$gray\}" |
︙ | ︙ | |||
1303 1304 1305 1306 1307 1308 1309 1310 1311 | set tmpFile3 [file nativename ~/tcldiff.ps] set lines1 {} set lines2 {} set tdump1 [.ft1.tt dump -tag -text 1.0 end] set tdump2 [.ft2.tt dump -tag -text 1.0 end] foreach tdump [list $tdump1 $tdump2] \ | > > | > | > | | 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 | set tmpFile3 [file nativename ~/tcldiff.ps] set lines1 {} set lines2 {} set tdump1 [.ft1.tt dump -tag -text 1.0 end] set tdump2 [.ft2.tt dump -tag -text 1.0 end] set lineNo1 [processLineno .ft1.tl] set lineNo2 [processLineno .ft2.tl] foreach tdump [list $tdump1 $tdump2] \ lineName {lines1 lines2} wrapName {wrap1 wrap2} \ lineNo [list $lineNo1 $lineNo2] { set lines {} set wraps {} set line [lindex $lineNo 0] set newline 0 set gray 1.0 set chars 0 set wrapc 0 foreach {key value index} $tdump { if {$key != "tagoff" && $newline == 1} { lappend lines $line lappend wraps $wrapc set newline 0 set line [lindex $lineNo [llength $lines]] append line "\0bggray\{$gray\}" set chars 0 set wrapc 0 } switch $key { text { set value [fixTextBlock $value $index] if {[string index $value end] == "\n"} { |
︙ | ︙ | |||
1422 1423 1424 1425 1426 1427 1428 | normalCursor destroy .dp toplevel .dp wm title .dp "Diff Print" button .dp.b -text Close -command {destroy .dp} label .dp.l -anchor w -justify left -text "The following files have\ | | | | | | | | | | | 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 | normalCursor destroy .dp toplevel .dp wm title .dp "Diff Print" button .dp.b -text Close -command {destroy .dp} label .dp.l -anchor w -justify left -text "The following files have\ been created:\n\n$tmpFile\nInput file to enscript.\ \n\n$tmpFile2\nCreated with 'enscript -c -B -e -p $tmpFile2\ $tmpFile'\n\n$tmpFile3\nCreated with 'mpage -bA4 -a2 $tmpFile2 >\ $tmpFile3'" -font "Courier 8" pack .dp.b -side bottom pack .dp.l -side top } proc my_yview args { foreach w {.ft1.tl .ft1.tt .ft2.tl .ft2.tt} { eval $w yview $args } } proc my_yscroll args { eval .sby set $args my_yview moveto [lindex $args 0] } proc chFont {} { global Pref font configure myfont -size $Pref(fontsize) -family $Pref(fontfamily) } proc applyColor {} { global Pref foreach w {.tl .tt} { .ft1$w tag configure new1 -foreground $Pref(colornew1) \ -background $Pref(bgnew1) .ft1$w tag configure change -foreground $Pref(colorchange) \ -background $Pref(bgchange) .ft2$w tag configure new2 -foreground $Pref(colornew2) \ -background $Pref(bgnew2) .ft2$w tag configure change -foreground $Pref(colorchange) \ -background $Pref(bgchange) } } proc scroll {n what} { if {![string match ".ft?.tt" [focus]]} { .ft1.tt yview scroll $n $what |
︙ | ︙ | |||
1499 1500 1501 1502 1503 1504 1505 | .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 printDiffs } .mf.m add separator .mf.m add command -label "Quit" -command cleanupAndExit | | | 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 | .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 printDiffs } .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 .mo.m add cascade -label Parse -underline 0 -menu .mo.mp .mo.m add command -label Colours -underline 0 -command makePrefWin .mo.m add checkbutton -label "Diffs only" -variable Pref(onlydiffs) |
︙ | ︙ | |||
1564 1565 1566 1567 1568 1569 1570 | font create myfont -family $Pref(fontfamily) -size $Pref(fontsize) label .l1 -textvariable leftLabel -anchor e -width 10 label .l2 -textvariable rightLabel -anchor e -width 10 frame .ft1 -borderwidth 2 -relief sunken text .ft1.tl -height 40 -width 5 -wrap none -yscrollcommand my_yscroll \ | | | | | | 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 | font create myfont -family $Pref(fontfamily) -size $Pref(fontsize) label .l1 -textvariable leftLabel -anchor e -width 10 label .l2 -textvariable rightLabel -anchor e -width 10 frame .ft1 -borderwidth 2 -relief sunken text .ft1.tl -height 40 -width 5 -wrap none -yscrollcommand my_yscroll \ -font myfont -borderwidth 0 -padx 0 -highlightthickness 0 text .ft1.tt -height 40 -width 80 -wrap none -yscrollcommand my_yscroll \ -xscrollcommand ".sbx1 set" -font myfont -borderwidth 0 -padx 0 \ -highlightthickness 0 pack .ft1.tl -side left -fill y pack .ft1.tt -side right -fill both -expand 1 scrollbar .sby -orient vertical -command "my_yview" scrollbar .sbx1 -orient horizontal -command ".ft1.tt xview" frame .ft2 -borderwidth 2 -relief sunken text .ft2.tl -height 60 -width 5 -wrap none -yscrollcommand my_yscroll \ -font myfont -borderwidth 0 -padx 0 -highlightthickness 0 text .ft2.tt -height 60 -width 80 -wrap none -yscrollcommand my_yscroll \ -xscrollcommand ".sbx2 set" -font myfont -borderwidth 0 -padx 0 \ -highlightthickness 0 pack .ft2.tl -side left -fill y pack .ft2.tt -side right -fill both -expand 1 scrollbar .sbx2 -orient horizontal -command ".ft2.tt xview" label .le -textvariable eqLabel -width 1 canvas .c -width 6 -bd 0 -selectborderwidth 0 -highlightthickness 0 |
︙ | ︙ | |||
1625 1626 1627 1628 1629 1630 1631 | .md.m add separator .md.m add command -label "Redraw Window" -command {makeDiffWin} .md.m add separator .md.m add command -label "Normal Cursor" -command {normalCursor} .md.m add separator .md.m add command -label "Evalstats" -command {evalstats} .md.m add command -label "_stats" -command {parray _stats} | | | | 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 | .md.m add separator .md.m add command -label "Redraw Window" -command {makeDiffWin} .md.m add separator .md.m add command -label "Normal Cursor" -command {normalCursor} .md.m add separator .md.m add command -label "Evalstats" -command {evalstats} .md.m add command -label "_stats" -command {parray _stats} pack .mf .mo .mh .md -in .f -side left } else { pack .mf .mo .mh -in .f -side left } pack .bfn .bfp .eo .lo -in .f -side right } proc applyPref {} { global Pref TmpPref array set Pref [array get TmpPref] applyColor } proc testColor {} { global TmpPref .pr.fc.t1 tag configure change -foreground $TmpPref(colorchange) \ -background $TmpPref(bgchange) .pr.fc.t2 tag configure new1 -foreground $TmpPref(colornew1) \ -background $TmpPref(bgnew1) .pr.fc.t3 tag configure new2 -foreground $TmpPref(colornew2) \ -background $TmpPref(bgnew2) } |
︙ | ︙ | |||
1666 1667 1668 1669 1670 1671 1672 | proc makePrefWin {} { global Pref TmpPref array set TmpPref [array get Pref] destroy .pr | | | 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 | proc makePrefWin {} { global Pref TmpPref array set TmpPref [array get Pref] destroy .pr toplevel .pr wm title .pr "Diff Preferences" frame .pr.fc -borderwidth 1 -relief solid label .pr.fc.l1 -text Colours -anchor w label .pr.fc.l2 -text Text -anchor w label .pr.fc.l3 -text Background -anchor w |
︙ | ︙ | |||
1745 1746 1747 1748 1749 1750 1751 | } } proc makeFontWin {} { global Pref TmpPref FontCache destroy .fo | | | 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 | } } proc makeFontWin {} { global Pref TmpPref FontCache destroy .fo toplevel .fo wm title .fo "Select Font" label .fo.ltmp -text "Searching for fonts..." pack .fo.ltmp update idletasks catch {font delete tmpfont} |
︙ | ︙ | |||
1782 1783 1784 1785 1786 1787 1788 | set fam [lsort -dictionary [font families]] font create testfont foreach f $fam { if {[string compare $f ""]} { font configure testfont -family $f if {[font metrics testfont -fixed]} { lappend FontCache $f | | | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 | set fam [lsort -dictionary [font families]] font create testfont foreach f $fam { if {[string compare $f ""]} { font configure testfont -family $f if {[font metrics testfont -fixed]} { lappend FontCache $f } } } font delete testfont } foreach f $FontCache { .fo.lb insert end $f if {![string compare $f $Pref(fontfamily)]} { |
︙ | ︙ | |||
1824 1825 1826 1827 1828 1829 1830 | toplevel .ab wm title .ab "About Diff.tcl" text .ab.t -width 45 -height 8 -wrap word button .ab.b -text "Close" -command "destroy .ab" pack .ab.b -side bottom pack .ab.t -side top -expand y -fill both | | | 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 | toplevel .ab wm title .ab "About Diff.tcl" text .ab.t -width 45 -height 8 -wrap word button .ab.b -text "Close" -command "destroy .ab" pack .ab.b -side bottom pack .ab.t -side top -expand y -fill both .ab.t insert end "A Tcl/Tk frontend to diff\n\n" .ab.t insert end "$diffver\n" .ab.t insert end "Made by Peter Spjuth\n" .ab.t insert end "E-Mail: peter.spjuth@space.se\n\n" } |
︙ | ︙ | |||
1852 1853 1854 1855 1856 1857 1858 | .he.t tag configure new1 -foreground $Pref(colornew1) \ -background $Pref(bgnew1) .he.t tag configure new2 -foreground $Pref(colornew2) \ -background $Pref(bgnew2) .he.t tag configure change -foreground $Pref(colorchange) \ -background $Pref(bgchange) .he.t tag configure ul -underline 1 | | | | 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 | .he.t tag configure new1 -foreground $Pref(colornew1) \ -background $Pref(bgnew1) .he.t tag configure new2 -foreground $Pref(colornew2) \ -background $Pref(bgnew2) .he.t tag configure change -foreground $Pref(colorchange) \ -background $Pref(bgchange) .he.t tag configure ul -underline 1 .he.t insert end {\ } "" {Commands} ul { File Menu Redo Diff : Run diff again on the same files. Open Both : Select two files, run diff. Open Left File : Select a file for left window, run diff Open Right File: Select a file for right window, run diff RCSDiff : (UNIX only) Select one file and diff like rcsdiff. Print : (UNIX only) Experimental print function. It currently creates a postscript file ~/tcldiff.ps Quit : Guess Options Menu |
︙ | ︙ | |||
1906 1907 1908 1909 1910 1911 1912 | } "" {Examples of effects of parse options.} ul { Below are two example files, and five different results when using different options with those files. Left file: Right file: NET '/I$1/N$1454' IC2-15 IC5-7 NET '/I$1/N$1454' IC1-4 IC2-15 IC5-2 IC5-7 | | | | | | | | | | 1960 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 | } "" {Examples of effects of parse options.} ul { Below are two example files, and five different results when using different options with those files. Left file: Right file: NET '/I$1/N$1454' IC2-15 IC5-7 NET '/I$1/N$1454' IC1-4 IC2-15 IC5-2 IC5-7 NET '/I$1/N$1455' IC2-14 IC6-8 NET '/I$1/N$1456' IC2-12 NET '/I$1/N$1456' IC2-13 IC2-12 NET '/I$1/N$1457' IC2-11 IC6-7 NET '/I$1/N$1457' IC2-11 IC6-7 NET '/I$1/N$1458' IC2-9 NET '/I$1/N$1458' IC2-10 } .he.t insert end "Example 1. No parsing.\n" .he.t insert end {1: NET '/I$1/N$1454' IC2-15 IC5-7 1: NET '/I$1/N$1454' IC1-4 IC2-15 IC5-2 IC5-7 } change .he.t insert end {2: NET '/I$1/N$1455' IC2-14 IC6-8 2: NET '/I$1/N$1456' IC2-12 } change .he.t insert end {3: NET '/I$1/N$1456' IC2-13 IC2-12 } change .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: NET '/I$1/N$1458' IC2-10 4: NET '/I$1/N$1458' IC2-9 } change .he.t insert end "\n" .he.t insert end "Example 2. Lines and characters\n" .he.t insert end {1: NET '/I$1/N$1454' IC2-15 IC5-7 1: NET '/I$1/N$1454' IC1-4 IC2-15 IC5-2 IC5-7 } change .he.t insert end {2: NET '/I$1/N$1455' IC2-14 IC6-8 2: NET '/I$1/N$1456' IC2-12 } change .he.t insert end {3: NET '/I$1/N$1456' IC2-13 IC2-12 } change .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" |
︙ | ︙ |