38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
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
|
+
-
+
|
set ::argv {}
set ::argc 0
package require Tk 8.4
catch {package require textSearch}
package require pstools
namespace import -force pstools::*
package require wcb
if {[catch {package require psballoon}]} {
# Add a dummy if it does not exist.
proc addBalloon {args} {}
} else {
namespace import -force psballoon::addBalloon
}
set debug 0
set diffver "Version 2.0.5 2004-08-20"
set diffver "Version 2.0.5+ 2004-09-06"
set thisScript [file join [pwd] [info script]]
set thisDir [file dirname $thisScript]
# Follow any link
set tmplink $thisScript
while {[file type $tmplink] eq "link"} {
set tmplink [file readlink $tmplink]
|
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
|
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
|
+
+
+
+
|
for {set t 0} {$t < $d} {incr t} {
$w insert end \n padding
}
}
close $ch1
close $ch2
# We can turn off editing in the text windows after everything
# is displayed.
noEdit $top
# Mark aligned lines
if {[info exists ::diff($top,aligns)] && \
[llength $::diff($top,aligns)] > 0} {
foreach {align1 align2} $::diff($top,aligns) {
set i [$::widgets($top,wLine1) search -regexp "\\m$align1\\M" 1.0]
if {$i != ""} {
|
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
|
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
|
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
+
|
# Clear Editing state
proc resetEdit {top} {
set ::diff($top,leftEdit) 0
set ::diff($top,rightEdit) 0
$top.mt.m entryconfigure "Edit Mode" -state normal
$::widgets($top,wDiff1) tag configure padding -background {}
$::widgets($top,wDiff2) tag configure padding -background {}
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 ::diff($w,allowChange) all
$::widgets($top,wDiff1) edit reset
$::widgets($top,wDiff1) configure -undo 0
$::widgets($top,wDiff2) edit reset
$::widgets($top,wDiff2) configure -undo 0
}
# Turn on editing on sides where it has not bew disallowed
wcb::callback $w before insert {}
wcb::callback $w before delete {}
}
# Do not allow any editing
proc noEdit {top} {
noEditW $::widgets($top,wDiff1)
noEditW $::widgets($top,wDiff2)
}
# Do not allow any editing in a Text widget
proc noEditW {w} {
set ::diff($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 {$::diff($w,allowChange) eq "none"} {
wcb::cancel
return
}
if {$::diff($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 {$::diff($w,allowChange) eq "none"} {
wcb::cancel
return
}
if {$::diff($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 ::diff($w,allowChange) line
}
# Turn on editing on sides where it has not been disallowed
proc allowEdit {top} {
$top.mt.m entryconfigure "Edit Mode" -state disable
if {$::diff($top,leftEdit) == 0} {
set ::diff($top,leftEdit) 1
$::widgets($top,wDiff1) tag configure padding -background \#f0f0f0
$::widgets($top,wDiff1) configure -undo 1
turnOnEdit $::widgets($top,wDiff1)
}
if {$::diff($top,rightEdit) == 0} {
set ::diff($top,rightEdit) 1
$::widgets($top,wDiff2) tag configure padding -background \#f0f0f0
$::widgets($top,wDiff2) configure -undo 1
turnOnEdit $::widgets($top,wDiff2)
}
}
# Turn off editing on sides that do not correspond to a file
proc disallowEdit {top {side 0}} {
if {$side == 0 || $side == 1} {
set ::diff($top,leftEdit) -1
|
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
|
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
|
+
+
+
+
|
}
}
# 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 ::diff($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 ::diff($w,allowChange) line
}
}
# Copy a block
proc copyBlock {top from first last} {
set to [expr {3 - $from}]
set wfrom $::widgets($top,wDiff$from)
set wto $::widgets($top,wDiff$to)
set tags ""
|