︙ | | | ︙ | |
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
puts "Resourcing $this"
uplevel \#0 [list source $this]
}
# This function is called when a toplevel is closed.
# If it is the last remaining toplevel, the application quits.
# If top = "all" it means quit.
proc cleanupAndExit {top} {
# A security thing to make sure we can exit.
set cont 0
if {[catch {
if {$top != "all"} {
set i [lsearch $::diff(diffWindows) $top]
if {$i >= 0} {
|
>
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
puts "Resourcing $this"
uplevel \#0 [list source $this]
}
# This function is called when a toplevel is closed.
# If it is the last remaining toplevel, the application quits.
# If top = "all" it means quit.
# If eskil is embedded, this should be used to close an eskil toplevel.
proc cleanupAndExit {top} {
# A security thing to make sure we can exit.
set cont 0
if {[catch {
if {$top != "all"} {
set i [lsearch $::diff(diffWindows) $top]
if {$i >= 0} {
|
︙ | | | ︙ | |
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
|
(This is a bug)\nTerminating application." -type ok
}
if {$cont} return
clearTmp
exit
}
# Format a line number
proc myFormL {lineNo} {
if {![string is integer -strict $lineNo]} {return "$lineNo\n"}
return [format "%3d: \n" $lineNo]
}
# Get a name for a temporary file
proc tmpFile {} {
if {[info exists ::tmpcnt]} {
incr ::tmpcnt
} else {
set ::tmpcnt 0
}
set name [file join $::diff(tmpdir) "tmpd[pid]a$::tmpcnt"]
lappend ::tmpfiles $name
return $name
}
# Delete temporary files
proc clearTmp {args} {
if {![info exists ::tmpfiles]} {
|
>
>
>
>
>
>
>
|
>
>
>
>
|
|
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
|
(This is a bug)\nTerminating application." -type ok
}
if {$cont} return
clearTmp
exit
}
# If embedding, tell eskil about any other toplevel, then
# cleanupAndExit can be used to get rid of it.
proc eskilRegisterToplevel {top} {
lappend ::diff(diffWindows) $top
}
# Format a line number
proc myFormL {lineNo} {
if {![string is integer -strict $lineNo]} {return "$lineNo\n"}
return [format "%3d: \n" $lineNo]
}
# Get a name for a temporary file
# A tail can be given to make the file more recognisable.
proc tmpFile {{tail {}}} {
if {[info exists ::tmpcnt]} {
incr ::tmpcnt
} else {
set ::tmpcnt 0
}
set name "tmpd[pid]a$::tmpcnt"
if {$tail ne ""} {
append name " [file tail $tail]"
}
set name [file join $::diff(tmpdir) $name]
lappend ::tmpfiles $name
return $name
}
# Delete temporary files
proc clearTmp {args} {
if {![info exists ::tmpfiles]} {
|
︙ | | | ︙ | |
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
|
proc applyColor {} {
global dirdiff Pref
foreach top $::diff(diffWindows) {
if {$top eq ".clipdiff"} continue
if {$top != ".dirdiff"} {
foreach item {wLine1 wDiff1 wLine2 wDiff2} {
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) \
|
>
|
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
|
proc applyColor {} {
global dirdiff Pref
foreach top $::diff(diffWindows) {
if {$top eq ".clipdiff"} continue
if {$top != ".dirdiff"} {
foreach item {wLine1 wDiff1 wLine2 wDiff2} {
if {![info exists ::widgets($top,$item)]} continue
set w $::widgets($top,$item)
$w tag configure equal -foreground $Pref(colorequal) \
-background $Pref(bgequal)
$w tag configure new1 -foreground $Pref(colornew1) \
-background $Pref(bgnew1)
$w tag configure change -foreground $Pref(colorchange) \
|
︙ | | | ︙ | |
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
|
set t 0
}
while {[winfo exists .diff$t]} {
incr t
}
set top .diff$t
toplevel $top
lappend ::diff(diffWindows) $top
}
wm title $top "Eskil:"
wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top]
ttk::frame $top.f
grid $top.f -row 0 -columnspan 4 -sticky nws
|
|
|
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
|
set t 0
}
while {[winfo exists .diff$t]} {
incr t
}
set top .diff$t
toplevel $top
eskilRegisterToplevel $top
}
wm title $top "Eskil:"
wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top]
ttk::frame $top.f
grid $top.f -row 0 -columnspan 4 -sticky nws
|
︙ | | | ︙ | |
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
|
}
if {$fail} {
puts "Argument $opt must be a list of RBG values from 0.0 to 1.0"
exit
}
}
# Go through all command line arguments
proc parseCommandLine {} {
global dirdiff Pref
set ::eskil(autoclose) 0
set ::eskil(ignorenewline) 0
if {$::eskil(argc) == 0} {
Init
makeDiffWin
return
}
set allOpts {
-w --help -help -b -noignore -i -nocase -nodigit -nokeyword -prefix
-noparse -line -smallblock -block -char -word -limit -nodiff -dir
-clip -patch -browse -conflict -print
-printHeaderSize -printCharsPerLine -printPaper
|
|
>
>
>
>
|
<
|
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
|
}
if {$fail} {
puts "Argument $opt must be a list of RBG values from 0.0 to 1.0"
exit
}
}
# Go through all command line arguments and start the appropriate
# diff window.
# Returns the created toplevel.
# This can be used as an entry point if embedding eskil.
# In that case fill in ::eskil(argv) and ::eskil(argc) before calling.
proc parseCommandLine {} {
global dirdiff Pref
set ::eskil(autoclose) 0
set ::eskil(ignorenewline) 0
if {$::eskil(argc) == 0} {
Init
return [makeDiffWin]
}
set allOpts {
-w --help -help -b -noignore -i -nocase -nodigit -nokeyword -prefix
-noparse -line -smallblock -block -char -word -limit -nodiff -dir
-clip -patch -browse -conflict -print
-printHeaderSize -printCharsPerLine -printPaper
|
︙ | | | ︙ | |
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
|
exit
}
set opts(plugin) $pinterp
}
# Do we start in clip diff mode?
if {$doclip} {
makeClipDiffWin
return
}
# Figure out if we start in a diff or dirdiff window.
set len [llength $files]
if {$len == 0 && $dodir} {
set dirdiff(leftDir) [pwd]
set dirdiff(rightDir) [pwd]
makeDirDiffWin
return
}
if {$len == 1} {
set fullname [lindex $files 0]
if {[FileIsDirectory $fullname 1]} {
set dirdiff(leftDir) $fullname
set dirdiff(rightDir) $dirdiff(leftDir)
makeDirDiffWin
return
}
} elseif {$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
makeDirDiffWin
return
}
}
# Ok, we have a normal diff
makeDiffWin
update
set top [lindex $::diff(diffWindows) end]
# Copy the previously collected options
foreach {item val} [array get opts] {
set ::diff($top,$item) $val
}
# It is preferable to see the end if the rev string is too long
$::widgets($top,rev1) xview end
$::widgets($top,rev2) xview end
if {$doreview} {
set rev [detectRevSystem "" $preferedRev]
set ::diff($top,modetype) $rev
set ::diff($top,mode) "patch"
set ::diff($top,patchFile) ""
set ::diff($top,reviewFiles) $files
set ::Pref(toolbar) 1
after idle [list doDiff $top]
return
}
if {$len == 1 || $foreach} {
set ReturnAfterLoop 0
set first 1
foreach file $files {
if {$first} {
set first 0
} else {
# Create new window for other files
makeDiffWin
update
set top [lindex $::diff(diffWindows) end]
# Copy the previously collected options
foreach {item val} [array get opts] {
set ::diff($top,$item) $val
}
# It is preferable to see the end if the rev string is too long
$::widgets($top,rev1) xview end
$::widgets($top,rev2) xview end
|
|
<
|
<
|
<
|
<
|
<
|
|
<
|
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
|
exit
}
set opts(plugin) $pinterp
}
# Do we start in clip diff mode?
if {$doclip} {
return [makeClipDiffWin]
}
# Figure out if we start in a diff or dirdiff window.
set len [llength $files]
if {$len == 0 && $dodir} {
set dirdiff(leftDir) [pwd]
set dirdiff(rightDir) [pwd]
return [makeDirDiffWin]
}
if {$len == 1} {
set fullname [lindex $files 0]
if {[FileIsDirectory $fullname 1]} {
set dirdiff(leftDir) $fullname
set dirdiff(rightDir) $dirdiff(leftDir)
return [makeDirDiffWin]
}
} elseif {$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]
}
}
# Ok, we have a normal diff
set top [makeDiffWin]
update
# Copy the previously collected options
foreach {item val} [array get opts] {
set ::diff($top,$item) $val
}
# It is preferable to see the end if the rev string is too long
$::widgets($top,rev1) xview end
$::widgets($top,rev2) xview end
if {$doreview} {
set rev [detectRevSystem "" $preferedRev]
set ::diff($top,modetype) $rev
set ::diff($top,mode) "patch"
set ::diff($top,patchFile) ""
set ::diff($top,reviewFiles) $files
set ::Pref(toolbar) 1
after idle [list doDiff $top]
return $top
}
if {$len == 1 || $foreach} {
set ReturnAfterLoop 0
set first 1
foreach file $files {
if {$first} {
set first 0
} else {
# Create new window for other files
set top [makeDiffWin]
update
# Copy the previously collected options
foreach {item val} [array get opts] {
set ::diff($top,$item) $val
}
# It is preferable to see the end if the rev string is too long
$::widgets($top,rev1) xview end
$::widgets($top,rev2) xview end
|
︙ | | | ︙ | |
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
|
} else {
after idle [list doDiff $top]
}
set ReturnAfterLoop 1
continue
}
}
if {$ReturnAfterLoop} return
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set ::diff($top,leftDir) $fulldir
set ::diff($top,leftFile) $fullname
set ::diff($top,leftLabel) $fullname
set ::diff($top,leftOK) 1
|
|
|
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
|
} else {
after idle [list doDiff $top]
}
set ReturnAfterLoop 1
continue
}
}
if {$ReturnAfterLoop} {return $top}
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set ::diff($top,leftDir) $fulldir
set ::diff($top,leftFile) $fullname
set ::diff($top,leftLabel) $fullname
set ::diff($top,leftOK) 1
|
︙ | | | ︙ | |
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
|
set fullname $::diff($top,leftFile)
set ::diff($top,leftOK) 0
startRevMode $top "CVS" $fullname
after idle [list doDiff $top]
}
}
}
}
# Save options to file ~/.eskilrc
proc saveOptions {top} {
global Pref
# Check if the window size has changed
|
>
|
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
|
set fullname $::diff($top,leftFile)
set ::diff($top,leftOK) 0
startRevMode $top "CVS" $fullname
after idle [list doDiff $top]
}
}
}
return $top
}
# Save options to file ~/.eskilrc
proc saveOptions {top} {
global Pref
# Check if the window size has changed
|
︙ | | | ︙ | |