Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Cleanup |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f02d0c04f1fc45f196713ad021f8167d |
User & Date: | peter 2019-11-10 17:28:42.940 |
Context
2019-11-10
| ||
19:47 | More Edit Mode commands check-in: 30dff04537 user: peter tags: trunk | |
17:28 | Cleanup check-in: f02d0c04f1 user: peter tags: trunk | |
16:29 | Cleanup check-in: 46064856af user: peter tags: trunk | |
Changes
Changes to eskil.vfs/lib/psballoon/psballoon.tcl.
︙ | ︙ | |||
57 58 59 60 61 62 63 | } lappend lines $line } set msg [join $lines \n] return $msg } | | | | | | | | | | 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 | } lappend lines $line } set msg [join $lines \n] return $msg } proc psballoon::addBalloon {W args} { variable balloon set msg [lindex $args end] set args [lrange $args 0 end-1] # Request for formatting if {"-fmt" in $args && $msg ne ""} { set msg [Fmt $msg] } set c [winfo class $W] if {$msg == "" && $c != "Listbox" && $c != "Label"} { error "Missing message to balloon for $W ($c)" } set balloon(msg,$W) $msg bind $W <Enter> { set ::psballoon::balloon(pending) 1 set ::psballoon::balloon(created) 0 set ::psballoon::balloon(id) [after 500 {psballoon::createBalloon %W %x %y}] } bind $W <Button> { psballoon::killBalloon } bind $W <Leave> { psballoon::killBalloon } bind $W <Motion> { if {$::psballoon::balloon(pending) == 1} { after cancel $::psballoon::balloon(id) } if {$::psballoon::balloon(created) == 1} { psballoon::killBalloon } set ::psballoon::balloon(id) [after 500 {psballoon::createBalloon %W %x %y}] |
︙ | ︙ | |||
120 121 122 123 124 125 126 | if {$lw > $len} { set len $lw } } return $len } | | | | | | | | | | | | | | | | | | 120 121 122 123 124 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 | if {$lw > $len} { set len $lw } } return $len } proc psballoon::createBalloon {W mx my} { variable balloon if {$balloon(created) == 0} { # Figure out widget's font if {[catch {set font [$W cget -font]}]} { set font [ttk::style lookup [winfo class $W] -font] } # Fallback to something reasonable of font fails. if {$font eq ""} { set font TkDefaultFont } set ww [winfo width $W] set ih [winfo height $W] if {[winfo class $W] in {TLabelframe Labelframe}} { # Put it below the label, not the entire widget. # 1.5 font heights is a reasonable guess set fh [font metrics $font -linespace] set ih [expr {$fh * 3 /2 }] # Below cursor at least if {$ih <= $my} { set ih [expr {$my + 5}] } } set ix 0 set iy 0 set create 1 set msg $balloon(msg,$W) if {$msg == ""} { switch [winfo class $W] { Listbox { set i [$W index @$mx,$my] set msg [$W get $i] foreach {ix iy iw ih} [$W bbox $i] {break} } Label { set msg [$W cget -text] set iw [Measure $font $msg] } } # Don't create a balloon if the text is fully visible. set create [expr {$iw > $ww - 8}] } else { if {[string index $msg 0] eq "\["} { set msg [subst -novariables -nobackslashes $msg] } set iw [Measure $font $msg] } if {$create} { set x [expr {[winfo rootx $W] + $ix}] set y [expr {[winfo rooty $W] + $iy + $ih + 2}] if {$x + $iw + 8 > [winfo screenwidth $W]} { set x [expr {[winfo screenwidth $W] - $iw - 8}] } toplevel .balloon -bg black wm overrideredirect .balloon 1 label .balloon.l \ -text $msg -relief flat -font $font -justify left \ -bg #ffffaa -fg black -padx 2 -pady 0 -anchor "w" pack .balloon.l -side left -padx 1 -pady 1 wm geometry .balloon +${x}+${y} set balloon(created) 1 } } } |
Changes to eskil.vfs/lib/pstools/pstools.tcl.
︙ | ︙ | |||
80 81 82 83 84 85 86 | $w configure -yscrollcommand [list pstools::CommonYScroll_YScroll $sby] } set yscroll($sby) $args } # A simple window for displaying e.g. help. # Returns the frame where things can be put. | | | | | | | | | | | | | | 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 | $w configure -yscrollcommand [list pstools::CommonYScroll_YScroll $sby] } set yscroll($sby) $args } # A simple window for displaying e.g. help. # Returns the frame where things can be put. proc pstools::helpWin {W title} { destroy $W toplevel $W -padx 2 -pady 2 wm title $W $title bind $W <Key-Return> [list destroy $W] bind $W <Key-Escape> [list destroy $W] frame $W.f button $W.b -text "Close" -command [list destroy $W] -width 10 \ -default active pack $W.b -side bottom -pady 2 pack $W.f -side top -expand y -fill both -padx 2 -pady 2 focus $W return $W.f } # Figure out a place to store temporary files. proc pstools::locateTmp {globVar} { upvar "#0" $globVar var set candidates {} |
︙ | ︙ |
Changes to nfplugin.tcl.
1 2 3 4 5 6 7 | ##Nagelfar Plugin : Check of Eskil's sources proc statementWords {words info} { set caller [dict get $info caller] set callee [lindex $words 0] set res {} | | > | < < | | | | > > > > > > > > > | > > | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ##Nagelfar Plugin : Check of Eskil's sources proc statementWords {words info} { set caller [dict get $info caller] set callee [lindex $words 0] set res {} # Rule: Space around initial "!" in expr. # Reason: I find it more readable if {$callee eq "if"} { set e [lindex $words 1] if {[regexp {\{(\s*)!(\s*)[\[$]} $e -> pre post]} { if {$pre ne " " || $post ne " "} { lappend res warning lappend res "Not (!) should be surrounded by one space" } } } # Rule: Do not allow single letter variables as arguments. # Reason: A lot of old unreadable code had them. # Exception: Upper-case "W","x" and "y". if {$callee eq "proc"} { set argList [lindex $words 2] foreach arg [lindex $argList 0] { set arg [lindex $arg 0] set lcArg [string tolower $arg] if {[string length $arg] == 1 && $lcArg eq $arg} { if {$arg ni {x y}} { lappend res warning lappend res "Single letter argument '$arg' is not allowed '$argList'" } } } } return $res } |
Changes to plugins/csv.tcl.
︙ | ︙ | |||
43 44 45 46 47 48 49 | } # Allow backslash for easy access to \t set opts(-sep) [subst -nocommands -novariables $opts(-sep)] # If any column is given by name, assume the file starts with # a header line of column names foreach col [concat $opts(-csvignore) $opts(-csvkey)] { | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | } # Allow backslash for easy access to \t set opts(-sep) [subst -nocommands -novariables $opts(-sep)] # If any column is given by name, assume the file starts with # a header line of column names foreach col [concat $opts(-csvignore) $opts(-csvkey)] { if { ! [string is integer $col]} { set opts(-csvheader) 1 } } if {$opts(-csvheader)} { set nameLine [gets $chi] # Keep it first in file puts $cho $nameLine |
︙ | ︙ |
Changes to plugins/keyword.tcl.
︙ | ︙ | |||
43 44 45 46 47 48 49 | # Compensate for any change in length if {[string length $f1] < [string length $f2]} { append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]] } if {[string length $f2] < [string length $f1]} { append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]] } | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # Compensate for any change in length if {[string length $f1] < [string length $f2]} { append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]] } if {[string length $f2] < [string length $f1]} { append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]] } if { ! [string equal $f1 $f2]} { # Returning 0 signals "not equal" return 0 } # Return 1 means "equal" # Return 2 means "equal this far", and lets normal compare take over return 2 } |
Changes to plugins/nocase.tcl.
︙ | ︙ | |||
33 34 35 36 37 38 39 | # Info dictionaries contain at least elements "name" and "size". proc FileCompare {ch1 ch2 info1 info2} { set bufsz 65536 while 1 { set f1 [read $ch1 $bufsz] set f2 [read $ch2 $bufsz] if {$f1 eq "" && $f2 eq ""} break | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # Info dictionaries contain at least elements "name" and "size". proc FileCompare {ch1 ch2 info1 info2} { set bufsz 65536 while 1 { set f1 [read $ch1 $bufsz] set f2 [read $ch2 $bufsz] if {$f1 eq "" && $f2 eq ""} break if { ! [string equal -nocase $f1 $f2]} { # Returning 0 signals "not equal" return 0 } } # Return 1 means "equal" # Return 2 means "equal this far", and lets normal compare take over |
︙ | ︙ |
Changes to plugins/pdf.tcl.
︙ | ︙ | |||
31 32 33 34 35 36 37 | if {[file exists $cand.exe]} { set cand $cand.exe set found 1 break } } | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | if {[file exists $cand.exe]} { set cand $cand.exe set found 1 break } } if { ! $found} { puts $cho "PDF plugin needs external tool 'pdftotext' to run" return 1 } if {[catch {llength $::Info}]} { puts $cho "PDF plugin needs -plugininfo parameter to be a list" return 1 } |
︙ | ︙ |
Changes to src/clip.tcl.
︙ | ︙ | |||
179 180 181 182 183 184 185 | #} grid $top.f.mf $top.f.b2 $top.f.b4 x $top.f.b x $top.f.b3 $top.f.b5 x \ -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] | | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | #} grid $top.f.mf $top.f.b2 $top.f.b4 x $top.f.b x $top.f.b3 $top.f.b5 x \ -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 } |
︙ | ︙ |
Changes to src/compare.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 32 33 | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- proc maxAbs {v1 v2} { return [expr {abs($v1) > abs($v2) ? $v1 : $v2}] } # Compare two lines and rate how much they resemble each other. # This has never worked well. Some day I'll sit down, think this through, # and come up with a better algorithm. proc CompareLines {line1 line2} { set opts $::Pref(ignore) |
︙ | ︙ |
Changes to src/debug.tcl.
︙ | ︙ | |||
32 33 34 35 36 37 38 | } # Get procs in global namespace proc ::_Debug::Procs {pat} { return [uplevel \#0 [list info procs $pat]] } | | | | | | | | | | | 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 | } # Get procs in global namespace proc ::_Debug::Procs {pat} { return [uplevel \#0 [list info procs $pat]] } proc debugMenu {mW} { $mW add cascade -label "Debug" -menu $mW.debug -underline 0 menu $mW.debug if {$::tcl_platform(platform) eq "windows"} { $mW.debug add checkbutton -label "Console" -variable consolestate \ -onvalue show -offvalue hide -command {console $consolestate} \ -underline 0 $mW.debug add separator } $mW.debug add command -label "Edit" -command ::_Debug::ProcEditor \ -underline 0 #::_Debug::DumpStuff return $mW.debug } proc ::_Debug::ProcEditorUpdate {aVal kVal} { # Only update on keys generating characters if {$aVal eq "" || ![string is graph $aVal]} return set p [Procs $::_Debug::ProcEditor(proc)] if {$p eq "" && $::_Debug::ProcEditor(proc) ne ""} { # Try prefix matching set p [Procs $::_Debug::ProcEditor(proc)*] # Include namespaces if starting with :: if {[string match "::*" $::_Debug::ProcEditor(proc)]} { |
︙ | ︙ | |||
137 138 139 140 141 142 143 | $top.t insert end $da } #----------------------------------------------------------------------------- # Tree view and filter #----------------------------------------------------------------------------- | | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | $top.t insert end $da } #----------------------------------------------------------------------------- # Tree view and filter #----------------------------------------------------------------------------- proc ::_Debug::ProcEditorFilter {aVal kVal} { # Only update on keys generating characters if {$aVal eq "" || ![string is graph $aVal]} return set f $::_Debug::ProcEditor(filter) set tree $::_Debug::ProcEditor(treeW) #foreach item [$tree] } proc ::_Debug::TreeCreatePath {tree path} { if {[$tree exists $path]} return |
︙ | ︙ | |||
255 256 257 258 259 260 261 | } # Which ones are procs? foreach cmd [info procs ${preNs}::*] { set allcmds($cmd) "proc" set thisround($cmd) 0 } # Which ones are imports? | | | | | 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 | } # Which ones are procs? foreach cmd [info procs ${preNs}::*] { set allcmds($cmd) "proc" set thisround($cmd) 0 } # Which ones are imports? if { ! [catch {namespace eval $ns {namespace import}} imports]} { foreach cmd $imports { set allcmds(${preNs}::$cmd) "import" set thisround(${preNs}::$cmd) 0 } } # Look through and command that is not something identified foreach cmd [array names thisround] { if { ! $thisround($cmd)} continue # Is it an ensemble? if {[namespace ensemble exists $cmd]} { set allcmds($cmd) ensemble foreach {key val} [namespace ensemble configure $cmd] { #lappend allcmds($cmd) $key $val if {$key eq "-map"} { #puts "$cmd $val" lappend allcmds($cmd) {*}$val } # Recognise a snit class if {$key eq "-unknown" && [string match ::snit::* $val]} { lset allcmds($cmd) 0 snit } } } # Is it oo::class? if { ! [catch {info class methods $cmd -private} methods]} { set allcmds($cmd) "oo::class $methods" } } # info class # info object # How to recognise methods? |
︙ | ︙ |
Changes to src/dirdiff.tcl.
︙ | ︙ | |||
42 43 44 45 46 47 48 | if {[lindex [lsort -dictionary [list $s1 $s2]] 0] eq $s1} { return -1 } return 1 } # Sort file names | | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | if {[lindex [lsort -dictionary [list $s1 $s2]] 0] eq $s1} { return -1 } return 1 } # Sort file names proc Fsort {lst} { lsort -dictionary $lst } # Compare two files or dirs # Return true if equal proc CompareFiles {file1 file2} { if {[catch {file lstat $file1 stat1}]} { return 0 |
︙ | ︙ | |||
144 145 146 147 148 149 150 | if {[string length $f1] < [string length $f2]} { append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]] } if {[string length $f2] < [string length $f1]} { append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]] } if {$nocase} { | | | | | | 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 | if {[string length $f1] < [string length $f2]} { append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]] } if {[string length $f2] < [string length $f1]} { append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]] } if {$nocase} { if { ! [string equal -nocase $f1 $f2]} { set eq 0 } } else { if { ! [string equal $f1 $f2]} { set eq 0 } } } while {$eq == 2 && ![eof $ch1] && ![eof $ch2]} { set f1 [read $ch1 $bufsz] set f2 [read $ch2 $bufsz] if {$nocase} { if { ! [string equal -nocase $f1 $f2]} { set eq 0 } } else { if { ! [string equal $f1 $f2]} { set eq 0 } } # It has been observered that sometimes channels fail to # signal eof. Maybe when they come from a pipe? # Protect by noticing empty strings. if {[string equal $f1 ""] || [string equal $f2 ""]} { |
︙ | ︙ | |||
245 246 247 248 249 250 251 | foreach pat $::Pref(dir,exdirs) { if {[string match $pat $tail]} { set allowed 0 break } } } | | | | 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 | foreach pat $::Pref(dir,exdirs) { if {[string match $pat $tail]} { set allowed 0 break } } } if { ! $allowed} continue } else { if {[llength $::Pref(dir,incfiles)] == 0} { set allowed 1 } else { set allowed 0 foreach pat $::Pref(dir,incfiles) { if {[string match $pat $tail]} { set allowed 1 break } } } if {$allowed} { foreach pat $::Pref(dir,exfiles) { if {[string match $pat $tail]} { set allowed 0 break } } } if { ! $allowed} continue } lappend files2 $full } return [Fsort $files2] } |
︙ | ︙ | |||
387 388 389 390 391 392 393 | } method SetDirOption {option value} { set options($option) $value if {$options(-leftdirvariable) eq ""} return upvar \#0 $options(-leftdirvariable) left | | | | | | | | 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 | } method SetDirOption {option value} { set options($option) $value if {$options(-leftdirvariable) eq ""} return upvar \#0 $options(-leftdirvariable) left if { ! [info exists left]} return if { ! [file isdirectory $left]} return if {$options(-rightdirvariable) eq ""} return upvar \#0 $options(-rightdirvariable) right if { ! [info exists right]} return if { ! [file isdirectory $right]} return set leftDir $left set rightDir $right if { ! $ScheduledRestart} { set ScheduledRestart 1 after idle [mymethod ReStart] } } method newTopDir {newLeft newRight} { if {$newLeft ne "" && [file isdirectory $newLeft]} { upvar \#0 $options(-leftdirvariable) left set left $newLeft set leftDir $left } if {$newRight ne "" && [file isdirectory $newRight]} { upvar \#0 $options(-rightdirvariable) right set right $newRight set rightDir $right } if { ! $ScheduledRestart} { set ScheduledRestart 1 after idle [mymethod ReStart] } } method nice {ms} { # Sanity check |
︙ | ︙ | |||
495 496 497 498 499 500 501 | # Format a time stamp for display proc FormatDate {date} { clock format $date -format "%Y-%m-%d %H:%M:%S" } method busyCursor {} { variable oldcursor | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | # Format a time stamp for display proc FormatDate {date} { clock format $date -format "%Y-%m-%d %H:%M:%S" } method busyCursor {} { variable oldcursor if { ! [info exists oldcursor]} { set oldcursor(hull) [$hull cget -cursor] set oldcursor(tree) [$tree cget -cursor] } $hull configure -cursor watch $tree configure -cursor watch } |
︙ | ︙ | |||
621 622 623 624 625 626 627 | file copy -force $src $dst # FIXA: update file info in tree too $self SetNodeStatus $node equal } } else { set msg "Copy\n$src\nto\n$dst ?" set dstdir [file dirname $dst] | | | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | file copy -force $src $dst # FIXA: update file info in tree too $self SetNodeStatus $node equal } } else { set msg "Copy\n$src\nto\n$dst ?" set dstdir [file dirname $dst] if { ! [file isdirectory $dstdir]} { append msg "\nCreating Directory\n$dstdir ?" } if {[tk_messageBox -icon question -title "Copy file?" -message \ $msg -type yesno] eq "yes"} { if { ! [file isdirectory $dstdir]} { file mkdir $dstdir } file copy $src $dst # FIXA: update file info in tree too $self SetNodeStatus $node equal } } |
︙ | ︙ | |||
731 732 733 734 735 736 737 | $m add command -label "Create Dir left" -command \ [mymethod CreateDir $node left] } } } if {$type eq "file"} { if {([string match left* $colname] || $oneside) && $lf ne ""} { | | | | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | $m add command -label "Create Dir left" -command \ [mymethod CreateDir $node left] } } } if {$type eq "file"} { if {([string match left* $colname] || $oneside) && $lf ne ""} { if { ! [dict get $protect right]} { $m add command -label "Copy File to Right" \ -command [mymethod CopyFile $node left] } $m add command -label "Edit Left File" \ -command [list EditFile $lf] $m add command -label "Mark Left File" \ -command [list set [myvar leftMark] $lf] if {$rightMark != ""} { $m add command -label "Compare Left with $rightMark" \ -command [list newDiff $lf $rightMark] } } elseif {([string match right* $colname] || $oneside) && $rf ne ""} { if { ! [dict get $protect left]} { $m add command -label "Copy File to Left" \ -command [mymethod CopyFile $node right] } $m add command -label "Edit Right File" \ -command [list EditFile $rf] $m add command -label "Mark Right File" \ -command [list set [myvar rightMark] $rf] |
︙ | ︙ | |||
1257 1258 1259 1260 1261 1262 1263 | $win.m add cascade -label "Tools" -underline 0 -menu $win.m.mt menu $win.m.mt $win.m.mt add command -label "New Diff Window" -underline 0 \ -command makeDiffWin $win.m.mt add command -label "Clip Diff" -underline 0 \ -command makeClipDiffWin if {$::tcl_platform(platform) eq "windows"} { | | | 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | $win.m add cascade -label "Tools" -underline 0 -menu $win.m.mt menu $win.m.mt $win.m.mt add command -label "New Diff Window" -underline 0 \ -command makeDiffWin $win.m.mt add command -label "Clip Diff" -underline 0 \ -command makeClipDiffWin if {$::tcl_platform(platform) eq "windows"} { if { ! [catch {package require registry}]} { $win.m.mt add separator $win.m.mt add command -label "Setup Registry" -underline 6 \ -command makeRegistryWin } } $win.m add cascade -label "Help" -underline 0 -menu $win.m.help |
︙ | ︙ | |||
1490 1491 1492 1493 1494 1495 1496 | grid $top.l2 $top.e2 -sticky we grid columnconfigure $top 1 -weight 1 grid rowconfigure $top 2 -weight 1 } proc makeDirDiffWin {} { | | | | 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 | grid $top.l2 $top.e2 -sticky we grid columnconfigure $top 1 -weight 1 grid rowconfigure $top 2 -weight 1 } proc makeDirDiffWin {} { if { ! [info exists ::dirdiff(leftDir)]} { set ::dirdiff(leftDir) "" } if { ! [info exists ::dirdiff(rightDir)]} { set ::dirdiff(rightDir) "" } # TODO, multi plugin for dirdiff? set ::eskil(.dirdiff,plugin,1) "" foreach {item val} $::eskil(defaultopts) { set ::eskil(.dirdiff,$item) $val } |
︙ | ︙ |
Changes to src/eskil.tcl.
︙ | ︙ | |||
66 67 68 69 70 71 72 | # cleanupAndExit can be used to get rid of it. proc eskilRegisterToplevel {top} { lappend ::eskil(diffWindows) $top } # Format a line number proc myFormL {lineNo} { | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # 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]} { |
︙ | ︙ | |||
89 90 91 92 93 94 95 | set name [file join $::eskil(tmpdir) $name] lappend ::tmpfiles $name return $name } # Delete temporary files proc clearTmp {args} { | | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | set name [file join $::eskil(tmpdir) $name] 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 { set i [lsearch -exact $::tmpfiles $f] if {$i >= 0} { |
︙ | ︙ | |||
116 117 118 119 120 121 122 | # insertLine, when in table mode proc insertLineTable {top side line text {tag equal}} { set RE $::eskil($top,separator) set words [split $text $RE] set id [$::widgets($top,wTable) insert end $words] if {$tag ne "equal"} { set col 0 | | | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # insertLine, when in table mode proc insertLineTable {top side line text {tag equal}} { set RE $::eskil($top,separator) set words [split $text $RE] set id [$::widgets($top,wTable) insert end $words] if {$tag ne "equal"} { set col 0 foreach word $words { if {$side == 1} { # TBD TABLE, r is faked here for now dict set ::eskil($top,tablechanges) $id,$col w1 $word dict set ::eskil($top,tablechanges) $id,$col w2 "" dict set ::eskil($top,tablechanges) $id,$col r "0 0 1 1" } else { dict set ::eskil($top,tablechanges) $id,$col w1 "" dict set ::eskil($top,tablechanges) $id,$col w2 $word dict set ::eskil($top,tablechanges) $id,$col r "0 0 1 1" } incr col } } } |
︙ | ︙ | |||
230 231 232 233 234 235 236 | } #puts "RES '$res'" return $res } # This is called from the table view whenever a cell is drawn. # Add color as needed. | | | | | | | | | | 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 | } #puts "RES '$res'" return $res } # This is called from the table view whenever a cell is drawn. # Add color as needed. proc tblModeColorCallback {win W key row col tabIdx1 tabIdx2 inStripe selected} { set cellX $key,$col set top [winfo toplevel $win] if { ! [dict exists $::eskil($top,tablechanges) $cellX]} { # No changes, nothing to do here return } set cinfo [dict get $::eskil($top,tablechanges) $cellX] set w1 [dict get $cinfo w1] set w2 [dict get $cinfo w2] #puts "COLOR UPDATE W $win K $key R $row C $col TB1 $tabIdx1 TB2 $tabIdx2" #puts " [string length $xxx] '$xxx'" #puts " CHANGEME" # Currently the displayed string is just $w1$w2 # The table might have cut of display of a cell so make sure to stay # within the boundaries. set txIdx1 [$W index $tabIdx1+1c] set l1 [string length $w1] set mid "$txIdx1 + $l1 char" if {[$W compare $mid >= $tabIdx2]} { set mid $tabIdx2 } $W tag add new1 $txIdx1 $mid $W tag add new2 $mid $tabIdx2 # Get the displayed string set xxx [$W get $txIdx1 $tabIdx2] if {$xxx ne "$w1$w2"} { # Make sure dots are coloured $W tag add change "$tabIdx2 - 3c" $tabIdx2 } } # insertMatchingLines, when in table mode proc insertMatchingLinesTable {top line1 line2} { global doingLine1 doingLine2 |
︙ | ︙ | |||
416 417 418 419 420 421 422 | set block1nostar [string map {* {}} $block1nospace] set block2nostar [string map {* {}} $block2nospace] if {$block1nostar eq $block2nostar} { set equal 1 } } } | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | 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 {} |
︙ | ︙ | |||
577 578 579 580 581 582 583 | if {$::eskil($top,ancestorRight,$t) eq "c"} { set rightChange 1 break } } } # Avoid fine grain if either side has no changes against ancestor | | | | 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | 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} { set finegrain 0 } # Avoid fine grain if both sides have at most additions if { ! $leftChange && !$rightChange} { set finegrain 0 } } set t1 0 set t2 0 foreach c $apa { |
︙ | ︙ | |||
664 665 666 667 668 669 670 | addChange $top 1 new2 [expr {$line1 + $t1}] 0 \ [expr {$line2 + $t2}] 1 nextHighlight $top } incr t2 } } | | | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | addChange $top 1 new2 [expr {$line1 + $t1}] 0 \ [expr {$line2 + $t2}] 1 nextHighlight $top } incr t2 } } if { ! $finegrain} { if {$details} { addChange $top [llength $apa] change $line1 $n1 $line2 $n2 nextHighlight $top } else { addMapLines $top [llength $apa] } } |
︙ | ︙ | |||
836 837 838 839 840 841 842 | proc busyCursor {top} { global oldcursor oldcursor2 if {$::eskil($top,view) eq "table"} { set items wTable } else { set items {wLine1 wDiff1 wLine2 wDiff2} } | | | | | | | 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 | proc busyCursor {top} { global oldcursor oldcursor2 if {$::eskil($top,view) eq "table"} { set items wTable } else { set items {wLine1 wDiff1 wLine2 wDiff2} } if { ! [info exists oldcursor]} { set oldcursor [$top cget -cursor] set i1 [lindex $items 0] set oldcursor2 [$::widgets($top,$i1) cget -cursor] } $top config -cursor watch foreach item $items { if {[info exists ::widgets($top,$item)]} { set W $::widgets($top,$item) $W config -cursor watch } } } proc normalCursor {top} { global oldcursor oldcursor2 if {$::eskil($top,view) eq "table"} { set items wTable } else { set items {wLine1 wDiff1 wLine2 wDiff2} } $top config -cursor $oldcursor foreach item $items { if {[info exists ::widgets($top,$item)]} { set W $::widgets($top,$item) $W config -cursor $oldcursor2 } } } ##################################### # Special cases. Conflict/patch ##################################### |
︙ | ︙ | |||
1239 1240 1241 1242 1243 1244 1245 | if {[regexp {^---\s*(\d*)} $line -> sub]} { if {$sub != ""} { set rightLine $sub } set state right continue } | | | | | 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | if {[regexp {^---\s*(\d*)} $line -> sub]} { if {$sub != ""} { set rightLine $sub } set state right continue } if { ! [regexp {^[\s!+-]} $line]} continue lappend leftLines [list $leftLine \ [string trim [string range $line 0 1]] \ [string range $line 2 end]] incr leftLine continue } # We are in the right part of a -c style diff if {$state eq "right"} { if { ! [regexp {^[\s!+-]} $line]} continue lappend rightLines [list $rightLine \ [string trim [string range $line 0 1]] \ [string range $line 2 end]] incr rightLine continue } # We are in a -u style diff if {$state eq "both"} { if { ! [regexp {^[\s+-]} $line]} continue set sig [string trim [string index $line 0]] set str [string range $line 1 end] if {$sig eq ""} { lappend leftLines [list $leftLine "" $str] lappend rightLines [list $rightLine "" $str] incr leftLine incr rightLine |
︙ | ︙ | |||
1295 1296 1297 1298 1299 1300 1301 | ##################################### # Main diff ##################################### proc highlightTabs {top} { foreach item {wDiff1 wDiff2} { | | | | | | | | 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | ##################################### # Main diff ##################################### proc highlightTabs {top} { foreach item {wDiff1 wDiff2} { set W $::widgets($top,$item) ##nagelfar vartype W _obj,text set count {} set x [$W search -regexp -all -count count {\t+} 1.0] foreach si $x l $count { $W tag add tab $si "$si + $l chars" } $W tag configure tab -background bisque $W tag raise tab } } # Prepare for a diff by creating needed temporary files proc prepareFiles {top} { set ::eskil($top,cleanup) {} if {$::eskil($top,mode) eq "rev"} { |
︙ | ︙ | |||
1383 1384 1385 1386 1387 1388 1389 | # TBD TABLE doDiff $top # Restore view return } # Note what rows are being displayed | | | | | | | | | 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 | # TBD TABLE doDiff $top # Restore view return } # Note what rows are being displayed set W $::widgets($top,wDiff1) set width [winfo width $W] set height [winfo height $W] set first [$W index @0,0] set last [$W index @[- $width 4],[- $height 4]] set first [lindex [split $first .] 0] set last [lindex [split $last .] 0] # Narrow it 5 lines since seeText will try to view 5 lines extra incr first 5 incr last -5 if {$last < $first} { set last $first } doDiff $top # Restore view foreach item {wLine1 wDiff1 wLine2 wDiff2} { 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)] |
︙ | ︙ | |||
1442 1443 1444 1445 1446 1447 1448 | } busyCursor $top resetEdit $top # Clear up everything before starting processing if {$::eskil($top,view) eq "table"} { | | | | | | | | | | 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 | } busyCursor $top resetEdit $top # Clear up everything before starting processing if {$::eskil($top,view) eq "table"} { set W $::widgets($top,wTable) # TBD TABLE $W configure -state normal $W delete 0 end set ::eskil($top,tablechanges) {} } else { foreach item {wLine1 wDiff1 wLine2 wDiff2 wTb} { set W $::widgets($top,$item) $W configure -state normal $W delete 1.0 end } } clearMap $top set ::HighLightCount 0 highLightChange $top -1 # 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 #drawEditButtons $top foreach item {wLine1 wLine2} { set W $::widgets($top,$item) $W configure -state disabled } update idletasks wm title $top "Eskil: [file tail $::eskil($top,patchFile)]" # TBD TABLE $::widgets($top,wLine2) see 1.0 if {$::eskil($top,printFileCmd) && $::eskil($top,printFile) ne ""} { after idle "doPrint $top 1 ; cleanupAndExit all" |
︙ | ︙ | |||
1648 1649 1650 1651 1652 1653 1654 | doText $top $ch1 $ch2 0 0 $end1 $end2 if {$::eskil($top,view) ne "table"} { # Make sure all text widgets have the same number of lines. # The common y scroll doesn't work well if not. set max 0.0 foreach item {wLine1 wDiff1 wLine2 wDiff2} { | | | | | | | | 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | doText $top $ch1 $ch2 0 0 $end1 $end2 if {$::eskil($top,view) ne "table"} { # Make sure all text widgets have the same number of lines. # The common y scroll doesn't work well if not. set max 0.0 foreach item {wLine1 wDiff1 wLine2 wDiff2} { set W $::widgets($top,$item) if {[$W index end] > $max} { set max [$W index end] } } foreach item {wLine1 wDiff1 wLine2 wDiff2} { set W $::widgets($top,$item) set d [expr {int($max) - int([$W index end])}] for {set t 0} {$t < $d} {incr t} { $W insert end \n padding } } } close $ch1 close $ch2 |
︙ | ︙ | |||
1690 1691 1692 1693 1694 1695 1696 | } } drawMap $top -1 #drawEditButtons $top if {$::eskil($top,view) ne "table"} { foreach item {wLine1 wLine2 wTb} { | | | | 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 | } } drawMap $top -1 #drawEditButtons $top if {$::eskil($top,view) ne "table"} { foreach item {wLine1 wLine2 wTb} { set W $::widgets($top,$item) $W configure -state disabled } update idletasks $::widgets($top,wLine2) see 1.0 } normalCursor $top showDiff $top 0 if {$::widgets($top,eqLabel) eq "!"} { |
︙ | ︙ | |||
1734 1735 1736 1737 1738 1739 1740 | # 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. | | | | | | | | | | | 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | # 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 changeIndex} { if {[info exists ::eskil($top,currHighLight)] && \ $::eskil($top,currHighLight) >= 0} { |
︙ | ︙ | |||
1792 1793 1794 1795 1796 1797 1798 | set line2 [expr {$line1 + [lindex $change 1]}] incr line1 set line1 $line1.0 set line2 $line2.0 } foreach item {wLine1 wDiff1 wLine2 wDiff2} { | | | | 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 | set line2 [expr {$line1 + [lindex $change 1]}] incr line1 set line1 $line1.0 set line2 $line2.0 } foreach item {wLine1 wDiff1 wLine2 wDiff2} { set W $::widgets($top,$item) seeText $W $line1 $line2 } } ##################################### # Editing ##################################### |
︙ | ︙ | |||
1832 1833 1834 1835 1836 1837 1838 | return } resetEditW $::widgets($top,wDiff1) resetEditW $::widgets($top,wDiff2) } # Clear Editing state for a Text widget | | | | | | | | | | | | | | | | | | | | | | | | 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 | return } 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} { if {$::eskil($top,view) eq "table"} { return } 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 |
︙ | ︙ | |||
1946 1947 1948 1949 1950 1951 1952 | } else { return [expr {$::eskil($top,rightEdit) == 1}] } } # Start an undo block in a bunch of text widgets proc startUndoBlock {args} { | | | | | | | | | 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 | } 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 {$from == 1 ? 2 : 1}] |
︙ | ︙ | |||
2020 2021 2022 2023 2024 2025 2026 | $wfrom insert $row.0 $text "" endUndoBlock $wfrom $wto } # Delete a row filling it with padding proc deleteBlock {top side from {to {}}} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | $wfrom insert $row.0 $text "" endUndoBlock $wfrom $wto } # Delete a row filling it with padding proc deleteBlock {top side from {to {}}} { set W $::widgets($top,wDiff$side) if {$to eq ""} {set to $from} startUndoBlock $W $W delete $from.0 $to.end+1c $W insert $from.0 [string repeat \n [expr {$to - $from + 1}]] padding endUndoBlock $W } # Get the lines involved in the display proc getLinesFromRange {W range} { set from [lindex $range 0] set to [lindex $range 1] lassign [split $from "."] fromr fromi lassign [split $to "."] tor toi if {$toi == 0} {incr tor -1} # Get the corresponding lines in the file set t [$W get $fromr.0 $tor.end] set lines [lsort -integer [regexp -all -inline {\d+} $t]] set froml [lindex $lines 0] set tol [lindex $lines end] return [list $fromr $tor $froml $tol] } # Called by popup menus over row numbers to add commands for editing. # Returns 1 if nothing was added. proc editMenu {mW top side changeIndex x y} { if { ! [mayEdit $top $side]} {return 1} # Only copy when in a change block if {$changeIndex ne ""} { set other [expr {$side == 1 ? 2 : 1}] set editOther [mayEdit $top $other] set W $::widgets($top,wLine$side) set oW $::widgets($top,wLine$other) # Get the row that was clicked set index [$W index @$x,$y] set row [lindex [split $index "."] 0] set line [regexp -inline {\d+} [$W get $row.0 $row.end]] set lineo [regexp -inline {\d+} [$oW get $row.0 $row.end]] # Row copy if {$lineo ne ""} { $mW add command -label "Copy Row from other side" \ -command [list copyRow $top $other $row] } else { $mW add command -label "Delete Row" \ -command [list deleteBlock $top $side $row] } if {$line ne "" && $editOther} { $mW add command -label "Copy Row to other side" \ -command [list copyRow $top $side $row] } # Get ranges for the change block set range [$W tag ranges hl$changeIndex] set rangeo [$oW tag ranges hl$changeIndex] # Get the lines involved in the block lassign [getLinesFromRange $W $range ] from to froml tol lassign [getLinesFromRange $oW $rangeo] fromo too fromlo tolo # More than one line in the block? set thisSize 0 set otherSize 0 if {$froml ne "" && $tol ne ""} { set thisSize [expr {$tol - $froml + 1}] } if {$fromlo ne "" && $tolo ne ""} { set otherSize [expr {$tolo - $fromlo + 1}] } if {$thisSize > 1 || $otherSize > 1} { if {$otherSize > 0} { $mW add command -label "Copy Block from other side" \ -command [list copyBlock $top $other $fromo $too] } else { $mW add command -label "Delete Block" \ -command [list deleteBlock $top $side $from $to] } if {$editOther && $thisSize > 0} { $mW add command -label "Copy Block to other side" \ -command [list copyBlock $top $side $from $to] } } } $mW add command -label "Save File" -command [list saveFile $top $side] $mW add command -label "Save File, Reload" -command [list saveFileR $top $side] return 0 } proc saveFile {top side} { if {$side == 1} { if { ! $::eskil($top,leftEdit)} return set fileName $::eskil($top,leftFile) set trans $::eskil($top,lefttranslation) } else { if { ! $::eskil($top,rightEdit)} return set fileName $::eskil($top,rightFile) set trans $::eskil($top,righttranslation) } set W $::widgets($top,wDiff$side) # Confirm dialog set apa no if {$::Pref(askOverwrite)} { set apa [tk_messageBox -parent $top -icon question \ -title "Overwrite file" -type yesnocancel -message \ "Overwriting file [file tail $fileName]\nDo you want to\ |
︙ | ︙ | |||
2155 2156 2157 2158 2159 2160 2161 | } set ch [open $fileName "w"] if {$trans ne ""} { fconfigure $ch -translation $trans } set save 1 | | | 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 | } set ch [open $fileName "w"] if {$trans ne ""} { fconfigure $ch -translation $trans } set save 1 foreach {key value index} [$W dump -all 1.0 end-1c] { switch -- $key { text { if {$save} { puts -nonewline $ch $value } } tagon { |
︙ | ︙ | |||
2196 2197 2198 2199 2200 2201 2202 | # Check if a filename is a directory and handle starkits proc FileIsDirectory {file {kitcheck 0}} { # Skip directories if {[file isdirectory $file]} {return 1} # This detects .kit but how to detect starpacks? if {[file extension $file] eq ".kit" || $kitcheck} { | | | | 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 | # Check if a filename is a directory and handle starkits proc FileIsDirectory {file {kitcheck 0}} { # Skip directories if {[file isdirectory $file]} {return 1} # This detects .kit but how to detect starpacks? if {[file extension $file] eq ".kit" || $kitcheck} { if { ! [catch {package require vfs::mk4}]} { if { ! [catch {vfs::mk4::Mount $file $file -readonly}]} { # Check for contents to ensure it is a kit if {[llength [glob -nocomplain $file/*]] == 0} { vfs::unmount $file } } # Now it is possible that the isdirectory status has changed return [file isdirectory $file] |
︙ | ︙ | |||
2225 2226 2227 2228 2229 2230 2231 | } # When in a vfs, make sure the Tcl file dialog is used # to be able to access the files in a starkit. if {$isVfs} { # 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 | | | | | 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 | } # When in a vfs, make sure the Tcl file dialog is used # to be able to access the files in a starkit. if {$isVfs} { # 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] } |
︙ | ︙ | |||
2388 2389 2390 2391 2392 2393 2394 | # Dropping two files mean set both if {[llength $files] >= 2} { set leftFile [lindex $files 0] set rightFile [lindex $files 1] } else { if {$side eq "any"} { # Dropped outside the text widgets. Try to be clever. | | | 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 | # Dropping two files mean set both if {[llength $files] >= 2} { set leftFile [lindex $files 0] set rightFile [lindex $files 1] } else { if {$side eq "any"} { # Dropped outside the text widgets. Try to be clever. if { ! [info exists ::eskil($top,lastDrop)]} { set side left } elseif {$::eskil($top,lastDrop) eq "left"} { set side right } else { set side left } } |
︙ | ︙ | |||
2432 2433 2434 2435 2436 2437 2438 | ##################################### # GUI stuff ##################################### # A little helper to make a window with scrollbars # It returns the name of the scrolled window | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | ##################################### # GUI stuff ##################################### # A little helper to make a window with scrollbars # It returns the name of the scrolled window proc Scroll {dir class W args} { switch -- $dir { both { set scrollx 1 set scrolly 1 } x { set scrollx 1 set scrolly 0 } y { set scrollx 0 set scrolly 1 } default { return -code error "Bad scrolldirection \"$dir\"" } } ttk::frame $W $class $W.s {*}$args # Move border properties to frame set bw [$W.s cget -borderwidth] set relief [$W.s cget -relief] $W configure -relief $relief -borderwidth $bw $W.s configure -borderwidth 0 grid $W.s -sticky news if {$scrollx} { $W.s configure -xscrollcommand [list $W.sbx set] ttk::scrollbar $W.sbx -orient horizontal -command [list $W.s xview] grid $W.sbx -row 1 -sticky we } if {$scrolly} { $W.s configure -yscrollcommand [list $W.sby set] ttk::scrollbar $W.sby -orient vertical -command [list $W.s yview] grid $W.sby -row 0 -column 1 -sticky ns } grid columnconfigure $W 0 -weight 1 grid rowconfigure $W 0 -weight 1 return $W.s } # Rearrange a dynamic grid to a specified number of columns proc DynGridRearrange {W cols} { # Go down columns first. Thus we must know how many rows there will be. set children [grid slaves $W._dyn] set rows [expr {([llength $children] + $cols - 1) / $cols}] set row 0 set col 0 foreach child $children { grid $child -row $row -column $col grid columnconfigure $W._dyn $col -uniform a incr row if {$row >= $rows} { incr col set row 0 } } # Clear other columns from uniform in case we shrunk if {$row != 0} { incr col } for {} {$col < 15} {incr col} { grid columnconfigure $W._dyn $col -uniform "" } # Recalculate update idletasks # Propagate Height set height [winfo reqheight $W._dyn] $W configure -width 100 -height $height } # Update dynamic grid on configure event proc DynGridRedo {W} { set maxW 0 set children [grid slaves $W._dyn] foreach child $children { set maxW [expr {max($maxW,[winfo reqwidth $child])}] } set fW [winfo width $W] set cols [expr {max(1,$fW / $maxW)}] # Rerrange if needed lassign [grid size $W._dyn] mCols mRows if {$mCols != $cols} { DynGridRearrange $W $cols } } # Ask for widget to have its children managed by dynGrid. proc dynGridManage {W} { # Limit its inital requirements pack propagate $W 0 |
︙ | ︙ | |||
2588 2589 2590 2591 2592 2593 2594 | # Mark a line as aligned. proc markAlign {top side line text} { set ::eskil($top,align$side) $line set ::eskil($top,aligntext$side) $text if {[info exists ::eskil($top,align1)] && [info exists ::eskil($top,align2)]} { | | | | | | | | | | 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 | # Mark a line as aligned. proc markAlign {top side line text} { set ::eskil($top,align$side) $line set ::eskil($top,aligntext$side) $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 } # Called by popup menus over row numbers to add command for alignment. # Returns 1 if nothing was added. proc alignMenu {mW top side x y} { # Get the row that was clicked set W $::widgets($top,wLine$side) set index [$W index @$x,$y] set row [lindex [split $index "."] 0] set data [$W get $row.0 $row.end] # Must be a line number if { ! [regexp {\d+} $data line]} { return 1 } set text [$::widgets($top,wDiff$side) get $row.0 $row.end] set other [expr {$side == 1 ? 2 : 1}] set cmd [list markAlign $top $side $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 {$side == 1 && $line == $align1} { set label "Remove alignment with line $align2" set cmd [list clearAlign $top $align1] } elseif {$side == 2 && $line == $align2} { set label "Remove alignment with line $align1" set cmd [list clearAlign $top $align1] } } } $mW add command -label $label -command $cmd return 0 } # Set up bindings to allow setting alignment using drag proc SetupAlignDrag {top left right} { bind $left <ButtonPress-1> [list startAlignDrag $top 1 %x %y %X %Y]\;break |
︙ | ︙ | |||
2662 2663 2664 2665 2666 2667 2668 | bind $right <ButtonRelease-1> [list endAlignDrag $top 2 %x %y %X %Y]\;break bind $right <B1-Leave> break } # Button has been pressed over line window proc startAlignDrag {top side x y X Y} { # Get the row that was clicked | | | | | | 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 | bind $right <ButtonRelease-1> [list endAlignDrag $top 2 %x %y %X %Y]\;break bind $right <B1-Leave> break } # Button has been pressed over line window proc startAlignDrag {top side x y X Y} { # Get the row that was clicked set W $::widgets($top,wLine$side) 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$side) get $row.0 $row.end] set other [expr {$side == 1 ? 2 : 1}] set ::eskil($top,alignDrag,X) $X set ::eskil($top,alignDrag,Y) $Y |
︙ | ︙ | |||
2692 2693 2694 2695 2696 2697 2698 | proc motionAlignDrag {top side 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 | | | | | | | | | | | | | 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 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 | proc motionAlignDrag {top side 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 {$side == 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 side x y X Y} { if {$::eskil($top,alignDrag,state) eq "drag"} { destroy $::eskil($top,alignDrag,W) |
︙ | ︙ | |||
2805 2806 2807 2808 2809 2810 2811 | } proc hlPopup {top side changeIndex X Y x y} { if {[info exists ::eskil($top,nopopup)] && $::eskil($top,nopopup)} return destroy .lpm menu .lpm | | | | | | | | | 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 | } proc hlPopup {top side changeIndex X Y x y} { if {[info exists ::eskil($top,nopopup)] && $::eskil($top,nopopup)} return destroy .lpm menu .lpm if { ! [editMenu .lpm $top $side $changeIndex $x $y]} { .lpm add separator } if {$changeIndex != ""} { .lpm add command -label "Select" \ -command [list hlSelect $top $changeIndex] } set other [expr {$side == 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 $side $changeIndex] alignMenu .lpm $top $side $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 -> side set tmp1 [editMenu .lpm $top $side "" $x $y] if { ! $tmp1} {.lpm add separator} set tmp2 [alignMenu .lpm $top $side $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} { |
︙ | ︙ | |||
2875 2876 2877 2878 2879 2880 2881 | incr ::HighLightCount } ######### # Zooming ######### | | | | | | | 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 | incr ::HighLightCount } ######### # Zooming ######### proc zoomRow {W X Y x y} { set top [winfo toplevel $W] # Get the row that was clicked set index [$W index @$x,$y] set row [lindex [split $index "."] 0] # Check if it is selected if {[lsearch [$W tag names $index] sel] >= 0} { regexp {(\d+)\D*$} $W -> side hlPopup $top $side "" $X $Y $x $y return } # Extract the data set data(1) [$::widgets($top,wDiff1) dump -tag -text $row.0 $row.end] set data(2) [$::widgets($top,wDiff2) dump -tag -text $row.0 $row.end] |
︙ | ︙ | |||
2970 2971 2972 2973 2974 2975 2976 | [winfo screenwidth $top]x[winfo reqheight $top.balloon] set wx 0 } wm geometry $top.balloon +$wx+$wy wm deiconify $top.balloon } | | | | | | | | | | 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 | [winfo screenwidth $top]x[winfo reqheight $top.balloon] set wx 0 } wm geometry $top.balloon +$wx+$wy wm deiconify $top.balloon } proc unzoomRow {W} { set top [winfo toplevel $W] destroy $top.balloon } # Reconfigure font proc chFont {} { font configure myfont -size $::Pref(fontsize) -family $::Pref(fontfamily) } # Change color settings proc applyColor {} { global dirdiff foreach top $::eskil(diffWindows) { if {$top eq ".clipdiff"} continue if {[string match .fourway* $top]} 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) \ -background $::Pref(bgequal) $W tag configure new1 -foreground $::Pref(colornew1) \ -background $::Pref(bgnew1) $W tag configure change -foreground $::Pref(colorchange) \ -background $::Pref(bgchange) $W tag configure new2 -foreground $::Pref(colornew2) \ -background $::Pref(bgnew2) } continue } } } |
︙ | ︙ | |||
3026 3027 3028 3029 3030 3031 3032 | } } # Emulate a label that: # 1 : Displays the right part of the text if there isn't enough room # 2 : Justfify text to the left if there is enough room. # 3 : Does not try to allocate space according to its contents | | | | | | | 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 | } } # Emulate a label that: # 1 : Displays the right part of the text if there isn't enough room # 2 : Justfify text to the left if there is enough room. # 3 : Does not try to allocate space according to its contents proc fileLabel {W args} { ttk::entryX $W -style TLabel $W configure {*}$args $W configure -takefocus 0 -state readonly ;#-readonlybackground $bg set i [lsearch $args -textvariable] if {$i >= 0} { set var [lindex $args [+ $i 1]] 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 |
︙ | ︙ | |||
3107 3108 3109 3110 3111 3112 3113 | wm deiconify $top raise $top update doDiff $top } # A thing to easily get to debug mode | | | | 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 | wm deiconify $top raise $top update doDiff $top } # A thing to easily get to debug mode proc backDoor {top aVal} { append ::eskil(backdoor) $aVal set ::eskil(backdoor) [string range $::eskil(backdoor) end-9 end] if {$::eskil(backdoor) eq "EskilDebug"} { set ::eskil(debug) 1 catch {console show} set ::eskil(backdoor) "" AddDebugMenu $top } |
︙ | ︙ | |||
3174 3175 3176 3177 3178 3179 3180 | wm title $top "Eskil:" wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top] ttk::frame $top.f grid $top.f -row 0 -columnspan 5 -sticky nws lappend ::widgets(toolbars) $top.f | | | 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 | wm title $top "Eskil:" wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top] ttk::frame $top.f grid $top.f -row 0 -columnspan 5 -sticky nws lappend ::widgets(toolbars) $top.f if { ! $::Pref(toolbar)} { grid remove $top.f } menu $top.m $top configure -menu $top.m $top.m add cascade -label "File" -underline 0 -menu $top.m.mf |
︙ | ︙ | |||
3344 3345 3346 3347 3348 3349 3350 | -command [list highlightTabs $top] set ::widgets($top,enableAlignCmd) [list \ $top.m.mt entryconfigure "Clear Align" -state normal] set ::widgets($top,disableAlignCmd) [list \ $top.m.mt entryconfigure "Clear Align" -state disabled] if {$::tcl_platform(platform) eq "windows"} { | | | 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 | -command [list highlightTabs $top] set ::widgets($top,enableAlignCmd) [list \ $top.m.mt entryconfigure "Clear Align" -state normal] set ::widgets($top,disableAlignCmd) [list \ $top.m.mt entryconfigure "Clear Align" -state disabled] if {$::tcl_platform(platform) eq "windows"} { if { ! [catch {package require registry}]} { $top.m.mt add separator $top.m.mt add command -label "Setup Registry" -underline 6 \ -command makeRegistryWin } } $top.m add cascade -label "Help" -underline 0 -menu $top.m.help |
︙ | ︙ | |||
3513 3514 3515 3516 3517 3518 3519 | # Set up a tag for incremental search bindings if {[info procs textSearch::enableSearch] != ""} { textSearch::enableSearch $top.ft1.tt -label ::widgets($top,isearchLabel) textSearch::enableSearch $top.ft2.tt -label ::widgets($top,isearchLabel) } # Set up file dropping in text windows if TkDnd is available | | | 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 | # Set up a tag for incremental search bindings if {[info procs textSearch::enableSearch] != ""} { textSearch::enableSearch $top.ft1.tt -label ::widgets($top,isearchLabel) textSearch::enableSearch $top.ft2.tt -label ::widgets($top,isearchLabel) } # Set up file dropping in text windows if TkDnd is available if { ! [catch {package require tkdnd}]} { dnd bindtarget $top text/uri-list <Drop> "fileDrop $top any %D" dnd bindtarget $top.ft1.tl text/uri-list <Drop> "fileDrop $top left %D" dnd bindtarget $top.ft1.tt text/uri-list <Drop> "fileDrop $top left %D" dnd bindtarget $top.ft2.tl text/uri-list <Drop> "fileDrop $top right %D" dnd bindtarget $top.ft2.tt text/uri-list <Drop> "fileDrop $top right %D" } |
︙ | ︙ | |||
3537 3538 3539 3540 3541 3542 3543 | text $top.tb -width 4 -wrap none -background $bg \ -font myfont -borderwidth 0 -padx 0 -highlightthickness 0 \ -takefocus 0 commonYScroll $top.sby $top.ft1.tl $top.ft1.tt $top.ft2.tl $top.ft2.tt \ ;#$top.tb applyColor | | | | | | | | | | | 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 | text $top.tb -width 4 -wrap none -background $bg \ -font myfont -borderwidth 0 -padx 0 -highlightthickness 0 \ -takefocus 0 commonYScroll $top.sby $top.ft1.tl $top.ft1.tt $top.ft2.tl $top.ft2.tt \ ;#$top.tb applyColor foreach W [list $top.ft1.tt $top.ft2.tt] { # The last change in a row is underlined $W tag configure last -underline 1 # Each file in a patch view starts with a block of this type $W tag configure patch -background gray # Make sure selection is visible $W tag raise sel bind $W <ButtonPress-3> "zoomRow %W %X %Y %x %y" bind $W <ButtonRelease-3> "unzoomRow %W" } foreach W [list $top.ft1.tl $top.ft2.tl] { $W tag configure align -underline 1 bind $W <ButtonPress-3> "rowPopup %W %X %Y %x %y" } SetupAlignDrag $top $top.ft1.tl $top.ft2.tl grid $top.l1 $top.le - - $top.l2 -row 1 -sticky news grid $top.ft1 $top.tb $map $top.sby $top.ft2 -row 2 -sticky news grid $top.sbx1 $top.ls - - $top.sbx2 -row 3 -sticky news grid columnconfigure $top "$top.ft1 $top.ft2" -weight 1 |
︙ | ︙ | |||
3605 3606 3607 3608 3609 3610 3611 | resetEdit $top return $top } proc ValidateNewColors {} { foreach item {colorchange bgchange colornew1 bgnew1 colornew2 bgnew2 colorequal bgequal} { | | | 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 | resetEdit $top return $top } proc ValidateNewColors {} { foreach item {colorchange bgchange colornew1 bgnew1 colornew2 bgnew2 colorequal bgequal} { if { ! [info exists ::TmpPref($item)]} continue set col $::TmpPref($item) if {$col eq ""} continue if {[catch {winfo rgb . $col}]} { # FIXA: Error message # Just restore for now set ::TmpPref($item) $::Pref($item) } |
︙ | ︙ | |||
3790 3791 3792 3793 3794 3795 3796 | 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 | | | | | 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 | 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]] font create testfont foreach f $fam { if { ! [string equal $f ""]} { font configure testfont -family $f lappend FontCache $f [font metrics testfont -fixed] } } font delete testfont } UpdateFontBox $lb |
︙ | ︙ |
Changes to src/fourway.tcl.
︙ | ︙ | |||
113 114 115 116 117 118 119 | grid $win.l3 $win.e3 $win.b3 $win.r3 -sticky we -padx 3 -pady {10 3} grid $win.l4 $win.e4 $win.b4 $win.r4 -sticky we -padx 3 -pady 3 grid $win.bd - - -padx 3 -pady {10 3} grid columnconfigure $win $win.el -weight 1 # Set up file dropping in entry windows if TkDnd is available | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | grid $win.l3 $win.e3 $win.b3 $win.r3 -sticky we -padx 3 -pady {10 3} grid $win.l4 $win.e4 $win.b4 $win.r4 -sticky we -padx 3 -pady 3 grid $win.bd - - -padx 3 -pady {10 3} grid columnconfigure $win $win.el -weight 1 # Set up file dropping in entry windows if TkDnd is available if { ! [catch {package require tkdnd}]} { dnd bindtarget $win text/uri-list <Drop> "[mymethod fileDrop any ] %D" dnd bindtarget $win.e1 text/uri-list <Drop> "[mymethod fileDrop base1 ] %D" dnd bindtarget $win.e2 text/uri-list <Drop> "[mymethod fileDrop change1] %D" dnd bindtarget $win.e3 text/uri-list <Drop> "[mymethod fileDrop base2 ] %D" dnd bindtarget $win.e4 text/uri-list <Drop> "[mymethod fileDrop change2] %D" } } |
︙ | ︙ | |||
234 235 236 237 238 239 240 | set revs($field) [lindex $revList 0] } } } } method doFourWayDiff {{skipPrepare 0}} { | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | set revs($field) [lindex $revList 0] } } } } method doFourWayDiff {{skipPrepare 0}} { if { ! $skipPrepare} { $self PrepareFw } # Extract revisions foreach field $fields { if {$revs($field) ne ""} { # Replace with checkout copy set files($field) [tmpFile] |
︙ | ︙ | |||
354 355 356 357 358 359 360 | lappend matching($side) {*}$rest($side) } set [myvar csList1] $matching(1) set [myvar csList2] $matching(2) #destroy $win.csf | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | lappend matching($side) {*}$rest($side) } set [myvar csList1] $matching(1) set [myvar csList2] $matching(2) #destroy $win.csf if { ! [winfo exists $win.csf]} { ttk::labelframe $win.csf -text "Change Set" -padding 3 grid $win.csf -columnspan 4 -sticky news -padx 3 -pady 3 grid rowconfigure $win $win.csf -weight 1 listbox $win.csf.lb1 -height 20 -listvariable [myvar csList1] \ -exportselection 0 bind $win.csf.lb1 <<ListboxSelect>> [mymethod csNewSelect] |
︙ | ︙ |
Changes to src/help.tcl.
︙ | ︙ | |||
20 21 22 23 24 25 26 | # #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # A simple window for displaying e.g. help. # Returns the frame where things can be put. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 132 133 134 135 136 137 138 139 140 | # #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- # A simple window for displaying e.g. help. # Returns the frame where things can be put. proc helpWin {W title} { destroy $W toplevel $W -padx 2 -pady 2 wm title $W $title bind $W <Key-Return> [list destroy $W] bind $W <Key-Escape> [list destroy $W] ttk::frame $W.f ttk::button $W.b -text "Close" -command [list destroy $W] -width 10 \ -default active pack $W.b -side bottom -pady 2 pack $W.f -side top -expand y -fill both -padx 2 -pady 2 focus $W return $W.f } proc makeAboutWin {} { set W [helpWin .ab "About Eskil"] set bg [ttk::style configure . -background] text $W.t -width 45 -height 11 -wrap none -relief flat \ -background $bg pack $W.t -side top -expand y -fill both $W.t insert end "A graphical frontend to diff\n\n" $W.t insert end "$::eskil(diffver)\n\n" $W.t insert end "Made by Peter Spjuth\n" $W.t insert end "E-Mail: peter.spjuth@gmail.com\n" $W.t insert end "\nURL: http://eskil.tcl.tk\n" $W.t insert end "\nTcl version: [info patchlevel]\n" set du $::DiffUtil::version append du " ($::DiffUtil::implementation)" $W.t insert end "DiffUtil version: $du\n" # Provide debug info to help when DiffUtil does not load. if {[info exists ::DiffUtil::DebugLibFile]} { set lf $::DiffUtil::DebugLibFile set exist [file exists $lf] set lf [file join {*}[lrange [file split $lf] end-1 end]] if {$exist} { $W.t insert end " DiffUtil debug: Could not load\n" $W.t insert end " $lf\n" } else { $W.t insert end " DiffUtil debug: Could not find\n" $W.t insert end " $lf\n" } } if {[catch {package require pdf4tcl} pdf4tclVer]} { set pdf4tclVer None } $W.t insert end "Pdf4Tcl version: $pdf4tclVer\n" if {[catch {package require snit} snitVer]} { set snitVer None } $W.t insert end "Snit version: $snitVer\n" if {[catch {package require vfs} vfsVer]} { set vfsVer None } $W.t insert end "Vfs version: $vfsVer\n" if {[catch {package require wcb} wcbVer]} { set wcbVer None } $W.t insert end "Wcb version: $wcbVer\n" if {[catch {package require tablelist_tile} tblVer]} { set tblVer None } $W.t insert end "Tablelist version: $tblVer\n" if {[catch {package require tkdnd} tkdndVer]} { set tkdndVer None } $W.t insert end "TkDnd version: $tkdndVer\n" $W.t insert end "\nCredits:\n" $W.t insert end "Ideas for scrollbar map and merge function\n" $W.t insert end "taken from TkDiff" set last [lindex [split [$W.t index end] "."] 0] $W.t configure -height $last $W.t configure -state disabled } # Insert a text file into a text widget. # Any XML-style tags in the file are used as tags in the text window. proc insertTaggedText {W file} { set ch [open $file r] set data [read $ch] close $ch set tags {} while {$data != ""} { if {[regexp {^([^<]*)<(/?)([^>]+)>(.*)$} $data -> pre sl tag post]} { $W insert end [subst -nocommands -novariables $pre] $tags set i [lsearch $tags $tag] if {$sl != ""} { # Remove tag if {$i >= 0} { set tags [lreplace $tags $i $i] } } else { # Add tag lappend tags $tag } set data $post } else { $W insert end [subst -nocommands -novariables $data] $tags set data "" } } } proc makeHelpWin {} { set doc [file join $::eskil(thisDir) .. doc/eskil.txt] if { ! [file exists $doc]} return set W [helpWin .he "Eskil Help"] set t [Scroll y text $W.t -width 85 -height 35] pack $W.t -side top -expand 1 -fill both configureDocWin $t # Set up tags for change marks $t tag configure new1 -foreground $::Pref(colornew1) \ -background $::Pref(bgnew1) $t tag configure new2 -foreground $::Pref(colornew2) \ |
︙ | ︙ | |||
164 165 166 167 168 169 170 | for {} {$t > -20} {incr t -1} { font configure docFontP -size $t if {[font metrics docFontP -linespace] >= $h} break } } # Configure a text window as Doc viewer | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | for {} {$t > -20} {incr t -1} { font configure docFontP -size $t if {[font metrics docFontP -linespace] >= $h} break } } # Configure a text window as Doc viewer proc configureDocWin {W} { createDocFonts $W configure -font docFont -wrap word $W tag configure ul -underline 1 $W tag configure b -font docFontB $W tag configure bullet -tabs "1c" -lmargin2 "1c" $W tag configure pre -font docFontP set top [winfo toplevel $W] foreach event {<Key-Prior> <Key-Next>} { bind $top $event [string map [list "%W" $W] [bind Text $event]] } } proc makeDocWin {fileName} { set W [helpWin .doc "Eskil Help"] set t [Scroll y text $W.t -width 80 -height 25] pack $W.t -side top -expand 1 -fill both configureDocWin $t if { ! [file exists $::eskil(thisDir)/../doc/$fileName]} { $t insert end "ERROR: Could not find doc file " $t insert end \"$fileName\" return } insertTaggedText $t $::eskil(thisDir)/../doc/$fileName #focus $t $t configure -state disabled } proc makeTutorialWin {} { set doc [file join $::eskil(thisDir) .. doc/tutorial.txt] if { ! [file exists $doc]} return if {[catch {cd [file join $::eskil(thisDir) .. examples]}]} { tk_messageBox -icon error -title "Eskil Error" -message \ "Could not locate examples directory." \ -type ok return } # 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"] text $W.t -width 82 -height 35 -yscrollcommand "$W.sb set" ttk::scrollbar $W.sb -orient vert -command "$W.t yview" pack $W.sb -side right -fill y pack $W.t -side left -expand 1 -fill both configureDocWin $W.t # Move border properties to frame set bw [$W.t cget -borderwidth] set relief [$W.t cget -relief] $W configure -relief $relief -borderwidth $bw $W.t configure -borderwidth 0 insertTaggedText $W.t $doc $W.t configure -state disabled } |
Changes to src/map.tcl.
︙ | ︙ | |||
49 50 51 52 53 54 55 | } # Temporarily ignore changes added by addChange. proc mapNoChange {top value} { set ::eskil($top,mapNoChange) $value } | | | | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | } # Temporarily ignore changes added by addChange. proc mapNoChange {top value} { set ::eskil($top,mapNoChange) $value } proc addChange {top nLines tag line1 n1 line2 n2} { if {$tag ne "" && $::eskil($top,mapNoChange) == 0} { lappend ::eskil($top,changes) [list $::eskil($top,mapMax) $nLines \ $tag $line1 $n1 $line2 $n2] } incr ::eskil($top,mapMax) $nLines } proc addMapLines {top nLines} { incr ::eskil($top,mapMax) $nLines } # Use the assembled information for the map to draw edit buttons proc drawEditButtons {top} { $::widgets($top,wTb) delete 1.0 end set l 0 foreach change $::eskil($top,changes) { |
︙ | ︙ | |||
99 100 101 102 103 104 105 | } proc drawMap {top newh} { set oldh [map$top cget -height] if {$oldh == $newh} return map$top blank | | | | 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 | } proc drawMap {top newh} { 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 |
︙ | ︙ |
Changes to src/merge.tcl.
︙ | ︙ | |||
24 25 26 27 28 29 30 | proc collectMergeData {top} { global eskil set eskil($top,leftMergeData) {} set eskil($top,rightMergeData) {} set eskil($top,mergeSelection,AnyConflict) 0 | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 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] |
︙ | ︙ | |||
110 111 112 113 114 115 116 | $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 | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | $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 } |
︙ | ︙ | |||
356 357 358 359 360 361 362 | set eskil($top,rightMergeData) {} array unset eskil $top,mergeSelection,* } # Create a window to display merge result. proc makeMergeWin {top} { collectMergeData $top | | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | 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]" |
︙ | ︙ | |||
452 453 454 455 456 457 458 | ttk::button $w.f.bs -text "Save" -command "saveMerge $top" ttk::button $w.f.bq -text "Close" -command "closeMerge $top" wm protocol $w WM_DELETE_WINDOW "closeMerge $top" grid $w.f.rb1 $w.f.rb2 $w.f.rb3 $w.f.rb4 x $w.f.b1 $w.f.b2 x \ $w.f.bl $w.f.br x $w.f.bs $w.f.bq -sticky we -padx 1 | | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | ttk::button $w.f.bs -text "Save" -command "saveMerge $top" ttk::button $w.f.bq -text "Close" -command "closeMerge $top" wm protocol $w WM_DELETE_WINDOW "closeMerge $top" grid $w.f.rb1 $w.f.rb2 $w.f.rb3 $w.f.rb4 x $w.f.b1 $w.f.b2 x \ $w.f.bl $w.f.br x $w.f.bs $w.f.bq -sticky we -padx 1 if { ! $anyC} { grid forget $w.f.bl $w.f.br } grid columnconfigure $w.f {4 7 10} -minsize 10 grid columnconfigure $w.f 10 -weight 1 grid columnconfigure $w.f {0 1 2 3} -uniform a grid columnconfigure $w.f {5 6 8 9 11 12} -uniform b #grid columnconfigure $w.f {11 13 14} -uniform c |
︙ | ︙ | |||
492 493 494 495 496 497 498 | 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} { | | | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | 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 detectLineEnd $top $::eskil($top,ancestorFile) mergetranslation lf } array unset ::eskil $top,ancestorLeft,* array unset ::eskil $top,ancestorRight,* set differrA1 [catch {DiffUtil::diffFiles {*}$opts \ $::eskil($top,ancestorFile) $dFile1} diffresA1] |
︙ | ︙ | |||
593 594 595 596 597 598 599 | if {[array size right] == 0} { # No changes to the right, so deleted to the left : Keep left side set comment "Left: Delete" return 1 } # Is it deleted on the left side? set delLeft [info exists ::eskil($top,ancestorLeft,d$line1)] | | | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | if {[array size right] == 0} { # No changes to the right, so deleted to the left : Keep left side set comment "Left: Delete" return 1 } # Is it deleted on the left side? set delLeft [info exists ::eskil($top,ancestorLeft,d$line1)] if { ! $delLeft} { # It is inserted to the right : Keep right side set comment "Right: Add" return 2 } # Deleted to left and changed to the right : ?? (right for now) # FIXA set comment "*** Left: Delete, Right: Change" |
︙ | ︙ | |||
621 622 623 624 625 626 627 | if {[array size left] == 0} { # No changes to the left, so deleted to the right : Keep right side set comment "Right: Delete" return 2 } # Is it deleted on the right side? set delRight [info exists ::eskil($top,ancestorRight,d$line2)] | | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | if {[array size left] == 0} { # No changes to the left, so deleted to the right : Keep right side set comment "Right: Delete" return 2 } # Is it deleted on the right side? set delRight [info exists ::eskil($top,ancestorRight,d$line2)] if { ! $delRight} { # It is inserted to the left : Keep left side set comment "Left: Add" return 1 } # Deleted to right and changed to the left : ?? (right for now) # FIXA set comment "*** Left: Change, Right: Delete" |
︙ | ︙ |
Changes to src/plugin.tcl.
︙ | ︙ | |||
38 39 40 41 42 43 44 | foreach dir $dirs { set dir [file normalize $dir] set files {} lappend files [file join $dir $plugin] lappend files [file join $dir $plugin.tcl] foreach file $files { | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | foreach dir $dirs { set dir [file normalize $dir] set files {} lappend files [file join $dir $plugin] lappend files [file join $dir $plugin.tcl] foreach file $files { if { ! [file exists $file]} continue if { ! [file isfile $file]} continue if { ! [file readable $file]} continue set ch [open $file r] set data [read $ch 20] close $ch if {[string match "##Eskil Plugin*" $data]} { set fSrc $file break } |
︙ | ︙ | |||
98 99 100 101 102 103 104 | # Setup info $pi eval [list set ::WhoAmI [file rootname [file tail $src]]] $pi eval [list set ::WhoAmIFull [file normalize $src]] $pi eval [list set ::Info $info] interp share {} stdout $pi # Expose needed commands | | | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | # Setup info $pi eval [list set ::WhoAmI [file rootname [file tail $src]]] $pi eval [list set ::WhoAmIFull [file normalize $src]] $pi eval [list set ::Info $info] interp share {} stdout $pi # Expose needed commands if { ! $allow} { interp expose $pi fconfigure ;# needed?? interp hide $pi close } set pinfo {file 0 dir 0} dict set pinfo "allow" $allow if {[$pi eval info proc PreProcess] ne ""} { |
︙ | ︙ | |||
127 128 129 130 131 132 133 | return } set ch [open $src] set lines [split [read $ch] \n] foreach line $lines { set lineT [string trim $line] if {$short} { | | | | | | 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 | return } set ch [open $src] set lines [split [read $ch] \n] foreach line $lines { set lineT [string trim $line] if {$short} { if { ! [string match "#*" $lineT]} { break } } puts $line } close $ch } proc listPlugins {} { set dirs [PluginSearchPath] set result {} foreach dir $dirs { set dir [file normalize $dir] set files [glob -nocomplain [file join $dir *.tcl]] foreach file $files { set file [file normalize $file] if {[info exists done($file)]} continue if { ! [file exists $file]} continue if { ! [file isfile $file]} continue if { ! [file readable $file]} continue set done($file) 1 set ch [open $file r] set data [read $ch 200] if {[regexp {^\#\#Eskil Plugin :(.*?)(\n|$)} $data -> descr]} { set root [file rootname [file tail $file]] dict set result $root "descr" $descr |
︙ | ︙ | |||
208 209 210 211 212 213 214 | } disallowEdit $top set in1 $::eskil($top,leftFile) set in2 $::eskil($top,rightFile) foreach item [lsort -dictionary [array names ::eskil $top,pluginname,*]] { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | } disallowEdit $top set in1 $::eskil($top,leftFile) set in2 $::eskil($top,rightFile) foreach item [lsort -dictionary [array names ::eskil $top,pluginname,*]] { set pI [lindex [split $item ","] end] set allow [dict get $::eskil($top,pluginpinfo,$pI) allow] # Pass ::argv to plugin set pArgv $::eskil(argv) if {[info exists ::eskil($top,pluginargv,$pI)]} { lappend pArgv {*}$::eskil($top,pluginargv,$pI) } $::eskil($top,plugin,$pI) eval [list set ::argv $pArgv] # Pass ::Pref to plugin $::eskil($top,plugin,$pI) eval [list array set ::Pref [array get ::Pref]] # Pass File info to plugin $::eskil($top,plugin,$pI) eval [list set ::File(left) $::eskil($top,leftFile)] $::eskil($top,plugin,$pI) eval [list set ::File(right) $::eskil($top,rightFile)] set out1 [tmpFile] set out2 [tmpFile] set chi [open $in1 r] set cho [open $out1 w] set chi2 [open $in2 r] set cho2 [open $out2 w] interp share {} $chi $::eskil($top,plugin,$pI) interp share {} $cho $::eskil($top,plugin,$pI) interp share {} $chi2 $::eskil($top,plugin,$pI) interp share {} $cho2 $::eskil($top,plugin,$pI) set cmd1 [list PreProcess left $chi $cho] set cmd2 [list PreProcess right $chi2 $cho2] if {[info commands yield] ne ""} { # When in 8.6, this is done in coroutines allowing each call # to yield and to alternate between them until done set c1 __plugin_cr1$top set c2 __plugin_cr2$top set cmd1 [linsert $cmd1 0 coroutine $c1] set cmd2 [linsert $cmd2 0 coroutine $c2] set usenew1 [$::eskil($top,plugin,$pI) eval $cmd1] set usenew2 [$::eskil($top,plugin,$pI) eval $cmd2] interp alias {} pnw $::eskil($top,plugin,$pI) namespace which while {[pnw $c1] ne {} || [pnw $c2] ne {}} { if {[pnw $c1] ne {}} { set usenew1 [$::eskil($top,plugin,$pI) eval $c1] } if {[pnw $c2] ne {}} { set usenew2 [$::eskil($top,plugin,$pI) eval $c2] } } } else { set usenew1 [$::eskil($top,plugin,$pI) eval $cmd1] set usenew2 [$::eskil($top,plugin,$pI) eval $cmd2] } if {$allow} { $::eskil($top,plugin,$pI) eval close $chi $::eskil($top,plugin,$pI) eval close $cho $::eskil($top,plugin,$pI) eval close $chi2 $::eskil($top,plugin,$pI) eval close $cho2 } else { $::eskil($top,plugin,$pI) invokehidden close $chi $::eskil($top,plugin,$pI) invokehidden close $cho $::eskil($top,plugin,$pI) invokehidden close $chi2 $::eskil($top,plugin,$pI) invokehidden close $cho2 } close $chi close $cho close $chi2 close $cho2 if {$usenew1} { # The file after processing should be used both # for comparison and for displaying. if { ! [info exists ::eskil($top,leftFileBak)]} { set ::eskil($top,leftFileBak) $::eskil($top,leftFile) } unset -nocomplain ::eskil($top,leftFileDiff) set ::eskil($top,leftFile) $out1 } else { set ::eskil($top,leftFileDiff) $out1 } if {$usenew2} { if { ! [info exists ::eskil($top,rightFileBak)]} { set ::eskil($top,rightFileBak) $::eskil($top,rightFile) } unset -nocomplain ::eskil($top,rightFileDiff) set ::eskil($top,rightFile) $out2 } else { set ::eskil($top,rightFileDiff) $out2 } |
︙ | ︙ | |||
404 405 406 407 408 409 410 | incr pos -1 $wt insert $pos $win } # Add a tab to plugin prefernces proc EditPrefPluginsAddTab {top dirdiff {pos {}}} { set wt $top.prefplugin.tab | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 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 637 638 | incr pos -1 $wt insert $pos $win } # Add a tab to plugin prefernces proc EditPrefPluginsAddTab {top dirdiff {pos {}}} { set wt $top.prefplugin.tab set pI [$wt index end] if {$pos eq "" || $pos >= ($pI - 1)} { # Since the "+" tab is last, the index is n for any new one set pos [expr {$pI - 1}] } ttk::frame $wt.f,$pI $wt insert $pos $wt.f,$pI -text "Plugin" set wt $wt.f,$pI set plugins [listPlugins] if {[llength $plugins] == 0} { grid [ttk::label $wt.l -text "No plugins found."] - -padx 3 -pady 3 } if { ! [info exists ::eskil($top,pluginname,$pI)]} { set ::eskil($top,pluginname,$pI) "" } if { ! [info exists ::eskil($top,plugininfo,$pI)]} { set ::eskil($top,plugininfo,$pI) "" } if { ! [info exists ::eskil($top,pluginallow,$pI)]} { set ::eskil($top,pluginallow,$pI) 0 } set ::eskil($top,edit,pluginname,$pI) $::eskil($top,pluginname,$pI) set ::eskil($top,edit,plugininfo,$pI) $::eskil($top,plugininfo,$pI) set ::eskil($top,edit,pluginallow,$pI) $::eskil($top,pluginallow,$pI) ttk::labelframe $wt.lfs -text "Select" grid columnconfigure $wt.lfs 1 -weight 1 set t 0 foreach {plugin info} $plugins { set descr [dict get $info descr] if {$dirdiff && ![dict get $info dir]} continue ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname,$pI) \ -value $plugin -text $plugin ttk::label $wt.l$t -text $descr -anchor w grid $wt.rb$t $wt.l$t -in $wt.lfs -sticky we -padx 3 -pady 3 incr t } ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname,$pI) \ -value "" -text "No Plugin" ttk::button $wt.bs -text "Show" \ -command "ShowPlugin $wt \$::eskil($top,edit,pluginname,$pI)" addBalloon $wt.bs "Show plugin source code." grid $wt.rb$t $wt.bs -in $wt.lfs -sticky we -padx 3 -pady 3 grid $wt.bs -sticky e ttk::labelframe $wt.lfgc -text "Generic Configuration" grid columnconfigure $wt.lfgc 1 -weight 1 ttk::label $wt.li -text "Info" -anchor w addBalloon $wt.li "Info passed to plugin. Plugin specific." ttk::entry $wt.ei -textvariable ::eskil($top,edit,plugininfo,$pI) grid $wt.li $wt.ei -in $wt.lfgc -sticky we -padx 3 -pady 3 ttk::checkbutton $wt.cb -text "Privilege" \ -variable ::eskil($top,edit,pluginallow,$pI) addBalloon $wt.cb "Run plugin with raised privileges" grid $wt.cb - -in $wt.lfgc -sticky w -padx 3 -pady 3 ttk::labelframe $wt.lfsc -text "Specific Configuration" set ::widgets($top,prefPluginsSpec,$pI) $wt.lfsc trace add variable ::eskil($top,edit,pluginname,$pI) write \ [list UpdateSpecificPluginConf $top $pI] UpdateSpecificPluginConf $top $pI grid $wt.lfs -sticky we -padx 3 -pady 3 grid $wt.lfgc -sticky we -padx 3 -pady 3 grid $wt.lfsc -sticky we -padx 3 -pady 3 grid columnconfigure $wt 0 -weight 1 } # When a new plugin is selected, update the list of specific options. # "args" is needed to swallow the extra variable trace args. proc UpdateSpecificPluginConf {top pI args} { set w $::widgets($top,prefPluginsSpec,$pI) # If the dialog is closed w might not exist if { ! [winfo exists $w]} return eval destroy [winfo children $w] set arg $::eskil($top,edit,pluginname,$pI) set pOpts {} if {$arg ne ""} { set res [LocatePlugin $arg] set pOpts [dict get $res opts] } # Look for defaults on the command line set pArgv $::eskil(argv) if {[info exists ::eskil($top,pluginargv,$pI)]} { lappend pArgv {*}$::eskil($top,pluginargv,$pI) } # Look for declarations of command line options set t 0 set ::eskil($top,edit,opts,$pI) $pOpts foreach {name flag doc} $pOpts { ttk::label $w.l$t -text $name addBalloon $w.l$t -fmt $doc grid $w.l$t -sticky "w" -padx 3 -pady 3 if {$flag} { # Initialise if given. if {[lsearch -exact $pArgv $name] >= 0} { set ::eskil($top,edit,$name,$pI) 1 # Move responsibility from global argv set ix [lsearch -exact $::eskil(argv) $name] if {$ix >= 0} { set ::eskil(argv) [lreplace $::eskil(argv) $ix $ix] lappend ::eskil($top,pluginargv,$pI) $name } } ttk::checkbutton $w.s$t -text "On" \ -variable ::eskil($top,edit,$name,$pI) grid $w.s$t -row $t -column 1 -sticky "w" -padx 3 -pady 3 } else { # Initialise if given. set ix [lsearch -exact $pArgv $name] if {$ix >= 0} { set ::eskil($top,edit,$name,$pI) [lindex $pArgv $ix+1] # Move responsibility from global argv set ix [lsearch -exact $::eskil(argv) $name] if {$ix >= 0} { lappend ::eskil($top,pluginargv,$pI) $name \ [lindex $::eskil(argv) $ix+1] set ::eskil(argv) [lreplace $::eskil(argv) $ix $ix+1] } } ttk::entry $w.s$t \ -textvariable ::eskil($top,edit,$name,$pI) grid $w.s$t -row $t -column 1 -sticky we -padx 3 -pady 3 } incr t } grid columnconfigure $w 1 -weight 1 if {$t == 0} { ttk::label $w.l -text "No specific configuration" grid $w.l -sticky "w" -padx 3 -pady 3 return } } # Ok or Apply pressend in Plugin Preference proc EditPrefPluginsOk {top wt apply} { # Compress plugin info in tab order set allN {} foreach win [$wt.tab tabs] { set pI [lindex [split $win ","] end] if { ! [string is integer -strict $pI]} continue # Find all used. if {$::eskil($top,edit,pluginname,$pI) ne ""} { lappend allN $pI } } if {[llength $allN] == 0} { lappend allN 1 } # Keep the dialog if we are only applying if { ! $apply} { destroy $wt } # Transfer them to consecutive numbers set t 1 foreach pI $allN { set ::eskil($top,pluginname,$t) $::eskil($top,edit,pluginname,$pI) set ::eskil($top,plugininfo,$t) $::eskil($top,edit,plugininfo,$pI) set ::eskil($top,pluginallow,$t) $::eskil($top,edit,pluginallow,$pI) incr t } # Remove any old foreach item [array names ::eskil $top,pluginname,*] { set pI [lindex [split $item ","] end] if {$pI >= $t} { unset ::eskil($top,pluginname,$pI) set ::eskil($top,plugininfo,$pI) "" set ::eskil($top,pluginallow,$pI) 0 } } # Handle all plugins foreach item [array names ::eskil $top,pluginname,*] { set pI [lindex [split $item ","] end] if {$::eskil($top,pluginname,$pI) ne ""} { set pinterp [createPluginInterp $::eskil($top,pluginname,$pI) \ $::eskil($top,plugininfo,$pI) \ $::eskil($top,pluginallow,$pI) pinfo] } else { set pinterp "" set pinfo "" } set ::eskil($top,plugin,$pI) $pinterp set ::eskil($top,pluginpinfo,$pI) $pinfo set ::eskil($top,pluginargv,$pI) {} foreach {name flag doc} $::eskil($top,edit,opts,$pI) { if {$flag} { if {[info exists ::eskil($top,edit,$name,$pI)] && \ $::eskil($top,edit,$name,$pI)} { lappend ::eskil($top,pluginargv,$pI) $name } } else { if {[info exists ::eskil($top,edit,$name,$pI)] && \ $::eskil($top,edit,$name,$pI) ne ""} { lappend ::eskil($top,pluginargv,$pI) $name \ $::eskil($top,edit,$name,$pI) } } } } } # Put Tcl code in a text widget, with some syntax highlighting proc TextViewTcl {tW data} { $tW tag configure comment -foreground "#b22222" foreach line [split $data \n] { if {[regexp {^\s*#} $line]} { $tW insert end $line\n comment } elseif {[regexp {^(.*;\s*)(#.*)$} $line -> pre post]} { $tW insert end $pre $tW insert end $post\n comment } else { $tW insert end $line\n } } } # Show plugin source proc ShowPlugin {parent plugin} { set res [LocatePlugin $plugin] |
︙ | ︙ |
Changes to src/preprocess.tcl.
︙ | ︙ | |||
78 79 80 81 82 83 84 | } } return $res } # This is called when Ok or Apply is pressed. # Update preference from dialog contents. | | | | | | 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 132 | } } return $res } # This is called when Ok or Apply is pressed. # Update preference from dialog contents. proc EditPrefRegsubOk {top W item {keep 0}} { 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) set l $::eskil($top,prefregleft$t) set r $::eskil($top,prefregright$t) if {$RE eq ""} continue switch $::eskil($top,prefregtype$t) { Subst { lappend result $RE $Sub Subst } Prefix { lappend result $RE "" Prefix } default { set side "" if {$l && !$r} { set side left } if { ! $l && $r} { set side right } if { ! $l && !$r} { continue } if {[catch {regsub -all -- $RE $exa $Sub _} err]} { return } lappend result $RE $Sub $side } } } set ::TmpPref(preprocess,re,$item) $result set ::TmpPref(preprocess,active,$item) 1 if {$keep} { # Apply was pressed, also apply main dialog # TODO: Get widgets right. Right now it does not matter EditPrefPrepOk . $top 1 return } destroy $W array unset ::eskil $top,prefregexp* array unset ::eskil $top,prefregsub* array unset ::eskil $top,prefregleft* array unset ::eskil $top,prefregright* array unset ::eskil $top,prefregtype* } |
︙ | ︙ | |||
213 214 215 216 217 218 219 | # Add a new entry in the preprocess dialog proc AddPrefRegsub {top parent {type {}}} { # Figure out next number to use for {set t 1} {[winfo exists $parent.fr$t]} {incr t} { #Empty } # Default values | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 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 | # Add a new entry in the preprocess dialog proc AddPrefRegsub {top parent {type {}}} { # Figure out next number to use for {set t 1} {[winfo exists $parent.fr$t]} {incr t} { #Empty } # Default values if { ! [info exists ::eskil($top,prefregexp$t)]} { set ::eskil($top,prefregtype$t) Generic set ::eskil($top,prefregexp$t) "" set ::eskil($top,prefregexp$t) "" set ::eskil($top,prefregsub$t) "" set ::eskil($top,prefregleft$t) 1 set ::eskil($top,prefregright$t) 1 } # Override type if given if {$type ne ""} { set ::eskil($top,prefregtype$t) $type } set W [ttk::frame $parent.fr$t -borderwidth 2 -relief groove -padding 3] pack $W -side "top" -fill x -padx 3 -pady 3 switch $::eskil($top,prefregtype$t) { Subst { ttk::label $W.l1 -text "Left:" -anchor w ttk::entryX $W.e1 -textvariable ::eskil($top,prefregexp$t) -width 20 ttk::label $W.l2 -text "Right:" -anchor w ttk::entryX $W.e2 -textvariable ::eskil($top,prefregsub$t) grid $W.l1 $W.e1 $W.l2 $W.e2 -sticky we -padx 3 -pady 3 grid columnconfigure $W {0 2} -uniform a grid columnconfigure $W {1 3} -weight 1 -uniform b addBalloon $W.l1 -fmt { Each pattern is applied to its side and substituted for a common unique string. } } Prefix { ttk::label $W.l1 -text "Prefix:" -anchor w ttk::entryX $W.e1 -textvariable ::eskil($top,prefregexp$t) -width 20 grid $W.l1 $W.e1 -sticky we -padx 3 -pady 3 grid columnconfigure $W 1 -weight 1 addBalloon $W.l1 -fmt { Only one word that start with prefix is valid for line comparison. } } default { 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) ttk::checkbutton $W.cb1 -text "Left" -variable ::eskil($top,prefregleft$t) ttk::checkbutton $W.cb2 -text "Right" -variable ::eskil($top,prefregright$t) addBalloon $W.cb1 "Apply to left file" addBalloon $W.cb2 "Apply to right file" grid $W.l1 $W.e1 $W.cb1 -sticky we -padx 3 -pady 3 grid $W.l2 $W.e2 $W.cb2 -sticky we -padx 3 -pady 3 grid columnconfigure $W 1 -weight 1 } } trace add variable ::eskil($top,prefregexp$t) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregsub$t) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregleft$t) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregright$t) write \ [list EditPrefRegsubUpdate $top] } # Editor for one item in ::Pref(preprocessn) proc EditPrefRegsub {top item} { set W $top.prefregsub ToplevelForce $W "Preferences: Preprocess group" # Buttons ttk::frame $W.fb1 -padding 3 ttk::button $W.fb1.b1 -text "Add" -command [list AddPrefRegsub $top $W Generic] addBalloon $W.fb1.b1 "Add generic pattern" ttk::button $W.fb1.b2 -text "Add Subst" -command [list AddPrefRegsub $top $W Subst] addBalloon $W.fb1.b2 "Add using substitution shortcut" ttk::button $W.fb1.b3 -text "Add Prefix" -command [list AddPrefRegsub $top $W Prefix] addBalloon $W.fb1.b3 "Add using prefix shortcut" grid $W.fb1.b1 $W.fb1.b2 $W.fb1.b3 -sticky we -ipadx 5 -padx 3 -pady 3 grid columnconfigure $W.fb1 all -uniform a grid anchor $W.fb1 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.l4l -text "Result 1 L:" -anchor w ttk::label $W.res.l4r -text "Result 1 R:" -anchor w ttk::label $W.res.e4l -textvariable ::eskil($top,prefregresultl) \ -anchor w -width 10 ttk::label $W.res.e4r -textvariable ::eskil($top,prefregresultr) \ -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.l6l -text "Result 2 L:" -anchor w ttk::label $W.res.l6r -text "Result 2 R:" -anchor w ttk::label $W.res.e6l -textvariable ::eskil($top,prefregresultl2) \ -anchor w -width 10 ttk::label $W.res.e6r -textvariable ::eskil($top,prefregresultr2) \ -anchor w -width 10 grid $W.res.l3 $W.res.e3 -sticky we -padx 3 -pady 3 grid $W.res.l4l $W.res.e4l -sticky we -padx 3 -pady 3 grid $W.res.l4r $W.res.e4r -sticky we -padx 3 -pady 3 grid $W.res.l5 $W.res.e5 -sticky we -padx 3 -pady 3 grid $W.res.l6l $W.res.e6l -sticky we -padx 3 -pady 3 grid $W.res.l6r $W.res.e6r -sticky we -padx 3 -pady 3 grid columnconfigure $W.res 1 -weight 1 # Buttons ttk::frame $W.fb -padding 3 ttk::button $W.fb.b1 -text "Ok" -command [list EditPrefRegsubOk $top $W $item] ttk::button $W.fb.b2 -text "Apply" -command [list EditPrefRegsubOk $top $W $item 1] ttk::button $W.fb.b3 -text "Cancel" -command [list destroy $W] set ::widgets($top,prefRegsubOk) $W.fb.b1 set ::widgets($top,prefRegsubApply) $W.fb.b2 grid $W.fb.b1 x $W.fb.b2 x $W.fb.b3 -sticky we grid columnconfigure $W.fb {0 2 4} -uniform a grid columnconfigure $W.fb {1 3} -weight 1 # Top layout pack $W.fb1 -side "top" -fill x -padx 3 -pady 3 pack $W.fb $W.res -side bottom -fill x -padx 3 -pady 3 # Fill in existing or an empty line set preprocess $::TmpPref(preprocess,re,$item) if {[llength $preprocess] == 0} { AddPrefRegsub $top $W Generic } else { set t 1 foreach {RE Sub side} $preprocess { set ::eskil($top,prefregexp$t) $RE set ::eskil($top,prefregsub$t) $Sub set ::eskil($top,prefregleft$t) 0 set ::eskil($top,prefregright$t) 0 set ::eskil($top,prefregtype$t) Generic if {$side in {Subst Prefix}} { set ::eskil($top,prefregtype$t) $side } else { if {$side eq "" || $side eq "left"} { set ::eskil($top,prefregleft$t) 1 } if {$side eq "" || $side eq "right"} { set ::eskil($top,prefregright$t) 1 } } 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 } # This is called when Ok or Apply is pressed. proc EditPrefPrepOk {top W {keep 0}} { # Update preference from dialog contents. set new {} for {set r 1} {$r <= $::TmpPref(preprocess,n)} {incr r} { set name $::TmpPref(preprocess,name,$r) set act $::TmpPref(preprocess,active,$r) set save $::TmpPref(preprocess,save,$r) set re $::TmpPref(preprocess,re,$r) lappend new $name lappend new [dict create active $act "save" $save preprocess $re] } set ::Pref(preprocessn) $new if {$keep} return destroy $W } # Create a toplevel, even if it exists proc ToplevelForce {W title} { destroy $W ttk::toplevel $W -padx 3 -pady 3 wm title $W $title } # Move an item one step up proc EditPrefPreUp {rI} { #puts EditPrefPreUp$rI # Sanity check if {$rI <= 1 || $rI > $::TmpPref(preprocess,n)} { return } set pI [expr {$rI - 1}] foreach item {name active save re} { set tmp $::TmpPref(preprocess,$item,$rI) set ::TmpPref(preprocess,$item,$rI) $::TmpPref(preprocess,$item,$pI) set ::TmpPref(preprocess,$item,$pI) $tmp } } proc EditPrefPreprocessAddItem {W autoEdit} { set r $::TmpPref(preprocess,n) incr r if { ! [info exists ::TmpPref(preprocess,name,$r)]} { set ::TmpPref(preprocess,name,$r) "" set ::TmpPref(preprocess,active,$r) 0 set ::TmpPref(preprocess,save,$r) 0 set ::TmpPref(preprocess,re,$r) "" } ttk::entry $W.fp.ne$r -textvariable ::TmpPref(preprocess,name,$r) addBalloon $W.fp.ne$r "Name of preprocess group (optional)" ttk::checkbutton $W.fp.cba$r -text "Active" \ -variable ::TmpPref(preprocess,active,$r) addBalloon $W.fp.cba$r "Activate group for this session" ttk::checkbutton $W.fp.cbs$r -text "Save" \ -variable ::TmpPref(preprocess,save,$r) addBalloon $W.fp.cbs$r "Save group when preferences are saved" ttk::button $W.fp.be$r -text "Edit" \ -command [list EditPrefRegsub $W $r] addBalloon $W.fp.be$r "Edit the associated list of regexps" if {$autoEdit} { after idle [list after 50 [list $W.fp.be$r invoke]] } ttk::button $W.fp.bu$r -image $::img(up) \ -command [list EditPrefPreUp $r] addBalloon $W.fp.bu$r "Move group up in list" grid $W.fp.ne$r $W.fp.cba$r $W.fp.cbs$r $W.fp.be$r $W.fp.bu$r -sticky we \ -padx 3 -pady 3 # Make buttons symmetric grid $W.fp.be$r $W.fp.bu$r -sticky news set ::TmpPref(preprocess,n) $r } proc EditPrefPreprocess {top} { set W $top.prefpreprocess # Make a working copy more suitable for GUI connection set r 0 foreach {name data} $::Pref(preprocessn) { incr r set ::TmpPref(preprocess,name,$r) $name set ::TmpPref(preprocess,active,$r) [dict get $data active] set ::TmpPref(preprocess,save,$r) [dict get $data save] set ::TmpPref(preprocess,re,$r) [dict get $data preprocess] } # Create one if there is none, to simplify GUI usage set autoEdit 0 if {$r == 0} { set autoEdit 1 incr r } set ::TmpPref(preprocess,n) 0 set nItems $r ToplevelForce $W "Preferences: Preprocess" # Frame for List of preprocessing ttk::frame $W.fp -padding 3 grid columnconfigure $W.fp 0 -weight 1 for {set r 1} {$r <= $nItems} {incr r} { EditPrefPreprocessAddItem $W $autoEdit } # Frame for action buttons ttk::frame $W.fa -padding 3 ttk::button $W.fa.b1 -text "Add" \ -command [list EditPrefPreprocessAddItem $W 1] addBalloon $W.fa.b1 "Add a preprocess group" grid $W.fa.b1 -sticky we grid columnconfigure $W.fa {0 2 4} -uniform a grid columnconfigure $W.fa {1 3} -weight 1 # Frame for dialog Buttons ttk::frame $W.fb -padding 3 ttk::button $W.fb.b1 -text "Ok" -command [list EditPrefPrepOk $top $W] ttk::button $W.fb.b2 -text "Apply" -command [list EditPrefPrepOk $top $W 1] ttk::button $W.fb.b3 -text "Cancel" -command [list destroy $W] grid $W.fb.b1 x $W.fb.b2 x $W.fb.b3 -sticky we grid columnconfigure $W.fb {0 2 4} -uniform a grid columnconfigure $W.fb {1 3} -weight 1 # Top layout pack $W.fb -side bottom -fill x pack $W.fa -side bottom -fill x pack $W.fp -side "top" -fill both -expand 1 } |
Changes to src/print.tcl.
︙ | ︙ | |||
38 39 40 41 42 43 44 | set res [format "%*s" $maxlen $res] } return $res } # Process the line numbers from the line number widget into a list # of "linestarters" | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | set res [format "%*s" $maxlen $res] } return $res } # Process the line numbers from the line number widget into a list # of "linestarters" proc ProcessLineno {W maxlen} { set tdump [$W dump -tag -text 1.0 end] set tag "" set line "" set lines {} foreach {key value index} $tdump { if {$key eq "tagon"} { if {$value eq "change" || [string match "new*" $value]} { set tag $value |
︙ | ︙ | |||
92 93 94 95 96 97 98 | set n [expr {(- $i - $index - 1) % 8 + 1}] set text [string replace $text $i $i [format %*s $n ""]] } return $text } # Find the lastnumber in a text widget | | | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | set n [expr {(- $i - $index - 1) % 8 + 1}] set text [string replace $text $i $i [format %*s $n ""]] } return $text } # Find the lastnumber in a text widget proc FindLastNumber {W} { set index [$W search -backwards -regexp {\d} end] if {$index eq ""} { # There where no numbers there, treat it like 0 return 0 } set line [$W get "$index linestart" "$index lineend"] #puts "X '$line' '$index'" regexp {\d+} $line number return $number } # Main print function proc PrintDiffs {top {quiet 0}} { |
︙ | ︙ | |||
245 246 247 248 249 250 251 | if {$::eskil($top,printFile) != ""} { set pdfFile $::eskil($top,printFile) } else { set pdfFile ~/eskil.pdf } | | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | 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] |
︙ | ︙ | |||
315 316 317 318 319 320 321 | for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} { $pdf drawTextLine [lindex $wraplines2 $i2] $pdf newLine } } $pdf endPrint | | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} { $pdf drawTextLine [lindex $wraplines2 $i2] $pdf newLine } } $pdf endPrint if { ! $quiet} { tk_messageBox -title "Eskil Print" -parent $top \ -message "Printed $npages pages to $pdfFile" -type ok } } # Count the length of a line during a text dump proc AccumulateMax {top key value index} { |
︙ | ︙ | |||
342 343 344 345 346 347 348 | set ::eskil($top,currentCharsPerLine) \ [lsort -integer $::eskil($top,currentCharsPerLine)] return [lindex $::eskil($top,currentCharsPerLine) end] } # In a sorted list of integers, figure out where val fits # In 8.6 this could use lsearch -bisect | | | | | | | | 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 | set ::eskil($top,currentCharsPerLine) \ [lsort -integer $::eskil($top,currentCharsPerLine)] return [lindex $::eskil($top,currentCharsPerLine) end] } # In a sorted list of integers, figure out where val fits # In 8.6 this could use lsearch -bisect proc FindPercentile {lst val} { set len [llength $lst] # No elements, so all are covered in a way if {$len == 0} { return 100 } # Above range, so 100% if {[lindex $lst end] <= $val} { return 100 } # Under range, so 0% if {[lindex $lst 0] > $val} { return 0 } # Single element should not slip through... if {$len <= 1} { return 0 } set i [lsearch -integer -all $lst $val] set i [lindex $i end] if {$i >= 0} { return [expr {100 * $i / ($len - 1)}] } # To keep search down, just look at multiples of 1% set prev 0 for {set t 0} {$t <= 100} {incr t} { set i [expr {$t * ($len - 1) / 100}] if {$val < [lindex $lst $i]} { return $prev } set prev $t } return 99 } |
︙ | ︙ | |||
417 418 419 420 421 422 423 | } set ::eskil($top,printFile) $apa $entry xview end } # Fix to give spinbox nicer appearance | | | | | | | | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | } set ::eskil($top,printFile) $apa $entry xview end } # Fix to give spinbox nicer appearance proc MySpinBox {W args} { # Handle if ttk::spinbox is not there since it was introduced later if {[info commands ttk::spinbox] eq ""} { set cmd [list tk::spinbox $W] } else { set cmd [list ttk::spinbox $W] lappend cmd -command [list $W selection clear] -state readonly } lappend cmd {*}$args {*}$cmd } proc PrintTracePrefs {W args} { set ::Pref(printColorChange) \ [list $::TmpPref(chr) $::TmpPref(chg) $::TmpPref(chb)] set ::Pref(printColorNew1) \ [list $::TmpPref(n1r) $::TmpPref(n1g) $::TmpPref(n1b)] set ::Pref(printColorNew2) \ [list $::TmpPref(n2r) $::TmpPref(n2g) $::TmpPref(n2b)] if { ! [winfo exists $W.cf.l1e]} return foreach num {1 2 3} p {ch n1 n2} { set r [expr {int(255*$::TmpPref(${p}r))}] set g [expr {int(255*$::TmpPref(${p}g))}] set b [expr {int(255*$::TmpPref(${p}b))}] set col [format \#%02X%02X%02X $r $g $b] $W.cf.l${num}e configure -background $col } } # Create a print dialog for PDF. proc doPrint {top {quiet 0}} { if {$quiet} { PrintDiffs $top 1 |
︙ | ︙ |
Changes to src/registry.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 32 33 34 35 36 | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # $Revision$ #---------------------------------------------------------------------- proc MakeRegistryFrame {W label key newvalue} { set old {} catch {set old [registry get $key {}]} set l [ttk::labelframe $W -text $label -padding 4] ttk::label $l.key1 -text "Key:" ttk::label $l.key2 -text $key ttk::label $l.old1 -text "Old value:" ttk::label $l.old2 -text $old ttk::label $l.new1 -text "New value:" ttk::label $l.new2 -text $newvalue |
︙ | ︙ |
Changes to src/rev.tcl.
︙ | ︙ | |||
155 156 157 158 159 160 161 | set dir [pwd] } else { set dir [file dirname $file] } if {[auto_execok cleartool] != ""} { set old [pwd] cd $dir | | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | set dir [pwd] } else { set dir [file dirname $file] } if {[auto_execok cleartool] != ""} { set old [pwd] cd $dir if { ! [catch {exec cleartool pwv -s} view] && $view != "** NONE **"} { cd $old return 1 } cd $old } return 0 } |
︙ | ︙ | |||
266 267 268 269 270 271 272 | set cmd [list exec cvs -z3 update -p] if {$rev != ""} { lappend cmd -r $rev } lappend cmd [file nativename $filename] > $outfile if {[catch {eval $cmd} res]} { | | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | set cmd [list exec cvs -z3 update -p] if {$rev != ""} { lappend cmd -r $rev } lappend cmd [file nativename $filename] > $outfile if {[catch {eval $cmd} res]} { if { ! [string match "*Checking out*" $res]} { tk_messageBox -icon error -title "CVS error" -message $res } } if {$old != ""} { cd $old } |
︙ | ︙ | |||
290 291 292 293 294 295 296 | # TODO: support files set cmd [list exec cvs diff -U $context] foreach rev $revs { lappend cmd -r $rev } if {[catch {eval $cmd} res]} { | | | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | # TODO: support files set cmd [list exec cvs diff -U $context] foreach rev $revs { lappend cmd -r $rev } if {[catch {eval $cmd} res]} { if { ! [string match "*=========*" $res]} { tk_messageBox -icon error -title "CVS error" -message $res return "" } } return $res } |
︙ | ︙ | |||
326 327 328 329 330 331 332 | if {$rev != ""} { lappend cmd -r $rev } lappend cmd [file nativename $filename] } lappend cmd > $outfile if {[catch {eval $cmd} res]} { | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | if {$rev != ""} { lappend cmd -r $rev } lappend cmd [file nativename $filename] } lappend cmd > $outfile if {[catch {eval $cmd} res]} { if { ! [string match "*Checking out*" $res]} { tk_messageBox -icon error -title "SVN error" -message $res } } if {$old != ""} { cd $old } |
︙ | ︙ | |||
563 564 565 566 567 568 569 | if {[llength $revs] == 2} { lappend cmd -r [lindex $revs 0]..[lindex $revs 1] } elseif {[llength $revs] == 1} { lappend cmd -r [lindex $revs 0] } if {[catch {eval $cmd} res]} { | | | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | if {[llength $revs] == 2} { lappend cmd -r [lindex $revs 0]..[lindex $revs 1] } elseif {[llength $revs] == 1} { lappend cmd -r [lindex $revs 0] } if {[catch {eval $cmd} res]} { if { ! [string match "*===*" $res]} { tk_messageBox -icon error -title "BZR error" -message $res return "" } } return $res } |
︙ | ︙ | |||
782 783 784 785 786 787 788 | } set cmd [list exec cvs -n status [file nativename $filename]] if {[catch {eval $cmd} res]} { # What to do here? set rev "1.1" } else { | | | 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | } set cmd [list exec cvs -n status [file nativename $filename]] if {[catch {eval $cmd} res]} { # What to do here? set rev "1.1" } else { if { ! [regexp {Working revision:\s+(\d\S*)} $res -> rev]} { set rev "1.1" } } if {$old != ""} { cd $old } |
︙ | ︙ | |||
813 814 815 816 817 818 819 | set cmd [list exec svn info [file nativename $filename]] } if {[catch {eval $cmd} res]} { # What to do here? set rev "1" set res "" } else { | | | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | set cmd [list exec svn info [file nativename $filename]] } if {[catch {eval $cmd} res]} { # What to do here? set rev "1" set res "" } else { if { ! [regexp {Last Changed Rev:\s+(\d+)} $res -> rev]} { set rev "1" } } if {$old != ""} { cd $old } |
︙ | ︙ | |||
1078 1079 1080 1081 1082 1083 1084 | return $result } # Look for alternative version in a branch # Return value, if any, is a full URL to the file proc eskil::rev::SVN::LookForBranch {filename rev} { set info [eskil::rev::SVN::GetCurrent $filename 1] | | | | | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | return $result } # Look for alternative version in a branch # Return value, if any, is a full URL to the file proc eskil::rev::SVN::LookForBranch {filename rev} { set info [eskil::rev::SVN::GetCurrent $filename 1] if { ! [regexp -line {URL:\s+(.+)} $info -> URL]} { return } if { ! [regexp -line {Repository Root:\s+(.+)} $info -> Root]} { return } set tail [string range $URL [string length $Root] end] if { ! [string match "/*" $tail]} { return } set tail [string range $tail 1 end] set parts [file split $tail] set alt {} switch [lindex $parts 0] { trunk { |
︙ | ︙ | |||
1124 1125 1126 1127 1128 1129 1130 | # Figure out SVN revision from arguments proc eskil::rev::SVN::ParseRevs {filename revs} { set result {} foreach rev $revs { set Url "" # Non-numeric could be a branch or tag. Look for it. | | | 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 | # Figure out SVN revision from arguments proc eskil::rev::SVN::ParseRevs {filename revs} { set result {} foreach rev $revs { set Url "" # Non-numeric could be a branch or tag. Look for it. if { ! [string is integer -strict $rev]} { if {[regexp {^([^@]+)@(.+)$} $rev -> pre post]} { set rev $pre set atRev $post } else { set atRev "" } set Url [eskil::rev::SVN::LookForBranch $filename $rev] |
︙ | ︙ | |||
1195 1196 1197 1198 1199 1200 1201 | set offset $tail if {$offset == -1} { # Predecessor return [exec cleartool describe -fmt %PSn $filename] } set rev [file dirname $rev] } # If the argument is of the form "name/rev", look for a fitting one | | | | | 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 | set offset $tail if {$offset == -1} { # Predecessor return [exec cleartool describe -fmt %PSn $filename] } set rev [file dirname $rev] } # If the argument is of the form "name/rev", look for a fitting one if { ! [string is integer $rev] && [regexp {^[^/.]+(/\d+)?$} $rev]} { if {[catch {exec cleartool lshistory -short $filename} allrevs]} {# tk_messageBox -icon error -title "Cleartool error" \ -message $allrevs return } set allrevs [split $allrevs \n] set i [lsearch -glob $allrevs "*$rev" ] if {$i >= 0} { set rev [lindex [split [lindex $allrevs $i] "@"] end] } } set rev [file normalize [file join $stream $rev]] # If we don't have a version number, try to find the latest if { ! [string is integer [file tail $rev]]} { if { ! [info exists allrevs]} { if {[catch {exec cleartool lshistory -short $filename} allrevs]} {# tk_messageBox -icon error -title "Cleartool error" \ -message $allrevs return } set allrevs [split $allrevs \n] } |
︙ | ︙ | |||
1356 1357 1358 1359 1360 1361 1362 | set precmd [list fossil commit -m] set postcmd $args GetTopDir [pwd] topdir _ # Files to commit might be relative to topdir, take care of that. # This can happen with -review in a subdir. set usetopdir "" foreach f $args { | | | 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 | set precmd [list fossil commit -m] set postcmd $args GetTopDir [pwd] topdir _ # Files to commit might be relative to topdir, take care of that. # This can happen with -review in a subdir. set usetopdir "" foreach f $args { if { ! [file exists $f]} { if {[file exists [file join $topdir $f]]} { set usetopdir $topdir } } } CommitDialog $top $target Fossil $usetopdir $precmd $postcmd 1 } |
︙ | ︙ | |||
1540 1541 1542 1543 1544 1545 1546 | proc eskil::rev::CT::current {filename} { # Figure out stream and current version if {[catch {exec cleartool ls $filename} info]} { tk_messageBox -icon error -title "Cleartool error" -message $info return } set currV {} | | | | 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 | proc eskil::rev::CT::current {filename} { # Figure out stream and current version if {[catch {exec cleartool ls $filename} info]} { tk_messageBox -icon error -title "Cleartool error" -message $info return } set currV {} if { ! [regexp {@@(\S+)\s+from (\S+)\s+Rule} $info -> dummy currV]} { regexp {@@(\S+)} $info -> currV } set stream [file dirname $currV] set latest [file tail $currV] return [list $stream $latest] } ############################################################################## # Exported procedures ############################################################################## # Figure out what revision control system a file is under # Returns name of rev system if detected, or "" if none. proc detectRevSystem {file {preference GIT}} { variable eskil::rev::cache if {$file ne ""} { if { ! [file exists $file]} { return "" } if {[info exists cache($file)]} { return $cache($file) } } set searchlist [list $preference GIT FOSSIL HG BZR P4] |
︙ | ︙ | |||
1865 1866 1867 1868 1869 1870 1871 | dynGridManage $w.f } tkwait visibility $w focus -force $w.t tkwait window $w.dummy | | | 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 | dynGridManage $w.f } tkwait visibility $w focus -force $w.t tkwait window $w.dummy if { ! $::eskil($top,logdialogok)} { return } set res [string trim $::eskil(logdialog)] set ::eskil(logdialog) $res set todo $postcmd |
︙ | ︙ |
Changes to src/startup.tcl.
︙ | ︙ | |||
136 137 138 139 140 141 142 | puts "Themed Tk not found" exit } } } # Provide a ttk-friendly toplevel, fixing background and menubar if {[info commands ttk::toplevel] eq ""} { | | | | | | | 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 | puts "Themed Tk not found" exit } } } # Provide a ttk-friendly toplevel, fixing background and menubar if {[info commands ttk::toplevel] eq ""} { proc ttk::toplevel {W args} { tk::toplevel $W {*}$args place [ttk::frame $W.tilebg] -border outside \ -x 0 -y 0 -relwidth 1 -relheight 1 return $W } } ::snit::widgetadaptor ttk::entryX { delegate method * to hull delegate option * to hull constructor {args} { installhull using ttk::entry $self configurelist $args # Make sure textvariable is initialised set varName [from args -textvariable ""] if {$varName ne ""} { upvar \#0 $varName var if { ! [info exists var]} { set var "" } } } # Circumvent a bug in ttk::entry that "xview end" does not work. method xview {args} { if {[llength $args] == 1} { |
︙ | ︙ | |||
231 232 233 234 235 236 237 | source $srcdir/plugin.tcl source $srcdir/printobj.tcl source $srcdir/print.tcl source $srcdir/rev.tcl source $srcdir/debug.tcl # Only load vcsvfs if vfs is present | | | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | source $srcdir/plugin.tcl source $srcdir/printobj.tcl source $srcdir/print.tcl source $srcdir/rev.tcl source $srcdir/debug.tcl # Only load vcsvfs if vfs is present if { ! [catch {package require vfs}]} { source $srcdir/vcsvfs.tcl } } # Debug function to be able to reread the source even when wrapped in a kit. proc EskilRereadSource {} { set this $::eskil(thisScript) |
︙ | ︙ | |||
347 348 349 350 351 352 353 | set usageStr [string map [list "%v%" $versionStr] $usageStr] puts $usageStr # Dump option info foreach name [lsort -dictionary [dict keys $::eskil(opts,info)]] { set outName $name | | | | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | set usageStr [string map [list "%v%" $versionStr] $usageStr] puts $usageStr # Dump option info foreach name [lsort -dictionary [dict keys $::eskil(opts,info)]] { set outName $name if { ! [dict exists $::eskil(opts,info) $name flag]} { puts "Internal Error: BOHOHOHO $name" break } if { ! [dict get $::eskil(opts,info) $name flag]} { set valueName v # Detect a reference in short description set short [dict get $::eskil(opts,info) $name shortdescr] if {[regexp {<(.*?)>} $short -> var] } { set valueName $var } append outName " <$valueName>" |
︙ | ︙ | |||
398 399 400 401 402 403 404 | ##################################### # Option/flag handling helpers ##################################### # Validators proc optValidatePdfColor {opt arg} { set fail 0 | | | | | | 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 | ##################################### # Option/flag handling helpers ##################################### # Validators proc optValidatePdfColor {opt arg} { set fail 0 if { ! [string is list $arg] || [llength $arg] != 3} { set fail 1 } else { foreach val $arg { if { ! [string is double -strict $val] || $val < 0.0 || $val > 1.0} { set fail 1 } } } if {$fail} { puts "Argument $opt must be a list of RBG values from 0.0 to 1.0" exit } } proc optValidatePositive {opt arg} { if { ! [string is double -strict $arg] || $arg <= 0} { puts "Argument $opt must be a positive number" exit } } proc optValidateNatural {opt arg} { if { ! [string is integer -strict $arg] || $arg < 0} { puts "Argument $opt must be a natural number" exit } } proc optValidatePaper {opt arg} { package require pdf4tcl if {[llength [pdf4tcl::getPaperSize $arg]] != 2} { |
︙ | ︙ | |||
646 647 648 649 650 651 652 | return [dict get $::eskil(opts) $arg] } # Helper to add a file argument to list of files proc cmdLineAddFile {filesName arg} { upvar 1 $filesName files set apa [file normalize [file join [pwd] $arg]] | | | 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | return [dict get $::eskil(opts) $arg] } # Helper to add a file argument to list of files proc cmdLineAddFile {filesName arg} { upvar 1 $filesName files set apa [file normalize [file join [pwd] $arg]] if { ! [file exists $apa]} { puts "Bad argument: $arg" exit } else { lappend files $apa } } |
︙ | ︙ | |||
842 843 844 845 846 847 848 | } if {$arg eq "-"} { # Allow "-" for stdin patch processing lappend files "-" continue } # Handle unknowns | | | 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 | } if {$arg eq "-"} { # Allow "-" for stdin patch processing lappend files "-" continue } # Handle unknowns if { ! [dict exists $::eskil(opts) $arg]} { # Try to see if it is an unique abbreviation of an option. set match [allOpts $arg*] if {[llength $match] == 1} { set arg [lindex $match 0] } else { # If not, try to put it among files cmdLineAddFile files $arg |
︙ | ︙ | |||
1031 1032 1033 1034 1035 1036 1037 | set len [llength $files] if {$len == 0 && $dodir} { set dirdiff(leftDir) "" set dirdiff(rightDir) "" return [makeDirDiffWin] } | | | | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | set len [llength $files] if {$len == 0 && $dodir} { set dirdiff(leftDir) "" set dirdiff(rightDir) "" return [makeDirDiffWin] } if { ! $doreview && $len == 1} { set fullname [lindex $files 0] if {[FileIsDirectory $fullname 1]} { set dirdiff(leftDir) $fullname set dirdiff(rightDir) $dirdiff(leftDir) return [makeDirDiffWin] } } elseif { ! $doreview && $len >= 2} { set fullname1 [lindex $files 0] set fullname2 [lindex $files 1] if {[FileIsDirectory $fullname1 1] && [FileIsDirectory $fullname2 1]} { set dirdiff(leftDir) $fullname1 set dirdiff(rightDir) $fullname2 return [makeDirDiffWin] } |
︙ | ︙ | |||
1089 1090 1091 1092 1093 1094 1095 | set fulldir [file dirname $fullname] if {$::eskil($top,mode) eq "conflict"} { startConflictDiff $top $fullname after idle [list doDiff $top] set ReturnAfterLoop 1 continue } | | | 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | 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 { |
︙ | ︙ | |||
1160 1161 1162 1163 1164 1165 1166 | enableRedo $top } else { after idle [list doDiff $top] } } } if {$autobrowse && (!$::eskil($top,leftOK) || !$::eskil($top,rightOK))} { | | | | | 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 | 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. # TBD: Extend this to all VCS:s? if {$::eskil($top,leftOK) && !$::eskil($top,rightOK) && \ [llength [glob -nocomplain [file join $fulldir CVS]]]} { |
︙ | ︙ | |||
1302 1303 1304 1305 1306 1307 1308 | # Handle old option set ::Pref(preprocess) {} # TODO: implement filter option fully set ::eskil(filter) "" | | | | | | 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 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 | # Handle old option set ::Pref(preprocess) {} # TODO: implement filter option fully set ::eskil(filter) "" if { ! [info exists ::eskil_testsuite] && [file exists "~/.eskilrc"]} { safeLoad "~/.eskilrc" ::Pref } if {$::Pref(editor) ne ""} { set ::util(editor) $::Pref(editor) } # If the user's file has this old option, translate it to the new if {$::Pref(preprocess) ne ""} { lappend ::Pref(preprocessn) "old" lappend ::Pref(preprocessn) \ [dict create preprocess $::Pref(preprocess) \ active 1 save 1] } array unset ::Pref preprocess # Set up reactions to some Pref settings if { ! [info exists ::widgets(toolbars)]} { set ::widgets(toolbars) {} } trace add variable ::Pref(toolbar) write TraceToolbar } proc TraceToolbar {args} { # FIXA: Handle destroyed windows ? foreach __ $::widgets(toolbars) { if {$::Pref(toolbar)} { grid configure $__ } else { grid remove $__ } } } # Global code is only run the first time to be able to reread source if { ! [info exists ::eskil(gurkmeja)]} { set ::eskil(gurkmeja) 1 package require pstools namespace import -force pstools::* getOptions if { ! [info exists ::eskil_testsuite]} { InitSourceEarly parseCommandLine } } |
Changes to src/vcsvfs.tcl.
︙ | ︙ | |||
89 90 91 92 93 94 95 | dict set finfo $parentStr type directory set parentStr [file join $parentStr $dirPath] } } } # Try to use "fossil ls -r, available in newer versions" set doneCollecting 0 | | | | | | 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 | dict set finfo $parentStr type directory set parentStr [file join $parentStr $dirPath] } } } # Try to use "fossil ls -r, available in newer versions" set doneCollecting 0 if { ! [catch {exec fossil ls -r $rev -v} lsdata]} { set lsdata [string trim $lsdata \n] foreach line [split $lsdata \n] { # Expected format in a line: # 2012-08-21 20:38:19 4563 tests/rev.test regexp {(\S+ \S+)\s+(\d+)\s+(.+)} $line -> fDate fSize fName dict set finfo $fName mtimestr $fDate dict set finfo $fName size $fSize } set doneCollecting 1 } # Getting files via http fileage to aquire file times # Since dates are parsed from the age string they are rather imprecise # Use a while around it to be able to break free easily (faking goto) while { ! $doneCollecting} { set html [exec fossil http << "GET /fileage?name=$rev"] if { ! [regexp {Files in.*} $html html]} { # Not the expected format of response, skip break } if { ! [regexp {\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}} $html cTime2]} { # Not the expected format of response, skip break } # This is currently unused since we do not trust the formatted time in # the web page. The time stamp from the artifact is used later. set commitTime2 [clock scan $cTime2 -gmt 1] #puts "CT $commitTime CT2 $commitTime2" |
︙ | ︙ | |||
198 199 200 201 202 203 204 | # As another step, get current file stamps from fossil ls. # Since ls show current checkout they might not be valid for the rev # being looked at. However if they are still present and older than the # ones from fileage they are likely correct. # Also, fileage and ls uses different criteria for which commit defines # the age (across merges), so things basically will be a best effort guess. | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | # As another step, get current file stamps from fossil ls. # Since ls show current checkout they might not be valid for the rev # being looked at. However if they are still present and older than the # ones from fileage they are likely correct. # Also, fileage and ls uses different criteria for which commit defines # the age (across merges), so things basically will be a best effort guess. if { ! $doneCollecting} { set allfiles [exec fossil ls --age .] foreach line [split $allfiles \n] { # Expected format in a line: # 2012-08-21 20:38:19 tests/rev.test regexp {(\S+ \S+)\s+(.+)} $line -> fDate fName set mTime [clock scan $fDate -gmt 1] if {[dict exists $finfo $fName mtime]} { |
︙ | ︙ | |||
261 262 263 264 265 266 267 | set oldpwd [pwd] cd $dir # The mount point will normally be at the wc root, even if # a sub directory was given. # Locate root for the given directory. set info [exec svn info] | | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | set oldpwd [pwd] cd $dir # The mount point will normally be at the wc root, even if # a sub directory was given. # Locate root for the given directory. set info [exec svn info] if { ! [regexp -line {Working Copy Root Path:\s*(\S.*)} $info -> root]} { # Fallback to given dir set root . } # TBD: Always root at given dir, for speed set root . set root [file normalize $root] cd $root |
︙ | ︙ | |||
392 393 394 395 396 397 398 | } } # TBD: Any way to get file sizes and mtimes from HG? # Try using the hglist extension set cmd [list hg ls --template "{size} {date} {name}\n" -a \ --recursive -r $rev] | | | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | } } # TBD: Any way to get file sizes and mtimes from HG? # Try using the hglist extension set cmd [list hg ls --template "{size} {date} {name}\n" -a \ --recursive -r $rev] if { ! [catch {exec {*}$cmd} allfiles]} { # Expected line format: # size date name foreach line [split $allfiles \n] { if {[regexp {^(\d+)\s+(\d+)\S*\s+(\S.*)$} $line -> size mtime fName]} { # Check that it matches something filled in from the manifest if {[dict exists $finfo $fName]} { dict set finfo $fName "mtime" $mtime |
︙ | ︙ | |||
570 571 572 573 574 575 576 | if {[dict exists $finfo $relative child]} { set childD [dict get $finfo $relative child] } else { # Empty dir return {} } foreach child [dict keys $childD] { | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | if {[dict exists $finfo $relative child]} { set childD [dict get $finfo $relative child] } else { # Empty dir return {} } foreach child [dict keys $childD] { if { ! [string match $pattern $child]} continue set local [file join $relative $child] if {[dict get $finfo $local isfile] && !$allowFile} continue if {[dict get $finfo $local isdir] && !$allowDir} continue lappend result [file join $actual $child] } return $result } |
︙ | ︙ | |||
679 680 681 682 683 684 685 | #puts " Ar $args" set rootD [dict get $mpoints $root] set origroot [dict get $rootD origroot] set finfo [dict get $rootD finfo] set vcstype [dict get $rootD vcstype] | | | 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | #puts " Ar $args" set rootD [dict get $mpoints $root] set origroot [dict get $rootD origroot] set finfo [dict get $rootD finfo] set vcstype [dict get $rootD vcstype] if { ! [dict exists $finfo $relative]} { # Unknown path vfs::filesystem posixerror $::vfs::posix(EACCES) return -code error $::vfs::posix(EACCES) } set finfor [dict get $finfo $relative] #puts " $finfor" |
︙ | ︙ | |||
723 724 725 726 727 728 729 | } stat { set res [dict create dev 0 ino 0 "mode" 0 nlink 0 uid 0 gid 0 \ size 0 atime 0 mtime 0 ctime 0 type file] dict set res type [dict get $finfor type] if {[dict get $finfor isfile]} { # Fill in any postponed info | | | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | } stat { set res [dict create dev 0 ino 0 "mode" 0 nlink 0 uid 0 gid 0 \ size 0 atime 0 mtime 0 ctime 0 type file] dict set res type [dict get $finfor type] if {[dict get $finfor isfile]} { # Fill in any postponed info if { ! [dict exists $finfor mtime]} { set mtime [vcsvfs::${vcstype}::mTime $finfor] dict set finfor "mtime" $mtime # Cache in main dictionary too dict set mpoints $root "finfo" $relative "mtime" $mtime } if { ! [dict exists $finfor size]} { set size [vcsvfs::${vcstype}::size $finfor] dict set finfor "size" $size # Cache in main dictionary too dict set mpoints $root "finfo" $relative "size" $size } dict set res "mtime" [dict get $finfor "mtime"] dict set res "size" [dict get $finfor "size"] |
︙ | ︙ |