︙ | | |
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
$::widgets($top,wLine1) insert end "\n" hl$::HighLightCount
$::widgets($top,wLine2) insert end "\n" hl$::HighLightCount
return [expr {($n1 > $n2 ? $n1 : $n2) + 1}]
} else {
return [expr {-($n1 > $n2 ? $n1 : $n2)}]
}
}
# Insert two blocks of lines in the compare windows.
# No extra parsing at all.
proc insertMatchingBlocksNoParse {top block1 block2 line1 line2 details} {
global doingLine1 doingLine2
set n1 [llength $block1]
set n2 [llength $block2]
# Is this a change block, a delete block or an insert block?
if {$n1 == 0} {set tag2 new2} else {set tag2 change}
if {$n2 == 0} {set tag1 new1} else {set tag1 change}
foreach line $block1 {
insertLine $top 1 $doingLine1 $line $tag1
incr doingLine1
}
foreach line $block2 {
insertLine $top 2 $doingLine2 $line $tag2
incr doingLine2
}
if {$n1 <= $n2} {
for {set t $n1} {$t < $n2} {incr t} {
emptyLine $top 1
}
addChange $top $n2 $tag2 $line1 $n1 $line2 $n2
nextHighlight $top
} elseif {$n2 < $n1} {
for {set t $n2} {$t < $n1} {incr t} {
emptyLine $top 2
}
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
# A large block may take time. Give a small warning.
set n1 [llength $block1]
|
︙ | | |
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
|
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
|
-
+
|
incr doingLine1
incr t
if {$limit >= 0 && $t >= $limit} break
}
return
}
# Is this a change block, a delete block or a insert block?
# Is this a change block, a delete block or an 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
|
︙ | | |
730
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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
|
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
|
if {$::eskil(filter) != "" && $::eskil(filterflag)} {
addMapLines $top $n1
} else {
addChange $top $n1 change $line1 $n1 $line2 $n2
nextHighlight $top
}
} else {
# Collect blocks
set block1 {}
for {set t 0} {$t < $n1} {incr t} {
gets $ch1 apa
lappend block1 $apa
}
set block2 {}
for {set t 0} {$t < $n2} {incr t} {
gets $ch2 apa
lappend block2 $apa
}
if {$n1 != 0 && $n2 != 0 && $Pref(parse) >= 2 && \
($n1 * $n2 < 1000 || $Pref(parse) == 3)} {
# Full block parsing
set block1 {}
for {set t 0} {$t < $n1} {incr t} {
gets $ch1 apa
lappend block1 $apa
}
set block2 {}
for {set t 0} {$t < $n2} {incr t} {
gets $ch2 apa
lappend block2 $apa
}
insertMatchingBlocks $top $block1 $block2 $line1 $line2 1
} else {
# No extra parsing at all.
for {set t 0} {$t < $n1} {incr t} {
gets $ch1 apa
insertLine $top 1 $doingLine1 $apa $tag1
incr doingLine1
}
for {set t 0} {$t < $n2} {incr t} {
gets $ch2 apa
insertLine $top 2 $doingLine2 $apa $tag2
incr doingLine2
}
if {$n1 <= $n2} {
for {set t $n1} {$t < $n2} {incr t} {
emptyLine $top 1
}
addChange $top $n2 $tag2 $line1 $n1 $line2 $n2
insertMatchingBlocksNoParse $top $block1 $block2 $line1 $line2 1
nextHighlight $top
} elseif {$n2 < $n1} {
for {set t $n2} {$t < $n1} {incr t} {
emptyLine $top 2
}
addChange $top $n1 $tag1 $line1 $n1 $line2 $n2
nextHighlight $top
}
}
}
# Empty return value
return
}
proc enableRedo {top} {
|
︙ | | |
978
979
980
981
982
983
984
985
986
987
988
989
990
991
|
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
|
+
+
+
+
+
|
}
continue
}
# No change block anymore. If one just ended, display it.
if {[llength $lblock] > 0 || [llength $rblock] > 0} {
set ::doingLine1 $lblockl
set ::doingLine2 $rblockl
# TODO: large/small block support
#set Pref(parse) 2
#if {$n1 != 0 && $n2 != 0 && $Pref(parse) >= 2 && \
# ($n1 * $n2 < 1000 || $Pref(parse) == 3)} {
# }
insertMatchingBlocks $top $lblock $rblock $lblockl $rblockl 0
set lblock {}
set rblock {}
}
if {$lmode == "" && $rmode == ""} {
insertLine $top 1 $lline $lstr
insertLine $top 2 $rline $rstr
|
︙ | | |
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
|
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
|
+
|
continue
}
}
# If the patch ended with a change block, display it.
if {[llength $lblock] > 0 || [llength $rblock] > 0} {
set ::doingLine1 $lblockl
set ::doingLine2 $rblockl
# TODO: large/small block support
insertMatchingBlocks $top $lblock $rblock $lblockl $rblockl 0
set lblock {}
set rblock {}
}
}
# Read a patch file and display it
|
︙ | | |