Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Cleanup of global variable usage. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ef2a6449e0fe34202142033d7cf1da6d |
User & Date: | peter.spjuth@gmail.com 2011-05-27 06:09:19.000 |
Context
2011-09-30
| ||
23:07 | Run tests from source to support code coverage. check-in: a97748bfa1 user: peter.spjuth@gmail.com tags: trunk | |
2011-05-27
| ||
06:09 | Cleanup of global variable usage. check-in: ef2a6449e0 user: peter.spjuth@gmail.com tags: trunk | |
2011-05-10
| ||
22:40 | Added balloon help on toolbuttons. Rearranged images. check-in: 0fbbd7316a user: peter.spjuth@gmail.com tags: trunk | |
Changes
Changes to src/clip.tcl.
︙ | ︙ | |||
29 30 31 32 33 34 35 | } proc DoClipDiff {} { set f1 [tmpFile] set f2 [tmpFile] set ch [open $f1 w] | | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | } proc DoClipDiff {} { set f1 [tmpFile] set f2 [tmpFile] set ch [open $f1 w] set data1 [$::eskil(wClip1) get 1.0 end] set data1 [ClipClean $data1] puts $ch $data1 close $ch set ch [open $f2 w] set data2 [$::eskil(wClip2) get 1.0 end] set data2 [ClipClean $data2] puts $ch $data2 close $ch #set line1 [split $data1 \n] #set len1 [llength $line1] #set line2 [split $data2 \n] |
︙ | ︙ | |||
62 63 64 65 66 67 68 | $::widgets($top,wLine1) configure -height 1 $t2 configure -height $lines2 $::widgets($top,wLine2) configure -height 1 } } proc ArmCatch {} { | | | | 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 | $::widgets($top,wLine1) configure -height 1 $t2 configure -height $lines2 $::widgets($top,wLine2) configure -height 1 } } proc ArmCatch {} { if {$::eskil(armcatch)} { bind .clipdiff <FocusOut> { if {[string equal %W .clipdiff]} { after 50 CatchFromWin } } } else { bind .clipdiff <FocusOut> {} } } proc CatchFromWin {} { set ::eskil(armcatch) 0 ArmCatch set win [twapi::get_foreground_window] if {$win eq ""} { #puts "No fg window" return } #puts "Locating windows" |
︙ | ︙ | |||
108 109 110 111 112 113 114 | twapi::send_keys ^(ac) after 50 "set ::CatchFromWinWait 1" ; vwait ::CatchFromWinWait lassign [twapi::get_window_coordinates $win] x1 y1 x2 y2 if {[catch {clipboard get} text]} continue if {$text eq ""} continue lappend capturedData [list $x1 $text] } | | | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | twapi::send_keys ^(ac) after 50 "set ::CatchFromWinWait 1" ; vwait ::CatchFromWinWait lassign [twapi::get_window_coordinates $win] x1 y1 x2 y2 if {[catch {clipboard get} text]} continue if {$text eq ""} continue lappend capturedData [list $x1 $text] } $::eskil(wClip1) delete 1.0 end $::eskil(wClip2) delete 1.0 end if {[llength $capturedData] == 0} return # Set it up left-to-right set capturedData [lsort -index 0 -integer $capturedData] if {[llength $capturedData] >= 1} { set text [lindex $capturedData 0 1] $::eskil(wClip1) insert end $text } if {[llength $capturedData] >= 2} { set text [lindex $capturedData 1 1] $::eskil(wClip2) insert end $text after idle DoClipDiff } } proc makeClipDiffWin {} { set top .clipdiff if {[winfo exists $top] && [winfo toplevel $top] eq $top} { |
︙ | ︙ | |||
142 143 144 145 146 147 148 | wm title $top "Clip Diff" wm protocol $top WM_DELETE_WINDOW "cleanupAndExit $top" set t1 [Scroll both \ text $top.t1 -width 60 -height 35 -font myfont] set t2 [Scroll both \ text $top.t2 -width 60 -height 35 -font myfont] | | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | wm title $top "Clip Diff" wm protocol $top WM_DELETE_WINDOW "cleanupAndExit $top" set t1 [Scroll both \ text $top.t1 -width 60 -height 35 -font myfont] set t2 [Scroll both \ text $top.t2 -width 60 -height 35 -font myfont] set ::eskil(wClip1) $t1 set ::eskil(wClip2) $t2 bind $t1 <Control-o> [list focus $t2] bind $t2 <Control-o> [list focus $t1] ttk::frame $top.f menubutton $top.f.mf -menu $top.f.mf.m -text "File" -underline 0 menu $top.f.mf.m |
︙ | ︙ | |||
181 182 183 184 185 186 187 | -padx 4 -pady 2 -sticky "w" grid $top.f.mf -sticky nw -pady 0 -padx 0 grid columnconfigure $top.f {0 3 5 8} -weight 1 grid columnconfigure $top.f 8 -minsize [winfo reqwidth $top.f.mf] if {![catch {package require twapi}]} { ttk::checkbutton $top.f.b6 -text "Capture" -command ArmCatch \ | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | -padx 4 -pady 2 -sticky "w" grid $top.f.mf -sticky nw -pady 0 -padx 0 grid columnconfigure $top.f {0 3 5 8} -weight 1 grid columnconfigure $top.f 8 -minsize [winfo reqwidth $top.f.mf] if {![catch {package require twapi}]} { ttk::checkbutton $top.f.b6 -text "Capture" -command ArmCatch \ -underline 0 -variable ::eskil(armcatch) bind $top <Alt-c> [list $top.f.b6 invoke] #raise $top.f.b6 place $top.f.b6 -anchor e -relx 1.0 -rely 0.5 } grid $top.f - -sticky we grid $top.t1 $top.t2 -sticky news grid $top.t2 -padx {2 0} grid rowconfigure $top 1 -weight 1 grid columnconfigure $top {0 1} -weight 1 return $top } |
Changes to src/dirdiff.tcl.
︙ | ︙ | |||
18 19 20 21 22 23 24 | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- | < < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # Compare file names proc FStrCmp {s1 s2} { # Equality is based on platform's standard # Order is dictionary order # Exact equal is equal regardless of platform. if {$s1 eq $s2} { |
︙ | ︙ |
Changes to src/eskil.tcl.
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Do initalisations for needed packages and globals. # This is not run until needed to speed up command line error reporting. proc Init {} { package require Tk 8.4 catch {package require textSearch} package require wcb package require snit if {[catch {package require psballoon}]} { # Add a dummy if it does not exist. proc addBalloon {args} {} } else { namespace import -force psballoon::addBalloon } | > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # Do initalisations for needed packages and globals. # This is not run until needed to speed up command line error reporting. proc Init {} { package require Tk 8.4 catch {package require textSearch} package require wcb package require snit package require tablelist_tile if {[catch {package require psballoon}]} { # Add a dummy if it does not exist. proc addBalloon {args} {} } else { namespace import -force psballoon::addBalloon } |
︙ | ︙ | |||
79 80 81 82 83 84 85 | source $::eskil(thisDir)/dirdiff.tcl source $::eskil(thisDir)/help.tcl source $::eskil(thisDir)/plugin.tcl source $::eskil(thisDir)/printobj.tcl source $::eskil(thisDir)/print.tcl source $::eskil(thisDir)/rev.tcl | < < | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | source $::eskil(thisDir)/dirdiff.tcl source $::eskil(thisDir)/help.tcl source $::eskil(thisDir)/plugin.tcl source $::eskil(thisDir)/printobj.tcl source $::eskil(thisDir)/print.tcl source $::eskil(thisDir)/rev.tcl # Diff functionality is in the DiffUtil package. package require DiffUtil # Help DiffUtil to find a diff executable, if needed catch {DiffUtil::LocateDiffExe $::eskil(thisScript)} # Figure out a place to store temporary files. locateTmp ::eskil(tmpdir) if {$::tcl_platform(platform) eq "windows"} { # Locate CVS if it is in c:/bin if {[auto_execok cvs] eq "" && [file exists "c:/bin/cvs.exe"]} { set ::env(PATH) "$::env(PATH);c:\\bin" auto_reset } |
︙ | ︙ | |||
162 163 164 165 166 167 168 | } } interp alias {} toplevel {} ttk::toplevel # Use demo images from Tablelist set dir $::eskil(thisDir)/../lib/tablelist/demos | > | | | > > > > > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | } } interp alias {} toplevel {} ttk::toplevel # Use demo images from Tablelist set dir $::eskil(thisDir)/../lib/tablelist/demos if {[catch { set ::img(clsd) [image create photo -file [file join $dir clsdFolder.gif]] set ::img(open) [image create photo -file [file join $dir openFolder.gif]] set ::img(file) [image create photo -file [file join $dir file.gif]] }]} then { set ::img(clsd) "" set ::img(open) "" set ::img(file) "" } # Local images set dir $::eskil(thisDir)/images set ::img(link) [image create photo -file [file join $dir link.gif]] set ::img(left) [image create photo -file [file join $dir arrow_left.gif]] set ::img(right) [image create photo -file [file join $dir arrow_right.gif]] set ::img(browse) [image create photo -file [file join $dir folderopen1.gif]] set ::img(up) [image create photo -file [file join $dir arrow_up.gif]] |
︙ | ︙ | |||
216 217 218 219 220 221 222 | # If top = "all" it means quit. # If eskil is embedded, this should be used to close an eskil toplevel. proc cleanupAndExit {top} { # A security thing to make sure we can exit. set cont 0 if {[catch { if {$top != "all"} { | | | | | | | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | # If top = "all" it means quit. # If eskil is embedded, this should be used to close an eskil toplevel. proc cleanupAndExit {top} { # A security thing to make sure we can exit. set cont 0 if {[catch { if {$top != "all"} { set i [lsearch $::eskil(diffWindows) $top] if {$i >= 0} { set ::eskil(diffWindows) [lreplace $::eskil(diffWindows) $i $i] } set i [lsearch $::widgets(toolbars) $top.f] if {$i >= 0} { set ::widgets(toolbars) [lreplace $::widgets(toolbars) $i $i] } destroy $top array unset ::eskil $top,* # Any windows remaining? if {[llength $::eskil(diffWindows)] > 0} { set cont 1 } } } errMsg]} { tk_messageBox -icon error -title "Eskil Error" -message \ "An error occured in the close process.\n$errMsg\n\ (This is a bug)\nTerminating application." -type ok } if {$cont} return clearTmp exit } # If embedding, tell eskil about any other toplevel, then # cleanupAndExit can be used to get rid of it. proc eskilRegisterToplevel {top} { lappend ::eskil(diffWindows) $top } # Format a line number proc myFormL {lineNo} { if {![string is integer -strict $lineNo]} {return "$lineNo\n"} return [format "%3d: \n" $lineNo] } # Get a name for a temporary file # A tail can be given to make the file more recognisable. proc tmpFile {{tail {}}} { if {[info exists ::tmpcnt]} { incr ::tmpcnt } else { set ::tmpcnt 0 } set name "tmpd[pid]a$::tmpcnt" if {$tail ne ""} { append name " [file tail $tail]" } set name [file join $::eskil(tmpdir) $name] lappend ::tmpfiles $name return $name } # Delete temporary files proc clearTmp {args} { if {![info exists ::tmpfiles]} { |
︙ | ︙ | |||
323 324 325 326 327 328 329 | # Insert one line in each text widget. # Mark them as changed, and optionally parse them. proc insertMatchingLines {top line1 line2} { global doingLine1 doingLine2 Pref # FIXA: fully implement filter | | | | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | # Insert one line in each text widget. # Mark them as changed, and optionally parse them. proc insertMatchingLines {top line1 line2} { global doingLine1 doingLine2 Pref # FIXA: fully implement filter if {$::eskil(filter) != ""} { if {[regexp $::eskil(filter) $line1]} { insertLine $top 1 $doingLine1 $line1 insertLine $top 2 $doingLine2 $line2 incr doingLine1 incr doingLine2 set ::eskil(filterflag) 1 return } set ::eskil(filterflag) 0 } if {$Pref(parse) != 0} { set opts $Pref(ignore) if {$Pref(nocase)} {lappend opts -nocase} if {$Pref(lineparsewords)} {lappend opts -words} set res [DiffUtil::diffStrings {*}$opts $line1 $line2] |
︙ | ︙ | |||
501 502 503 504 505 506 507 | set apa [compareBlocks $block1 $block2] # Fine grained changes means that each line is considered its own # chunk. This is used for merging better to avoid the same decision # for an entire block. set finegrain [expr {$::Pref(finegrainchunks) && $details}] | | | | | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | set apa [compareBlocks $block1 $block2] # Fine grained changes means that each line is considered its own # chunk. This is used for merging better to avoid the same decision # for an entire block. set finegrain [expr {$::Pref(finegrainchunks) && $details}] if {$finegrain && $::eskil($top,ancestorFile) ne ""} { # Avoid fine grain depending on relation to ancestor set leftChange 0 set leftChangeOrAdd 0 for {set t $line1} {$t < $line1 + $n1} {incr t} { if {[info exists ::eskil($top,ancestorLeft,$t)]} { set leftChangeOrAdd 1 if {$::eskil($top,ancestorLeft,$t) eq "c"} { set leftChange 1 break } } } set rightChange 0 set rightChangeOrAdd 0 for {set t $line2} {$t < $line2 + $n2} {incr t} { if {[info exists ::eskil($top,ancestorRight,$t)]} { set rightChangeOrAdd 1 if {$::eskil($top,ancestorRight,$t) eq "c"} { set rightChange 1 break } } } # Avoid fine grain if either side has no changes against ancestor if {!$leftChangeOrAdd || !$rightChangeOrAdd} { |
︙ | ︙ | |||
626 627 628 629 630 631 632 | # All blocks have been processed. Continue until end of file. # If "show all" is not on, just display a couple of context lines. set limit -1 if {$Pref(context) >= 0} { set limit $Pref(context) } # Consider any total limit on displayed lines. | | | | 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | # All blocks have been processed. Continue until end of file. # If "show all" is not on, just display a couple of context lines. set limit -1 if {$Pref(context) >= 0} { set limit $Pref(context) } # Consider any total limit on displayed lines. if {$::eskil($top,limitlines)} { set limit [expr {$::eskil($top,limitlines) - $::eskil($top,mapMax)}] if {$limit < 0} { set limit 0 } } if {$limit >= 0} {disallowEdit $top} set t 0 |
︙ | ︙ | |||
691 692 693 694 695 696 697 | emptyLine $top 2 0 addMapLines $top 1 } } incr doingLine1 incr doingLine2 incr t | | | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | emptyLine $top 2 0 addMapLines $top 1 } } incr doingLine1 incr doingLine2 incr t if {$::eskil($top,limitlines) && \ ($::eskil($top,mapMax) > $::eskil($top,limitlines))} { return } } # This should not happen unless something is wrong... if {$doingLine2 != $line2} { disallowEdit $top $::widgets($top,wDiff1) insert end \ |
︙ | ︙ | |||
718 719 720 721 722 723 724 | # If block parsing is turned off, only do line parsing for # blocks of equal size. for {set t 0} {$t < $n1} {incr t} { gets $ch1 textline1 gets $ch2 textline2 insertMatchingLines $top $textline1 $textline2 } | | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | # If block parsing is turned off, only do line parsing for # blocks of equal size. for {set t 0} {$t < $n1} {incr t} { gets $ch1 textline1 gets $ch2 textline2 insertMatchingLines $top $textline1 $textline2 } if {$::eskil(filter) != "" && $::eskil(filterflag)} { addMapLines $top $n1 } else { addChange $top $n1 change $line1 $n1 $line2 $n2 nextHighlight $top } } else { if {$n1 != 0 && $n2 != 0 && $Pref(parse) >= 2 && \ |
︙ | ︙ | |||
811 812 813 814 815 816 817 | } ##################################### # Special cases. Conflict/patch ##################################### proc startConflictDiff {top file} { | | | | | | | | | | | | | | | | | | | | | | | | | 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 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 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 | } ##################################### # Special cases. Conflict/patch ##################################### proc startConflictDiff {top file} { set ::eskil($top,mode) "conflict" set ::eskil($top,modetype) "" set ::eskil($top,conflictFile) $file set ::eskil($top,rightDir) [file dirname $file] set ::eskil($top,rightOK) 1 set ::eskil($top,rightLabel) $file set ::eskil($top,leftLabel) $file set ::eskil($top,leftOK) 0 # Turn off ignore set ::Pref(ignore) " " set ::Pref(nocase) 0 set ::Pref(noempty) 0 # Try to autodetect line endings in file set ch [open $file rb] set data [read $ch 10000] close $ch if {[string first \r\n $data] >= 0} { set ::eskil($top,mergetranslation) crlf } else { set ::eskil($top,mergetranslation) lf } } # Read a conflict file and extract the two versions. proc prepareConflict {top} { global Pref disallowEdit $top set ::eskil($top,leftFile) [tmpFile] set ::eskil($top,rightFile) [tmpFile] set ch1 [open $::eskil($top,leftFile) w] set ch2 [open $::eskil($top,rightFile) w] set ch [open $::eskil($top,conflictFile) r] set ::eskil($top,conflictDiff) {} set leftLine 1 set rightLine 1 set state both 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 ::eskil($top,conflictDiff) [list \ $start1 [expr {$end1 - $start1 + 1}] \ $start2 [expr {$end2 - $start2 + 1}]] } 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 $::eskil($top,conflictFile)]" set rightName $leftName } set ::eskil($top,leftLabel) $leftName set ::eskil($top,rightLabel) $rightName update idletasks } # Clean up after a conflict diff. proc cleanupConflict {top} { global Pref clearTmp $::eskil($top,rightFile) $::eskil($top,leftFile) set ::eskil($top,rightFile) $::eskil($top,conflictFile) set ::eskil($top,leftFile) $::eskil($top,conflictFile) } # Display one chunk from a patch file proc displayOnePatch {top leftLines rightLines leftLine rightLine} { emptyLine $top 1 emptyLine $top 2 |
︙ | ︙ | |||
1014 1015 1016 1017 1018 1019 1020 | } } # Read a patch file and display it proc displayPatch {top} { global Pref | | | | | | | | | 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 | } } # Read a patch file and display it proc displayPatch {top} { global Pref set ::eskil($top,leftLabel) "Patch $::eskil($top,patchFile): old" set ::eskil($top,rightLabel) "Patch $::eskil($top,patchFile): new" update idletasks if {$::eskil($top,patchFile) eq ""} { if {$::eskil($top,patchData) eq ""} { set data [getFullPatch $top] } else { set data $::eskil($top,patchData) } } elseif {$::eskil($top,patchFile) eq "-"} { set data [read stdin] } else { set ch [open $::eskil($top,patchFile) r] set data [read $ch] close $ch } set style "" set divider "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-" |
︙ | ︙ | |||
1197 1198 1199 1200 1201 1202 1203 | ##################################### # Main diff ##################################### # Prepare for a diff by creating needed temporary files proc prepareFiles {top} { | | | | | | | | | | | 1202 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 1233 1234 1235 1236 1237 1238 1239 | ##################################### # Main diff ##################################### # Prepare for a diff by creating needed temporary files proc prepareFiles {top} { set ::eskil($top,cleanup) {} if {$::eskil($top,mode) eq "rev"} { prepareRev $top lappend ::eskil($top,cleanup) "rev" } elseif {$::eskil($top,mode) eq "conflict"} { prepareConflict $top lappend ::eskil($top,cleanup) "conflict" } if {$::eskil($top,plugin) ne ""} { preparePlugin $top set ::eskil($top,cleanup) "plugin $::eskil($top,cleanup)" } } # Clean up after a diff proc cleanupFiles {top} { foreach keyword $::eskil($top,cleanup) { switch $keyword { "rev" {cleanupRev $top} "conflict" {cleanupConflict $top} "plugin" {cleanupPlugin $top} } } set ::eskil($top,cleanup) {} } # Redo Diff command proc redoDiff {top} { # Note what rows are being displayed set w $::widgets($top,wDiff1) |
︙ | ︙ | |||
1255 1256 1257 1258 1259 1260 1261 | set w $::widgets($top,$item) seeText $w $first.0 $last.0 } } # Make an appropriate tail for a window title, depending on mode and files. proc TitleTail {top} { | | | | | | | | | | 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 | set w $::widgets($top,$item) seeText $w $first.0 $last.0 } } # Make an appropriate tail for a window title, depending on mode and files. proc TitleTail {top} { set tail1 [file tail $::eskil($top,rightLabel)] set tail2 [file tail $::eskil($top,leftLabel)] if {$::eskil($top,mode) ne "" || $tail1 eq $tail2} { if {$::eskil($top,mode) eq "rev"} { set tail1 [file tail $::eskil($top,RevFile)] } elseif {$::eskil($top,mode) eq "conflict"} { set tail1 [file tail $::eskil($top,conflictFile)] } return $tail1 } else { return "$tail2 vs $tail1" } } # Main diff function. proc doDiff {top} { global Pref global doingLine1 doingLine2 if {$::eskil($top,mode) eq "" && ($::eskil($top,leftOK) == 0 || $::eskil($top,rightOK) == 0)} { disableRedo $top return } else { enableRedo $top } busyCursor $top |
︙ | ︙ | |||
1300 1301 1302 1303 1304 1305 1306 | # Display a star during diff execution, to know when the internal # processing starts, and when the label is "valid". set ::widgets($top,eqLabel) "*" wm title $top "Eskil:" update idletasks | | | | | | | | | | | | | | | | | | | | | | | | 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 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 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 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 | # Display a star during diff execution, to know when the internal # processing starts, and when the label is "valid". set ::widgets($top,eqLabel) "*" wm title $top "Eskil:" update idletasks if {$::eskil($top,mode) eq "patch"} { disallowEdit $top displayPatch $top drawMap $top -1 foreach item {wLine1 wLine2} { set w $::widgets($top,$item) $w configure -state disabled } update idletasks wm title $top "Eskil: [file tail $::eskil($top,patchFile)]" $::widgets($top,wLine2) see 1.0 normalCursor $top return } else { prepareFiles $top } wm title $top "Eskil: [TitleTail $top]" # Run diff and parse the result. set opts $Pref(ignore) if {$Pref(nocase)} {lappend opts -nocase} if {$Pref(noempty)} {lappend opts -noempty} if {[info exists ::eskil($top,aligns)] && \ [llength $::eskil($top,aligns)] > 0} { lappend opts -align $::eskil($top,aligns) } set range {} if {[info exists ::eskil($top,range)] && \ [llength $::eskil($top,range)] == 4} { set range $::eskil($top,range) lappend opts -range $range } if {[llength $Pref(regsub)] > 0} { lappend opts -regsub $Pref(regsub) } # Apply nodigit after preprocess if {$Pref(nodigit)} {lappend opts -nodigit} # If a special file for diffing is present, use it. if {[info exists ::eskil($top,leftFileDiff)]} { set dFile1 $::eskil($top,leftFileDiff) } else { set dFile1 $::eskil($top,leftFile) } if {[info exists ::eskil($top,rightFileDiff)]} { set dFile2 $::eskil($top,rightFileDiff) } else { set dFile2 $::eskil($top,rightFile) } set differr [catch {DiffUtil::diffFiles {*}$opts \ $dFile1 $dFile2} diffres] # 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 {$::eskil($top,mode) eq "conflict" && $::eskil($top,modetype) eq "Pure"} { set diffres $::eskil($top,conflictDiff) } if {$differr != 0} { $::widgets($top,wDiff1) insert end $diffres normalCursor $top return } if {[llength $diffres] == 0} { set ::widgets($top,eqLabel) "=" # Automatically close if equal if {$::eskil(autoclose)} { after idle cleanupAndExit $top return } } else { set ::widgets($top,eqLabel) " " } # Update the equal label immediately for better feedback update idletasks if {$::eskil($top,ancestorFile) ne ""} { collectAncestorInfo $top $dFile1 $dFile2 $opts } set firstview 1 set ch1 [open $::eskil($top,leftFile)] set ch2 [open $::eskil($top,rightFile)] set doingLine1 1 set doingLine2 1 # If there is a range, skip lines up to the range if {[llength $range] != 0} { disallowEdit $top lassign $range start1 end1 start2 end2 while {$doingLine1 < $start1 && [gets $ch1 line] >= 0} { incr doingLine1 } while {$doingLine2 < $start2 && [gets $ch2 line] >= 0} { incr doingLine2 } } set t 0 foreach i $diffres { lassign $i line1 n1 line2 n2 doText $top $ch1 $ch2 $n1 $n2 $line1 $line2 if {$::eskil($top,limitlines) && \ ($::eskil($top,mapMax) > $::eskil($top,limitlines))} { break } # Get one update when the screen has been filled. # Show the first diff. if {$firstview && $::eskil($top,mapMax) > 100} { set firstview 0 showDiff $top 0 update idletasks } } # If there is a range, just display the range |
︙ | ︙ | |||
1454 1455 1456 1457 1458 1459 1460 | close $ch2 # We can turn off editing in the text windows after everything # is displayed. noEdit $top # Mark aligned lines | | | | | 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 | close $ch2 # We can turn off editing in the text windows after everything # is displayed. noEdit $top # Mark aligned lines if {[info exists ::eskil($top,aligns)] && \ [llength $::eskil($top,aligns)] > 0} { foreach {align1 align2} $::eskil($top,aligns) { set i [$::widgets($top,wLine1) search -regexp "\\m$align1\\M" 1.0] if {$i != ""} { $::widgets($top,wLine1) tag add align \ "$i linestart" "$i lineend" } set i [$::widgets($top,wLine2) search -regexp "\\m$align2\\M" 1.0] if {$i != ""} { |
︙ | ︙ | |||
1484 1485 1486 1487 1488 1489 1490 | normalCursor $top showDiff $top 0 if {$::widgets($top,eqLabel) eq "!"} { set ::widgets($top,eqLabel) " " } cleanupFiles $top | | | | | | | | | | | | | | | | | | | 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 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | normalCursor $top showDiff $top 0 if {$::widgets($top,eqLabel) eq "!"} { set ::widgets($top,eqLabel) " " } cleanupFiles $top if {$::eskil($top,mode) eq "conflict"} { if {$::widgets($top,eqLabel) != "="} { makeMergeWin $top } } elseif {$::eskil($top,ancestorFile) ne ""} { if {$::widgets($top,eqLabel) != "="} { makeMergeWin $top } } if {$::eskil($top,printFile) ne ""} { after idle "doPrint $top 1 ; cleanupAndExit all" } } # This is the entrypoint to do a diff via DDE or Send proc remoteDiff {file1 file2} { newDiff $file1 $file2 } ##################################### # Highlight and navigation stuff ##################################### # Scroll windows to next/previous diff proc findDiff {top delta} { showDiff $top [expr {$::eskil($top,currHighLight) + $delta}] } # Scroll a text window to view a certain range, and possibly some # lines before and after. proc seeText {w si ei} { $w see $ei $w see $si $w see $si-5lines $w see $ei+5lines if {[llength [$w bbox $si]] == 0} { $w yview $si-5lines } if {[llength [$w bbox $ei]] == 0} { $w yview $si } } # Highlight a diff proc highLightChange {top n} { if {[info exists ::eskil($top,currHighLight)] && \ $::eskil($top,currHighLight) >= 0} { $::widgets($top,wLine1) tag configure hl$::eskil($top,currHighLight) \ -background {} $::widgets($top,wLine2) tag configure hl$::eskil($top,currHighLight) \ -background {} } set ::eskil($top,currHighLight) $n if {$::eskil($top,currHighLight) < 0} { set ::eskil($top,currHighLight) -1 } elseif {$::eskil($top,currHighLight) >= [llength $::eskil($top,changes)]} { set ::eskil($top,currHighLight) [llength $::eskil($top,changes)] } else { $::widgets($top,wLine1) tag configure hl$::eskil($top,currHighLight) \ -background yellow $::widgets($top,wLine2) tag configure hl$::eskil($top,currHighLight) \ -background yellow } } # Highlight a diff and scroll windows to it. proc showDiff {top num} { highLightChange $top $num set change [lindex $::eskil($top,changes) $::eskil($top,currHighLight)] set line1 [lindex $change 0] if {$::eskil($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]}] |
︙ | ︙ | |||
1584 1585 1586 1587 1588 1589 1590 | ##################################### # FIXA: Use snit to adapt text widget instead of using wcb # include seeText in such a snidget. # Clear Editing state proc resetEdit {top} { | | | | | | | | | | | | | | | | | | | | | | 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 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 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 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 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 | ##################################### # FIXA: Use snit to adapt text widget instead of using wcb # include seeText in such a snidget. # Clear Editing state proc resetEdit {top} { set ::eskil($top,leftEdit) 0 set ::eskil($top,rightEdit) 0 $top.m.mt entryconfigure "Edit Mode" -state normal resetEditW $::widgets($top,wDiff1) resetEditW $::widgets($top,wDiff2) } # Clear Editing state for a Text widget proc resetEditW {w} { $w tag configure padding -background {} $w edit reset $w configure -undo 0 set ::eskil($w,allowChange) all wcb::callback $w before insert {} wcb::callback $w before delete {} } # Do not allow any editing proc noEdit {top} { noEditW $::widgets($top,wDiff1) noEditW $::widgets($top,wDiff2) } # Do not allow any editing in a Text widget proc noEditW {w} { set ::eskil($w,allowChange) none wcb::callback $w before insert [list TextInterceptInsert $w] wcb::callback $w before delete [list TextInterceptDelete $w] } proc TextInterceptInsert {w ow index str args} { if {$::eskil($w,allowChange) eq "none"} { wcb::cancel return } if {$::eskil($w,allowChange) eq "all"} return #wcb::cancel - Cancel a widget command #wcb::replace - Replace arguments of a widget command with new ones # Disallow all new lines if {[string first "\n" $str] >= 0} { wcb::cancel return } foreach {tag str2} $args { if {[string first "\n" $str2] >= 0} { wcb::cancel return } } } proc TextInterceptDelete {w ow from {to {}}} { if {$::eskil($w,allowChange) eq "none"} { wcb::cancel return } if {$::eskil($w,allowChange) eq "all"} return if {$to eq ""} { set to $from+1char } set text [$ow get $from $to] # Disallow all new lines if {[string first "\n" $text] >= 0} { wcb::cancel return } } # Turn on editing for a Text widget proc turnOnEdit {w} { $w tag configure padding -background \#f0f0f0 $w configure -undo 1 set ::eskil($w,allowChange) line } # Turn on editing on sides where it has not been disallowed proc allowEdit {top} { $top.m.mt entryconfigure "Edit Mode" -state disable if {$::eskil($top,leftEdit) == 0} { set ::eskil($top,leftEdit) 1 turnOnEdit $::widgets($top,wDiff1) } if {$::eskil($top,rightEdit) == 0} { set ::eskil($top,rightEdit) 1 turnOnEdit $::widgets($top,wDiff2) } } # Turn off editing on sides that do not correspond to a file proc disallowEdit {top {side 0}} { if {$side == 0 || $side == 1} { set ::eskil($top,leftEdit) -1 } if {$side == 0 || $side == 2} { set ::eskil($top,rightEdit) -1 } if {$::eskil($top,leftEdit) == -1 && $::eskil($top,rightEdit) == -1} { $top.m.mt entryconfigure "Edit Mode" -state disabled } } # Ask if editing is allowed on a side proc mayEdit {top side} { if {$side == 1} { return [expr {$::eskil($top,leftEdit) == 1}] } else { return [expr {$::eskil($top,rightEdit) == 1}] } } # Start an undo block in a bunch of text widgets proc startUndoBlock {args} { foreach w $args { $w configure -autoseparators 0 # Open up editing for copy functions set ::eskil($w,allowChange) all } } # End an undo block in a bunch of text widgets proc endUndoBlock {args} { foreach w $args { $w configure -autoseparators 1 $w edit separator set ::eskil($w,allowChange) line } } # Copy a block proc copyBlock {top from first last} { set to [expr {3 - $from}] |
︙ | ︙ | |||
1876 1877 1878 1879 1880 1881 1882 | $m add command -label "Save File" -command [list saveFile $top $n] return 0 } proc saveFile {top side} { if {$side == 1} { | | | | | | 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 | $m add command -label "Save File" -command [list saveFile $top $n] return 0 } proc saveFile {top side} { if {$side == 1} { if {!$::eskil($top,leftEdit)} return set fileName $::eskil($top,leftFile) } else { if {!$::eskil($top,rightEdit)} return set fileName $::eskil($top,rightFile) } set w $::widgets($top,wDiff$side) # Confirm dialog set apa [tk_messageBox -parent $top -icon question \ -title "Overwrite file" -type yesnocancel -message \ |
︙ | ︙ | |||
1953 1954 1955 1956 1957 1958 1959 | return [file isdirectory $file] } # 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. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1958 1959 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 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 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 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 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 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 | return [file isdirectory $file] } # 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 ::eskil(tutorial)] && $::eskil(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 [::tk::dialog::file:: open {*}$args]}]} { return $res } } } return [tk_getOpenFile {*}$args] } proc doOpenLeft {top {forget 0}} { if {!$forget && [info exists ::eskil($top,leftDir)]} { set initDir $::eskil($top,leftDir) } elseif {[info exists ::eskil($top,rightDir)]} { set initDir $::eskil($top,rightDir) } else { set initDir [pwd] } set apa [myOpenFile -title "Select left file" -initialdir $initDir \ -parent $top] if {$apa != ""} { set ::eskil($top,leftDir) [file dirname $apa] set ::eskil($top,leftFile) $apa set ::eskil($top,leftLabel) $apa set ::eskil($top,leftOK) 1 return 1 } return 0 } proc doOpenRight {top {forget 0}} { if {!$forget && [info exists ::eskil($top,rightDir)]} { set initDir $::eskil($top,rightDir) } elseif {[info exists ::eskil($top,leftDir)]} { set initDir $::eskil($top,leftDir) } else { set initDir [pwd] } set apa [myOpenFile -title "Select right file" -initialdir $initDir \ -parent $top] if {$apa != ""} { set ::eskil($top,rightDir) [file dirname $apa] set ::eskil($top,rightFile) $apa set ::eskil($top,rightLabel) $apa set ::eskil($top,rightOK) 1 return 1 } return 0 } proc doOpenAncestor {top} { if {$::eskil($top,ancestorFile) ne ""} { set initDir [file dirname $::eskil($top,ancestorFile)] } elseif {[info exists ::eskil($top,leftDir)]} { set initDir $::eskil($top,leftDir) } elseif {[info exists ::eskil($top,rightDir)]} { set initDir $::eskil($top,rightDir) } else { set initDir [pwd] } set apa [myOpenFile -title "Select ancestor file" -initialdir $initDir \ -parent $top] if {$apa != ""} { set ::eskil($top,ancestorFile) $apa return 1 } return 0 } proc openLeft {top} { if {[doOpenLeft $top]} { set ::eskil($top,mode) "" set ::eskil($top,mergeFile) "" doDiff $top } } proc openRight {top} { if {[doOpenRight $top]} { set ::eskil($top,mode) "" set ::eskil($top,mergeFile) "" doDiff $top } } proc openAncestor {top} { if {[doOpenAncestor $top]} { # Redo diff with ancestor doDiff $top } } proc openConflict {top} { global Pref if {[doOpenRight $top]} { startConflictDiff $top $::eskil($top,rightFile) set ::eskil($top,mergeFile) "" doDiff $top } } proc openPatch {top} { global Pref if {[doOpenLeft $top]} { set ::eskil($top,mode) "patch" set Pref(ignore) " " set Pref(nocase) 0 set Pref(noempty) 0 set ::eskil($top,patchFile) $::eskil($top,leftFile) set ::eskil($top,patchData) "" doDiff $top } } # Get data from clipboard and display as a patch. proc doPastePatch {top} { if {[catch {::tk::GetSelection $top CLIPBOARD} sel]} { tk_messageBox -icon error -title "Eskil Error" -parent $top \ -message "Could not retreive clipboard" -type ok return } set ::eskil($top,mode) "patch" set ::Pref(ignore) " " set ::Pref(nocase) 0 set ::Pref(noempty) 0 set ::eskil($top,patchFile) "" set ::eskil($top,patchData) $sel doDiff $top } proc openRev {top} { if {[doOpenRight $top]} { set rev [detectRevSystem $::eskil($top,rightFile)] if {$rev eq ""} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not figure out which revison control system\ \"$::eskil($top,rightFile)\" is under." -type ok return } startRevMode $top $rev $::eskil($top,rightFile) set ::eskil($top,mergeFile) "" doDiff $top } } proc openBoth {top forget} { if {[doOpenLeft $top]} { if {[doOpenRight $top $forget]} { set ::eskil($top,mode) "" set ::eskil($top,mergeFile) "" doDiff $top } } } # File drop using TkDnd proc fileDrop {top side files} { # FIXA: Maybe single drop during rev mode should stay in rev mode? # Dropping two files mean set both if {[llength $files] >= 2} { set leftFile [lindex $files 0] set rightFile [lindex $files 1] } elseif {$side eq "left"} { set leftFile [lindex $files 0] set rightFile "" } else { set leftFile "" set rightFile [lindex $files 0] } if {$leftFile ne ""} { set ::eskil($top,leftDir) [file dirname $leftFile] set ::eskil($top,leftFile) $leftFile set ::eskil($top,leftLabel) $leftFile set ::eskil($top,leftOK) 1 set ::eskil($top,mode) "" set ::eskil($top,mergeFile) "" } if {$rightFile ne ""} { set ::eskil($top,rightDir) [file dirname $rightFile] set ::eskil($top,rightFile) $rightFile set ::eskil($top,rightLabel) $rightFile set ::eskil($top,rightOK) 1 set ::eskil($top,mode) "" set ::eskil($top,mergeFile) "" } if {$::eskil($top,leftOK) && $::eskil($top,rightOK)} { doDiff $top } } ##################################### # GUI stuff ##################################### |
︙ | ︙ | |||
2214 2215 2216 2217 2218 2219 2220 | proc disableAlign {top} { eval $::widgets($top,disableAlignCmd) } # Remove one or all alignment pairs proc clearAlign {top {leftline {}}} { if {$leftline == ""} { | | | | | | | | | | | | | | | 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 | proc disableAlign {top} { eval $::widgets($top,disableAlignCmd) } # Remove one or all alignment pairs proc clearAlign {top {leftline {}}} { if {$leftline == ""} { set ::eskil($top,aligns) {} } else { set i 0 while 1 { set i [lsearch -integer -start $i $::eskil($top,aligns) $leftline] if {$i < 0} break if {($i % 2) == 0} { set ::eskil($top,aligns) [lreplace $::eskil($top,aligns) \ $i [+ $i 1]] break } incr i } } if {[llength $::eskil($top,aligns)] == 0} { disableAlign $top } } proc NoMarkAlign {top} { unset -nocomplain ::eskil($top,align1) unset -nocomplain ::eskil($top,align2) unset -nocomplain ::eskil($top,aligntext1) unset -nocomplain ::eskil($top,aligntext2) } # Mark a line as aligned. proc markAlign {top n line text} { set ::eskil($top,align$n) $line set ::eskil($top,aligntext$n) $text if {[info exists ::eskil($top,align1)] && [info exists ::eskil($top,align2)]} { if {![string equal $::eskil($top,aligntext1) $::eskil($top,aligntext2)]} { set apa [tk_messageBox -icon question -title "Align" -type yesno \ -message "Those lines are not equal.\nReally align them?"] if {$apa != "yes"} { return 0 } } lappend ::eskil($top,aligns) $::eskil($top,align1) $::eskil($top,align2) enableAlign $top NoMarkAlign $top return 1 } return 0 } |
︙ | ︙ | |||
2281 2282 2283 2284 2285 2286 2287 | if {![regexp {\d+} $data line]} { return 1 } set text [$::widgets($top,wDiff$n) get $row.0 $row.end] set other [expr {$n == 1 ? 2 : 1}] set cmd [list markAlign $top $n $line $text] | | | | | | 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 | if {![regexp {\d+} $data line]} { return 1 } set text [$::widgets($top,wDiff$n) get $row.0 $row.end] set other [expr {$n == 1 ? 2 : 1}] set cmd [list markAlign $top $n $line $text] if {![info exists ::eskil($top,align$other)]} { set label "Mark line for alignment" } else { set label "Align with line $::eskil($top,align$other) on other side" } if {[info exists ::eskil($top,aligns)]} { foreach {align1 align2} $::eskil($top,aligns) { if {$n == 1 && $line == $align1} { set label "Remove alignment with line $align2" set cmd [list clearAlign $top $align1] } elseif {$n == 2 && $line == $align2} { set label "Remove alignment with line $align1" set cmd [list clearAlign $top $align1] } |
︙ | ︙ | |||
2326 2327 2328 2329 2330 2331 2332 | proc startAlignDrag {top n x y X Y} { # Get the row that was clicked set w $::widgets($top,wLine$n) set index [$w index @$x,$y] set row [lindex [split $index "."] 0] set data [$w get $row.0 $row.end] | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 | proc startAlignDrag {top n x y X Y} { # Get the row that was clicked set w $::widgets($top,wLine$n) set index [$w index @$x,$y] set row [lindex [split $index "."] 0] set data [$w get $row.0 $row.end] set ::eskil($top,alignDrag,state) none # Must be a line number if {![regexp {\d+} $data line]} { return 1 } # Set up information about start of drag set text [$::widgets($top,wDiff$n) get $row.0 $row.end] set other [expr {$n == 1 ? 2 : 1}] set ::eskil($top,alignDrag,X) $X set ::eskil($top,alignDrag,Y) $Y set ::eskil($top,alignDrag,from) $n set ::eskil($top,alignDrag,line$n) $line set ::eskil($top,alignDrag,text$n) $text set ::eskil($top,alignDrag,line$other) "?" set ::eskil($top,alignDrag,state) press } # Mouse moves with button down proc motionAlignDrag {top n shift x y X Y} { if {$::eskil($top,alignDrag,state) eq "press"} { # Have we moved enough to call it dragging? set dX [expr {abs($X - $::eskil($top,alignDrag,X))}] set dY [expr {abs($Y - $::eskil($top,alignDrag,Y))}] if {$dX + $dY > 3} { # Start a drag action set w $top.alignDrag destroy $w toplevel $w wm overrideredirect $w 1 label $w.l -borderwidth 1 -relief solid -justify left pack $w.l set ::eskil($top,alignDrag,W) $w set ::eskil($top,alignDrag,state) "drag" } } if {$::eskil($top,alignDrag,state) eq "drag"} { set w $::eskil($top,alignDrag,W) # Move drag label with cursor wm geometry $w +[expr {$X + 1}]+[expr {$Y + 1}] set n $::eskil($top,alignDrag,from) set other [expr {$n == 1 ? 2 : 1}] set w2 $::widgets($top,wLine$other) # Are we over the other line window? if {[winfo containing $X $Y] eq $w2} { set x [expr {$X - [winfo rootx $w2]}] set y [expr {$Y - [winfo rooty $w2]}] set index [$w2 index @$x,$y] set row [lindex [split $index "."] 0] set data [$w2 get $row.0 $row.end] if {![regexp {\d+} $data line]} { set ::eskil($top,alignDrag,line$other) "?" } else { set ::eskil($top,alignDrag,line$other) $line set text [$::widgets($top,wDiff$other) get $row.0 $row.end] set ::eskil($top,alignDrag,text$other) $text } } else { set ::eskil($top,alignDrag,line$other) "?" } set txt "Align Left $::eskil($top,alignDrag,line1)" append txt "\nwith Right $::eskil($top,alignDrag,line2)" set ::eskil($top,alignDrag,shift) $shift if {$shift} { append txt "\nAnd Redo Diff" } $w.l configure -text $txt } } # Button has been released proc endAlignDrag {top n x y X Y} { if {$::eskil($top,alignDrag,state) eq "drag"} { destroy $::eskil($top,alignDrag,W) # Are both line numbers valid? I.e. is this a full align operation? if {$::eskil($top,alignDrag,line1) ne "?" && \ $::eskil($top,alignDrag,line2) ne "?"} { NoMarkAlign $top markAlign $top 1 $::eskil($top,alignDrag,line1) \ $::eskil($top,alignDrag,text1) set marked [markAlign $top 2 $::eskil($top,alignDrag,line2) \ $::eskil($top,alignDrag,text2)] if {$::eskil($top,alignDrag,shift) && $marked} { redoDiff $top } } } set ::eskil($top,alignDrag,state) none } ################### # Diff highlighting ################### proc hlSelect {top hl} { highLightChange $top $hl } proc hlSeparate {top n hl} { set ::eskil($top,separate$n) $hl set wd $::widgets($top,wDiff$n) set wl $::widgets($top,wLine$n) if {$hl eq ""} { set range [$wd tag ranges sel] } else { set range [$wl tag ranges hl$::eskil($top,separate$n)] } set text [$wd get {*}$range] set ::eskil($top,separatetext$n) $text # Get the lines involved in the display set from [lindex $range 0] set to [lindex $range 1] lassign [split $from "."] froml fromi lassign [split $to "."] tol toi if {$toi == 0} {incr tol -1} # Get the corresponding lines in the file set t [$wl get $froml.0 $tol.end] set lines [lsort -integer [regexp -all -inline {\d+} $t]] set froml [lindex $lines 0] set tol [lindex $lines end] set ::eskil($top,separatelines$n) [list $froml $tol] if {[info exists ::eskil($top,separate1)] && \ [info exists ::eskil($top,separate2)]} { if {1} { cloneDiff $top [concat $::eskil($top,separatelines1) \ $::eskil($top,separatelines2)] } else { set f1 [tmpFile] set f2 [tmpFile] set ch [open $f1 w] puts $ch $::eskil($top,separatetext1) close $ch set ch [open $f2 w] puts $ch $::eskil($top,separatetext2) close $ch newDiff $f1 $f2 } unset ::eskil($top,separate1) unset ::eskil($top,separate2) } } proc hlPopup {top n hl X Y x y} { if {[info exists ::eskil($top,nopopup)] && $::eskil($top,nopopup)} return destroy .lpm menu .lpm if {![editMenu .lpm $top $n $hl $x $y]} { .lpm add separator } if {$hl != ""} { .lpm add command -label "Select" \ -command [list hlSelect $top $hl] } set other [expr {$n == 1 ? 2 : 1}] if {![info exists ::eskil($top,separate$other)]} { set label "Mark for Separate Diff" } else { set label "Separate Diff" } .lpm add command -label $label -command [list hlSeparate $top $n $hl] alignMenu .lpm $top $n $x $y set ::eskil($top,nopopup) 1 tk_popup .lpm $X $Y after idle [list after 1 [list set ::eskil($top,nopopup) 0]] return } # This is called when right clicking over the line numbers which are not # marked for changes proc rowPopup {w X Y x y} { set top [winfo toplevel $w] if {[info exists ::eskil($top,nopopup)] && $::eskil($top,nopopup)} return destroy .lpm menu .lpm regexp {(\d+)\D*$} $w -> n set tmp1 [editMenu .lpm $top $n "" $x $y] if {!$tmp1} {.lpm add separator} set tmp2 [alignMenu .lpm $top $n $x $y] if {$tmp1 && $tmp2} { # Nothing in the menu return } if {!$tmp1 && $tmp2} {.lpm delete last} set ::eskil($top,nopopup) 1 tk_popup .lpm $X $Y after idle [list after 1 [list set ::eskil($top,nopopup) 0]] } proc nextHighlight {top} { set tag hl$::HighLightCount foreach n {1 2} { $::widgets($top,wLine$n) tag bind $tag <ButtonPress-3> \ "hlPopup $top $n $::HighLightCount %X %Y %x %y ; break" |
︙ | ︙ | |||
2653 2654 2655 2656 2657 2658 2659 | font configure myfont -size $Pref(fontsize) -family $Pref(fontfamily) } # Change color settings proc applyColor {} { global dirdiff Pref | | | 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 | font configure myfont -size $Pref(fontsize) -family $Pref(fontfamily) } # Change color settings proc applyColor {} { global dirdiff Pref foreach top $::eskil(diffWindows) { if {$top eq ".clipdiff"} continue if {$top != ".dirdiff"} { foreach item {wLine1 wDiff1 wLine2 wDiff2} { if {![info exists ::widgets($top,$item)]} continue set w $::widgets($top,$item) $w tag configure equal -foreground $Pref(colorequal) \ |
︙ | ︙ | |||
2717 2718 2719 2720 2721 2722 2723 | uplevel \#0 "trace variable $var w \ {after idle {$w xview end} ;#}" } } # Fill in default data for a diff window proc initDiffData {top} { | | | | | | | | | | | | | | | | | | | | | | | 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 | uplevel \#0 "trace variable $var w \ {after idle {$w xview end} ;#}" } } # Fill in default data for a diff window proc initDiffData {top} { set ::eskil($top,leftOK) 0 set ::eskil($top,rightOK) 0 set ::eskil($top,mode) "" set ::eskil($top,printFile) "" set ::eskil($top,mergeFile) "" set ::eskil($top,ancestorFile) "" set ::eskil($top,conflictFile) "" set ::eskil($top,limitlines) 0 set ::eskil($top,plugin) "" } # Create a new diff window and diff two files proc newDiff {file1 file2 {range {}}} { set top [makeDiffWin] update set ::eskil($top,leftDir) [file dirname $file1] set ::eskil($top,leftFile) $file1 set ::eskil($top,leftLabel) $file1 set ::eskil($top,leftOK) 1 set ::eskil($top,rightDir) [file dirname $file2] set ::eskil($top,rightFile) $file2 set ::eskil($top,rightLabel) $file2 set ::eskil($top,rightOK) 1 set ::eskil($top,mode) "" set ::eskil($top,range) $range wm deiconify $top raise $top update doDiff $top return $top } # Create a new diff window equal to another, except for possibly a range proc cloneDiff {other {range {}}} { set top [makeDiffWin] update foreach item [array names ::diff $other,*] { regsub {^[^,]*,} $item {} item set ::eskil($top,$item) $::eskil($other,$item) } if {[llength $range] != 0} { set ::eskil($top,range) $range } wm deiconify $top raise $top update doDiff $top } |
︙ | ︙ | |||
2789 2790 2791 2792 2793 2794 2795 | global Pref tcl_platform if {$top != "" && [winfo exists $top] && [winfo toplevel $top] eq $top} { # Reuse the old window destroy {*}[winfo children $top] } else { # Locate a free toplevel name | | | | 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 | global Pref tcl_platform if {$top != "" && [winfo exists $top] && [winfo toplevel $top] eq $top} { # Reuse the old window destroy {*}[winfo children $top] } else { # Locate a free toplevel name if {[info exists ::eskil(topDiffCnt)]} { set t $::eskil(topDiffCnt) } else { set t 0 } while {[winfo exists .diff$t]} { incr t } set top .diff$t |
︙ | ︙ | |||
2980 2981 2982 2983 2984 2985 2986 | -command [list makeDocWin $file] -underline 0 } $top.m.help add separator $top.m.help add command -label "About" -command makeAboutWin -underline 0 ttk::label $top.lr1 -text "Rev 1" addBalloon $top.lr1 "Revision number for version diff." | | | | 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 | -command [list makeDocWin $file] -underline 0 } $top.m.help add separator $top.m.help add command -label "About" -command makeAboutWin -underline 0 ttk::label $top.lr1 -text "Rev 1" addBalloon $top.lr1 "Revision number for version diff." ttk::entryX $top.er1 -width 12 -textvariable ::eskil($top,doptrev1) set ::widgets($top,rev1) $top.er1 bind $top.er1 <Key-Return> [list redoDiff $top] ttk::label $top.lr2 -text "Rev 2" addBalloon $top.lr2 "Revision number for version diff." ttk::entryX $top.er2 -width 12 -textvariable ::eskil($top,doptrev2) set ::widgets($top,rev2) $top.er2 bind $top.er2 <Key-Return> [list redoDiff $top] ttk::button $top.bcm -text Commit -command [list revCommit $top] \ -state disabled -underline 0 set ::widgets($top,commit) $top.bcm ttk::button $top.blg -text Log -command [list revLog $top] \ |
︙ | ︙ | |||
3010 3011 3012 3013 3014 3015 3016 | bind $top <Alt-p> [list findDiff $top -1] bind $top <Alt-c> [list revCommit $top] bind $top <Alt-l> [list revLog $top] catch {font delete myfont} font create myfont -family $Pref(fontfamily) -size $Pref(fontsize) | | | | 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 | bind $top <Alt-p> [list findDiff $top -1] bind $top <Alt-c> [list revCommit $top] bind $top <Alt-l> [list revLog $top] catch {font delete myfont} font create myfont -family $Pref(fontfamily) -size $Pref(fontsize) fileLabel $top.l1 -textvariable ::eskil($top,leftLabel) fileLabel $top.l2 -textvariable ::eskil($top,rightLabel) ttk::frame $top.ft1 -borderwidth 2 -relief sunken text $top.ft1.tl -height $Pref(lines) -width 5 -wrap none \ -font myfont -borderwidth 0 -padx 0 -highlightthickness 0 \ -takefocus 0 text $top.ft1.tt -height $Pref(lines) -width $Pref(linewidth) -wrap none \ -xscrollcommand [list $top.sbx1 set] \ |
︙ | ︙ | |||
3125 3126 3127 3128 3129 3130 3131 | $top.m.md add separator } $top.m.md add checkbutton -label "Wrap" -variable wrapstate \ -onvalue char -offvalue none -command \ "$top.ft1.tt configure -wrap \$wrapstate ;\ $top.ft2.tt configure -wrap \$wrapstate" $top.m.md add command -label "Date Filter" \ | | | 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 | $top.m.md add separator } $top.m.md add checkbutton -label "Wrap" -variable wrapstate \ -onvalue char -offvalue none -command \ "$top.ft1.tt configure -wrap \$wrapstate ;\ $top.ft2.tt configure -wrap \$wrapstate" $top.m.md add command -label "Date Filter" \ -command {set ::eskil(filter) {^Date}} $top.m.md add separator $top.m.md add command -label "Reread Source" -underline 0 \ -command {EskilRereadSource} $top.m.md add separator $top.m.md add command -label "Redraw Window" \ -command [list makeDiffWin $top] $top.m.md add separator |
︙ | ︙ | |||
3308 3309 3310 3311 3312 3313 3314 | font configure tmpfont -size $TmpPref(fontsize) } } proc UpdateFontBox {lb} { $lb delete 0 end foreach {f fixed} $::FontCache { | | | 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 | font configure tmpfont -size $TmpPref(fontsize) } } proc UpdateFontBox {lb} { $lb delete 0 end foreach {f fixed} $::FontCache { if {$fixed || !$::eskil(fixedfont)} { $lb insert end $f if {[string equal -nocase $f $::Pref(fontfamily)]} { $lb selection set end $lb see end } } } |
︙ | ︙ | |||
3347 3348 3349 3350 3351 3352 3353 | ttk::labelframe .fo.ls -text "Size" -padding 3 spinbox .fo.ls.sp -from 1 -to 30 -increment 1 -width 3 -state readonly \ -textvariable TmpPref(fontsize) -command [list exampleFont $lb] pack .fo.ls.sp -fill both -expand 1 ttk::label .fo.le -text "Example\n0Ooi1Il" -anchor w -font tmpfont \ -width 1 -justify left | | | | 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 | ttk::labelframe .fo.ls -text "Size" -padding 3 spinbox .fo.ls.sp -from 1 -to 30 -increment 1 -width 3 -state readonly \ -textvariable TmpPref(fontsize) -command [list exampleFont $lb] pack .fo.ls.sp -fill both -expand 1 ttk::label .fo.le -text "Example\n0Ooi1Il" -anchor w -font tmpfont \ -width 1 -justify left if {![info exists ::eskil(fixedfont)]} {set ::eskil(fixedfont) 1} ttk::checkbutton .fo.cb -text "Fixed" -variable ::eskil(fixedfont) \ -command [list UpdateFontBox $lb] ttk::button .fo.bo -text "Ok" -command "applyFont $lb ; destroy .fo" ttk::button .fo.ba -text "Apply" -command "applyFont $lb" ttk::button .fo.bc -text "Close" -command "destroy .fo" if {![info exists FontCache]} { set fam [lsort -dictionary [font families]] |
︙ | ︙ | |||
3387 3388 3389 3390 3391 3392 3393 | } ########################### # Editor for ::Pref(regsub) ########################### proc EditPrefRegsubOk {top w} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 | } ########################### # Editor for ::Pref(regsub) ########################### proc EditPrefRegsubOk {top w} { set exa $::eskil($top,prefregexa) set result {} for {set t 1} {[info exists ::eskil($top,prefregexp$t)]} {incr t} { set RE $::eskil($top,prefregexp$t) set Sub $::eskil($top,prefregsub$t) if {$RE eq ""} continue if {[catch {regsub -all -- $RE $exa $Sub _} err]} { return } lappend result $RE $Sub } set ::Pref(regsub) $result destroy $w array unset ::eskil $top,prefregexp* array unset ::eskil $top,prefregsub* } proc EditPrefRegsubUpdate {top args} { set exa $::eskil($top,prefregexa) set exa2 $::eskil($top,prefregexa2) set ok $::widgets($top,prefRegsubOk) for {set t 1} {[info exists ::eskil($top,prefregexp$t)]} {incr t} { set RE $::eskil($top,prefregexp$t) set Sub $::eskil($top,prefregsub$t) if {$RE eq ""} continue if {[catch {regsub -all -- $RE $exa $Sub result} err]} { set ::eskil($top,prefregresult) "$t ERROR: $err" $ok configure -state disabled return } else { set exa $result } if {[catch {regsub -all -- $RE $exa2 $Sub result} err]} { set ::eskil($top,prefregresult2) "$t ERROR: $err" $ok configure -state disabled return } else { set exa2 $result } } set ::eskil($top,prefregresult2) $exa2 set ::eskil($top,prefregresult) $exa $ok configure -state normal } proc AddPrefRegsub {top parent} { for {set t 1} {[winfo exists $parent.fr$t]} {incr t} { #Empty } set w [ttk::frame $parent.fr$t -borderwidth 2 -relief groove -padding 3] ttk::label $w.l1 -text "Regexp:" -anchor "w" ttk::entryX $w.e1 -textvariable ::eskil($top,prefregexp$t) -width 60 ttk::label $w.l2 -text "Subst:" -anchor "w" ttk::entryX $w.e2 -textvariable ::eskil($top,prefregsub$t) grid $w.l1 $w.e1 -sticky we -padx 3 -pady 3 grid $w.l2 $w.e2 -sticky we -padx 3 -pady 3 grid columnconfigure $w 1 -weight 1 pack $w -side "top" -fill x -padx 3 -pady 3 trace add variable ::eskil($top,prefregexp$t) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregsub$t) write \ [list EditPrefRegsubUpdate $top] } # Editor for ::Pref(regsub) proc EditPrefRegsub {top} { set w $top.prefregsub if {[winfo exists $w] && [winfo toplevel $w] eq $w} { wm deiconify $w raise $w focus $w } else { toplevel $w -padx 3 -pady 3 wm title $w "Preferences: Preprocess" } ttk::button $w.b -text "Add" -command [list AddPrefRegsub $top $w] # Result example part if {![info exists ::eskil($top,prefregexa)]} { set ::eskil($top,prefregexa) \ "An example TextString FOR_REGSUB /* Comment */" set ::eskil($top,prefregexa2) \ "An example TextString FOR_REGSUB /* Comment */" } ttk::labelframe $w.res -text "Preprocessing result" -padding 3 ttk::label $w.res.l3 -text "Example 1:" -anchor "w" ttk::entryX $w.res.e3 -textvariable ::eskil($top,prefregexa) -width 60 ttk::label $w.res.l4 -text "Result 1:" -anchor "w" ttk::label $w.res.e4 -textvariable ::eskil($top,prefregresult) \ -anchor "w" -width 10 ttk::label $w.res.l5 -text "Example 2:" -anchor "w" ttk::entryX $w.res.e5 -textvariable ::eskil($top,prefregexa2) ttk::label $w.res.l6 -text "Result 2:" -anchor "w" ttk::label $w.res.e6 -textvariable ::eskil($top,prefregresult2) \ -anchor "w" -width 10 grid $w.res.l3 $w.res.e3 -sticky we -padx 3 -pady 3 grid $w.res.l4 $w.res.e4 -sticky we -padx 3 -pady 3 grid $w.res.l5 $w.res.e5 -sticky we -padx 3 -pady 3 grid $w.res.l6 $w.res.e6 -sticky we -padx 3 -pady 3 grid columnconfigure $w.res 1 -weight 1 |
︙ | ︙ | |||
3521 3522 3523 3524 3525 3526 3527 | # Fill in existing or an empty line if {[llength $::Pref(regsub)] == 0} { AddPrefRegsub $top $w } else { set t 1 foreach {RE Sub} $::Pref(regsub) { | | | | | | 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 | # Fill in existing or an empty line if {[llength $::Pref(regsub)] == 0} { AddPrefRegsub $top $w } else { set t 1 foreach {RE Sub} $::Pref(regsub) { set ::eskil($top,prefregexp$t) $RE set ::eskil($top,prefregsub$t) $Sub AddPrefRegsub $top $w incr t } } trace add variable ::eskil($top,prefregexa) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregexa2) write \ [list EditPrefRegsubUpdate $top] EditPrefRegsubUpdate $top } proc defaultGuiOptions {} { catch {package require griffin} |
︙ | ︙ | |||
3997 3998 3999 4000 4001 4002 4003 | } # Ok, we have a normal diff set top [makeDiffWin] update # Copy the previously collected options foreach {item val} [array get opts] { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 | } # Ok, we have a normal diff set top [makeDiffWin] update # Copy the previously collected options foreach {item val} [array get opts] { set ::eskil($top,$item) $val } # It is preferable to see the end if the rev string is too long $::widgets($top,rev1) xview end $::widgets($top,rev2) xview end if {$doreview} { set rev [detectRevSystem "" $preferedRev] set ::eskil($top,modetype) $rev set ::eskil($top,mode) "patch" set ::eskil($top,patchFile) "" set ::eskil($top,patchData) "" set ::eskil($top,reviewFiles) $files set ::Pref(toolbar) 1 after idle [list doDiff $top] return $top } if {$len == 1 || $foreach} { set ReturnAfterLoop 0 set first 1 foreach file $files { if {$first} { set first 0 } else { # Create new window for other files set top [makeDiffWin] update # Copy the previously collected options foreach {item val} [array get opts] { set ::eskil($top,$item) $val } # It is preferable to see the end if the rev string is too long $::widgets($top,rev1) xview end $::widgets($top,rev2) xview end } set fullname $file set fulldir [file dirname $fullname] if {$::eskil($top,mode) eq "conflict"} { startConflictDiff $top $fullname after idle [list doDiff $top] set ReturnAfterLoop 1 continue } if {!$autobrowse && !$dopatch} { # Check for revision control set rev [detectRevSystem $fullname $preferedRev] if {$rev ne ""} { startRevMode $top $rev $fullname if {$noautodiff} { enableRedo $top } else { after idle [list doDiff $top] } set ReturnAfterLoop 1 continue } } # No revision control. Is it a patch file? set ::eskil($top,leftDir) $fulldir set ::eskil($top,leftFile) $fullname set ::eskil($top,leftLabel) $fullname set ::eskil($top,leftOK) 1 if {$dopatch || \ [regexp {\.(diff|patch)$} $fullname] || \ $fullname eq "-"} { set ::eskil($top,mode) "patch" set ::eskil($top,patchFile) $fullname set ::eskil($top,patchData) "" set autobrowse 0 if {$noautodiff} { enableRedo $top } else { after idle [list doDiff $top] } set ReturnAfterLoop 1 continue } } if {$ReturnAfterLoop} {return $top} } elseif {$len >= 2} { set fullname [file join [pwd] [lindex $files 0]] set fulldir [file dirname $fullname] set ::eskil($top,leftDir) $fulldir set ::eskil($top,leftFile) $fullname set ::eskil($top,leftLabel) $fullname set ::eskil($top,leftOK) 1 set fullname [file join [pwd] [lindex $files 1]] set fulldir [file dirname $fullname] set ::eskil($top,rightDir) $fulldir set ::eskil($top,rightFile) $fullname set ::eskil($top,rightLabel) $fullname set ::eskil($top,rightOK) 1 if {$noautodiff} { enableRedo $top } else { after idle [list doDiff $top] } } if {$autobrowse && (!$::eskil($top,leftOK) || !$::eskil($top,rightOK))} { if {!$::eskil($top,leftOK) && !$::eskil($top,rightOK)} { openBoth $top 0 } elseif {!$::eskil($top,leftOK)} { openLeft $top } elseif {!$::eskil($top,rightOK)} { openRight $top } # If we cancel the second file and detect CVS, ask about it. if {$::eskil($top,leftOK) && !$::eskil($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 fullname $::eskil($top,leftFile) set ::eskil($top,leftOK) 0 startRevMode $top "CVS" $fullname after idle [list doDiff $top] } } } return $top } |
︙ | ︙ | |||
4221 4222 4223 4224 4225 4226 4227 | # Store default preferences, to filter saved preferences array set ::DefaultPref [array get Pref] # Backward compatibilty option set Pref(onlydiffs) -1 | | | 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 | # Store default preferences, to filter saved preferences array set ::DefaultPref [array get Pref] # Backward compatibilty option set Pref(onlydiffs) -1 set ::eskil(filter) "" if {![info exists ::eskil_testsuite] && [file exists "~/.eskilrc"]} { safeLoad "~/.eskilrc" Pref } if {$Pref(editor) ne ""} { set ::util(editor) $Pref(editor) |
︙ | ︙ |
Changes to src/help.tcl.
︙ | ︙ | |||
214 215 216 217 218 219 220 | if {[catch {cd [file join $::eskil(thisDir) .. examples]}]} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not locate examples directory." \ -type ok return } | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | if {[catch {cd [file join $::eskil(thisDir) .. examples]}]} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not locate examples directory." \ -type ok return } #set ::eskil(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 set w [helpWin .ht "Eskil Tutorial"] |
︙ | ︙ |
Changes to src/map.tcl.
︙ | ︙ | |||
40 41 42 43 44 45 46 | bind $w <Configure> [list drawMap $top %h] bind $w <Button-2> [list ThumbMap $top %y] return $w } proc clearMap {top} { | | | | | | | | | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | bind $w <Configure> [list drawMap $top %h] bind $w <Button-2> [list ThumbMap $top %y] return $w } proc clearMap {top} { set ::eskil($top,changes) {} set ::eskil($top,mapMax) 0 drawMap $top -1 } proc addChange {top n tag line1 n1 line2 n2} { if {$tag ne ""} { lappend ::eskil($top,changes) [list $::eskil($top,mapMax) $n \ $tag $line1 $n1 $line2 $n2] } incr ::eskil($top,mapMax) $n } proc addMapLines {top n} { incr ::eskil($top,mapMax) $n } proc drawMap {top newh} { global Pref set oldh [map$top cget -height] if {$oldh == $newh} return map$top blank if {![info exists ::eskil($top,changes)] || \ [llength $::eskil($top,changes)] == 0} return set w [winfo width $top.c_map] set h [winfo height $top.c_map] set x2 [expr {$w - ($Pref(wideMap) ? 5 : 1)}] if {$x2 < 0} { set x2 0 } map$top configure -width $w -height $h incr h -1 set y0 0 foreach change $::eskil($top,changes) { lassign $change start length type set y1 [expr {$start * $h / $::eskil($top,mapMax) + 1}] if {!$y0} { set y0 $y1 } ;# Record first occurance if {$y1 < 1} {set y1 1} if {$y1 > $h} {set y1 $h} set y2 [expr {($start + $length) * $h / $::eskil($top,mapMax) + 1}] if {$y2 < 1} {set y2 1} if {$y2 <= $y1} {set y2 [expr {$y1 + 1}]} if {$y2 > $h} {set y2 $h} incr y2 map$top put $Pref(color$type) -to 1 $y1 $x2 $y2 } if {$Pref(wideMap)} { |
︙ | ︙ |
Changes to src/merge.tcl.
︙ | ︙ | |||
18 19 20 21 22 23 24 | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # Get all data from the files to merge proc collectMergeData {top} { | | | | | | | | | | | | | | | | | | | | | | | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # Get all data from the files to merge proc collectMergeData {top} { global eskil set eskil($top,leftMergeData) {} set eskil($top,rightMergeData) {} set eskil($top,mergeSelection,AnyConflict) 0 if {![info exists eskil($top,changes)]} { set eskil($top,changes) {} } prepareFiles $top set ch1 [open $eskil($top,leftFile) r] set ch2 [open $eskil($top,rightFile) r] set doingLine1 1 set doingLine2 1 set changeNo 0 foreach change $eskil($top,changes) { lassign $change start length type line1 n1 line2 n2 set data1 {} set data2 {} while {$doingLine1 < $line1} { gets $ch1 apa append data1 $apa\n incr doingLine1 } while {$doingLine2 < $line2} { gets $ch2 apa append data2 $apa\n incr doingLine2 } lappend eskil($top,leftMergeData) $data1 lappend eskil($top,rightMergeData) $data2 set data1 {} set data2 {} for {set t 0} {$t < $n1} {incr t} { gets $ch1 apa append data1 $apa\n incr doingLine1 } for {set t 0} {$t < $n2} {incr t} { gets $ch2 apa append data2 $apa\n incr doingLine2 } lappend eskil($top,leftMergeData) $data1 lappend eskil($top,rightMergeData) $data2 set eskil($top,mergeSelection,$changeNo) \ [WhichSide $top $line1 $n1 $line2 $n2 conflict comment] set eskil($top,mergeSelection,Conflict,$changeNo) $conflict set eskil($top,mergeSelection,Comment,$changeNo) $comment if {$conflict} { set eskil($top,mergeSelection,AnyConflict) 1 } incr changeNo } set data1 {} set data2 {} while {[gets $ch1 apa] != -1} { append data1 $apa\n incr doingLine1 } while {[gets $ch2 apa] != -1} { append data2 $apa\n incr doingLine2 } lappend eskil($top,leftMergeData) $data1 lappend eskil($top,rightMergeData) $data2 close $ch1 close $ch2 cleanupFiles $top } # Fill up the merge window with the initial version of merged files. proc fillMergeWindow {top} { global eskil set w $top.merge.t $w delete 1.0 end set marks {} set t 0 set firstConflict -1 foreach {commLeft diffLeft} $eskil($top,leftMergeData) \ {commRight diffRight} $eskil($top,rightMergeData) { $w insert end $commRight if {![info exists eskil($top,mergeSelection,$t)]} continue $w mark set merges$t insert $w mark gravity merges$t left switch $eskil($top,mergeSelection,$t) { 1 { $w insert end $diffLeft merge$t } 2 { $w insert end $diffRight merge$t } 12 { $w insert end $diffLeft merge$t $w insert end $diffRight merge$t } 21 { $w insert end $diffRight merge$t $w insert end $diffLeft merge$t } } if {$eskil($top,mergeSelection,Conflict,$t)} { $w tag configure merge$t -background grey if {$firstConflict == -1} { set firstConflict $t } } lappend marks mergee$t [$w index insert] incr t |
︙ | ︙ | |||
140 141 142 143 144 145 146 | $w mark set merges[expr {$t + 1}] end set showFirst 0 if {$firstConflict != -1} { set showFirst $firstConflict } | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | $w mark set merges[expr {$t + 1}] end set showFirst 0 if {$firstConflict != -1} { set showFirst $firstConflict } set eskil($top,curMerge) $showFirst set eskil($top,curMergeSel) $eskil($top,mergeSelection,$showFirst) $w tag configure merge$showFirst -foreground red showDiff $top $showFirst update # If there is any diff, show the first if {$t > 0} { seeText $w merges$showFirst mergee$showFirst # Show status for first chunk set eskil($top,mergeStatus) \ $eskil($top,mergeSelection,Comment,$showFirst) } } # Move to and highlight another diff. proc nextMerge {top delta} { global eskil set w $top.merge.t $w tag configure merge$eskil($top,curMerge) -foreground "" set last [expr {[llength $eskil($top,leftMergeData)] / 2 - 1}] if {$delta == -1000} { # Search backward for conflict for {set t [expr {$eskil($top,curMerge) - 1}]} {$t >= 0} {incr t -1} { if {$eskil($top,mergeSelection,Conflict,$t)} { set delta [expr {$t - $eskil($top,curMerge)}] break } } } elseif {$delta == 1000} { # Search forward for conflict for {set t [expr {$eskil($top,curMerge) + 1}]} {$t <= $last} {incr t} { if {$eskil($top,mergeSelection,Conflict,$t)} { set delta [expr {$t - $eskil($top,curMerge)}] break } } } set eskil($top,curMerge) [expr {$eskil($top,curMerge) + $delta}] if {$eskil($top,curMerge) < 0} {set eskil($top,curMerge) 0} if {$eskil($top,curMerge) > $last} { set eskil($top,curMerge) $last } set eskil($top,curMergeSel) $eskil($top,mergeSelection,$eskil($top,curMerge)) $w tag configure merge$eskil($top,curMerge) -foreground red showDiff $top $eskil($top,curMerge) seeText $w merges$eskil($top,curMerge) mergee$eskil($top,curMerge) set eskil($top,mergeStatus) \ $eskil($top,mergeSelection,Comment,$eskil($top,curMerge)) } # Select a merge setting for all diffs. proc selectMergeAll {top new} { global eskil set end [expr {[llength $eskil($top,leftMergeData)] / 2}] for {set t 0} {$t < $end} {incr t} { selectMerge2 $top $t $new } set eskil($top,curMergeSel) $new set w $top.merge.t seeText $w merges$eskil($top,curMerge) mergee$eskil($top,curMerge) } # Change merge setting fo current diff. proc selectMerge {top} { global eskil set w $top.merge.t selectMerge2 $top $eskil($top,curMerge) $eskil($top,curMergeSel) seeText $w merges$eskil($top,curMerge) mergee$eskil($top,curMerge) } # Change merge setting for a diff. proc selectMerge2 {top no new} { global eskil set w $top.merge.t # Delete current string $w delete merges$no mergee$no set eskil($top,mergeSelection,$no) $new set i [expr {$no * 2 + 1}] set diffLeft [lindex $eskil($top,leftMergeData) $i] set diffRight [lindex $eskil($top,rightMergeData) $i] # Temporarily switch surrounding marks # Two steps are enough since there can't be consecutive empty areas # The one before and/or the one after the one being switch might # be empty. $w mark gravity mergee[expr {$no - 2}] left $w mark gravity mergee[expr {$no - 1}] left $w mark gravity merges[expr {$no + 1}] right $w mark gravity merges[expr {$no + 2}] right if {$eskil($top,mergeSelection,$no) == 12} { $w insert merges$no $diffLeft$diffRight merge$no } elseif {$eskil($top,mergeSelection,$no) == 21} { $w insert merges$no $diffRight$diffLeft merge$no } elseif {$eskil($top,mergeSelection,$no) == 1} { $w insert merges$no $diffLeft merge$no } elseif {$eskil($top,mergeSelection,$no) == 2} { $w insert merges$no $diffRight merge$no } # Switch back surrounding marks $w mark gravity mergee[expr {$no - 2}] right $w mark gravity mergee[expr {$no - 1}] right $w mark gravity merges[expr {$no + 1}] left $w mark gravity merges[expr {$no + 2}] left } # Save the merge result. proc saveMerge {top} { set w $top.merge.t if {$::eskil($top,mergeFile) eq "" && $::eskil($top,mode) eq "conflict"} { set apa [tk_messageBox -parent $top.merge -icon question \ -title "Save merge file" -type yesno -message \ "Do you want to overwrite the original conflict file?"] if {$apa == "yes"} { set ::eskil($top,mergeFile) $::eskil($top,conflictFile) } } if {$::eskil($top,mergeFile) eq ""} { # Ask user which file set buttons {} set text "Overwrite file or Browse?" if {[file exists $::eskil($top,leftFile)] && \ $::eskil($top,leftFile) eq $::eskil($top,leftLabel)} { lappend buttons Left append text "\nLeft: $::eskil($top,leftFile)" } if {[file exists $::eskil($top,rightFile)] && \ $::eskil($top,rightFile) eq $::eskil($top,rightLabel)} { lappend buttons Right append text "\nRight: $::eskil($top,rightFile)" } lappend buttons Browse Cancel if {[llength $buttons] > 2} { set apa [tk_dialog .savemerge "Save merge file" \ $text \ questhead -1 {*}$buttons] if {$apa < 0} return set apa [lindex $buttons $apa] if {$apa eq "Left"} { set ::eskil($top,mergeFile) $::eskil($top,leftFile) } elseif {$apa eq "Right"} { set ::eskil($top,mergeFile) $::eskil($top,rightFile) } elseif {$apa eq "Cancel"} { return } } if {$::eskil($top,mergeFile) eq ""} { # Browse if {[info exists ::eskil($top,rightDir)]} { set initDir $::eskil($top,rightDir) } elseif {[info exists ::eskil($top,leftDir)]} { set initDir $::eskil($top,leftDir) } else { set initDir [pwd] } set apa [tk_getSaveFile -title "Save merge file" -initialdir $initDir \ -parent $top.merge] if {$apa eq ""} return set ::eskil($top,mergeFile) $apa } } set ch [open $::eskil($top,mergeFile) "w"] fconfigure $ch -translation $::eskil($top,mergetranslation) puts -nonewline $ch [$w get 1.0 end-1char] close $ch # Detect if this is a GIT merge, and possibly add it to the index # after save (i.e. git add file) if {[detectRevSystem $::eskil($top,mergeFile)] eq "GIT"} { set apa [tk_messageBox -parent $top.merge -icon info -type yesno \ -title "Diff" \ -message "Saved merge to file $::eskil($top,mergeFile).\nAdd\ it to GIT index?"] if {$apa eq "yes"} { eskil::rev::GIT::add $::eskil($top,mergeFile) } } else { tk_messageBox -parent $top.merge -icon info -type ok -title "Diff" \ -message "Saved merge to file $::eskil($top,mergeFile)." } } # Close merge window and clean up. proc closeMerge {top} { global eskil destroy $top.merge set eskil($top,leftMergeData) {} set eskil($top,rightMergeData) {} array unset eskil $top,mergeSelection,* } # Create a window to display merge result. proc makeMergeWin {top} { collectMergeData $top if {![info exists ::eskil($top,mergetranslation)]} { if {$::tcl_platform(platform) eq "windows"} { set ::eskil($top,mergetranslation) crlf } else { set ::eskil($top,mergetranslation) lf } } set w $top.merge if {![winfo exists $w]} { toplevel $w } else { destroy {*}[winfo children $w] } set anyC $::eskil($top,mergeSelection,AnyConflict) wm title $w "Merge result: [TitleTail $top]" menu $w.m $w configure -menu $w.m $w.m add cascade -label "File" -underline 0 -menu $w.m.mf menu $w.m.mf $w.m.mf add command -label "Save" -underline 0 -command "saveMerge $top" $w.m.mf add separator $w.m.mf add command -label "Close" -underline 0 -command "closeMerge $top" $w.m add cascade -label "Select" -underline 0 -menu $w.m.ms menu $w.m.ms $w.m.ms add radiobutton -label "Left+Right" -value 12 \ -variable ::eskil($top,curMergeSel) -command "selectMerge $top" $w.m.ms add radiobutton -label "Left" -underline 0 -value 1 \ -variable ::eskil($top,curMergeSel) -command "selectMerge $top" $w.m.ms add radiobutton -label "Right" -underline 0 -value 2 \ -variable ::eskil($top,curMergeSel) -command "selectMerge $top" $w.m.ms add radiobutton -label "Right+Left" -value 21 \ -variable ::eskil($top,curMergeSel) -command "selectMerge $top" $w.m.ms add separator $w.m.ms add command -label "All Left" -command "selectMergeAll $top 1" $w.m.ms add command -label "All Right" -command "selectMergeAll $top 2" $w.m add cascade -label "Goto" -underline 0 -menu $w.m.mg menu $w.m.mg $w.m.mg add command -accelerator "Up" -label "Previous" -command "nextMerge $top -1" $w.m.mg add command -accelerator "Down" -label "Next" -command "nextMerge $top 1" if {$anyC} { $w.m.mg add command -accelerator "Shift-Up" -label "Previous Conflict" -command "nextMerge $top -1000" $w.m.mg add command -accelerator "Shift-Down" -label "Next Conflict" -command "nextMerge $top 1000" } else { $w.m.mg add command -accelerator "Shift-Up" -label "Previous 10" -command "nextMerge $top -10" $w.m.mg add command -accelerator "Shift-Down" -label "Next 10" -command "nextMerge $top 10" } $w.m add cascade -label "Config" -underline 0 -menu $w.m.mc menu $w.m.mc $w.m.mc add radiobutton -label "Line end LF" -value lf -variable ::eskil($top,mergetranslation) $w.m.mc add radiobutton -label "Line end CRLF" -value crlf -variable ::eskil($top,mergetranslation) if {$::eskil($top,mode) eq "conflict"} { $w.m.mc add separator $w.m.mc add checkbutton -label "Pure" -variable ::eskil($top,modetype) \ -onvalue "Pure" -offvalue "" -command {doDiff} } ttk::frame $w.f ttk::radiobutton $w.f.rb1 -text "LR" -value 12 \ -variable ::eskil($top,curMergeSel) \ -command "selectMerge $top" ttk::radiobutton $w.f.rb2 -text "L" -value 1 \ -variable ::eskil($top,curMergeSel) \ -command "selectMerge $top" ttk::radiobutton $w.f.rb3 -text "R" -value 2 \ -variable ::eskil($top,curMergeSel) \ -command "selectMerge $top" ttk::radiobutton $w.f.rb4 -text "RL" -value 21 \ -variable ::eskil($top,curMergeSel) \ -command "selectMerge $top" bind $w <Key-Left> "focus $w; set ::eskil($top,curMergeSel) 1; selectMerge $top" bind $w <Key-Right> "focus $w; set ::eskil($top,curMergeSel) 2; selectMerge $top" ttk::button $w.f.bl -text "Prev C" -command "nextMerge $top -1000" ttk::button $w.f.br -text "Next C" -command "nextMerge $top 1000" ttk::button $w.f.b1 -text "Prev" -command "nextMerge $top -1" ttk::button $w.f.b2 -text "Next" -command "nextMerge $top 1" bind $w <Key-Down> "focus $w ; nextMerge $top 1" |
︙ | ︙ | |||
459 460 461 462 463 464 465 | text $w.t -width 80 -height 20 -xscrollcommand "$w.sbx set" \ -yscrollcommand "$w.sby set" -font myfont scrollbar $w.sbx -orient horizontal -command "$w.t xview" scrollbar $w.sby -orient vertical -command "$w.t yview" bind $w.t <Key-Escape> [list focus $w] | | | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | text $w.t -width 80 -height 20 -xscrollcommand "$w.sbx set" \ -yscrollcommand "$w.sby set" -font myfont scrollbar $w.sbx -orient horizontal -command "$w.t xview" scrollbar $w.sby -orient vertical -command "$w.t yview" bind $w.t <Key-Escape> [list focus $w] ttk::label $w.ls -textvariable ::eskil($top,mergeStatus) # Prevent toplevel bindings on keys to fire while in the text widget. bindtags $w.t [list Text $w.t $w all] bind $w.t <Key-Left> "break" bind $w.t <Key-Right> "break" bind $w.t <Key-Down> "break" bind $w.t <Key-Up> "break" |
︙ | ︙ | |||
482 483 484 485 486 487 488 | grid rowconfigure $w 1 -weight 1 fillMergeWindow $top } # Compare each file against an ancestor file for three-way merge proc collectAncestorInfo {top dFile1 dFile2 opts} { | | | | | | | | | | | | | | | | | | | | | | | | | | | 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | grid rowconfigure $w 1 -weight 1 fillMergeWindow $top } # Compare each file against an ancestor file for three-way merge proc collectAncestorInfo {top dFile1 dFile2 opts} { if {![info exists ::eskil($top,mergetranslation)]} { # Try to autodetect line endings in ancestor file set ch [open $::eskil($top,ancestorFile) rb] set data [read $ch 10000] close $ch if {[string first \r\n $data] >= 0} { set ::eskil($top,mergetranslation) crlf } else { set ::eskil($top,mergetranslation) lf } } array unset ::eskil $top,ancestorLeft,* array unset ::eskil $top,ancestorRight,* set differrA1 [catch {DiffUtil::diffFiles {*}$opts \ $::eskil($top,ancestorFile) $dFile1} diffresA1] set differrA2 [catch {DiffUtil::diffFiles {*}$opts \ $::eskil($top,ancestorFile) $dFile2} diffresA2] if {$differrA1 != 0 || $differrA2 != 0} { puts $diffresA1 puts $diffresA2 return } foreach i $diffresA1 { lassign $i line1 n1 line2 n2 if {$n1 == 0} { # Added lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::eskil($top,ancestorLeft,$t) a } } elseif {$n2 == 0} { # Deleted lines # Mark the following line set ::eskil($top,ancestorLeft,d$line2) d } else { # Changed lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::eskil($top,ancestorLeft,$t) c } } } foreach i $diffresA2 { lassign $i line1 n1 line2 n2 if {$n1 == 0} { # Added lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::eskil($top,ancestorRight,$t) a } } elseif {$n2 == 0} { # Deleted lines # Mark the following line set ::eskil($top,ancestorRight,d$line2) d } else { # Changed lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::eskil($top,ancestorRight,$t) c } } } #parray ::diff $top,ancestor* } # Use ancestor info to select which side to use in a merge chunk ##nagelfar syntax WhichSide x x x x x n n proc WhichSide {top line1 n1 line2 n2 conflictName commentName} { upvar 1 $conflictName conflict $commentName comment set conflict 0 set comment "" if {$::eskil($top,ancestorFile) eq ""} { # No ancestor info, just select right side return 2 } if {$n1 == 0} { # Only to the right set delLeft [info exists ::eskil($top,ancestorLeft,d$line1)] # Inserted to right : Keep right side if {!$delLeft} { set comment "Right: Add" return 2 } for {set t $line2} {$t < $line2 + $n2} {incr t} { if {[info exists ::eskil($top,ancestorRight,$t)]} { set right($::eskil($top,ancestorRight,$t)) 1 } } # Deleted to left : Keep left side if {[array size right] == 0} { set comment "Left: Delete" return 1 } # Deleted to left and changed to the right : ?? (right for now) # FIXA set comment "*** Left: Delete, Right: Change" set conflict 1 return 2 } elseif {$n2 == 0} { # Only to the left, this can be: set delRight [info exists ::eskil($top,ancestorRight,d$line2)] # Inserted to left : Keep left side if {!$delRight} { set comment "Left: Add" return 1 } for {set t $line1} {$t < $line1 + $n1} {incr t} { if {[info exists ::eskil($top,ancestorLeft,$t)]} { set left($::eskil($top,ancestorLeft,$t)) 1 } } # Deleted to right : Keep right side if {[array size left] == 0} { set comment "Right: Delete" return 2 } # Deleted to right and changed to the left : ?? (right for now) # FIXA set comment "*** Left: Change, Right: Delete" set conflict 1 return 2 } else { # Changed on both sides # Collect left side info for {set t $line1} {$t < $line1 + $n1} {incr t} { if {[info exists ::eskil($top,ancestorLeft,$t)]} { set left($::eskil($top,ancestorLeft,$t)) 1 } } # No changes against ancestor on left side means it is just # changed to the right : Keep right if {[array size left] == 0} { set comment "Right: Change" return 2 } # Collect right side info for {set t $line2} {$t < $line2 + $n2} {incr t} { if {[info exists ::eskil($top,ancestorRight,$t)]} { set right($::eskil($top,ancestorRight,$t)) 1 } } # No changes against ancestor on right side means it is just # changed to the left : Keep left if {[array size right] == 0} { set comment "Left: Change" |
︙ | ︙ |
Changes to src/plugin.tcl.
︙ | ︙ | |||
125 126 127 128 129 130 131 | puts "Plugin \"$plugin\" : $descr" } } proc preparePlugin {top} { #FIXA: plugin miffo disallowEdit $top | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | puts "Plugin \"$plugin\" : $descr" } } proc preparePlugin {top} { #FIXA: plugin miffo disallowEdit $top $::eskil($top,plugin) eval [list array set ::Pref [array get ::Pref]] set out1 [tmpFile] set out2 [tmpFile] set chi [open $::eskil($top,leftFile) r] set cho [open $out1 w] interp share {} $chi $::eskil($top,plugin) interp share {} $cho $::eskil($top,plugin) set usenew1 [$::eskil($top,plugin) eval [list PreProcess left $chi $cho]] $::eskil($top,plugin) invokehidden close $chi $::eskil($top,plugin) invokehidden close $cho close $chi close $cho set chi [open $::eskil($top,rightFile) r] set cho [open $out2 w] interp share {} $chi $::eskil($top,plugin) interp share {} $cho $::eskil($top,plugin) set usenew2 [$::eskil($top,plugin) eval [list PreProcess right $chi $cho]] $::eskil($top,plugin) invokehidden close $chi $::eskil($top,plugin) invokehidden close $cho close $chi close $cho if {$usenew1} { # The file after processing should be used both # for comparison and for displaying. set ::eskil($top,leftFileBak) $::eskil($top,leftFile) set ::eskil($top,leftFile) $out1 } else { set ::eskil($top,leftFileDiff) $out1 #set ::eskil($top,leftLabel) "$::eskil($top,RevFile) $tag" } if {$usenew2} { set ::eskil($top,rightFileBak) $::eskil($top,rightFile) set ::eskil($top,rightFile) $out2 } else { set ::eskil($top,rightFileDiff) $out2 #set ::eskil($top,rightLabel) $::eskil($top,RevFile) } } proc cleanupPlugin {top} { if {[info exists ::eskil($top,leftFileBak)]} { set ::eskil($top,leftFile) $::eskil($top,leftFileBak) } if {[info exists ::eskil($top,rightFileBak)]} { set ::eskil($top,rightFile) $::eskil($top,rightFileBak) } unset -nocomplain \ ::eskil($top,leftFileBak) ::eskil($top,rightFileBak) \ ::eskil($top,leftFileDiff) ::eskil($top,rightFileDiff) } # GUI for plugin selection proc EditPrefPlugins {top} { set w $top.prefplugin # Create window destroy $w toplevel $w -padx 3 -pady 3 ttk::frame $w._bg place $w._bg -x 0 -y 0 -relwidth 1.0 -relheight 1.0 -border outside wm title $w "Preferences: Plugins" set plugins [listPlugins] if {[llength $plugins] == 0} { grid [ttk::label $w.l -text "No plugins found."] - -padx 3 -pady 3 } if {![info exists ::eskil($top,pluginname)]} { set ::eskil($top,pluginname) "" } if {![info exists ::eskil($top,plugininfo)]} { set ::eskil($top,plugininfo) "" } set ::eskil($top,edit,pluginname) $::eskil($top,pluginname) set ::eskil($top,edit,plugininfo) $::eskil($top,plugininfo) set t 0 foreach {plugin descr} $plugins { ttk::radiobutton $w.rb$t -variable ::eskil($top,edit,pluginname) -value $plugin -text $plugin ttk::label $w.l$t -text $descr -anchor "w" grid $w.rb$t $w.l$t -sticky we -padx 3 -pady 3 incr t } ttk::radiobutton $w.rb$t -variable ::eskil($top,edit,pluginname) -value "" -text "No Plugin" grid $w.rb$t -sticky we -padx 3 -pady 3 ttk::label $w.li -text "Info" -anchor "w" ttk::entry $w.ei -textvariable ::eskil($top,edit,plugininfo) grid $w.li $w.ei -sticky we -padx 3 -pady 3 ttk::frame $w.fb -padding 3 ttk::button $w.fb.b1 -text "Ok" -command [list EditPrefPluginsOk $top $w] ttk::button $w.fb.b2 -text "Cancel" -command [list destroy $w] set ::widgets($top,prefPluginsOk) $w.fb.b1 grid $w.fb.b1 x $w.fb.b2 -sticky we grid columnconfigure $w.fb {0 2} -uniform a grid columnconfigure $w.fb 1 -weight 1 grid $w.fb - -sticky we grid columnconfigure $w 1 -weight 1 } proc EditPrefPluginsOk {top w} { destroy $w set ::eskil($top,pluginname) $::eskil($top,edit,pluginname) set ::eskil($top,plugininfo) $::eskil($top,edit,plugininfo) if {$::eskil($top,pluginname) ne ""} { set pinterp [createPluginInterp $::eskil($top,pluginname) $::eskil($top,plugininfo)] } else { set pinterp "" } set ::eskil($top,plugin) $pinterp } |
Changes to src/print.tcl.
︙ | ︙ | |||
235 236 237 238 239 240 241 | # Finished normalCursor $top } proc PdfPrint {top cpl cpln wraplines1 wraplines2} { | | | | | | | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | # Finished normalCursor $top } proc PdfPrint {top cpl cpln wraplines1 wraplines2} { if {$::eskil($top,printFile) != ""} { set pdfFile $::eskil($top,printFile) } else { set pdfFile ~/eskil.pdf } if {![regexp {^(.*)( \(.*?\))$} $::eskil($top,leftLabel) -> lfile lrest]} { set lfile $::eskil($top,leftLabel) set lrest "" } set lfile [file tail $lfile]$lrest if {![regexp {^(.*)( \(.*?\))$} $::eskil($top,rightLabel) -> rfile rrest]} { set rfile $::eskil($top,rightLabel) set rrest "" } set rfile [file tail $rfile]$rrest set pdf [eskilprint %AUTO% -file $pdfFile -cpl $cpl -cpln $cpln \ -headleft $lfile -headright $rfile -headsize 10] set linesPerPage [$pdf getNLines] |
︙ | ︙ | |||
289 290 291 292 293 294 295 | $pdf endPrint } # Count the length of a line during a text dump proc AccumulateMax {key value index} { set index [lindex [split $index "."] 1] set len [expr {[string length $value] + $index - 1}] | | | | | | | | 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 | $pdf endPrint } # Count the length of a line during a text dump proc AccumulateMax {key value index} { set index [lindex [split $index "."] 1] set len [expr {[string length $value] + $index - 1}] if {$len > $::eskil(currentCharsPerLine)} { set ::eskil(currentCharsPerLine) $len } } # Count the longest line length in the current display proc CountCharsPerLine {top} { set ::eskil(currentCharsPerLine) 0 $::widgets($top,wDiff1) dump -text -command AccumulateMax 1.0 end $::widgets($top,wDiff2) dump -text -command AccumulateMax 1.0 end return $::eskil(currentCharsPerLine) } proc BrowsePrintFileName {top entry} { set prev $::eskil($top,printFile) set dir [file dirname $prev] set apa [tk_getSaveFile -initialdir $dir -initialfile [file tail $prev] \ -parent [winfo toplevel $entry] -title "PDF file"] if {$apa ne ""} { set ::eskil($top,printFile) $apa $entry xview end } } # Create a print dialog for PDF. proc doPrint {top {quiet 0}} { if {$quiet} { |
︙ | ︙ | |||
401 402 403 404 405 406 407 | grid .pr.cf.l1 .pr.cf.s1r .pr.cf.s1g .pr.cf.s1b -sticky w -padx 3 -pady 3 grid .pr.cf.l2 .pr.cf.s2r .pr.cf.s2g .pr.cf.s2b -sticky w -padx 3 -pady 3 grid .pr.cf.l3 .pr.cf.s3r .pr.cf.s3g .pr.cf.s3b -sticky w -padx 3 -pady 3 # File ttk::label .pr.fnl -anchor w -text "File name" | | | | | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | grid .pr.cf.l1 .pr.cf.s1r .pr.cf.s1g .pr.cf.s1b -sticky w -padx 3 -pady 3 grid .pr.cf.l2 .pr.cf.s2r .pr.cf.s2g .pr.cf.s2b -sticky w -padx 3 -pady 3 grid .pr.cf.l3 .pr.cf.s3r .pr.cf.s3g .pr.cf.s3b -sticky w -padx 3 -pady 3 # File ttk::label .pr.fnl -anchor w -text "File name" ttk::entryX .pr.fne -textvariable ::eskil($top,printFile) -width 30 ttk::button .pr.fnb -text Browse \ -command [list BrowsePrintFileName $top .pr.fne] if {$::eskil($top,printFile) eq ""} { set ::eskil($top,printFile) "~/eskil.pdf" } ttk::frame .pr.fb ttk::button .pr.b1 -text "Print to File" \ -command "destroy .pr; update; PrintDiffs $top" ttk::button .pr.b2 -text "Cancel" -command {destroy .pr} pack .pr.b1 -in .pr.fb -side left -padx 3 -pady 3 -ipadx 5 |
︙ | ︙ |
Changes to src/rev.tcl.
︙ | ︙ | |||
939 940 941 942 943 944 945 | } return } # Initialise revision control mode # The file name should be an absolute normalized path. proc startRevMode {top rev file} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | } return } # Initialise revision control mode # The file name should be an absolute normalized path. proc startRevMode {top rev file} { set ::eskil($top,mode) "rev" set ::eskil($top,modetype) $rev set ::eskil($top,rightDir) [file dirname $file] set ::eskil($top,RevFile) $file set ::eskil($top,rightLabel) $file set ::eskil($top,rightFile) $file set ::eskil($top,rightOK) 1 set ::eskil($top,leftLabel) $rev set ::eskil($top,leftOK) 0 set ::Pref(toolbar) 1 } # Prepare for revision diff. Checkout copies of the versions needed. proc prepareRev {top} { global Pref $::widgets($top,commit) configure -state disabled $::widgets($top,log) configure -state disabled set type $::eskil($top,modetype) set revs {} # Search for revision options if {$::eskil($top,doptrev1) != ""} { lappend revs $::eskil($top,doptrev1) } if {$::eskil($top,doptrev2) != ""} { lappend revs $::eskil($top,doptrev2) } set revs [eskil::rev::${type}::ParseRevs $::eskil($top,RevFile) $revs] set revlabels {} foreach rev $revs { lappend revlabels [GetLastTwoPath $rev] } set ::eskil($top,RevRevs) $revs if {[llength $revs] < 2} { # Compare local file with specified version. disallowEdit $top 1 if {[llength $revs] == 0} { set r "" set tag "($type)" } else { set r [lindex $revs 0] set tag "($type [lindex $revlabels 0])" } set ::eskil($top,leftFile) [tmpFile] set ::eskil($top,leftLabel) "$::eskil($top,RevFile) $tag" set ::eskil($top,rightLabel) $::eskil($top,RevFile) set ::eskil($top,rightFile) $::eskil($top,RevFile) eskil::rev::${type}::get $::eskil($top,RevFile) $::eskil($top,leftFile) $r if {[llength $revs] == 0} { if {[info commands eskil::rev::${type}::commitFile] ne ""} { $::widgets($top,commit) configure -state normal } } } else { # Compare the two specified versions. disallowEdit $top set r1 [lindex $revs 0] set r2 [lindex $revs 1] set ::eskil($top,leftFile) [tmpFile] set ::eskil($top,rightFile) [tmpFile] set ::eskil($top,leftLabel) \ "$::eskil($top,RevFile) ($type [lindex $revlabels 0])" set ::eskil($top,rightLabel) \ "$::eskil($top,RevFile) ($type [lindex $revlabels 1])" eskil::rev::${type}::get $::eskil($top,RevFile) $::eskil($top,leftFile) $r1 eskil::rev::${type}::get $::eskil($top,RevFile) $::eskil($top,rightFile) $r2 } if {[llength $revs] > 0} { if {[info commands eskil::rev::${type}::viewLog] ne ""} { $::widgets($top,log) configure -state normal } } # Make sure labels are updated before processing starts update idletasks } # Clean up after a revision diff. proc cleanupRev {top} { global Pref clearTmp $::eskil($top,rightFile) $::eskil($top,leftFile) set ::eskil($top,rightFile) $::eskil($top,RevFile) set ::eskil($top,leftFile) $::eskil($top,RevFile) } proc revCommit {top} { if {[$::widgets($top,commit) cget -state] eq "disabled"} return set type $::eskil($top,modetype) if {$::eskil($top,mode) eq "patch"} { set files $::eskil($top,reviewFiles) } else { set files [list $::eskil($top,RevFile)] } eskil::rev::${type}::commitFile $top {*}$files } proc revLog {top} { if {[$::widgets($top,log) cget -state] eq "disabled"} return set type $::eskil($top,modetype) eskil::rev::${type}::viewLog $top $::eskil($top,RevFile) \ $::eskil($top,RevRevs) } # Get a complete tree patch from this system. proc getFullPatch {top} { global Pref $::widgets($top,commit) configure -state disabled $::widgets($top,log) configure -state disabled set type $::eskil($top,modetype) set files $::eskil($top,reviewFiles) set revs {} # Search for revision options if {$::eskil($top,doptrev1) != ""} { lappend revs $::eskil($top,doptrev1) } if {$::eskil($top,doptrev2) != ""} { lappend revs $::eskil($top,doptrev2) } set revs [eskil::rev::${type}::ParseRevs "" $revs] set revlabels {} foreach rev $revs { lappend revlabels [GetLastTwoPath $rev] } |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | # Dialog for log message proc LogDialog {top target {clean 0}} { set w $top.logmsg destroy $w toplevel $w -padx 3 -pady 3 wm title $w "Commit log message for $target" | | | | | | | | | | 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | # Dialog for log message proc LogDialog {top target {clean 0}} { set w $top.logmsg destroy $w toplevel $w -padx 3 -pady 3 wm title $w "Commit log message for $target" set ::eskil($top,logdialogok) 0 text $w.t -width 70 -height 10 if {!$clean && [info exists ::eskil(logdialog)]} { $w.t insert end $::eskil(logdialog) $w.t tag add sel 1.0 end-1c $w.t mark set insert 1.0 } ttk::button $w.ok -width 10 -text "Commit" -underline 1 \ -command "set ::eskil($top,logdialogok) 1 ; \ set ::eskil(logdialog) \[$w.t get 1.0 end\] ; \ destroy $w" ttk::button $w.ca -width 10 -text "Cancel" -command "destroy $w" \ -underline 0 bind $w <Alt-o> [list $w.ok invoke]\;break bind $w <Alt-c> [list destroy $w]\;break bind $w <Key-Escape> [list destroy $w]\;break grid $w.t - -sticky news -padx 3 -pady 3 grid $w.ok $w.ca -padx 3 -pady 3 tkwait visibility $w focus -force $w.t tkwait window $w if {$::eskil($top,logdialogok)} { set res [string trim $::eskil(logdialog)] set ::eskil(logdialog) $res if {$res eq ""} { set res "No Log" } } else { set res "" } return $res |
︙ | ︙ |
Changes to tests/patch.test.
1 2 3 4 5 6 | # Tests for patch file parsingunctions -*- tcl -*- #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # Overload exec during these tests | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Tests for patch file parsingunctions -*- tcl -*- #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # Overload exec during these tests set ::eskil(gurka,patchFile) "" set ::eskil(gurka,patchData) "" stub update args {} stub getFullPatch {top} { return $::testpatch } stub displayOnePatch {top leftLines rightLines leftLine rightLine} { } stub emptyLine {top n {highlight 1}} { |
︙ | ︙ |
Changes to tests/rev.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Tests for revision control functions -*- tcl -*- #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # Overload exec during these tests stub exec {args} { set cmd [lindex $args 0] switch -- $cmd { cleartool { # cleartool lshistory -short $filename # cleartool pwv -s # cleartool get -to $outfile $filerev | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Tests for revision control functions -*- tcl -*- #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # Overload exec during these tests stub exec {args} { set cmd [lindex $args 0] switch -- $cmd { cleartool { # cleartool lshistory -short $filename # cleartool pwv -s # cleartool get -to $outfile $filerev # cleartool ls $::eskil($top,RevFile) if {[lindex $args 1] eq "lshistory"} { return [join [list x@/Apa/Bepa/12 x@/Apa/Cepa/2 x@/Apa/22 x@/Apa] \n] } if {[lindex $args 1] eq "pwv"} { return $::ct_pwv } if {[lindex $args 1] eq "ls"} { |
︙ | ︙ |