︙ | | |
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
-
+
|
# 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.4+ 2004-08-17"
set diffver "Version 2.0.4+ 2004-08-18"
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]
|
︙ | | |
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
|
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
|
+
+
+
+
+
+
+
|
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 {}
$::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
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
}
if {$::diff($top,rightEdit) == 0} {
set ::diff($top,rightEdit) 1
$::widgets($top,wDiff2) tag configure padding -background \#f0f0f0
$::widgets($top,wDiff2) configure -undo 1
}
}
# 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
|
︙ | | |
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
proc mayEdit {top side} {
if {$side == 1} {
return [expr {$::diff($top,leftEdit) == 1}]
} else {
return [expr {$::diff($top,rightEdit) == 1}]
}
}
# Start an undo block in a bunch of text widgets
proc startUndoBlock {args} {
foreach w $args {
$w configure -autoseparators 0
}
}
# End an undo block in a bunch of text widgets
proc endUndoBlock {args} {
foreach w $args {
$w configure -autoseparators 1
$w edit separator
}
}
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 ""
set dump [$wfrom dump -all $first.0 $last.end+1c]
startUndoBlock $wfrom $wto
$wfrom delete $first.0 $last.end+1c
$wto delete $first.0 $last.end+1c
foreach {key value index} $dump {
switch -- $key {
text {
|
︙ | | |
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
|
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
|
-
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
tagoff {
if {$value eq "padding"} {
set tags 0
}
}
}
}
endUndoBlock $wfrom $wto
}
# Copy a row between text widgets
proc copyRow {top from row} {
set to [expr {3 - $from}]
set wfrom $::widgets($top,wDiff$from)
set wto $::widgets($top,wDiff$to)
set text [$wfrom get $row.0 $row.end+1c]
startUndoBlock $wfrom $wto
$wto delete $row.0 $row.end+1c
$wto insert $row.0 $text ""
# Rewrite the source row to remove any tags
$wfrom delete $row.0 $row.end+1c
$wfrom insert $row.0 $text ""
}
endUndoBlock $wfrom $wto
}
# Delete a row filling it with padding
proc deleteBlock {top side from {to {}}} {
set w $::widgets($top,wDiff$side)
if {$to eq ""} {set to $from}
startUndoBlock $w
$w delete $from.0 $to.end+1c
$w insert $from.0 [string repeat \n [expr {$to - $from + 1}]] padding
endUndoBlock $w
}
# Get the lines involved in the display
proc getLinesFromRange {w range} {
set from [lindex $range 0]
set to [lindex $range 1]
foreach {fromr fromi} [split $from "."] break
foreach {tor toi} [split $to "."] break
|
︙ | | |
1836
1837
1838
1839
1840
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
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
|
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
|
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
proc editMenu {m top n hl x y} {
if {![mayEdit $top $n]} {return 1}
# Only copy when in a change block
if {$hl ne ""} {
set o [expr {3 - $n}]
set editOther [mayEdit $top $o]
set w $::widgets($top,wLine$n)
set wo $::widgets($top,wLine$o)
# Get the row that was clicked
set index [$w index @$x,$y]
set row [lindex [split $index "."] 0]
set line [regexp -inline {\d+} [$w get $row.0 $row.end]]
set lineo [regexp -inline {\d+} [$wo get $row.0 $row.end]]
# Row copy
if {$lineo ne ""} {
$m add command -label "Copy Row from other side" \
-command [list copyRow $top $o $row]
} else {
$m add command -label "Delete Row" \
-command [list deleteBlock $top $n $row]
}
if {$line ne ""} {
if {$line ne "" && $editOther} {
$m add command -label "Copy Row to other side" \
-command [list copyRow $top $n $row]
}
# Get ranges for the change block
set range [$w tag ranges hl$hl]
set rangeo [$wo tag ranges hl$hl]
# Get the lines involved in the block
foreach {from to froml tol} [getLinesFromRange $w $range ] break
foreach {fromo too fromlo tolo} [getLinesFromRange $wo $rangeo] break
# More than one line in the block?
set thisSize 0
set otherSize 0
if {($froml ne "" && $tol ne "" && $froml < $tol) ||
($fromlo ne "" && $tolo ne "" && $fromlo < $tolo)} {
$m add command -label "Copy Block to other side" \
-command [list copyBlock $top $n $from $to]
$m add command -label "Copy Block from other side" \
-command [list copyBlock $top $o $fromo $too]
if {$froml ne "" && $tol ne ""} {
set thisSize [expr {$tol - $froml + 1}]
}
if {$fromlo ne "" && $tolo ne ""} {
set otherSize [expr {$tolo - $fromlo + 1}]
}
if {$thisSize > 1 || $otherSize > 1} {
if {$otherSize > 0} {
$m add command -label "Copy Block from other side" \
-command [list copyBlock $top $o $fromo $too]
} else {
$m add command -label "Delete Block" \
-command [list deleteBlock $top $n $from $to]
}
if {$editOther && $thisSize > 0} {
$m add command -label "Copy Block to other side" \
-command [list copyBlock $top $n $from $to]
}
}
}
$m add command -label "Save File" -command [list saveFile $top $n]
return 0
}
|
︙ | | |
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
|
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
|
-
+
+
+
|
}
proc hlPopup {top n hl X Y x y} {
if {[info exists ::diff($top,nopopup)] && $::diff($top,nopopup)} return
destroy .lpm
menu .lpm
editMenu .lpm $top $n $hl $x $y
if {![editMenu .lpm $top $n $hl $x $y]} {
.lpm add separator
}
if {$hl != ""} {
.lpm add command -label "Select" \
-command [list hlSelect $top $hl]
}
set other [expr {$n == 1 ? 2 : 1}]
|
︙ | | |
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
|
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
|
+
+
-
+
+
+
+
|
proc rowPopup {w X Y x y} {
set top [winfo toplevel $w]
if {[info exists ::diff($top,nopopup)] && $::diff($top,nopopup)} return
destroy .lpm
menu .lpm
regexp {(\d+)\D*$} $w -> n
set tmp1 [editMenu .lpm $top $n "" $x $y]
if {!$tmp1} {.lpm add separator}
if {[editMenu .lpm $top $n "" $x $y] && [alignMenu .lpm $top $n $x $y]} {
set tmp2 [alignMenu .lpm $top $n $x $y]
if {$tmp1 && $tmp2} {
# Nothing in the menu
return
}
if {!$tmp1 && $tmp2} {.lpm delete last}
set ::diff($top,nopopup) 1
tk_popup .lpm $X $Y
after idle [list after 1 [list set ::diff($top,nopopup) 0]]
}
proc bindHighlight {top} {
|
︙ | | |