︙ | | |
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
|
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
|
-
+
-
-
-
-
+
+
+
+
-
+
|
}
$::widgets($top,wDiff$n) insert end "\n" padding
}
# Insert one line in each text widget.
# Mark them as changed, and optionally parse them.
proc insertMatchingLines {top line1 line2} {
global doingLine1 doingLine2 Pref
global doingLine1 doingLine2
# FIXA: fully implement filter
if {$::eskil(filter) != ""} {
if {[regexp $::eskil(filter) $line1]} {
insertLine $top 1 $doingLine1 $line1
insertLine $top 2 $doingLine2 $line2
incr doingLine1
incr doingLine2
set ::eskil(filterflag) 1
return
}
set ::eskil(filterflag) 0
}
if {$Pref(parse) != 0} {
set opts $Pref(ignore)
if {$Pref(nocase)} {lappend opts -nocase}
if {$Pref(lineparsewords)} {lappend opts -words}
if {$::Pref(parse) != 0} {
set opts $::Pref(ignore)
if {$::Pref(nocase)} {lappend opts -nocase}
if {$::Pref(lineparsewords)} {lappend opts -words}
set res [DiffUtil::diffStrings {*}$opts $line1 $line2]
set dotag 0
set n [expr {[llength $res] / 2}]
$::widgets($top,wLine1) insert end [myFormL $doingLine1] \
"hl$::HighLightCount change"
$::widgets($top,wLine2) insert end [myFormL $doingLine2] \
"hl$::HighLightCount change"
set new1 "new1"
set new2 "new2"
set change "change"
foreach {i1 i2} $res {
incr n -1
if {$dotag} {
if {$n == 1 && $Pref(marklast)} {
if {$n == 1 && $::Pref(marklast)} {
lappend new1 last
lappend new2 last
lappend change last
}
if {$i1 eq ""} {
$::widgets($top,wDiff2) insert end $i2 $new2
} elseif {$i2 eq ""} {
|
︙ | | |
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
-
+
-
-
+
+
|
addChange $top $n1 $tag1 $line1 $n1 $line2 $n2
nextHighlight $top
}
}
# Insert two blocks of lines in the compare windows.
proc insertMatchingBlocks {top block1 block2 line1 line2 details} {
global doingLine1 doingLine2 Pref
global doingLine1 doingLine2
set n1 [llength $block1]
set n2 [llength $block2]
set large [expr {$n1 * $n2 > 1000}]
if {$n1 == 0 || $n2 == 0 || $Pref(parse) < 2 || \
($large && $Pref(parse) < 3)} {
if {$n1 == 0 || $n2 == 0 || $::Pref(parse) < 2 || \
($large && $::Pref(parse) < 3)} {
# No extra parsing at all.
insertMatchingBlocksNoParse $top $block1 $block2 $line1 $line2 $details
return
}
# A large block may take time. Give a small warning.
if {$large} {
|
︙ | | |
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
|
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
|
-
+
-
-
+
+
|
# ch1 is a file channel for the left file
# ch2 is a file channel for the right file
# n1/n2 is the number of lines involved
# line1/line2 says on what lines this block starts
# If n1/n2 are both 0, it means that this is the last lines to be displayed.
# In that case line1/line2, if non-zero says the last line to display.
proc doText {top ch1 ch2 n1 n2 line1 line2} {
global doingLine1 doingLine2 Pref
global doingLine1 doingLine2
if {$n1 == 0 && $n2 == 0} {
# All blocks have been processed. Continue until end of file.
# If "show all" is not on, just display a couple of context lines.
set limit -1
if {$Pref(context) >= 0} {
set limit $Pref(context)
if {$::Pref(context) >= 0} {
set limit $::Pref(context)
}
# Consider any total limit on displayed lines.
if {$::eskil($top,limitlines)} {
set limit [expr {$::eskil($top,limitlines) - $::eskil($top,mapMax)}]
if {$limit < 0} {
set limit 0
}
|
︙ | | |
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
|
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
|
-
+
-
-
-
+
+
+
|
if {$n1 == 0} {set tag2 new2} else {set tag2 change}
if {$n2 == 0} {set tag1 new1} else {set tag1 change}
# Display all equal lines before next diff, or skip if context is set.
# If context is on, only skip a section if the blank
# line replaces at least 3 lines.
set limit -1
if {$Pref(context) == 0} {
if {$::Pref(context) == 0} {
set limit 0
} elseif {$Pref(context) > 0 && \
($line1 - $doingLine1 > (2 * $Pref(context) + 2))} {
set limit $Pref(context)
} elseif {$::Pref(context) > 0 && \
($line1 - $doingLine1 > (2 * $::Pref(context) + 2))} {
set limit $::Pref(context)
}
if {$doingLine1 == 1} {
set allowStartFill 0
} else {
set allowStartFill 1
}
set t 0
|
︙ | | |
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
|
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
|
-
+
|
"**Bad alignment here!! $doingLine2 $line2**\n"
$::widgets($top,wLine1) insert end "\n"
$::widgets($top,wLine2) insert end "\n"
}
# Process the block
if {$n1 == $n2 && ($n1 == 1 || $Pref(parse) < 2)} {
if {$n1 == $n2 && ($n1 == 1 || $::Pref(parse) < 2)} {
# Never do block parsing for one line blocks.
# If block parsing is turned off, only do line parsing for
# blocks of equal size.
for {set t 0} {$t < $n1} {incr t} {
gets $ch1 textline1
gets $ch2 textline2
insertMatchingLines $top $textline1 $textline2
|
︙ | | |
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
|
903
904
905
906
907
908
909
910
911
912
913
914
915
916
|
-
-
|
} else {
set ::eskil($top,mergetranslation) lf
}
}
# Read a conflict file and extract the two versions.
proc prepareConflict {top} {
global Pref
disallowEdit $top
set ::eskil($top,leftFile) [tmpFile]
set ::eskil($top,rightFile) [tmpFile]
set ch1 [open $::eskil($top,leftFile) w]
set ch2 [open $::eskil($top,rightFile) w]
set ch [open $::eskil($top,conflictFile) r]
|
︙ | | |
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
|
961
962
963
964
965
966
967
968
969
970
971
972
973
974
|
-
-
|
set ::eskil($top,leftLabel) $leftName
set ::eskil($top,rightLabel) $rightName
update idletasks
}
# Clean up after a conflict diff.
proc cleanupConflict {top} {
global Pref
clearTmp $::eskil($top,rightFile) $::eskil($top,leftFile)
set ::eskil($top,rightFile) $::eskil($top,conflictFile)
set ::eskil($top,leftFile) $::eskil($top,conflictFile)
}
# Display one chunk from a patch file
proc displayOnePatch {top leftLines rightLines leftLine rightLine} {
|
︙ | | |
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
|
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
|
-
-
|
set rblock {}
}
mapNoChange $top 0
}
# Read a patch file and display it
proc displayPatch {top} {
global Pref
set ::eskil($top,leftLabel) "Patch $::eskil($top,patchFile): old"
set ::eskil($top,rightLabel) "Patch $::eskil($top,patchFile): new"
update idletasks
if {$::eskil($top,patchFile) eq ""} {
if {$::eskil($top,patchData) eq ""} {
set data [getFullPatch $top]
|
︙ | | |
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
|
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
|
-
|
} else {
return "$tail2 vs $tail1"
}
}
# Main diff function.
proc doDiff {top} {
global Pref
global doingLine1 doingLine2
if {$::eskil($top,mode) eq "" && ($::eskil($top,leftOK) == 0 || $::eskil($top,rightOK) == 0)} {
disableRedo $top
return
} else {
enableRedo $top
|
︙ | | |
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
|
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
|
-
-
-
-
+
+
+
+
-
+
-
+
|
} else {
prepareFiles $top
}
wm title $top "Eskil: [TitleTail $top]"
# Run diff and parse the result.
set opts $Pref(ignore)
if {$Pref(nocase)} {lappend opts -nocase}
if {$Pref(noempty)} {lappend opts -noempty}
if {$Pref(pivot) > 0} {lappend opts -pivot $Pref(pivot)}
set opts $::Pref(ignore)
if {$::Pref(nocase)} {lappend opts -nocase}
if {$::Pref(noempty)} {lappend opts -noempty}
if {$::Pref(pivot) > 0} {lappend opts -pivot $::Pref(pivot)}
if {[info exists ::eskil($top,aligns)] && \
[llength $::eskil($top,aligns)] > 0} {
lappend opts -align $::eskil($top,aligns)
}
set range {}
if {[info exists ::eskil($top,range)] && \
[llength $::eskil($top,range)] == 4} {
set range $::eskil($top,range)
lappend opts -range $range
}
foreach {RE sub side} $Pref(preprocess) {
foreach {RE sub side} $::Pref(preprocess) {
lappend opts -regsub$side [list $RE $sub]
}
# Apply nodigit after preprocess
if {$Pref(nodigit)} {lappend opts -nodigit}
if {$::Pref(nodigit)} {lappend opts -nodigit}
# If a special file for diffing is present, use it.
if {[info exists ::eskil($top,leftFileDiff)]} {
set dFile1 $::eskil($top,leftFileDiff)
} else {
set dFile1 $::eskil($top,leftFile)
}
|
︙ | | |
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
|
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
|
-
-
-
-
-
+
+
+
|
if {[doOpenAncestor $top]} {
# Redo diff with ancestor
doDiff $top
}
}
proc openConflict {top} {
global Pref
if {[doOpenRight $top]} {
startConflictDiff $top $::eskil($top,rightFile)
set ::eskil($top,mergeFile) ""
doDiff $top
}
}
proc openPatch {top} {
global Pref
if {[doOpenLeft $top]} {
set ::eskil($top,mode) "patch"
set Pref(ignore) " "
set Pref(nocase) 0
set Pref(noempty) 0
set ::Pref(ignore) " "
set ::Pref(nocase) 0
set ::Pref(noempty) 0
set ::eskil($top,patchFile) $::eskil($top,leftFile)
set ::eskil($top,patchData) ""
doDiff $top
}
}
# Get data from clipboard and display as a patch.
|
︙ | | |
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
|
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
|
-
|
}
#########
# Zooming
#########
proc zoomRow {w X Y x y} {
global Pref
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} {
|
︙ | | |
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
|
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
|
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
|
wm withdraw $top.balloon
wm overrideredirect $top.balloon 1
set wid 0
foreach x {1 2} {
text $top.balloon.t$x -relief flat -font $font -background \#ffffcc \
-foreground black -padx 2 -pady 0 -height 1 -wrap word
$top.balloon.t$x tag configure new1 -foreground $Pref(colornew1) \
-background $Pref(bgnew1)
$top.balloon.t$x tag configure change -foreground $Pref(colorchange) \
-background $Pref(bgchange)
$top.balloon.t$x tag configure new2 -foreground $Pref(colornew2) \
-background $Pref(bgnew2)
$top.balloon.t$x tag configure equal -foreground $Pref(colorequal) \
-background $Pref(bgequal)
$top.balloon.t$x tag configure new1 -foreground $::Pref(colornew1) \
-background $::Pref(bgnew1)
$top.balloon.t$x tag configure change -foreground $::Pref(colorchange) \
-background $::Pref(bgchange)
$top.balloon.t$x tag configure new2 -foreground $::Pref(colornew2) \
-background $::Pref(bgnew2)
$top.balloon.t$x tag configure equal -foreground $::Pref(colorequal) \
-background $::Pref(bgequal)
pack $top.balloon.t$x -side "top" -padx 1 -pady 1 -fill both -expand 1
set tags {}
foreach {key value index} $data($x) {
if {$key eq "tagon"} {
lappend tags $value
set tags [lsort -unique $tags]
|
︙ | | |
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
|
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
2748
2749
2750
2751
2752
|
-
-
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
proc unzoomRow {w} {
set top [winfo toplevel $w]
destroy $top.balloon
}
# Reconfigure font
proc chFont {} {
global Pref
font configure myfont -size $Pref(fontsize) -family $Pref(fontfamily)
font configure myfont -size $::Pref(fontsize) -family $::Pref(fontfamily)
}
# Change color settings
proc applyColor {} {
global dirdiff Pref
global dirdiff
foreach top $::eskil(diffWindows) {
if {$top eq ".clipdiff"} continue
if {$top != ".dirdiff"} {
foreach item {wLine1 wDiff1 wLine2 wDiff2} {
if {![info exists ::widgets($top,$item)]} continue
set w $::widgets($top,$item)
$w tag configure equal -foreground $Pref(colorequal) \
-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)
$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
}
# $dirdiff(wLeft) tag configure new1 -foreground $Pref(colornew1) \
# -background $Pref(bgnew1)
# $dirdiff(wLeft) tag configure change -foreground $Pref(colorchange) \
# -background $Pref(bgchange)
# $dirdiff(wLeft) tag configure changed -foreground $Pref(colorchange)
# $dirdiff(wLeft) tag configure invalid -background #a9a9a9
# $dirdiff(wRight) tag configure new2 -foreground $Pref(colornew2) \
# -background $Pref(bgnew2)
# $dirdiff(wRight) tag configure change -foreground $Pref(colorchange) \
# -background $Pref(bgchange)
# $dirdiff(wRight) tag configure changed -foreground $Pref(colorchange)
# $dirdiff(wRight) tag configure invalid -background #a9a9a9
}
}
# Scroll text windows
proc scrollText {top n what} {
# Do not scroll if focus is in a text window.
# This is for scroll bindings in the toplevel.
|
︙ | | |
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
|
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
|
-
+
|
$dMenu add command -label "_stats" -command {parray _stats}
$dMenu add command -label "Nuisance" -command [list makeNuisance \
$top "It looks like you are trying out the debug menu."]
}
# Build the main window
proc makeDiffWin {{top {}}} {
global Pref tcl_platform
global tcl_platform
if {$top != "" && [winfo exists $top] && [winfo toplevel $top] eq $top} {
# Reuse the old window
destroy {*}[winfo children $top]
} else {
# Locate a free toplevel name
if {[info exists ::eskil(topDiffCnt)]} {
|
︙ | | |
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
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
|
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
|
$top.m.mo add separator
$top.m.mo add command -label "Save default" \
-command [list saveOptions $top]
menu $top.m.mo.f
$top.m.mo.f add command -label "Select..." -command makeFontWin \
-underline 0
$top.m.mo.f add radiobutton -label 6 -variable Pref(fontsize) -value 6 \
$top.m.mo.f add radiobutton -label 6 -variable ::Pref(fontsize) -value 6 \
-command chFont
$top.m.mo.f add radiobutton -label 7 -variable Pref(fontsize) -value 7 \
$top.m.mo.f add radiobutton -label 7 -variable ::Pref(fontsize) -value 7 \
-command chFont
$top.m.mo.f add radiobutton -label 8 -variable Pref(fontsize) -value 8 \
$top.m.mo.f add radiobutton -label 8 -variable ::Pref(fontsize) -value 8 \
-command chFont
$top.m.mo.f add radiobutton -label 9 -variable Pref(fontsize) -value 9 \
$top.m.mo.f add radiobutton -label 9 -variable ::Pref(fontsize) -value 9 \
-command chFont
$top.m.mo.f add radiobutton -label 10 -variable Pref(fontsize) -value 10 \
$top.m.mo.f add radiobutton -label 10 -variable ::Pref(fontsize) -value 10 \
-command chFont
menu $top.m.mo.i
$top.m.mo.i add radiobutton -label "No spaces" \
-variable Pref(ignore) -value " "
-variable ::Pref(ignore) -value " "
$top.m.mo.i add radiobutton -label "Space changes (-b)" \
-variable Pref(ignore) -value "-b"
-variable ::Pref(ignore) -value "-b"
$top.m.mo.i add radiobutton -label "All spaces (-w)" \
-variable Pref(ignore) -value "-w"
-variable ::Pref(ignore) -value "-w"
$top.m.mo.i add separator
$top.m.mo.i add checkbutton -label "Case (-i)" \
-variable Pref(nocase)
-variable ::Pref(nocase)
$top.m.mo.i add checkbutton -label "Empty" \
-variable Pref(noempty)
-variable ::Pref(noempty)
$top.m.mo.i add checkbutton -label "Digits" \
-variable Pref(nodigit)
-variable ::Pref(nodigit)
menu $top.m.mo.p
$top.m.mo.p add radiobutton -label "Nothing" -variable Pref(parse) -value 0
$top.m.mo.p add radiobutton -label "Lines" -variable Pref(parse) -value 1
$top.m.mo.p add radiobutton -label "Blocks (small)" -variable Pref(parse) \
$top.m.mo.p add radiobutton -label "Nothing" -variable ::Pref(parse) -value 0
$top.m.mo.p add radiobutton -label "Lines" -variable ::Pref(parse) -value 1
$top.m.mo.p add radiobutton -label "Blocks (small)" -variable ::Pref(parse) \
-value 2
$top.m.mo.p add radiobutton -label "Blocks" -variable Pref(parse) -value 3
$top.m.mo.p add radiobutton -label "Blocks" -variable ::Pref(parse) -value 3
$top.m.mo.p add separator
$top.m.mo.p add radiobutton -label "Characters" \
-variable Pref(lineparsewords) -value "0"
-variable ::Pref(lineparsewords) -value "0"
$top.m.mo.p add radiobutton -label "Words" \
-variable Pref(lineparsewords) -value "1"
-variable ::Pref(lineparsewords) -value "1"
$top.m.mo.p add separator
$top.m.mo.p add checkbutton -label "Fine chunks" -variable Pref(finegrainchunks)
$top.m.mo.p add checkbutton -label "Fine chunks" -variable ::Pref(finegrainchunks)
$top.m.mo.p add separator
$top.m.mo.p add checkbutton -label "Mark last" -variable Pref(marklast)
$top.m.mo.p add checkbutton -label "Mark last" -variable ::Pref(marklast)
menu $top.m.mo.c
$top.m.mo.c add radiobutton -label "Show all lines" \
-variable ::Pref(context) -value -1
$top.m.mo.c add radiobutton -label "Show only diffs" \
-variable ::Pref(context) -value 0
$top.m.mo.c add separator
|
︙ | | |
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
|
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
|
-
+
-
+
-
+
-
+
-
+
|
-underline 0
bind $top <Alt-n> [list findDiff $top 1]
bind $top <Alt-p> [list findDiff $top -1]
bind $top <Alt-c> [list revCommit $top]
bind $top <Alt-l> [list revLog $top]
catch {font delete myfont}
font create myfont -family $Pref(fontfamily) -size $Pref(fontsize)
font create myfont -family $::Pref(fontfamily) -size $::Pref(fontsize)
fileLabel $top.l1 -textvariable ::eskil($top,leftLabel)
fileLabel $top.l2 -textvariable ::eskil($top,rightLabel)
ttk::frame $top.ft1 -borderwidth 2 -relief sunken
text $top.ft1.tl -height $Pref(lines) -width 5 -wrap none \
text $top.ft1.tl -height $::Pref(lines) -width 5 -wrap none \
-font myfont -borderwidth 0 -padx 0 -highlightthickness 0 \
-takefocus 0
text $top.ft1.tt -height $Pref(lines) -width $Pref(linewidth) -wrap none \
text $top.ft1.tt -height $::Pref(lines) -width $::Pref(linewidth) -wrap none \
-xscrollcommand [list $top.sbx1 set] \
-font myfont -borderwidth 0 -padx 1 \
-highlightthickness 0
$top.ft1.tt configure -tabstyle wordprocessor
tk::frame $top.ft1.f -width 2 -height 2 -background lightgray
pack $top.ft1.tl -side left -fill y
pack $top.ft1.f -side left -fill y
pack $top.ft1.tt -side right -fill both -expand 1
scrollbar $top.sby -orient vertical
scrollbar $top.sbx1 -orient horizontal -command [list $top.ft1.tt xview]
set ::widgets($top,wLine1) $top.ft1.tl
set ::widgets($top,wDiff1) $top.ft1.tt
ttk::frame $top.ft2 -borderwidth 2 -relief sunken
text $top.ft2.tl -height $Pref(lines) -width 5 -wrap none \
text $top.ft2.tl -height $::Pref(lines) -width 5 -wrap none \
-font myfont -borderwidth 0 -padx 0 -highlightthickness 0 \
-takefocus 0
text $top.ft2.tt -height $Pref(lines) -width $Pref(linewidth) -wrap none \
text $top.ft2.tt -height $::Pref(lines) -width $::Pref(linewidth) -wrap none \
-xscrollcommand [list $top.sbx2 set] \
-font myfont -borderwidth 0 -padx 1 \
-highlightthickness 0
$top.ft2.tt configure -tabstyle wordprocessor
tk::frame $top.ft2.f -width 2 -height 2 -background lightgray
pack $top.ft2.tl -side left -fill y
pack $top.ft2.f -side left -fill y
|
︙ | | |
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
|
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
|
-
-
-
+
+
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
-
+
-
-
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
|
initDiffData $top
resetEdit $top
return $top
}
proc ValidateNewColors {} {
global TmpPref
foreach item {colorchange bgchange colornew1 bgnew1
colornew2 bgnew2 colorequal bgequal} {
if {![info exists TmpPref($item)]} continue
set col $TmpPref($item)
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)
set ::TmpPref($item) $::Pref($item)
}
}
}
# Set new preferences.
proc applyPref {} {
global Pref TmpPref
ValidateNewColors
array set Pref [array get TmpPref]
array set ::Pref [array get ::TmpPref]
applyColor
}
# Update test color fields.
proc testColor {} {
global TmpPref
ValidateNewColors
.pr.fc.t1 tag configure change -foreground $TmpPref(colorchange) \
-background $TmpPref(bgchange)
.pr.fc.t2 tag configure new1 -foreground $TmpPref(colornew1) \
-background $TmpPref(bgnew1)
.pr.fc.t3 tag configure new2 -foreground $TmpPref(colornew2) \
-background $TmpPref(bgnew2)
.pr.fc.t4 tag configure equal -foreground $TmpPref(colorequal) \
-background $TmpPref(bgequal)
.pr.fc.t1 tag configure change -foreground $::TmpPref(colorchange) \
-background $::TmpPref(bgchange)
.pr.fc.t2 tag configure new1 -foreground $::TmpPref(colornew1) \
-background $::TmpPref(bgnew1)
.pr.fc.t3 tag configure new2 -foreground $::TmpPref(colornew2) \
-background $::TmpPref(bgnew2)
.pr.fc.t4 tag configure equal -foreground $::TmpPref(colorequal) \
-background $::TmpPref(bgequal)
}
# Color dialog.
proc selColor {name} {
global TmpPref
set old $TmpPref($name)
set old $::TmpPref($name)
if {$old eq ""} {
set t [tk_chooseColor -parent .pr]
} else {
set t [tk_chooseColor -parent .pr -initialcolor $old]
}
if {$t != ""} {
set TmpPref($name) $t
set ::TmpPref($name) $t
}
}
# Create a window for changing preferences.
# Currently only colors are changed in this dialog.
proc makePrefWin {} {
global Pref TmpPref
array set TmpPref [array get Pref]
array set ::TmpPref [array get ::Pref]
destroy .pr
toplevel .pr
wm title .pr "Eskil Preferences"
ttk::frame .pr.fc -borderwidth 1 -relief solid
ttk::label .pr.fc.l1 -text "Colours" -anchor w
ttk::label .pr.fc.l2 -text "Text" -anchor w
ttk::label .pr.fc.l3 -text "Background" -anchor w
ttk::entryX .pr.fc.e1 -textvariable "TmpPref(colorchange)" -width 10
ttk::entryX .pr.fc.e2 -textvariable "TmpPref(colornew1)" -width 10
ttk::entryX .pr.fc.e3 -textvariable "TmpPref(colornew2)" -width 10
ttk::entryX .pr.fc.e4 -textvariable "TmpPref(colorequal)" -width 10
ttk::entryX .pr.fc.e1 -textvariable "::TmpPref(colorchange)" -width 10
ttk::entryX .pr.fc.e2 -textvariable "::TmpPref(colornew1)" -width 10
ttk::entryX .pr.fc.e3 -textvariable "::TmpPref(colornew2)" -width 10
ttk::entryX .pr.fc.e4 -textvariable "::TmpPref(colorequal)" -width 10
ttk::button .pr.fc.b1 -text "Sel" -command "selColor colorchange"
ttk::button .pr.fc.b2 -text "Sel" -command "selColor colornew1"
ttk::button .pr.fc.b3 -text "Sel" -command "selColor colornew2"
ttk::button .pr.fc.b4 -text "Sel" -command "selColor colorequal"
ttk::entryX .pr.fc.e5 -textvariable "TmpPref(bgchange)" -width 10
ttk::entryX .pr.fc.e6 -textvariable "TmpPref(bgnew1)" -width 10
ttk::entryX .pr.fc.e7 -textvariable "TmpPref(bgnew2)" -width 10
ttk::entryX .pr.fc.e8 -textvariable "TmpPref(bgequal)" -width 10
ttk::entryX .pr.fc.e5 -textvariable "::TmpPref(bgchange)" -width 10
ttk::entryX .pr.fc.e6 -textvariable "::TmpPref(bgnew1)" -width 10
ttk::entryX .pr.fc.e7 -textvariable "::TmpPref(bgnew2)" -width 10
ttk::entryX .pr.fc.e8 -textvariable "::TmpPref(bgequal)" -width 10
ttk::button .pr.fc.b5 -text "Sel" -command "selColor bgchange"
ttk::button .pr.fc.b6 -text "Sel" -command "selColor bgnew1"
ttk::button .pr.fc.b7 -text "Sel" -command "selColor bgnew2"
ttk::button .pr.fc.b8 -text "Sel" -command "selColor bgequal"
text .pr.fc.t1 -width 12 -height 1 -font myfont -takefocus 0
text .pr.fc.t2 -width 12 -height 1 -font myfont -takefocus 0
text .pr.fc.t3 -width 12 -height 1 -font myfont -takefocus 0
text .pr.fc.t4 -width 12 -height 1 -font myfont -takefocus 0
.pr.fc.t1 tag configure change -foreground $TmpPref(colorchange) \
-background $TmpPref(bgchange)
.pr.fc.t2 tag configure new1 -foreground $TmpPref(colornew1) \
-background $TmpPref(bgnew1)
.pr.fc.t3 tag configure new2 -foreground $TmpPref(colornew2) \
-background $TmpPref(bgnew2)
.pr.fc.t4 tag configure equal -foreground $TmpPref(colorequal) \
-background $TmpPref(bgequal)
.pr.fc.t1 tag configure change -foreground $::TmpPref(colorchange) \
-background $::TmpPref(bgchange)
.pr.fc.t2 tag configure new1 -foreground $::TmpPref(colornew1) \
-background $::TmpPref(bgnew1)
.pr.fc.t3 tag configure new2 -foreground $::TmpPref(colornew2) \
-background $::TmpPref(bgnew2)
.pr.fc.t4 tag configure equal -foreground $::TmpPref(colorequal) \
-background $::TmpPref(bgequal)
.pr.fc.t1 insert end "Changed text" change
.pr.fc.t2 insert end "Deleted text" new1
.pr.fc.t3 insert end "Added text" new2
.pr.fc.t4 insert end "Equal text" equal
.pr.fc.t1 configure -state disabled
.pr.fc.t2 configure -state disabled
|
︙ | | |
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
|
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
|
-
-
-
+
-
+
-
-
+
-
-
-
+
+
+
-
+
-
+
-
+
|
pack .pr.fc -side top -fill x
pack .pr.b1 .pr.b2 .pr.b3 -side left -expand 1 -fill x -anchor s \
-padx 2 -pady 2
}
# Change font preference
proc applyFont {lb} {
global Pref TmpPref
set Pref(fontsize) $TmpPref(fontsize)
set ::Pref(fontsize) $::TmpPref(fontsize)
set i [lindex [$lb curselection] 0]
set Pref(fontfamily) [$lb get $i]
set ::Pref(fontfamily) [$lb get $i]
chFont
}
# Update example font
proc exampleFont {lb} {
global TmpPref
set i [lindex [$lb curselection] 0]
if {$i eq ""} return
set TmpPref(fontfamily) [$lb get $i]
set ::TmpPref(fontfamily) [$lb get $i]
font configure tmpfont -family $TmpPref(fontfamily)
if {[string is integer -strict $TmpPref(fontsize)]} {
font configure tmpfont -size $TmpPref(fontsize)
font configure tmpfont -family $::TmpPref(fontfamily)
if {[string is integer -strict $::TmpPref(fontsize)]} {
font configure tmpfont -size $::TmpPref(fontsize)
}
}
proc UpdateFontBox {lb} {
$lb delete 0 end
foreach {f fixed} $::FontCache {
if {$fixed || !$::eskil(fixedfont)} {
$lb insert end $f
if {[string equal -nocase $f $::Pref(fontfamily)]} {
$lb selection set end
$lb see end
}
}
}
}
# Font dialog
proc makeFontWin {} {
global Pref TmpPref FontCache
global FontCache
destroy .fo
toplevel .fo -padx 3 -pady 3
wm title .fo "Select Font"
ttk::label .fo.ltmp -text "Searching for fonts..."
pack .fo.ltmp -padx {10 50} -pady {10 50}
update
catch {font delete tmpfont}
font create tmpfont
array set TmpPref [array get Pref]
array set ::TmpPref [array get ::Pref]
ttk::labelframe .fo.lf -text "Family" -padding 3
set lb [Scroll y listbox .fo.lf.lb -width 15 -height 10 \
-exportselection no -selectmode single]
bind $lb <<ListboxSelect>> [list exampleFont $lb]
pack .fo.lf.lb -fill both -expand 1
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]
-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]
|
︙ | | |
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
|
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
|
-
+
|
# 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
global dirdiff
set ::eskil(autoclose) 0
set ::eskil(ignorenewline) 0
if {$::eskil(argc) == 0} {
Init
return [makeDiffWin]
|
︙ | | |
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
|
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
} elseif {$nextArg eq "printFile"} {
set opts(printFile) [file join [pwd] $arg]
} elseif {$nextArg eq "printHeaderSize"} {
if {![string is double -strict $arg] || $arg <= 0} {
puts "Argument -printHeaderSize must be a positive number"
exit
}
set Pref(printHeaderSize) $arg
set ::Pref(printHeaderSize) $arg
} elseif {$nextArg eq "printCharsPerLine"} {
if {![string is integer -strict $arg] || $arg <= 0} {
puts "Argument -printCharsPerLine must be a positive number"
exit
}
set Pref(printCharsPerLine) $arg
set ::Pref(printCharsPerLine) $arg
} elseif {$nextArg eq "printPaper"} {
package require pdf4tcl
if {[llength [pdf4tcl::getPaperSize $arg]] != 2} {
puts "Argument -printPaper must be a valid paper size"
puts "Valid paper sizes:"
puts [join [lsort -dictionary [pdf4tcl::getPaperSizeList]] \n]
exit
}
set Pref(printPaper) $arg
set ::Pref(printPaper) $arg
} elseif {$nextArg eq "printColorChange"} {
ValidatePdfColor $arg -printColorChange
set Pref(printColorChange) $arg
set ::Pref(printColorChange) $arg
} elseif {$nextArg eq "printColorOld"} {
ValidatePdfColor $arg -printColorOld
set Pref(printColorNew1) $arg
set ::Pref(printColorNew1) $arg
} elseif {$nextArg eq "printColorNew"} {
ValidatePdfColor $arg -printColorNew
set Pref(printColorNew2) $arg
set ::Pref(printColorNew2) $arg
} elseif {$nextArg eq "revision"} {
set opts(doptrev$revNo) $arg
incr revNo
} elseif {$nextArg eq "limitlines"} {
set opts(limitlines) $arg
} elseif {$nextArg eq "context"} {
set Pref(context) $arg
set ::Pref(context) $arg
} elseif {$nextArg eq "pivot"} {
if {$arg >= 1} {
set Pref(pivot) $arg
set ::Pref(pivot) $arg
}
} elseif {$nextArg eq "prefix"} {
set RE [string map [list % $arg] {^.*?\m(%\w+).*$}]
if {$Pref(nocase)} {
if {$::Pref(nocase)} {
set RE "(?i)$RE"
}
lappend ::Pref(preprocess) $RE {\1} ""
} elseif {$nextArg eq "plugin"} {
set plugin $arg
} elseif {$nextArg eq "plugininfo"} {
set plugininfo $arg
|
︙ | | |
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
|
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
set match [lsearch -glob -all -inline $allOpts $arg*]
if {[llength $match] == 1} {
set arg [lindex $match 0]
}
}
if {$arg eq "-w"} {
set Pref(ignore) "-w"
set ::Pref(ignore) "-w"
} elseif {$arg eq "--help" || $arg eq "-help"} {
printUsage
exit
} elseif {$arg eq "-b"} {
set Pref(ignore) "-b"
set ::Pref(ignore) "-b"
} elseif {$arg eq "-noignore"} {
set Pref(ignore) " "
set ::Pref(ignore) " "
} elseif {$arg eq "-i"} {
set Pref(nocase) 1
set ::Pref(nocase) 1
} elseif {$arg eq "-nocase"} {
set Pref(nocase) 1
set ::Pref(nocase) 1
} elseif {$arg eq "-noempty"} { # FIXA: Add to documentation
set Pref(noempty) 1
set ::Pref(noempty) 1
} elseif {$arg eq "-pivot"} { # FIXA: Add to documentation
set nextArg pivot
} elseif {$arg eq "-nodigit"} {
set Pref(nodigit) 1
set ::Pref(nodigit) 1
} elseif {$arg eq "-nokeyword"} {
set Pref(dir,ignorekey) 1
set ::Pref(dir,ignorekey) 1
} elseif {$arg eq "-prefix"} {
set nextArg prefix
} elseif {$arg eq "-preprocess"} {
set nextArg preprocess
} elseif {$arg eq "-preprocessleft"} {
set nextArg preprocessleft
} elseif {$arg eq "-preprocessright"} {
set nextArg preprocessright
} elseif {$arg eq "-plugin"} {
set nextArg "plugin"
} elseif {$arg eq "-plugininfo"} {
set nextArg "plugininfo"
} elseif {$arg eq "-plugindump"} {
set nextArg "plugindump"
} elseif {$arg eq "-pluginlist"} {
set pluginlist 1
} elseif {$arg eq "-context"} {
set nextArg context
} elseif {$arg eq "-noparse"} {
set Pref(parse) 0
set ::Pref(parse) 0
} elseif {$arg eq "-line"} {
set Pref(parse) 1
set ::Pref(parse) 1
} elseif {$arg eq "-smallblock"} {
set Pref(parse) 2
set ::Pref(parse) 2
} elseif {$arg eq "-block"} {
set Pref(parse) 3
set ::Pref(parse) 3
} elseif {$arg eq "-char"} {
set Pref(lineparsewords) 0
set ::Pref(lineparsewords) 0
} elseif {$arg eq "-word"} {
set Pref(lineparsewords) 1
set ::Pref(lineparsewords) 1
} elseif {$arg eq "-2nd"} { # Deprecated
#set Pref(extralineparse) 1
#set ::Pref(extralineparse) 1
} elseif {$arg eq "-no2nd"} { # Deprecated
#set Pref(extralineparse) 0
#set ::Pref(extralineparse) 0
} elseif {$arg eq "-limit"} {
set nextArg limitlines
} elseif {$arg eq "-nodiff"} {
set noautodiff 1
} elseif {$arg eq "-nocdiff"} {
set nocdiff 1
} elseif {$arg eq "-dir"} {
|
︙ | | |
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
|
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
|
-
+
-
+
|
tk appname Eskil
}
} elseif {$arg eq "-o"} {
set nextArg mergeFile
} elseif {$arg eq "-a"} {
set nextArg ancestorFile
# Default is no ignore on three-way merge
set Pref(ignore) " "
set ::Pref(ignore) " "
} elseif {$arg eq "-fine"} {
set Pref(finegrainchunks) 1
set ::Pref(finegrainchunks) 1
} elseif {$arg eq "-r"} {
set nextArg revision
} elseif {$arg eq "-debug"} {
set ::eskil(debug) 1
} elseif {$arg eq "-svn"} {
set preferedRev "SVN"
} elseif {$arg eq "-cvs"} {
|
︙ | | |
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
|
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
|
-
-
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
|
}
}
return $top
}
# Save options to file ~/.eskilrc
proc saveOptions {top} {
global Pref
# Check if the window size has changed
set w $::widgets($top,wDiff1)
if {[winfo reqwidth $w] != [winfo width $w] || \
[winfo reqheight $w] != [winfo height $w]} {
set dx [expr {[winfo width $w] - [winfo reqwidth $w]}]
set dy [expr {[winfo height $w] - [winfo reqheight $w]}]
set cx [font measure myfont 0]
set cy [font metrics myfont -linespace]
set neww [expr {[$w cget -width] + $dx / $cx}]
set newh [expr {[$w cget -height] + $dy / $cy}]
if {$neww != $Pref(linewidth) || $newh != $Pref(lines)} {
if {$neww != $::Pref(linewidth) || $newh != $::Pref(lines)} {
set apa [tk_messageBox -title "Save Preferences" -icon question \
-type yesno -message "Should I save the current window\
size with the preferences?\nCurrent: $neww x $newh Old:\
$Pref(linewidth) x $Pref(lines)"]
$::Pref(linewidth) x $::Pref(lines)"]
if {$apa == "yes"} {
set Pref(linewidth) $neww
set Pref(lines) $newh
set ::Pref(linewidth) $neww
set ::Pref(lines) $newh
}
}
}
set rcfile "~/.eskilrc"
if {[catch {set ch [open $rcfile "w"]} err]} {
tk_messageBox -icon error -title "File error" -message \
"Error when trying to save preferences:\n$err"
return
}
foreach i [array names Pref] {
foreach i [array names ::Pref] {
# Skip unchanged options.
if {[info exists ::DefaultPref($i)]} {
if {$::DefaultPref($i) eq $Pref($i)} {
if {$::DefaultPref($i) eq $::Pref($i)} {
continue
}
}
puts $ch [list set Pref($i) $Pref($i)]
puts $ch [list set ::Pref($i) $::Pref($i)]
}
close $ch
tk_messageBox -icon info -title "Saved" -message \
"Preferences saved to:\n[file nativename $rcfile]"
}
proc getOptions {} {
global Pref
set Pref(fontsize) 8
set ::DefaultPref(fontsize) 8
# Maybe change to TkFixedFont in 8.5 ?
set Pref(fontfamily) Courier
set Pref(ignore) "-b"
set Pref(nocase) 0
set Pref(noempty) 0
set Pref(pivot) 100
set Pref(nodigit) 0
set Pref(parse) 2
set Pref(lineparsewords) 0
set Pref(colorequal) ""
set Pref(colorchange) red
set Pref(colornew1) darkgreen
set Pref(colornew2) blue
set Pref(bgequal) ""
set Pref(bgchange) \#ffe0e0
set Pref(bgnew1) \#a0ffa0
set Pref(bgnew2) \#e0e0ff
set Pref(context) -1
set Pref(finegrainchunks) 0
set Pref(marklast) 1
set Pref(linewidth) 80
set Pref(lines) 60
set Pref(editor) ""
set Pref(preprocess) {}
set Pref(toolbar) 0
set Pref(wideMap) 0 ;# Not settable in GUI yet
set ::DefaultPref(fontfamily) Courier
set ::DefaultPref(ignore) "-b"
set ::DefaultPref(nocase) 0
set ::DefaultPref(noempty) 0
set ::DefaultPref(pivot) 100
set ::DefaultPref(nodigit) 0
set ::DefaultPref(parse) 2
set ::DefaultPref(lineparsewords) 0
set ::DefaultPref(colorequal) ""
set ::DefaultPref(colorchange) red
set ::DefaultPref(colornew1) darkgreen
set ::DefaultPref(colornew2) blue
set ::DefaultPref(bgequal) ""
set ::DefaultPref(bgchange) \#ffe0e0
set ::DefaultPref(bgnew1) \#a0ffa0
set ::DefaultPref(bgnew2) \#e0e0ff
set ::DefaultPref(context) -1
set ::DefaultPref(finegrainchunks) 0
set ::DefaultPref(marklast) 1
set ::DefaultPref(linewidth) 80
set ::DefaultPref(lines) 60
set ::DefaultPref(editor) ""
set ::DefaultPref(preprocess) {}
set ::DefaultPref(toolbar) 0
set ::DefaultPref(wideMap) 0 ;# Not settable in GUI yet
# Print options
set Pref(printHeaderSize) 10
set Pref(printCharsPerLine) 80
set Pref(printPaper) a4
set Pref(printColorChange) "1.0 0.7 0.7"
set Pref(printColorNew1) "0.7 1.0 0.7"
set Pref(printColorNew2) "0.8 0.8 1.0"
set ::DefaultPref(printHeaderSize) 10
set ::DefaultPref(printCharsPerLine) 80
set ::DefaultPref(printPaper) a4
set ::DefaultPref(printColorChange) "1.0 0.7 0.7"
set ::DefaultPref(printColorNew1) "0.7 1.0 0.7"
set ::DefaultPref(printColorNew2) "0.8 0.8 1.0"
# Directory diff options
set Pref(dir,comparelevel) 1
set Pref(dir,ignorekey) 0
set Pref(dir,incfiles) ""
set Pref(dir,exfiles) "*.o"
set Pref(dir,incdirs) ""
set Pref(dir,exdirs) "RCS CVS .git .svn .hg"
set Pref(dir,onlyrev) 0
set ::DefaultPref(dir,comparelevel) 1
set ::DefaultPref(dir,ignorekey) 0
set ::DefaultPref(dir,incfiles) ""
set ::DefaultPref(dir,exfiles) "*.o"
set ::DefaultPref(dir,incdirs) ""
set ::DefaultPref(dir,exdirs) "RCS CVS .git .svn .hg"
set ::DefaultPref(dir,onlyrev) 0
# Store default preferences, to filter saved preferences
array set ::DefaultPref [array get Pref]
# Start with default preferences, before loading setup file
array set ::Pref [array get ::DefaultPref]
# Backward compatibilty options
set Pref(onlydiffs) -1
set Pref(regsub) {}
set ::Pref(onlydiffs) -1
set ::Pref(regsub) {}
set ::eskil(filter) ""
if {![info exists ::eskil_testsuite] && [file exists "~/.eskilrc"]} {
safeLoad "~/.eskilrc" Pref
safeLoad "~/.eskilrc" ::Pref
}
if {$Pref(editor) ne ""} {
set ::util(editor) $Pref(editor)
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(onlydiffs) == 0} {
set Pref(context) -1
if {$::Pref(onlydiffs) == 0} {
set ::Pref(context) -1
}
unset Pref(onlydiffs)
if {$Pref(regsub) ne ""} {
foreach {a b} $Pref(regsub) {
lappend Pref(preprocess) $a $b ""
unset ::Pref(onlydiffs)
if {$::Pref(regsub) ne ""} {
foreach {a b} $::Pref(regsub) {
lappend ::Pref(preprocess) $a $b ""
}
}
unset Pref(regsub)
unset ::Pref(regsub)
# Set up reactions to some Pref settings
if {![info exists ::widgets(toolbars)]} {
set ::widgets(toolbars) {}
}
trace add variable ::Pref(toolbar) write TraceToolbar
}
|
︙ | | |