Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changed a lot of == to eq. Added 'see end' to dirdiff's entries. Start tutorial with dirdiff. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
505c82fc6fce92f50c0ecb8c110d95fa |
User & Date: | peter 2004-01-27 23:15:30.000 |
Context
2004-01-28
| ||
19:51 | Entry widgets have 'xview' not 'see'. Updated to 2.0. check-in: 899abc3b4d user: peter tags: trunk | |
2004-01-27
| ||
23:15 | Changed a lot of == to eq. Added 'see end' to dirdiff's entries. Start tutorial with dirdiff. check-in: 505c82fc6f user: peter tags: trunk | |
2004-01-21
| ||
22:25 | Initial revision check-in: e069acddad user: peter tags: trunk | |
Changes
Changes to src/eskil.tcl.
︙ | ︙ | |||
33 34 35 36 37 38 39 | set debug 1 set diffver "Version 2.0b3+ 2004-01-20" set thisScript [file join [pwd] [info script]] set thisDir [file dirname $thisScript] # Follow any link set tmplink $thisScript | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | set debug 1 set diffver "Version 2.0b3+ 2004-01-20" set thisScript [file join [pwd] [info script]] set thisDir [file dirname $thisScript] # Follow any link set tmplink $thisScript while {[file type $tmplink] eq "link"} { set tmplink [file readlink $tmplink] set tmplink [file normalize [file join $thisDir $tmplink]] set thisDir [file dirname $tmplink] } unset tmplink set ::util(cvsExists) [expr {![string equal [auto_execok cvs] ""]}] |
︙ | ︙ | |||
62 63 64 65 66 67 68 | # Are we in a starkit? if {[string match "*/lib/app-eskil" $::thisDir]} { lappend dirs [file dirname [file dirname [file dirname $::thisDir]]] # And for a starpack lappend dirs [file dirname [info nameofexecutable]] } lappend dirs c:/bin | | | | | 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 | # Are we in a starkit? if {[string match "*/lib/app-eskil" $::thisDir]} { lappend dirs [file dirname [file dirname [file dirname $::thisDir]]] # And for a starpack lappend dirs [file dirname [info nameofexecutable]] } lappend dirs c:/bin foreach dir $dirs { set try [file join $dir diff.exe] if {[file exists $try]} { set ::util(diffexe) $try return } } if {[string equal [auto_execok diff] ""]} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not locate any external diff executable." \ -type ok exit } } if {$tcl_platform(platform) eq "windows"} { locateDiffExe # Locate CVS if it is in c:/bin if {!$::util(cvsExists) && [file exists "c:/bin/cvs.exe"]} { set env(PATH) "$env(PATH);c:\\bin" auto_reset set ::util(cvsExists) [expr {![string equal [auto_execok cvs] ""]}] } |
︙ | ︙ | |||
103 104 105 106 107 108 109 | if {$top != "all"} { set i [lsearch $::diff(diffWindows) $top] if {$i >= 0} { set ::diff(diffWindows) [lreplace $::diff(diffWindows) $i $i] } destroy $top array unset ::diff $top,* | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | if {$top != "all"} { set i [lsearch $::diff(diffWindows) $top] if {$i >= 0} { set ::diff(diffWindows) [lreplace $::diff(diffWindows) $i $i] } destroy $top array unset ::diff $top,* # Any windows remaining? if {[llength $::diff(diffWindows)] > 0} { set cont 1 } } } errMsg]} { tk_messageBox -icon error -title "Eskil Error" -message \ |
︙ | ︙ | |||
233 234 235 236 237 238 239 | } } if {$Pref(lineparsewords) != 0 && $test == 0} { set newt $t if {($t > 0 && [string index $s1 [expr {$t - 1}]] != " ") || \ ($i > 0 && [string index $s2 [expr {$i - 1}]] != " ")} { for {} {$newt < $p1} {incr newt} { | | | | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | } } if {$Pref(lineparsewords) != 0 && $test == 0} { set newt $t if {($t > 0 && [string index $s1 [expr {$t - 1}]] != " ") || \ ($i > 0 && [string index $s2 [expr {$i - 1}]] != " ")} { for {} {$newt < $p1} {incr newt} { if {[string index $s1 $newt] eq " "} break } } set newp1 [expr {$p1 - 1}] if {($p1 < $len1 && [string index $s1 $p1] != " ") || \ ($p2 < $len2 && [string index $s2 $p2] != " ")} { for {} {$newp1 > $newt} {incr newp1 -1} { if {[string index $s1 $newp1] eq " "} break } } incr newp1 if {$newp1 - $newt > $minlen} { set foundlen [expr {$newp1 - $newt}] set found1 $newt |
︙ | ︙ | |||
340 341 342 343 344 345 346 | 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 } | | | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | 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 eq " "} { set s $t set flag 1 } } if {$Pref(lineparsewords) == 0 || $test != 0} { incr leftp1 $t |
︙ | ︙ | |||
375 376 377 378 379 380 381 | 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 } | | | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | 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 eq " "} { set s1 $t1 set s2 $t2 set flag 1 } } if {$Pref(lineparsewords) == 1 && $test == 0} { if {$flag >= 2} { |
︙ | ︙ | |||
753 754 755 756 757 758 759 | incr n -1 if {$dotag} { if {$n == 1 && $Pref(marklast)} { lappend new1 last lappend new2 last lappend change last } | | | | 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | incr n -1 if {$dotag} { if {$n == 1 && $Pref(marklast)} { lappend new1 last lappend new2 last lappend change last } if {$i1 eq ""} { $::diff($top,wDiff2) insert end $i2 $new2 } elseif {$i2 eq ""} { $::diff($top,wDiff1) insert end $i1 $new1 } else { $::diff($top,wDiff1) insert end $i1 $change $::diff($top,wDiff2) insert end $i2 $change } set dotag 0 } else { |
︙ | ︙ | |||
788 789 790 791 792 793 794 | global doingLine1 doingLine2 set apa [compareBlocks $block1 $block2] set t1 0 set t2 0 foreach c $apa { | | < | < | < | | 788 789 790 791 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 | global doingLine1 doingLine2 set apa [compareBlocks $block1 $block2] set t1 0 set t2 0 foreach c $apa { if {$c eq "c"} { set textline1 [lindex $block1 $t1] set textline2 [lindex $block2 $t2] insertMatchingLines $top $textline1 $textline2 incr t1 incr t2 } elseif {$c eq "C"} { # This is two lines that the block matching considered # too different to use line parsing on them. # Marked the whole line as deleted/inserted set textline1 [lindex $block1 $t1] set textline2 [lindex $block2 $t2] $::diff($top,wLine1) insert end [myFormL $doingLine1] \ "hl$::HighLightCount change" $::diff($top,wDiff1) insert end "$textline1\n" new1 $::diff($top,wLine2) insert end [myFormL $doingLine2] \ "hl$::HighLightCount change" $::diff($top,wDiff2) insert end "$textline2\n" new2 incr doingLine1 incr doingLine2 incr t1 incr t2 } elseif {$c eq "d"} { set bepa [lindex $block1 $t1] $::diff($top,wLine1) insert end [myFormL $doingLine1] \ "hl$::HighLightCount change" $::diff($top,wDiff1) insert end "$bepa\n" new1 emptyLine $top 2 incr doingLine1 incr t1 } elseif {$c eq "a"} { set bepa [lindex $block2 $t2] $::diff($top,wLine2) insert end [myFormL $doingLine2] \ "hl$::HighLightCount change" $::diff($top,wDiff2) insert end "$bepa\n" new2 emptyLine $top 1 incr doingLine2 incr t2 |
︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 | set rightName "" set leftName "" while {[gets $ch line] != -1} { if {[string match <<<<<<* $line]} { set state right regexp {<*\s*(.*)} $line -> rightName set start2 $rightLine | | | | | | | 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 | set rightName "" set leftName "" while {[gets $ch line] != -1} { if {[string match <<<<<<* $line]} { set state right regexp {<*\s*(.*)} $line -> rightName set start2 $rightLine } elseif {[string match ======* $line] && $state eq "right"} { set state left set end2 [expr {$rightLine - 1}] set start1 $leftLine } elseif {[string match >>>>>>* $line] && $state eq "left"} { set state both regexp {>*\s*(.*)} $line -> leftName set end1 [expr {$leftLine - 1}] lappend diff($top,conflictDiff) $start1,${end1}c$start2,$end2 } elseif {$state eq "both"} { puts $ch1 $line puts $ch2 $line incr leftLine incr rightLine } elseif {$state eq "left"} { puts $ch1 $line incr leftLine } else { puts $ch2 $line incr rightLine } } close $ch close $ch1 close $ch2 if {$leftName eq "" && $rightName eq ""} { set leftName "No Conflict: [file tail $diff($top,conflictFile)]" set rightName $leftName } set diff($top,leftLabel) $leftName set diff($top,rightLabel) $rightName update idletasks } |
︙ | ︙ | |||
1214 1215 1216 1217 1218 1219 1220 | } set leftLines {} set rightLines {} set state none continue } # Detect the first line in a -c style diff | | | | | | | | | 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | } set leftLines {} set rightLines {} set state none continue } # Detect the first line in a -c style diff if {$state eq "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 eq "none" && [regexp {^---} $line]} { set state newfile set style u set leftRE {^---\s+(.*)$} set rightRE {^\+\+\+\s+(.*)$} } if {$state eq "newfile" && [regexp $leftRE $line -> sub]} { emptyLine $top 1 insertLine $top 1 "" $divider insertLine $top 1 "" $sub insertLine $top 1 "" $divider lappend ::diff($top,changes) [list $::diff($top,mapMax) 4 \ change 0 0 0 0] incr ::diff($top,mapMax) 4 continue } if {$state eq "newfile" && [regexp $rightRE $line -> sub]} { emptyLine $top 2 insertLine $top 2 "" $divider insertLine $top 2 "" $sub insertLine $top 2 "" $divider continue } # A new section in a -u style diff if {[regexp {^@@\s+-(\d+),\d+\s+\+(\d+),} $line -> sub1 sub2]} { if {$state eq "both"} { displayOnePatch $top $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 eq "right"} { displayOnePatch $top $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 eq "left"} { if {[regexp {^\*\*\*\s*(\d*)} $line -> sub]} { if {$sub != ""} { set leftLine $sub } continue } if {[regexp {^---\s*(\d*)} $line -> sub]} { |
︙ | ︙ | |||
1290 1291 1292 1293 1294 1295 1296 | 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 | | | | | | 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 | 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 eq "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 eq "both"} { if {![regexp {^[\s+-]} $line]} continue set sig [string trim [string index $line 0]] set str [string range $line 1 end] if {$sig eq ""} { lappend leftLines [list $leftLine "" $str] lappend rightLines [list $leftLine "" $str] incr leftLine incr rightLine } elseif {$sig eq "-"} { lappend leftLines [list $leftLine "-" $str] incr leftLine } else { lappend rightLines [list $leftLine "+" $str] incr rightLine } continue |
︙ | ︙ | |||
1371 1372 1373 1374 1375 1376 1377 | switch [llength $revs] { 0 { # Compare local file with latest version. set diff($top,leftFile) [tmpFile] set diff($top,rightLabel) $diff($top,RCSFile) set diff($top,rightFile) $diff($top,RCSFile) | | | | | 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 | switch [llength $revs] { 0 { # Compare local file with latest version. set diff($top,leftFile) [tmpFile] set diff($top,rightLabel) $diff($top,RCSFile) set diff($top,rightFile) $diff($top,RCSFile) if {$diff($top,mode) eq "CVS"} { set diff($top,leftLabel) "$diff($top,RCSFile) (CVS)" execCvsUpdate $diff($top,RCSFile) $diff($top,leftFile) } else { set diff($top,leftLabel) "$diff($top,RCSFile) (RCS)" catch {exec co -p [file nativename $diff($top,RCSFile)] \ > $diff($top,leftFile)} } } 1 { # Compare local file with specified version. set r [lindex $revs 0] set diff($top,leftFile) [tmpFile] set diff($top,rightLabel) $diff($top,RCSFile) set diff($top,rightFile) $diff($top,RCSFile) if {$diff($top,mode) eq "CVS"} { set diff($top,leftLabel) "$diff($top,RCSFile) (CVS $r)" execCvsUpdate $diff($top,RCSFile) $diff($top,leftFile) -r $r } else { set diff($top,leftLabel) "$diff($top,RCSFile) (RCS $r)" catch {exec co -p$r [file nativename $diff($top,RCSFile)] \ > $diff($top,leftFile)} } } default { # Compare the two specified versions. set r1 [lindex $revs 0] set r2 [lindex $revs 1] set diff($top,leftFile) [tmpFile] set diff($top,rightFile) [tmpFile] if {$diff($top,mode) eq "CVS"} { set diff($top,leftLabel) "$diff($top,RCSFile) (CVS $r1)" set diff($top,rightLabel) "$diff($top,RCSFile) (CVS $r2)" execCvsUpdate $diff($top,RCSFile) $diff($top,leftFile) -r $r1 execCvsUpdate $diff($top,RCSFile) $diff($top,rightFile) -r $r2 } else { set diff($top,leftLabel) "$diff($top,RCSFile) (RCS $r1)" set diff($top,rightLabel) "$diff($top,RCSFile) (RCS $r2)" |
︙ | ︙ | |||
1441 1442 1443 1444 1445 1446 1447 | # Compare local file with latest version. set diff($top,leftFile) [tmpFile] set diff($top,rightLabel) $diff($top,RCSFile) set diff($top,rightFile) $diff($top,RCSFile) set diff($top,leftLabel) "$diff($top,RCSFile) (CT)" | | | | | 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 | # Compare local file with latest version. set diff($top,leftFile) [tmpFile] set diff($top,rightLabel) $diff($top,RCSFile) set diff($top,rightFile) $diff($top,RCSFile) set diff($top,leftLabel) "$diff($top,RCSFile) (CT)" if {[catch {exec cleartool pwv -s} view] || $view eq "** NONE **"} { puts "MIFFFO" return } if {[catch {exec cleartool get -to $diff($top,leftFile) [file nativename $diff($top,RCSFile)@@/main/$view/LATEST]} msg]} { puts "Cleartool error: $msg" return } } # Prepare for a diff by creating needed temporary files proc prepareFiles {top} { set ::diff($top,cleanup) "" if {$::diff($top,mode) eq "RCS" || $::diff($top,mode) eq "CVS"} { prepareRCS $top set ::diff($top,cleanup) "RCS" } elseif {$::diff($top,mode) eq "CT"} { prepareClearCase $top set ::diff($top,cleanup) "CT" } elseif {[string match "conflict*" $::diff($top,mode)]} { prepareConflict $top set ::diff($top,cleanup) "conflict" } elseif {[lindex [file system $::diff($top,leftFile)] 0] ne "native" || \ [lindex [file system $::diff($top,rightFile)] 0] ne "native"} { |
︙ | ︙ | |||
1495 1496 1497 1498 1499 1500 1501 | } # Main diff function. proc doDiff {top} { global diff Pref global doingLine1 doingLine2 | | | 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 | } # Main diff function. proc doDiff {top} { global diff Pref global doingLine1 doingLine2 if {$diff($top,mode) eq "" && ($diff($top,leftOK) == 0 || $diff($top,rightOK) == 0)} { disableRedo $top return } else { enableRedo $top } busyCursor $top |
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 | drawMap $top -1 # Display a star during diff execution, to know when the internal # processing starts, and when the label is "valid". set ::diff($top,eqLabel) "*" update idletasks | | | 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 | drawMap $top -1 # Display a star during diff execution, to know when the internal # processing starts, and when the label is "valid". set ::diff($top,eqLabel) "*" update idletasks if {$diff($top,mode) eq "patch"} { displayPatch $top drawMap $top -1 foreach item {wLine1 wLine2} { set w $::diff($top,$item) $w configure -state disabled } update idletasks |
︙ | ︙ | |||
1556 1557 1558 1559 1560 1561 1562 | lappend result $i } } # In conflict mode we can use the diff information collected when # parsing the conflict file. This makes sure the blocks in the conflict # file become change-blocks during merge. | | | 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 | lappend result $i } } # In conflict mode we can use the diff information collected when # parsing the conflict file. This makes sure the blocks in the conflict # file become change-blocks during merge. if {$diff($top,mode) eq "conflictPure"} { set result $diff($top,conflictDiff) } if {[llength $result] == 0} { if {$differr == 1} { $::diff($top,wDiff1) insert end $diffres normalCursor $top |
︙ | ︙ | |||
1578 1579 1580 1581 1582 1583 1584 | # Update the equal label immediately for better feedback update idletasks set firstview 1 set ch1 [open $diff($top,leftFile)] set ch2 [open $diff($top,rightFile)] | | | 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 | # Update the equal label immediately for better feedback update idletasks set firstview 1 set ch1 [open $diff($top,leftFile)] set ch2 [open $diff($top,rightFile)] if {$::tcl_platform(platform) eq "windows" && $Pref(crlf)} { fconfigure $ch1 -translation crlf fconfigure $ch2 -translation crlf } set doingLine1 1 set doingLine2 1 set t 0 foreach i $result { |
︙ | ︙ | |||
1743 1744 1745 1746 1747 1748 1749 | set change [lindex $::diff($top,changes) $::diff($top,currHighLight)] set line1 [lindex $change 0] if {$::diff($top,currHighLight) < 0} { set line1 1.0 set line2 1.0 | | | 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 | set change [lindex $::diff($top,changes) $::diff($top,currHighLight)] set line1 [lindex $change 0] if {$::diff($top,currHighLight) < 0} { set line1 1.0 set line2 1.0 } elseif {$line1 eq ""} { set line1 end set line2 end } else { set line2 [expr {$line1 + [lindex $change 1]}] incr line1 set line1 $line1.0 set line2 $line2.0 |
︙ | ︙ | |||
1769 1770 1771 1772 1773 1774 1775 | # A wrapper for tk_getOpenFile proc myOpenFile {args} { # When in tutorial mode, make sure the Tcl file dialog is used # to be able to access the files in a starkit. if {[info exists ::diff(tutorial)] && $::diff(tutorial)} { # Only do this if tk_getOpenFile is not a proc. | | | 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 | # A wrapper for tk_getOpenFile proc myOpenFile {args} { # When in tutorial mode, make sure the Tcl file dialog is used # to be able to access the files in a starkit. if {[info exists ::diff(tutorial)] && $::diff(tutorial)} { # Only do this if tk_getOpenFile is not a proc. if {[info procs tk_getOpenFile] eq ""} { # If there is any problem, call the real one if {![catch {set res [eval ::tk::dialog::file:: open $args]}]} { return $res } } } return [eval tk_getOpenFile $args] |
︙ | ︙ | |||
1944 1945 1946 1947 1948 1949 1950 | set leftMergeData {} set rightMergeData {} if {![info exists ::diff($top,changes)]} { set ::diff($top,changes) {} } | | | 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 | set leftMergeData {} set rightMergeData {} if {![info exists ::diff($top,changes)]} { set ::diff($top,changes) {} } if {$diff($top,mode) eq "RCS" || $diff($top,mode) eq "CVS"} { prepareRCS $top } elseif {[string match "conflict*" $diff($top,mode)]} { prepareConflict $top } set ch1 [open $diff($top,leftFile) r] set ch2 [open $diff($top,rightFile) r] |
︙ | ︙ | |||
2005 2006 2007 2008 2009 2010 2011 | } lappend leftMergeData $data1 lappend rightMergeData $data2 close $ch1 close $ch2 | | | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 | } lappend leftMergeData $data1 lappend rightMergeData $data2 close $ch1 close $ch2 if {$diff($top,mode) eq "RCS" || $diff($top,mode) eq "CVS"} { cleanupRCS $top } elseif {[string match "conflict*" $diff($top,mode)]} { cleanupConflict $top } } # Fill up the merge window with the initial version of merged files. |
︙ | ︙ | |||
2113 2114 2115 2116 2117 2118 2119 | # Save the merge result. proc saveMerge {top} { global diff set w $top.merge.t | | | | 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 | # Save the merge result. proc saveMerge {top} { global diff set w $top.merge.t if {$diff($top,mergeFile) eq ""} { if {[info exists diff($top,rightDir)]} { set initDir $diff($top,rightDir) } elseif {[info exists diff($top,leftDir)]} { set initDir $diff($top,leftDir) } else { set initDir [pwd] } set apa [tk_getSaveFile -title "Save merge file" -initialdir $initDir] if {$apa eq ""} return set diff($top,mergeFile) $apa } set ch [open $diff($top,mergeFile) "w"] puts -nonewline $ch [$w get 1.0 end-1char] close $ch tk_messageBox -parent $top.merge -icon info -type ok -title "Diff" \ |
︙ | ︙ | |||
2218 2219 2220 2221 2222 2223 2224 | # Format a line number for printing proc formatLineno {lineno gray} { set res [format "%3d: " $lineno] if {[string length $res] > 5} { set res [string range $res end-5 end-1] } | | | | | | | | | | | | 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 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 | # Format a line number for printing proc formatLineno {lineno gray} { set res [format "%3d: " $lineno] if {[string length $res] > 5} { set res [string range $res end-5 end-1] } if {$gray eq "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 eq "tagon"} { if {$value eq "change"} { set gray $::grayLevel1 } elseif {[string match "new*" $value]} { set gray $::grayLevel2 } } elseif {$key eq "tagoff"} { if {$value eq "change" || [string match "new*" $value]} { set gray 1.0 } } elseif {$key eq "text"} { append line $value if {[string index $value end] eq "\n"} { set line [string trim [string trim $line] :] if {$line eq ""} { 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 eq "1.0"} { return "\n " } else { return "\0bggray\{1.0\}\n \0bggray\{$gray\}" } } # Prepare a text block for printing proc fixTextBlock {text index} { # Remove any form feed if {[regsub -all "\f" $text {} apa]} { set text $apa } regexp {\d+\.(\d+)} $index -> index # Expand tabs to 8 chars while 1 { set i [string first \t $text] if {$i eq -1} break set n [expr {(- $i - $index - 1) % 8 + 1}] set text [string replace $text $i $i [format %${n}s ""]] } return $text } # Main print function |
︙ | ︙ | |||
2328 2329 2330 2331 2332 2333 2334 | append line "\0bggray\{$gray\}" set chars 0 set wrapc 0 } switch $key { text { set value [fixTextBlock $value $index] | | | | 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 | append line "\0bggray\{$gray\}" set chars 0 set wrapc 0 } switch $key { text { set value [fixTextBlock $value $index] if {[string index $value end] eq "\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] } append line $value incr chars $len } tagon { if {$value eq "change"} { set gray $::grayLevel1 append line "\0bggray\{$gray\}" } elseif {$value != "last"} { set gray $::grayLevel2 append line "\0bggray\{$gray\}" } } |
︙ | ︙ | |||
2415 2416 2417 2418 2419 2420 2421 | puts $ch [lindex $wraplines2 $i2] } if {$i < 66} {puts -nonewline $ch "\f"} } close $ch | | | 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 | puts $ch [lindex $wraplines2 $i2] } if {$i < 66} {puts -nonewline $ch "\f"} } close $ch if {$::tcl_platform(platform) eq "windows" &&\ ![info exists ::env(ENSCRIPT_LIBRARY)]} { set ::env(ENSCRIPT_LIBRARY) [pwd] } set enscriptCmd [list enscript -2jcre] if {![regexp {^(.*)( \(.*?\))$} $::diff($top,leftLabel) -> lfile lrest]} { set lfile $::diff($top,leftLabel) set lrest "" |
︙ | ︙ | |||
2701 2702 2703 2704 2705 2706 2707 | } proc hlSeparate {top n hl} { set ::diff($top,separate$n) $hl set wd $::diff($top,wDiff$n) set wl $::diff($top,wLine$n) | | | 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 | } proc hlSeparate {top n hl} { set ::diff($top,separate$n) $hl set wd $::diff($top,wDiff$n) set wl $::diff($top,wLine$n) if {$hl eq ""} { set range [$wd tag ranges sel] } else { set range [$wl tag ranges hl$::diff($top,separate$n)] } set text [eval $wd get $range] set ::diff($top,separatetext$n) $text |
︙ | ︙ | |||
2826 2827 2828 2829 2830 2831 2832 | -background $Pref(bgchange) $top.balloon.t$x tag configure new2 -foreground $Pref(colornew2) \ -background $Pref(bgnew2) pack $top.balloon.t$x -side "top" -padx 1 -pady 1 -fill both -expand 1 set tags {} foreach {key value index} $data($x) { | | | | 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 | -background $Pref(bgchange) $top.balloon.t$x tag configure new2 -foreground $Pref(colornew2) \ -background $Pref(bgnew2) pack $top.balloon.t$x -side "top" -padx 1 -pady 1 -fill both -expand 1 set tags {} foreach {key value index} $data($x) { if {$key eq "tagon"} { lappend tags $value set tags [lsort -unique $tags] } elseif {$key eq "tagoff"} { set i [lsearch $tags $value] if {$i >= 0} { set tags [lreplace $tags $i $i] } } else { $top.balloon.t$x insert end $value $tags } |
︙ | ︙ | |||
2895 2896 2897 2898 2899 2900 2901 | } # Change color settings proc applyColor {} { global diff dirdiff Pref foreach top $diff(diffWindows) { | | | 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 | } # Change color settings proc applyColor {} { global diff dirdiff Pref foreach top $diff(diffWindows) { if {$top eq ".clipdiff"} continue if {$top != ".dirdiff"} { foreach item {wLine1 wDiff1 wLine2 wDiff2} { set w $diff($top,$item) $w tag configure new1 -foreground $Pref(colornew1) \ -background $Pref(bgnew1) $w tag configure change -foreground $Pref(colorchange) \ |
︙ | ︙ | |||
3031 3032 3033 3034 3035 3036 3037 | update doDiff $top } # Build the main window proc makeDiffWin {{top {}}} { global Pref tcl_platform debug | | | | 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 | update doDiff $top } # Build the main window proc makeDiffWin {{top {}}} { global Pref tcl_platform debug if {$top != "" && [winfo exists $top] && [winfo toplevel $top] eq $top} { # Reuse the old window eval destroy [winfo children $top] } else { # Locate a free toplevel name if {[info exists ::diff(topDiffCnt)]} { set t $::diff(topDiffCnt) } else { |
︙ | ︙ | |||
3056 3057 3058 3059 3060 3061 3062 | wm title $top "Eskil" wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top] frame $top.f grid $top.f -row 0 -columnspan 4 -sticky news | | | 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 | wm title $top "Eskil" wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top] frame $top.f grid $top.f -row 0 -columnspan 4 -sticky news if {$tcl_platform(platform) eq "windows"} { #frame $top.f.line -height 1 -bg SystemButtonHighlight #pack $top.f.line -side bottom -fill x } menubutton $top.mf -text "File" -underline 0 -menu $top.mf.m menu $top.mf.m $top.mf.m add command -label "Redo Diff" -underline 5 \ |
︙ | ︙ | |||
3081 3082 3083 3084 3085 3086 3087 | -command [list openLeft $top] $top.mf.m add command -label "Open Right File..." \ -command [list openRight $top] $top.mf.m add command -label "Open Conflict File..." \ -command [list openConflict $top] $top.mf.m add command -label "Open Patch File..." \ -command [list openPatch $top] | | | 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 | -command [list openLeft $top] $top.mf.m add command -label "Open Right File..." \ -command [list openRight $top] $top.mf.m add command -label "Open Conflict File..." \ -command [list openConflict $top] $top.mf.m add command -label "Open Patch File..." \ -command [list openPatch $top] if {$tcl_platform(platform) eq "unix"} { $top.mf.m add command -label "RCSDiff..." -underline 0 \ -command [list openRCS $top] } if {$::util(cvsExists)} { $top.mf.m add command -label "CVSDiff..." -underline 1 \ -command [list openCVS $top] } |
︙ | ︙ | |||
3106 3107 3108 3109 3110 3111 3112 | menubutton $top.mo -text "Options" -underline 0 -menu $top.mo.m menu $top.mo.m $top.mo.m add cascade -label "Font" -underline 0 -menu $top.mo.mf $top.mo.m add cascade -label "Ignore" -underline 0 -menu $top.mo.mi $top.mo.m add cascade -label "Parse" -underline 0 -menu $top.mo.mp $top.mo.m add command -label "Colours..." -underline 0 -command makePrefWin $top.mo.m add checkbutton -label "Diffs only" -variable Pref(onlydiffs) | | | 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 | menubutton $top.mo -text "Options" -underline 0 -menu $top.mo.m menu $top.mo.m $top.mo.m add cascade -label "Font" -underline 0 -menu $top.mo.mf $top.mo.m add cascade -label "Ignore" -underline 0 -menu $top.mo.mi $top.mo.m add cascade -label "Parse" -underline 0 -menu $top.mo.mp $top.mo.m add command -label "Colours..." -underline 0 -command makePrefWin $top.mo.m add checkbutton -label "Diffs only" -variable Pref(onlydiffs) if {$tcl_platform(platform) eq "windows"} { $top.mo.m add checkbutton -label "Force crlf translation" \ -variable Pref(crlf) } $top.mo.m add separator $top.mo.m add command -label "Save default" -command saveOptions menu $top.mo.mf |
︙ | ︙ | |||
3171 3172 3173 3174 3175 3176 3177 | -command makeDirDiffWin $top.mt.m add command -label "Clip Diff" -underline 0 \ -command makeClipDiffWin $top.mt.m add command -label "Merge" -underline 0 \ -command [list makeMergeWin $top] -state disabled $top.mt.m add command -label "Align" -command [list runAlign $top] \ -state disabled | | | 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 | -command makeDirDiffWin $top.mt.m add command -label "Clip Diff" -underline 0 \ -command makeClipDiffWin $top.mt.m add command -label "Merge" -underline 0 \ -command [list makeMergeWin $top] -state disabled $top.mt.m add command -label "Align" -command [list runAlign $top] \ -state disabled if {$::tcl_platform(platform) eq "windows"} { if {![catch {package require registry}]} { $top.mt.m add separator $top.mt.m add command -label "Setup Registry" -underline 6 \ -command makeRegistryWin } } |
︙ | ︙ | |||
3280 3281 3282 3283 3284 3285 3286 | grid $top.l1 $top.le - $top.l2 -row 1 -sticky news grid $top.ft1 $top.c $top.sby $top.ft2 -row 2 -sticky news grid $top.sbx1 $top.ls - $top.sbx2 -row 3 -sticky news grid columnconfigure $top {0 3} -weight 1 grid rowconfigure $top 2 -weight 1 grid $top.c -pady [expr {[$top.sby cget -width] + 2}] grid $top.ls -sticky "" | | | | 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 | grid $top.l1 $top.le - $top.l2 -row 1 -sticky news grid $top.ft1 $top.c $top.sby $top.ft2 -row 2 -sticky news grid $top.sbx1 $top.ls - $top.sbx2 -row 3 -sticky news grid columnconfigure $top {0 3} -weight 1 grid rowconfigure $top 2 -weight 1 grid $top.c -pady [expr {[$top.sby cget -width] + 2}] grid $top.ls -sticky "" image create photo map$top $top.c create image 0 0 -anchor nw -image map$top bind $top.c <Destroy> [list image delete map$top] bind $top.c <Configure> [list drawMap $top %h] bind $top <Key-Up> [list scrollText $top -1 u] bind $top <Key-Down> [list scrollText $top 1 u] bind $top <Key-Prior> [list scrollText $top -1 p] bind $top <Key-Next> [list scrollText $top 1 p] bind $top <Key-Escape> [list focus $top] pack $top.mf $top.mo $top.ms $top.mt -in $top.f -side left -anchor n pack $top.mh -in $top.f -side left -anchor n pack $top.bfn -in $top.f -side right -padx {3 6} pack $top.bfp $top.er2 $top.lr2 $top.er1 $top.lr1 $top.eo $top.lo \ -in $top.f -side right -padx 3 if {$debug == 1} { menubutton $top.md -text "Debug" -menu $top.md.m -underline 0 menu $top.md.m if {$tcl_platform(platform) eq "windows"} { $top.md.m add checkbutton -label "Console" -variable consolestate \ -onvalue show -offvalue hide \ -command {console $consolestate} $top.md.m add separator } $top.md.m add radiobutton -label "Context 2" \ -variable ::Pref(context) -value 2 |
︙ | ︙ | |||
3455 3456 3457 3458 3459 3460 3461 | chFont } # Update example font proc exampleFont {lb} { global TmpPref set i [lindex [$lb curselection] 0] | | | 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 | chFont } # Update example font proc exampleFont {lb} { global TmpPref set i [lindex [$lb curselection] 0] if {$i eq ""} return set TmpPref(fontfamily) [$lb get $i] font configure tmpfont -family $TmpPref(fontfamily) if {[string is integer -strict $TmpPref(fontsize)]} { font configure tmpfont -size $TmpPref(fontsize) } } |
︙ | ︙ | |||
3575 3576 3577 3578 3579 3580 3581 | if {[regexp {^(.*wish)\d+\.exe$} $exe -> pre]} { set alt $pre.exe if {[file exists $alt]} { set a [tk_messageBox -icon question -title "Which Wish" -message \ "Would you prefer to use the executable\n\ \"$alt\"\ninstead of\n\ \"$exe\"\nin the registry settings?" -type yesno] | | | | 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 | if {[regexp {^(.*wish)\d+\.exe$} $exe -> pre]} { set alt $pre.exe if {[file exists $alt]} { set a [tk_messageBox -icon question -title "Which Wish" -message \ "Would you prefer to use the executable\n\ \"$alt\"\ninstead of\n\ \"$exe\"\nin the registry settings?" -type yesno] if {$a eq "yes"} { set exe $alt } } } set top .reg destroy $top toplevel $top wm title $top "Register Eskil" # Registry keys #set keyg {HKEY_CLASSES_ROOT\Folder\shell\Grep\command} set keydd {HKEY_CLASSES_ROOT\Folder\shell\Diff\command} set keyd {HKEY_CLASSES_ROOT\*\shell\Diff\command} set keyc {HKEY_CLASSES_ROOT\*\shell\DiffC\command} set keye {HKEY_CLASSES_ROOT\*\shell\Emacs\command} # Are we in a starkit? if {[info exists ::starkit::topdir]} { # In a starpack ? set exe [file normalize $exe] if {[string equal [file normalize $::starkit::topdir] $exe]} { set myexe [list $exe] } else { |
︙ | ︙ | |||
3652 3653 3654 3655 3656 3657 3658 | ##################################### # Directory diff section ##################################### # Compare file names proc FStrCmp {s1 s2} { # On Unix filenames are case sensitive | | | | 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 | ##################################### # Directory diff section ##################################### # Compare file names proc FStrCmp {s1 s2} { # On Unix filenames are case sensitive if {$::tcl_platform(platform) eq "unix"} { return [string compare $s1 $s2] } string compare -nocase $s1 $s2 } # Sort file names proc Fsort {l} { if {$::tcl_platform(platform) eq "unix"} { return [lsort $l] } # Case insensitive on windows lsort -dictionary $l } # Compare two files |
︙ | ︙ | |||
3686 3687 3688 3689 3690 3691 3692 | return 0 } # If contents is not checked, same size is enough to be equal if {$stat1(size) == $stat2(size) && $Pref(comparelevel) == 0} { return 1 } # Different size is enough when doing binary compare | | | 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 | return 0 } # If contents is not checked, same size is enough to be equal if {$stat1(size) == $stat2(size) && $Pref(comparelevel) == 0} { return 1 } # Different size is enough when doing binary compare if {$stat1(size) != $stat2(size) && $Pref(comparelevel) eq "1b"} { return 0 } # Same size and time is always considered equal if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} { return 1 } # Don't check further if contents should not be checked |
︙ | ︙ | |||
3709 3710 3711 3712 3713 3714 3715 | switch $Pref(comparelevel) { 1b - 1 { # Check contents internally set bufsz 65536 set eq 1 set ch1 [open $file1 r] set ch2 [open $file2 r] | | | 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 | switch $Pref(comparelevel) { 1b - 1 { # Check contents internally set bufsz 65536 set eq 1 set ch1 [open $file1 r] set ch2 [open $file2 r] if {$Pref(comparelevel) eq "1b"} { fconfigure $ch1 -translation binary fconfigure $ch2 -translation binary } while {![eof $ch1] && ![eof $ch2]} { set f1 [read $ch1 $bufsz] set f2 [read $ch2 $bufsz] if {![string equal $f1 $f2]} { |
︙ | ︙ | |||
3765 3766 3767 3768 3769 3770 3771 | return } } lappend dirdiff(leftFiles) $df1 lappend dirdiff(rightFiles) $df2 set info [expr {$diff? 16 : 0}] | | | | 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 | return } } lappend dirdiff(leftFiles) $df1 lappend dirdiff(rightFiles) $df2 set info [expr {$diff? 16 : 0}] if {$df1 eq ""} { incr info 1 } if {$df2 eq ""} { incr info 2 } if {$df1 != ""} { set f1 [file split $df1] set i [expr {[llength $f1] - $level - 1}] set f1 [eval file join [lrange $f1 $i end]] } |
︙ | ︙ | |||
3791 3792 3793 3794 3795 3796 3797 | incr info 4 } if {[file isdirectory $df2]} { append f2 / incr info 8 } | | | | | | 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 | incr info 4 } if {[file isdirectory $df2]} { append f2 / incr info 8 } if {$df1 eq ""} { set tag2 new2 } elseif {!$diff} { set tag2 "" } else { if {$info & 8} { set tag2 changed } else { set tag2 change } } if {$df2 eq ""} { set tag1 new1 } elseif {!$diff} { set tag1 "" } else { if {$info & 4} { set tag1 changed } else { set tag1 change } } if {$df2 eq ""} { $dirdiff(wRight) insert end \n } else { if {[catch {set size [file size $df2]}]} { set size -1 set mtime 0 lappend tag2 invalid } else { set mtime [file mtime $df2] } $dirdiff(wRight) insert end [format "%-30s %8d %16s\n" \ $f2 $size \ [clock format $mtime -format "%Y-%m-%d %H:%M"]] \ $tag2 } if {$df1 eq ""} { $dirdiff(wLeft) insert end \n } else { if {[catch {set size [file size $df1]}]} { set size -1 set mtime 0 lappend tag1 invalid } else { |
︙ | ︙ | |||
3877 3878 3879 3880 3881 3882 3883 | if {$apa == 0} { set apa [expr {- [file isdirectory $df1] \ + [file isdirectory $df2]}] } switch -- $apa { 0 { set diff [expr {![compareFiles $df1 $df2]}] | | | | 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 | if {$apa == 0} { set apa [expr {- [file isdirectory $df1] \ + [file isdirectory $df2]}] } switch -- $apa { 0 { set diff [expr {![compareFiles $df1 $df2]}] if {$diff || !$Pref(dir,onlydiffs)} { listFiles $df1 $df2 $diff $level } if {[file isdirectory $df1] && [file isdirectory $df2] && \ $Pref(recursive) && [file tail $df1] != "CVS"} { compareDirs $df1 $df2 [expr {$level + 1}] } incr p1 incr p2 } -1 { listFiles $df1 "" 0 $level incr p1 } 1 { listFiles "" $df2 0 $level incr p2 } } } elseif {$p1 < $len1 && $p2 >= $len2} { set f1 [lindex $files1 $p1] |
︙ | ︙ | |||
3927 3928 3929 3930 3931 3932 3933 | busyCursor .dirdiff update idletasks compareDirs $dirdiff(leftDir) $dirdiff(rightDir) normalCursor .dirdiff } # Pick a directory for compare | | > | | 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 | busyCursor .dirdiff update idletasks compareDirs $dirdiff(leftDir) $dirdiff(rightDir) normalCursor .dirdiff } # Pick a directory for compare proc browseDir {dirVar entryW} { global Pref upvar "#0" $dirVar dir set newdir $dir while {$newdir != "." && ![file isdirectory $newdir]} { set newdir [file dirname $newdir] } set newdir [tk_chooseDirectory -initialdir $newdir -title "Select Directory"] if {$newdir != ""} { set dir $newdir $entryW see end } if {$Pref(autocompare)} doCompare } # This is called when double clicking on a file in # the directory compare window proc selectFile {w x y} { global dirdiff Pref set row [expr {int([$w index @$x,$y]) - 1}] set lf [lindex $dirdiff(leftFiles) $row] set rf [lindex $dirdiff(rightFiles) $row] |
︙ | ︙ | |||
3999 4000 4001 4002 4003 4004 4005 | [list set dirdiff(rightDir) $rf] [list if \$Pref(autocompare) "after idle doCompare"] " } elseif {($i & 3) == 0} { # Both exists $m add command -label "Compare Files" -command [list \ newDiff $lf $rf] } | | | | | | | | | | | | | 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 | [list set dirdiff(rightDir) $rf] [list if \$Pref(autocompare) "after idle doCompare"] " } elseif {($i & 3) == 0} { # Both exists $m add command -label "Compare Files" -command [list \ newDiff $lf $rf] } if {$w eq $dirdiff(wLeft) && ($i & 13) == 0} { $m add command -label "Copy File" \ -command [list copyFile $row right] $m add command -label "Edit File" \ -command [list editFile $row left] } if {$w eq $dirdiff(wRight) && ($i & 14) == 0} { $m add command -label "Copy File" \ -command [list copyFile $row left] $m add command -label "Edit File" \ -command [list editFile $row right] } tk_popup $m $X $Y } # Copy a file from one directory to the other proc copyFile {row to} { global dirdiff Pref if {$to eq "left"} { set src [lindex $dirdiff(rightFiles) $row] set n [expr {[string length $dirdiff(rightDir)] + 1}] set dst [file join $dirdiff(leftDir) [string range $src $n end]] } elseif {$to eq "right"} { set src [lindex $dirdiff(leftFiles) $row] set n [expr {[string length $dirdiff(leftDir)] + 1}] set dst [file join $dirdiff(rightDir) [string range $src $n end]] } else { error "Bad to argument to copyFile: $to" } if {[file exists $dst]} { if {[tk_messageBox -icon question -title "Overwrite file?" -message \ "Copy\n$src\noverwriting\n$dst ?" -type yesno] eq "yes"} { file copy -force $src $dst } } else { if {[tk_messageBox -icon question -title "Copy file?" -message \ "Copy\n$src\nto\n$dst ?" -type yesno] eq "yes"} { file copy $src $dst } } } # Bring up an editor to display a file. proc editFile {row from} { global dirdiff Pref if {$from eq "left"} { set src [file join $dirdiff(leftDir) [lindex $dirdiff(leftFiles) $row]] } elseif {$from eq "right"} { set src [file join $dirdiff(rightDir) [lindex $dirdiff(rightFiles) $row]] } else { error "Bad from argument to editFile: $from" } locateEditor ::util(editor) exec $::util(editor) $src & } # Go up one level in directory hierarchy. # 0 = both proc upDir {{n 0}} { global dirdiff Pref switch $n { 0 { set dirdiff(leftDir) [file dirname $dirdiff(leftDir)] set dirdiff(rightDir) [file dirname $dirdiff(rightDir)] if {$Pref(autocompare)} doCompare } 1 { set dirdiff(leftDir) [file dirname $dirdiff(leftDir)] if {$Pref(autocompare)} doCompare } 2 { set dirdiff(rightDir) [file dirname $dirdiff(rightDir)] if {$Pref(autocompare)} doCompare } } } # Create directory diff window. proc makeDirDiffWin {{redraw 0}} { global Pref dirdiff set top .dirdiff if {[winfo exists $top] && [winfo toplevel $top] eq $top} { if {$redraw} { eval destroy [winfo children $top] } else { raise $top focus -force $top return } |
︙ | ︙ | |||
4142 4143 4144 4145 4146 4147 4148 | -label "Diff, ignore case" $top.mo.mc add radiobutton -variable Pref(comparelevel) -value 5 \ -label "Diff, ignore RCS" pack $top.mf $top.mo -in $top.fm -side left -anchor n if {$::debug} { menubutton $top.md -text "Debug" -menu $top.md.m -underline 0 menu $top.md.m | | | 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 | -label "Diff, ignore case" $top.mo.mc add radiobutton -variable Pref(comparelevel) -value 5 \ -label "Diff, ignore RCS" pack $top.mf $top.mo -in $top.fm -side left -anchor n if {$::debug} { menubutton $top.md -text "Debug" -menu $top.md.m -underline 0 menu $top.md.m if {$::tcl_platform(platform) eq "windows"} { $top.md.m add checkbutton -label "Console" -variable consolestate \ -onvalue show -offvalue hide -command {console $consolestate} $top.md.m add separator } $top.md.m add command -label "Reread Source" -underline 0 \ -command {source $thisScript} $top.md.m add separator |
︙ | ︙ | |||
4167 4168 4169 4170 4171 4172 4173 | catch {font delete myfont} font create myfont -family $Pref(fontfamily) -size $Pref(fontsize) entry $top.e1 -textvariable dirdiff(leftDir) button $top.bu1 -text "Up" -padx 10 -command {upDir 1} button $top.bb1 -text "Browse" -padx 10 \ | | | | 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 | catch {font delete myfont} font create myfont -family $Pref(fontfamily) -size $Pref(fontsize) entry $top.e1 -textvariable dirdiff(leftDir) button $top.bu1 -text "Up" -padx 10 -command {upDir 1} button $top.bb1 -text "Browse" -padx 10 \ -command [list browseDir dirdiff(leftDir) $top.e1] entry $top.e2 -textvariable dirdiff(rightDir) button $top.bu2 -text "Up" -padx 10 -command {upDir 2} button $top.bb2 -text "Browse" -padx 10 \ -command [list browseDir dirdiff(rightDir) $top.e2] bind $top.e1 <Return> doCompare bind $top.e2 <Return> doCompare pack $top.bb1 $top.bu1 -in $top.fe1 -side right -pady 1 pack $top.bu1 -padx 6 pack $top.e1 -in $top.fe1 -side left -fill x -expand 1 pack $top.bb2 $top.bu2 -in $top.fe2 -side right -pady 1 |
︙ | ︙ | |||
4234 4235 4236 4237 4238 4239 4240 | puts $ch [string trimright [$diff(wClip1) get 1.0 end] \n] close $ch set ch [open $f2 w] puts $ch [string trimright [$diff(wClip2) get 1.0 end] \n] close $ch newDiff $f1 $f2 | | | | 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 | puts $ch [string trimright [$diff(wClip1) get 1.0 end] \n] close $ch set ch [open $f2 w] puts $ch [string trimright [$diff(wClip2) get 1.0 end] \n] close $ch newDiff $f1 $f2 } proc makeClipDiffWin {} { global diff set top .clipdiff if {[winfo exists $top] && [winfo toplevel $top] eq $top} { raise $top focus -force $top return } destroy $top toplevel $top lappend diff(diffWindows) $top |
︙ | ︙ | |||
4276 4277 4278 4279 4280 4281 4282 | -command [list cleanupAndExit all] button $top.f.b -text "Diff" -command doClipDiff -underline 0 -width 8 bind $top <Alt-d> [list $top.f.b invoke] button $top.f.b2 -text "Left Clear" -command "$t1 delete 1.0 end" \ -underline 0 bind $top <Alt-l> "[list $top.f.b2 invoke] ; [list focus $t1]" | | | 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 | -command [list cleanupAndExit all] button $top.f.b -text "Diff" -command doClipDiff -underline 0 -width 8 bind $top <Alt-d> [list $top.f.b invoke] button $top.f.b2 -text "Left Clear" -command "$t1 delete 1.0 end" \ -underline 0 bind $top <Alt-l> "[list $top.f.b2 invoke] ; [list focus $t1]" button $top.f.b3 -text "Right Clear" -command "$t2 delete 1.0 end" \ -underline 0 bind $top <Alt-r> "[list $top.f.b3 invoke] ; [list focus $t2]" button $top.f.b4 -text "Left Clear&Paste" -command \ "$t1 delete 1.0 end ; event generate $t1 <<Paste>>" button $top.f.b5 -text "Right Clear&Paste" -command \ "$t2 delete 1.0 end ; event generate $t2 <<Paste>>" |
︙ | ︙ | |||
4431 4432 4433 4434 4435 4436 4437 | if {[catch {cd [file join $::thisDir examples]}]} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not locate examples directory." \ -type ok return } | | > > > > > > | 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 | if {[catch {cd [file join $::thisDir examples]}]} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not locate examples directory." \ -type ok return } #set ::diff(tutorial) 1 # Start up a dirdiff in the examples directory set ::dirdiff(leftDir) [file join [pwd] dir1] set ::dirdiff(rightDir) [file join [pwd] dir2] makeDirDiffWin doCompare set w [helpWin .ht "Eskil Tutorial"] text $w.t -width 82 -height 35 -wrap word -yscrollcommand "$w.sb set"\ -font "Courier 10" scrollbar $w.sb -orient vert -command "$w.t yview" pack $w.sb -side right -fill y |
︙ | ︙ | |||
4509 4510 4511 4512 4513 4514 4515 | global diff dirdiff Pref global argv argc tcl_platform if {$argc == 0} { makeDiffWin return } | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 | global diff dirdiff Pref global argv argc tcl_platform if {$argc == 0} { makeDiffWin return } set noautodiff 0 set autobrowse 0 set dodir 0 set doclip 0 set files "" set nextArg "" set revNo 1 foreach arg $argv { if {$nextArg != ""} { if {$nextArg eq "mergeFile"} { set opts(mergeFile) [file join [pwd] $arg] } elseif {$nextArg eq "printFile"} { set opts(printFile) [file join [pwd] $arg] } elseif {$nextArg eq "revision"} { set opts(doptrev$revNo) $arg incr revNo } elseif {$nextArg eq "limitlines"} { set opts(limitlines) $arg } set nextArg "" continue } if {$arg eq "-w"} { set Pref(ignore) "-w" } elseif {$arg eq "--help"} { printUsage exit } elseif {$arg eq "-b"} { set Pref(ignore) "-b" } elseif {$arg eq "-noignore"} { set Pref(ignore) " " } elseif {$arg eq "-noparse"} { set Pref(parse) 0 } elseif {$arg eq "-line"} { set Pref(parse) 1 } elseif {$arg eq "-smallblock"} { set Pref(parse) 2 } elseif {$arg eq "-block"} { set Pref(parse) 3 } elseif {$arg eq "-char"} { set Pref(lineparsewords) 0 } elseif {$arg eq "-word"} { set Pref(lineparsewords) 1 } elseif {$arg eq "-2nd"} { set Pref(extralineparse) 1 } elseif {$arg eq "-no2nd"} { set Pref(extralineparse) 0 } elseif {$arg eq "-limit"} { set nextArg limitlines } elseif {$arg eq "-nodiff"} { set noautodiff 1 } elseif {$arg eq "-dir"} { set dodir 1 } elseif {$arg eq "-clip"} { set doclip 1 } elseif {$arg eq "-browse"} { set autobrowse 1 } elseif {$arg eq "-conflict"} { set opts(mode) "conflict" set Pref(ignore) " " } elseif {$arg eq "-print"} { set nextArg printFile } elseif {$arg eq "-server"} { if {$tcl_platform(platform) eq "windows"} { catch { package require dde dde servername Eskil } } else { tk appname Eskil } } elseif {$arg eq "-o"} { set nextArg mergeFile } elseif {$arg eq "-r"} { set nextArg revision } elseif {[string range $arg 0 1] eq "-r"} { set opts(doptrev$revNo) [string range $arg 2 end] incr revNo } elseif {[string range $arg 0 0] eq "-"} { append opts(dopt) " $arg" } else { set apa [file normalize [file join [pwd] $arg]] if {![file exists $apa]} { puts "Ignoring argument: $arg" } else { lappend files $apa } } } # Do we start in clip diff mode? if {$doclip} { makeClipDiffWin return } # Figure out if we start in a diff or dirdiff window. set len [llength $files] if {$len == 0 && $dodir} { set dirdiff(leftDir) [pwd] set dirdiff(rightDir) [pwd] makeDirDiffWin return } if {$len == 1} { |
︙ | ︙ | |||
4633 4634 4635 4636 4637 4638 4639 | if {[file isdirectory $fullname1] && [file isdirectory $fullname2]} { set dirdiff(leftDir) $fullname1 set dirdiff(rightDir) $fullname2 makeDirDiffWin after idle doCompare return } | | | | 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 | if {[file isdirectory $fullname1] && [file isdirectory $fullname2]} { set dirdiff(leftDir) $fullname1 set dirdiff(rightDir) $fullname2 makeDirDiffWin after idle doCompare return } } # Ok, we have a normal diff makeDiffWin update set top [lindex $::diff(diffWindows) end] # Copy the previously collected options foreach {item val} [array get opts] { set diff($top,$item) $val } if {$len == 1} { set fullname [file join [pwd] [lindex $files 0]] set fulldir [file dirname $fullname] if {$diff($top,mode) eq "conflict"} { set diff($top,conflictFile) $fullname set diff($top,rightDir) $fulldir set diff($top,rightOK) 1 set diff($top,rightLabel) $fullname set diff($top,leftLabel) $fullname after idle [list doDiff $top] return |
︙ | ︙ | |||
4673 4674 4675 4676 4677 4678 4679 | set diff($top,leftLabel) "RCS" if {$noautodiff} { enableRedo $top } else { after idle [list doDiff $top] } return | | | 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 | set diff($top,leftLabel) "RCS" if {$noautodiff} { enableRedo $top } else { after idle [list doDiff $top] } return } # CVS if {[llength [glob -nocomplain [file join $fulldir CVS]]]} { set diff($top,mode) "CVS" set diff($top,rightDir) $fulldir set diff($top,RCSFile) $fullname set diff($top,rightLabel) $fullname set diff($top,rightFile) $fullname |
︙ | ︙ | |||
4758 4759 4760 4761 4762 4763 4764 | openRight $top } # If we cancel the second file and detect CVS, ask about it. if {$diff($top,leftOK) && !$diff($top,rightOK) && \ [llength [glob -nocomplain [file join $fulldir CVS]]]} { if {[tk_messageBox -title Diff -icon question \ | | | 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 | openRight $top } # If we cancel the second file and detect CVS, ask about it. if {$diff($top,leftOK) && !$diff($top,rightOK) && \ [llength [glob -nocomplain [file join $fulldir CVS]]]} { if {[tk_messageBox -title Diff -icon question \ -message "Do CVS diff?" -type yesno] eq "yes"} { set fulldir $diff($top,leftDir) set fullname $diff($top,leftFile) set diff($top,leftOK) 0 set diff($top,mode) "CVS" set diff($top,rightDir) $fulldir set diff($top,RCSFile) $fullname set diff($top,rightLabel) $fullname |
︙ | ︙ | |||
4831 4832 4833 4834 4835 4836 4837 | } } proc defaultGuiOptions {} { catch {package require griffin} option add *Menu.tearOff 0 | | | | | | | 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 | } } proc defaultGuiOptions {} { catch {package require griffin} option add *Menu.tearOff 0 if {[tk windowingsystem] eq "x11"} { option add *Menu.activeBorderWidth 1 option add *Menu.borderWidth 1 option add *Listbox.exportSelection 0 option add *Listbox.borderWidth 1 #option add *Listbox.highlightThickness 1 option add *Font "Helvetica -12" option add *Scrollbar.highlightThickness 0 option add *Scrollbar.takeFocus 0 } if {$::tcl_platform(platform) eq "windows"} { option add *Panedwindow.sashRelief flat option add *Panedwindow.sashWidth 4 option add *Panedwindow.sashPad 0 #option add *Menubutton.activeBackground SystemHighlight #option add *Menubutton.activeForeground SystemHighlightText option add *Menubutton.padY 1 } } if {![info exists gurkmeja]} { set gurkmeja 1 defaultGuiOptions if {0 && [bind all <Alt-KeyPress>] eq ""} { bind all <Alt-KeyPress> [bind Menubutton <Alt-KeyPress>] #after 500 "tk_messageBox -message Miffo" } getOptions wm withdraw . parseCommandLine } |