︙ | | |
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-
+
|
# Usage
# Do 'diff.tcl' for interactive mode
# Do 'diff.tcl -h' for command line usage
#
# Author Peter Spjuth 980612
#
# Revised Date Remark
#
#
# 1.0 980612 New Version.
# 1.1 980807 Parsing of change blocks added
# Options menu and variables changed
# Command line options added
# 1.2 980818 Improved yscroll
# Added map next to y-scrollbar
# 1.3 980921 Added Prev Diff button
|
︙ | | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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
|
-
-
+
+
+
+
|
#
#-----------------------------------------------
# $Revision$
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"
set debug 1
set diffver "Version 1.9.4b 2002-05-14"
set debug 0
set diffver "Version 1.9.5 2002-08-09"
set tmpcnt 0
set tmpfiles {}
set thisscript [file join [pwd] [info script]]
set thisdir [file dirname $thisscript]
set ::diff(cvsExists) [expr {![string equal [auto_execok cvs] ""]}]
set ::diff(diffexe) diff
# Experimenting with DiffUtil package
set ::diff(diffutil) [expr {![catch {package require DiffUtil}]}]
set ::diff(diffutil) 0
if {[info exists env(TEMP)]} {
set ::diff(tmpdir) $env(TEMP)
} elseif {[info exists env(TMP)]} {
set ::diff(tmpdir) $env(TMP)
} else {
if {$tcl_platform(platform) == "windows"} {
|
︙ | | |
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
+
+
+
+
+
+
|
catch {file delete $f}
}
set ::tmpfiles {}
}
# 2nd stage line parsing
# Recursively look for common substrings in strings s1 and s2
# The strings are known to not have anything in common at start or end.
# The return value is, for each string, a list where the second, fourth etc.
# element is equal between the strings.
# This is sort of a Longest Common Subsequence algorithm but with
# a preference for long consecutive substrings, and it does not look
# for really small substrings.
##syntax compareMidString x x n n x?
proc compareMidString {s1 s2 res1Name res2Name {test 0}} {
global Pref
upvar $res1Name res1
upvar $res2Name res2
set len1 [string length $s1]
|
︙ | | |
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
|
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
|
+
+
+
+
+
|
compareMidString $right1 $right2 right1 right2 $test
set res1 [concat $left1 [list $mid1] $right1]
set res2 [concat $left2 [list $mid2] $right2]
}
}
# Experiment using DiffUtil
proc compareLinesX {line1 line2 res1Name res2Name {test 0}} {
global Pref
upvar $res1Name res1
upvar $res2Name res2
set args "$Pref(ignore)\
[expr {($Pref(lineparsewords) && !$test) ? "-word" : ""}]"
eval DiffUtil::compareLines $args \$line1 \$line2 res1 res2
}
# Compare two lines to find inequalities to highlight.
# The return value is, for each line, a list where the first, third etc.
# element is equal between the lines. The second, fourth etc. will be
# highlighted.
##syntax compareLines x x n n x?
proc compareLines {line1 line2 res1Name res2Name {test 0}} {
global Pref
upvar $res1Name res1
upvar $res2Name res2
# This processes the lines from both ends first.
# A typical line has few changes thus this gets rid of most
# equalities. The middle part is then optionally parsed further.
if {$Pref(ignore) != " "} {
# Skip white space in both ends
set apa1 [string trimleft $line1]
set leftp1 [expr {[string length $line1] - [string length $apa1]}]
set mid1 [string trimright $line1]
|
︙ | | |
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
+
|
set right2 [string range $line2 [expr {$t2 + 1}] end]
set mid2 [string range $line2 $leftp2 $t2]
set left2 [string range $line2 0 [expr {$leftp2 - 1}]]
set res2 [list $left2 $mid2 $right2]
if {$Pref(extralineparse) != 0 && $mid1 != "" && $mid2 != ""} {
compareMidString $mid1 $mid2 mid1 mid2 $test
# Replace middle element in res* with list elements from mid*
#set res1 [eval lreplace \$res1 1 1 $mid1]
#set res2 [eval lreplace \$res2 1 1 $mid2]
# This makes use of pure-list optimisation in eval
set res1 [eval [linsert $mid1 0 lreplace $res1 1 1]]
set res2 [eval [linsert $mid2 0 lreplace $res2 1 1]]
}
|
︙ | | |
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
|
+
+
+
+
|
insert 1 $doingLine1 $line1 change
insert 2 $doingLine2 $line2 change
}
incr doingLine1
incr doingLine2
}
# Insert two blocks of lines in the compare windows.
# Returns number of lines used to display the blocks
proc insertMatchingBlocks {block1 block2} {
global doingLine1 doingLine2
set apa [compareBlocks $block1 $block2]
set t1 0
set t2 0
foreach c $apa {
if {$c == "c"} {
set textline1 [lindex $block1 $t1]
set textline2 [lindex $block2 $t2]
insertMatchingLines $textline1 $textline2
incr t1
incr t2
}
if {$c == "C"} {
# This is two lines that the block matching considered
# too different to use line parsing on them.
# Marked the whole line as deleted/inserted
set textline1 [lindex $block1 $t1]
set textline2 [lindex $block2 $t2]
.ft1.tl insert end [myforml $doingLine1] \
"hl$::HighLightCount change"
.ft1.tt insert end "$textline1\n" new1
.ft2.tl insert end [myforml $doingLine2] \
"hl$::HighLightCount change"
|
︙ | | |
761
762
763
764
765
766
767
768
769
770
771
772
773
774
|
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
|
+
|
if {$n1 == 0 && $n2 == 0} {
# All blocks have been processed. Continue until end of file.
# If "only diffs" is on, just display a couple of context lines.
set limit -1
if {$Pref(onlydiffs) == 1} {
set limit $Pref(context)
}
# Consider any total limit on displayed lines.
if {$::diff(limitlines)} {
set limit [expr {$::diff(limitlines) - $mapMax}]
if {$limit < 0} {
set limit 0
}
}
set t 0
|
︙ | | |
785
786
787
788
789
790
791
792
793
794
795
796
797
798
|
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
|
+
|
incr doingLine1
incr t
if {$limit >= 0 && $t >= $limit} break
}
return
}
# Is this a change block, a delete block or a insert block?
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
# If only diff is on, only skip a section if the blank
# line replaces at least 3 lines.
set limit -1
|
︙ | | |
817
818
819
820
821
822
823
824
825
826
827
828
829
830
|
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
|
+
|
incr doingLine1
incr doingLine2
incr t
if {$::diff(limitlines) && $mapMax > $::diff(limitlines)} {
return
}
}
# This should not happen unless something is wrong...
if {$doingLine2 != $line2} {
.ft1.tt insert end "**Bad alignment here!! $doingLine2 $line2**\n"
.ft2.tt insert end "**Bad alignment here!! $doingLine2 $line2**\n"
.ft1.tl insert end "\n"
.ft2.tl insert end "\n"
}
|
︙ | | |
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
|
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
|
-
|
set differr [catch {eval DiffUtil::diffFiles $Pref(ignore) \
\$diff(leftFile) \$diff(rightFile)} diffres]
} else {
set differr [catch {eval exec \$::diff(diffexe) \
$Pref(dopt) $Pref(ignore) \
\$diff(leftFile) \$diff(rightFile)} diffres]
}
set apa [split $diffres "\n"]
set result {}
foreach i $apa {
if {[string match {[0-9]*} $i]} {
lappend result $i
}
}
|
︙ | | |
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
|
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
|
-
-
-
+
+
+
+
|
}
}
}
if {$::diff(limitlines) && $::mapMax > $::diff(limitlines)} {
break
}
if {[incr t] >= 10} {
update idletasks
.ft2.tl see end
update idletasks
update idletasks
.ft2.tl see end
update idletasks
set t 0
}
bindHighlight
incr ::HighLightCount
}
dotext $ch1 $ch2 0 0 0 0
# Make sure all text widgets have the same number of lines.
# The common y scroll doesn't work well if not.
|
︙ | | |
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
|
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
|
-
+
|
# Highlight a diff and scroll windows to it.
proc showDiff {num} {
global CurrentHighLight changesList
highLightChange $num
set line1 [lindex $changesList [expr {$CurrentHighLight * 7}]]
if {$CurrentHighLight < 0} {
set line1 1.0
set line2 1.0
} elseif {$line1 == ""} {
set line1 end
set line2 end
} else {
|
︙ | | |
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
|
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
|
-
+
|
global leftMergeData rightMergeData
set w .merge.t
# Delete current string
$w delete merges$no mergee$no
set mergeSelection($no) $new
set i [expr {$no * 2 + 1}]
set diffLeft [lindex $leftMergeData $i]
set diffRight [lindex $rightMergeData $i]
if {$mergeSelection($no) == 12} {
$w insert merges$no $diffLeft$diffRight merge$no
} elseif {$mergeSelection($no) == 21} {
|
︙ | | |
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
|
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|
+
+
|
button $w.f.bl -text "All L" -command {selectMergeAll 1}
button $w.f.br -text "All R" -command {selectMergeAll 2}
button $w.f.b1 -text "Prev" -command {nextMerge -1}
button $w.f.b2 -text "Next" -command {nextMerge 1}
bind $w <Key-Down> {focus .merge ; nextMerge 1}
bind $w <Key-Up> {focus .merge ; nextMerge -1}
bind $w <Shift-Key-Down> {focus .merge ; nextMerge 10}
bind $w <Shift-Key-Up> {focus .merge ; nextMerge -10}
button $w.f.bs -text "Save" -command saveMerge
button $w.f.bq -text "Close" -command closeMerge
wm protocol $w WM_CLOSE_WINDOW closeMerge
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 x x $w.f.bs $w.f.bq
|
︙ | | |
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
|
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
|
-
+
-
+
|
# This shouldn't happen
if {$isearchW != ""} {
endIncrementalSearch
}
set isearchW $w
# Setup all bindings for incremental search
bind ISearch <Control-Key-s> "textSearch::isearchAgain %W ; break"
bind ISearch <Key-Delete> "textSearch::isearchBack %W ; break"
bind ISearch <Key-BackSpace> "textSearch::isearchBack %W ; break"
bind ISearch <Key> "textSearch::isearchKey %W %A %s %K"
bind ISearch <Key-Escape> "textSearch::endIncrementalSearch ; break"
bind ISearch <Control-Key-g> "textSearch::endIncrementalSearch ; break"
bind ISearch <FocusOut> "textSearch::endIncrementalSearch"
# Initialise variables
set ::textSearch::isearchString ""
set ::textSearch::isearchHistory {}
set ::textSearch::isearchIndex [$w index insert]
set ::textSearch::statusLabel "i"
}
|
︙ | | |
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
|
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
|
-
+
-
+
-
+
|
endIncrementalSearch
return
}
if {[llength $::textSearch::isearchHistory] < 2} {
bell
return
}
set str [lindex $::textSearch::isearchHistory end]
set found [lindex $::textSearch::isearchHistory end-1]
set ::textSearch::isearchHistory \
[lrange $::textSearch::isearchHistory 0 end-2]
isearchShow $w $found $str
}
# End an incremental search
proc textSearch::endIncrementalSearch {} {
set ::textSearch::isearchW ""
set ::textSearch::statusLabel ""
# Remove all bindings from ISearch
foreach b [bind ISearch] {
bind ISearch $b ""
}
bind ISearch <Control-Key-s> "textSearch::startIncrementalSearch %W"
}
# Dialog functions from "Practical Programming in Tcl And Tk" by Welch.
proc textSearch::DialogCreate {top title args} {
variable dialog
if {[winfo exists $top]} {
|
︙ | | |
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
|
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
|
-
+
-
+
-
+
|
wm title $top $title
return 1
}
}
proc textSearch::DialogWait {top varName {focus {}}} {
upvar $varName var
# Poke the variable if the user nukes the window
bind $top <Destroy> [list set $varName $var]
# Grab focus for the dialog
if {[string length $focus] == 0} {
set focus $top
}
set old [focus -displayof $top]
focus $focus
catch {tkwait visibility $top}
catch {grab $top}
# Wait for the dialog to complete
tkwait variable $varName
catch {grab release $top}
focus $old
}
proc textSearch::DialogDismiss {top} {
|
︙ | | |
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
|
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
|
-
+
-
+
|
# Ask for a search string
proc textSearch::FindDialog {string} {
variable prompt
set f .prompt
if {[DialogCreate $f "Find" -borderwidth 10]} {
message $f.msg -text $string -aspect 1000
entry $f.entry -textvariable ::textSearch::prompt(result)
checkbutton $f.case -text "Match Case" -anchor w\
-variable ::textSearch::searchCase
button $f.ok -text OK -width 7 \
-command {set ::textSearch::prompt(ok) 1}
button $f.cancel -text Cancel -width 7 \
-command {set ::textSearch::prompt(ok) 0}
grid $f.msg - - -sticky w
grid $f.entry - - -sticky we
|
︙ | | |
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
|
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
|
-
+
-
+
|
return
}
$searchWin see $searchPos
$searchWin tag remove sel 1.0 end
$searchWin tag add sel $searchPos "$searchPos + $cnt chars"
set searchIndex $searchPos
}
}
# Search again
proc textSearch::searchNext {} {
variable searchString
variable searchWin
variable searchCase
variable searchIndex
if {$searchString == ""} return
if {$searchCase} {
set searchPos [$searchWin search -count cnt \
$searchString "$searchIndex + 1 chars"]
} else {
set searchPos [$searchWin search -count cnt -nocase \
$searchString "$searchIndex + 1 chars"]
}
if {$searchPos == "" || $searchPos == $searchIndex} {
tk_messageBox -message "String not found!" -type ok -title Search
return
}
$searchWin see $searchPos
$searchWin tag remove sel 1.0 end
|
︙ | | |
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
|
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
|
-
+
|
set searchPos [$searchWin search -count cnt -backwards \
$searchString "$searchIndex - 1 chars"]
} else {
set searchPos [$searchWin search -count cnt -backwards \
-nocase \
$searchString "$searchIndex - 1 chars"]
}
if {$searchPos == "" || $searchPos == $searchIndex} {
tk_messageBox -message "String not found!" -type ok -title Search
return
}
$searchWin see $searchPos
$searchWin tag remove sel 1.0 end
|
︙ | | |
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
|
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
|
-
|
pack .dp.b -side bottom
pack .dp.l -side top
}
}
# Create a print dialog.
proc doPrint {{quiet 0}} {
if {![info exists ::grayLevel1]} {
set ::grayLevel1 0.6
set ::grayLevel2 0.8
}
if {$quiet} {
printDiffs 1
return
|
︙ | | |
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
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
|
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
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
2862
2863
2864
2865
2866
2867
2868
2869
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
|
pack .pr.r1 .pr.r2 .pr.r3 .pr.r4 -in .pr.f -side left -fill x -expand 1
}
#####################################
# GUI stuff
#####################################
proc hlSelect {hl} {
highLightChange $hl
}
proc hlSeparate {n hl} {
set ::diff(separate$n) $hl
if {[info exists ::diff(separate1)] && [info exists ::diff(separate2)]} {
set tag1 hl$::diff(separate1)
set tag2 hl$::diff(separate2)
set range1 [.ft1.tl tag ranges $tag1]
set range2 [.ft2.tl tag ranges $tag2]
set text1 [eval .ft1.tt get $range1]
set text2 [eval .ft2.tt get $range2]
set f1 [tmpfile]
set f2 [tmpfile]
set ch [open $f1 w]
puts $ch $text1
close $ch
set ch [open $f2 w]
puts $ch $text2
close $ch
catch {exec [info nameofexecutable] diff.tcl $f1 $f2 &}
unset ::diff(separate1)
unset ::diff(separate2)
}
}
proc hlPopup {n hl X Y} {
destroy .lpm
menu .lpm -tearoff 0
.lpm add command -label "Select" \
-command [list hlSelect $hl]
set other [expr {$n == 1 ? 2 : 1}]
if {![info exists ::diff(separate$other)]} {
set label "Mark for Separate Diff"
} else {
set label "Separate Diff"
}
.lpm add command -label $label -command [list hlSeparate $n $hl]
tk_popup .lpm $X $Y
return -code break
}
proc bindHighlight {} {
set tag hl$::HighLightCount
foreach n {1 2} {
.ft$n.tl tag bind $tag <ButtonPress-3> \
"hlPopup $n $::HighLightCount %X %Y"
.ft$n.tl tag bind $tag <ButtonPress-1> \
"hlSelect $::HighLightCount"
}
}
proc zoomRow {w X Y x y} {
global Pref
# Get the row that was clicked
set index [$w index @$x,$y]
set row [lindex [split $index "."] 0]
# Extract the data
set data1 [.ft1.tt dump -tag -text $row.0 $row.end]
set data2 [.ft2.tt dump -tag -text $row.0 $row.end]
if {[llength $data1] == 0 && [llength $data2] == 0} return
set font [.ft1.tt cget -font]
set wx $X
set wy [expr {$Y + 4}]
destroy .balloon
toplevel .balloon -bg black
wm withdraw .balloon
wm overrideredirect .balloon 1
set wid 0
foreach x {1 2} {
text .balloon.t$x -relief flat -font $font -bg #ffffaa -fg black \
-padx 2 -pady 0 -height 1 -wrap word
.balloon.t$x tag configure new1 -foreground $Pref(colornew1) \
-background $Pref(bgnew1)
.balloon.t$x tag configure change -foreground $Pref(colorchange) \
-background $Pref(bgchange)
.balloon.t$x tag configure new2 -foreground $Pref(colornew2) \
-background $Pref(bgnew2)
pack .balloon.t$x -side top -padx 1 -pady 1 -fill both -expand 1
set data [set data$x]
set tags {}
foreach {key value index} $data {
if {$key == "tagon"} {
lappend tags $value
set tags [lsort -unique $tags]
} elseif {$key == "tagoff"} {
set i [lsearch $tags $value]
if {$i >= 0} {
set tags [lreplace $tags $i $i]
}
} else {
.balloon.t$x insert end $value $tags
}
}
set text [.balloon.t$x get 1.0 1.end]
regsub -all "\t" $text " " text
.balloon.t$x configure -width [string length $text]
}
# Let geometry requests propagate
update idletasks
# Is the balloon within the diff window?
set wid [winfo reqwidth .balloon]
if {$wid + $wx > [winfo rootx .] + [winfo width .]} {
# No.
# Center on diff window
set wx [expr {([winfo width .] - $wid) / 2 + [winfo rootx .]}]
if {$wx < 0} {set wx 0}
# Is the balloon not within the screen?
if {$wx + $wid > [winfo screenwidth .]} {
# Center in screen
set wx [expr {([winfo screenwidth .] - $wid) / 2}]
if {$wx < 0} {set wx 0}
}
}
# Does the balloon fit within the screen?
if {$wid > [winfo screenwidth .]} {
# How many rows does it take?
set rows [expr {ceil(double($wid) / [winfo screenwidth .])}]
# Add rows and fill screen width
.balloon.t1 configure -height $rows
.balloon.t2 configure -height $rows
|
︙ | | |
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
|
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
|
-
+
|
.mo.mp add radiobutton -label "Words" -variable Pref(lineparsewords) \
-value "1"
.mo.mp add separator
.mo.mp add checkbutton -label "Use 2nd stage" \
-variable Pref(extralineparse)
.mo.mp add checkbutton -label "Mark last" -variable Pref(marklast)
menubutton .ms -text Search -underline 0 -menu .ms.m
menubutton .ms -text Search -underline 0 -menu .ms.m
menu .ms.m
textSearch::searchMenu .ms.m
menubutton .mh -text Help -underline 0 -menu .mh.m
menu .mh.m
.mh.m add command -label "Help" -command makeHelpWin
.mh.m add command -label "About" -command makeAboutWin
|
︙ | | |
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
|
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
|
-
+
|
label .le -textvariable ::diff(eqLabel) -width 1
label .ls -textvariable ::textSearch::statusLabel -width 1 -pady 0 -padx 0
canvas .c -width 6 -bd 0 -selectborderwidth 0 -highlightthickness 0
applyColor
.ft1.tt tag configure last -underline 1
.ft2.tt tag configure last -underline 1
foreach w {.ft1.tt .ft1.tl .ft2.tt .ft2.tl} {
foreach w {.ft1.tt .ft2.tt} {
bind $w <ButtonPress-3> "zoomRow %W %X %Y %x %y"
bind $w <ButtonRelease-3> "unzoomRow"
}
grid .l1 .le - .l2 -row 1 -sticky news
grid .ft1 .c .sby .ft2 -row 2 -sticky news
grid .sbx1 .ls - .sbx2 -row 3 -sticky news
|
︙ | | |
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
|
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
|
-
+
|
wm transient .nui .
wm geometry .nui +400+400
wm title .nui ""
label .nui.l -image nuisance
pack .nui.l
wm protocol .nui WM_DELETE_WINDOW {destroy .nui2 .nui}
update
destroy .nui2
toplevel .nui2 -bg yellow
wm transient .nui2 .nui
wm overrideredirect .nui2 1
wm title .nui2 ""
label .nui2.l -text "$str\nDo you want help?" -justify left -bg yellow
button .nui2.b -text "No, get out of my face!" -command {destroy .nui2 .nui} -bg yellow
|
︙ | | |
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
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
|
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
|
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
Mark last : Last change of a line is underlined
Colours : Choose highlight colours.
Diffs only : Only differing lines will be displayed.
Force crlf translation : (Windows only) Use crlf mode when reading files.
Save default: Save current option settings in ~/.diffrc
Diff Options Field: Any text written here will be passed to diff.
In RCS/CVS mode, any -r options will be used to select
versions.
In RCS/CVS mode, any -r options will be used internally
to select versions.
Prev Diff Button: Scrolls to the previous differing block, or to the top
if there are no more diffs.
Next Diff Button: Scrolls to the next differing block, or to the bottom
if there are no more diffs.
Equal sign: Above the vertical scrollbar, a "=" will appear if the files
are equal.
are equal. While the external diff executes a "*" is shown
and is replaced with "=" or "" before the files are displayed
to give that information early.
} "" {Bindings} ul {
Up, Down, Page Up and Page Down scrolls main windows.
Escape takes focus out of text windows.
Right mouse button "zooms" a line of text.
Ctrl-s starts incremental search. Incremental search is stopped by Escape
or Ctrl-g.
Ctrl-f brings up search dialog. F3 is "search again".
Left mouse click on the line number of a diff highlights it.
Right mouse click on the line number of a diff gives a menu where it can
be selected for separate diff. This can be used to check a block that has
been moved.
} "" {Merge Window (Appears in conflict mode)} ul {
You can, for each difference, select which version you want to appear
in the output file. The buttons "LR", "L", "R" and "RL" select the
lines from the left file, right file or both files.
"Prev" and "Next" buttons moves between differences.
"All L" and "All R" buttons select "L" or "R" for all differences.
"Pure" ...
"Save" saves the merge result to a file.
On the keyboard, Up and Down keys means the same as "Prev" and "Next".
Left and Right keys selects "L" and "R".
When saved it is the contents of the text widget that is saved which
means you can hand edit there if you are careful. E.g. you can't use
cursor keys, but you can type text, delete text and copy/paste with
mouse assistance.
} "" {Examples of effects of parse options.} ul {
Below are two example files, and five different results when using
different options with those files.
Left file: Right file:
|
︙ | | |
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
|
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
|
-
+
|
-noignore : Don't ignore any whitespace.
-b : Ignore space changes. Default.
-w : Ignore all spaces.
-conflict : Treat file as a merge conflict file and enter merge
mode.
-o <file> : Specify merge result output file.
-o <file> : Specify merge result output file.
-browse : Automatically bring up file dialog after starting.
-server : Set up diff to be controllable from the outside.
-print <file> : Generate postscript and exit.
-limit <lines> : Do not process more than <lines> lines.
|
︙ | | |
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
|
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
|
-
+
|
set diff(patchFile) $fullname
set autobrowse 0
if {$noautodiff} {
enableRedo
} else {
after idle doDiff
}
}
}
}
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set diff(leftDir) $fulldir
set diff(leftFile) $fullname
set diff(leftLabel) $fullname
|
︙ | | |
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
|
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
|
-
-
-
+
+
+
|
set Pref(dopt) ""
set Pref(parse) 2
set Pref(lineparsewords) "0"
set Pref(extralineparse) 1
set Pref(colorchange) red
set Pref(colornew1) darkgreen
set Pref(colornew2) blue
set Pref(bgchange) gray
set Pref(bgnew1) gray
set Pref(bgnew2) gray
set Pref(bgchange) #ffe0e0
set Pref(bgnew1) #a0ffa0
set Pref(bgnew2) #e0e0ff
set Pref(onlydiffs) 0
set Pref(context) 2
set Pref(crlf) 0
set Pref(marklast) 1
if {[file exists "~/.diffrc"]} {
source "~/.diffrc"
|
︙ | | |