Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Cleanup and comments. Release 2.2 |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ae677d875842abaf3ba0e4a7af383576 |
User & Date: | peter 2007-04-05 13:09:48.000 |
Context
2007-04-05
| ||
13:11 | Release 2.2 check-in: c61dc27a08 user: peter tags: trunk | |
13:09 | Cleanup and comments. Release 2.2 check-in: ae677d8758 user: peter tags: trunk | |
13:07 | No Log check-in: 7ec5255ab9 user: peter tags: trunk | |
Changes
Changes to src/eskil.tcl.
︙ | ︙ | |||
35 36 37 38 39 40 41 | # Stop Tk from meddling with the command line by copying it first. set ::eskil(argv) $::argv set ::eskil(argc) $::argc set ::argv {} set ::argc 0 set debug 0 | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # Stop Tk from meddling with the command line by copying it first. set ::eskil(argv) $::argv set ::eskil(argc) $::argc set ::argv {} set ::argc 0 set debug 0 set diffver "Version 2.2 2007-04-05" set ::thisScript [file join [pwd] [info script]] # 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} |
︙ | ︙ | |||
105 106 107 108 109 110 111 | } # Debug function to be able to reread the source even when wrapped in a kit. proc EskilRereadSource {} { set this $::thisScript # FIXA: Better detection of starkit? | | | > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | } # Debug function to be able to reread the source even when wrapped in a kit. proc EskilRereadSource {} { set this $::thisScript # FIXA: Better detection of starkit? # Maybe look at ::starkit::topdir ? #if {[info exists ::starkit::topdir]} { # puts "Topdir: $::starkit::topdir" #} # Are we in a Starkit? if {[regexp {^(.*eskil)((?:\.[^/]+)?)(/src/.*)$} $this -> \ pre ext post]} { if {$ext ne ".vfs"} { # If the unpacked vfs directory is available, read from that # instead. |
︙ | ︙ | |||
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 | # Format a line number proc myFormL {lineNo} { if {![string is integer -strict $lineNo]} {return "$lineNo\n"} return [format "%3d: \n" $lineNo] } proc tmpFile {} { if {[info exists ::tmpcnt]} { incr ::tmpcnt } else { set ::tmpcnt 0 } set name [file join $::diff(tmpdir) "tmpd[pid]a$::tmpcnt"] lappend ::tmpfiles $name return $name } proc clearTmp {args} { if {![info exists ::tmpfiles]} { set ::tmpfiles {} return } if {[llength $args] > 0} { foreach f $args { | > > | 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 | # 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 proc tmpFile {} { if {[info exists ::tmpcnt]} { incr ::tmpcnt } else { set ::tmpcnt 0 } set name [file join $::diff(tmpdir) "tmpd[pid]a$::tmpcnt"] lappend ::tmpfiles $name return $name } # Delete temporary files proc clearTmp {args} { if {![info exists ::tmpfiles]} { set ::tmpfiles {} return } if {[llength $args] > 0} { foreach f $args { |
︙ | ︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 | } if {$tag != ""} { set tag "hl$::HighLightCount $tag" } $::widgets($top,wLine$n) insert end [myFormL $line] $tag } proc emptyLine {top n {highlight 1}} { if {$highlight} { $::widgets($top,wLine$n) insert end "\n" hl$::HighLightCount } else { $::widgets($top,wLine$n) insert end "*****\n" } $::widgets($top,wDiff$n) insert end "\n" padding | > | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | } if {$tag != ""} { set tag "hl$::HighLightCount $tag" } $::widgets($top,wLine$n) insert end [myFormL $line] $tag } # Insert an empty line on one side of the diff. proc emptyLine {top n {highlight 1}} { if {$highlight} { $::widgets($top,wLine$n) insert end "\n" hl$::HighLightCount } else { $::widgets($top,wLine$n) insert end "*****\n" } $::widgets($top,wDiff$n) insert end "\n" padding |
︙ | ︙ | |||
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | } else { insertLine $top 1 $doingLine1 $line1 "change" insertLine $top 2 $doingLine2 $line2 "change" } incr doingLine1 incr doingLine2 } # Insert two blocks of lines in the compare windows. # Returns number of lines used to display the blocks # Negative if the block should be viewed as equal proc insertMatchingBlocks {top block1 block2} { global doingLine1 doingLine2 # A large block may take time. Give a small warning. if {[llength $block1] * [llength $block2] > 1000} { set ::widgets($top,eqLabel) "!" #puts "Eskil warning: Analyzing a large block. ($size1 $size2)" update idletasks } # Detect if only newlines has changed within the block, e.g. # when rearranging newlines. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < | < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 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 | } else { insertLine $top 1 $doingLine1 $line1 "change" insertLine $top 2 $doingLine2 $line2 "change" } incr doingLine1 incr doingLine2 } # Detect if only newlines has changed within the block, e.g. # when rearranging newlines. # Rearranging newlines in comment blocks usually leads to # words moving across "*", ignore * too. # Returns 0 if the block in not handled here, non-zero if the block is done. proc ParseBlocksAcrossNewline {top block1 block2} { global doingLine1 doingLine2 set map {{ } {} \t {}} set RE {\n\s*\*?|\s} set equal 0 set visible [expr {$::eskil(ignorenewline) == 1}] if 1 { set block1nospace [regsub -all $RE [join $block1 \n] {}] set block2nospace [regsub -all $RE [join $block2 \n] {}] if {$block1nospace eq $block2nospace} { set equal 1 } } else { set block1nospace [string map $map [join $block1 ""]] set block2nospace [string map $map [join $block2 ""]] if {$block1nospace eq $block2nospace} { set equal 1 } else { # Look for newlines rearranged in a comment block. set block1nostar [string map {* {}} $block1nospace] set block2nostar [string map {* {}} $block2nospace] if {$block1nostar eq $block2nostar} { set equal 1 } } } if {!$equal} { return 0 } if {$visible} { set tag change } else { set tag {} } # Just insert the blocks foreach line $block1 { insertLine $top 1 $doingLine1 $line {} $tag incr doingLine1 } foreach line $block2 { insertLine $top 2 $doingLine2 $line {} $tag incr doingLine2 } set n1 [llength $block1] set n2 [llength $block2] if {$n1 <= $n2} { for {set t $n1} {$t < $n2} {incr t} { if {$visible} { $::widgets($top,wDiff1) insert end "\n" "padding change" $::widgets($top,wLine1) insert end "\n" hl$::HighLightCount } else { emptyLine $top 1 } } } elseif {$n2 < $n1} { if {$visible} { for {set t $n2} {$t < $n1} {incr t} { $::widgets($top,wDiff2) insert end "\n" "padding change" $::widgets($top,wLine2) insert end "\n" hl$::HighLightCount } } else { emptyLine $top 2 } } if {$visible} { $::widgets($top,wDiff1) insert end "\n" "padding change" $::widgets($top,wDiff2) insert end "\n" "padding change" $::widgets($top,wLine1) insert end "\n" hl$::HighLightCount $::widgets($top,wLine2) insert end "\n" hl$::HighLightCount return [expr {($n1 > $n2 ? $n1 : $n2) + 1}] } else { return [expr {-($n1 > $n2 ? $n1 : $n2)}] } } # Insert two blocks of lines in the compare windows. # Returns number of lines used to display the blocks # Negative if the block should be viewed as equal proc insertMatchingBlocks {top block1 block2} { global doingLine1 doingLine2 # A large block may take time. Give a small warning. if {[llength $block1] * [llength $block2] > 1000} { set ::widgets($top,eqLabel) "!" #puts "Eskil warning: Analyzing a large block. ($size1 $size2)" update idletasks } # Detect if only newlines has changed within the block, e.g. # when rearranging newlines. if {$::eskil(ignorenewline)} { set res [ParseBlocksAcrossNewline $top $block1 $block2] if {$res != 0} { return $res } } set apa [compareBlocks $block1 $block2] set t1 0 set t2 0 |
︙ | ︙ | |||
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 | } } ##################################### # Editing ##################################### # Clear Editing state proc resetEdit {top} { set ::diff($top,leftEdit) 0 set ::diff($top,rightEdit) 0 $top.m.mt entryconfigure "Edit Mode" -state normal resetEditW $::widgets($top,wDiff1) | > > > | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 | } } ##################################### # Editing ##################################### # FIXA: Use snit to adapt text widget instead of using wcb # include seeText in such a snidget. # Clear Editing state proc resetEdit {top} { set ::diff($top,leftEdit) 0 set ::diff($top,rightEdit) 0 $top.m.mt entryconfigure "Edit Mode" -state normal resetEditW $::widgets($top,wDiff1) |
︙ | ︙ | |||
1671 1672 1673 1674 1675 1676 1677 | # Check if a filename is a directory and handle starkits proc FileIsDirectory {file} { # Skip directories if {[file isdirectory $file]} {return 1} # This detects .kit but how to detect starpacks? if {[file extension $file] eq ".kit"} { | | | | | | > | 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 | # Check if a filename is a directory and handle starkits proc FileIsDirectory {file} { # Skip directories if {[file isdirectory $file]} {return 1} # This detects .kit but how to detect starpacks? if {[file extension $file] eq ".kit"} { if {![catch {package require vfs::mk4}]} { vfs::mk4::Mount $file $file -readonly # Check for contents to ensure it is a kit if {[llength [glob -nocomplain $file/*]] == 0} { vfs::unmount $file } } } return [file isdirectory $file] } # A wrapper for tk_getOpenFile proc myOpenFile {args} { |
︙ | ︙ |