2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
|
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
|
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
# Called by popup menus over row numbers to add commands for editing.
# Returns 1 if nothing was added.
proc editMenu {mW top side changeIndex x y} {
if { ! [mayEdit $top $side]} {return 1}
# Only copy when in a change block
if {$changeIndex ne ""} {
set other [expr {$side == 1 ? 2 : 1}]
set editOther [mayEdit $top $other]
set W $::widgets($top,wLine$side)
set oW $::widgets($top,wLine$other)
set other [expr {$side == 1 ? 2 : 1}]
set editOther [mayEdit $top $other]
set dW $::widgets($top,wDiff$side)
set lW $::widgets($top,wLine$side)
set oW $::widgets($top,wLine$other)
set changed 1
if {$changeIndex eq "_"} {
# The popup is on unchanged line numbers
set changed 0
# Get the row that was clicked
set index [$W index @$x,$y]
set index [$lW 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+} [$oW get $row.0 $row.end]]
# Row copy
if {$lineo ne ""} {
$mW add command -label "Copy Row from other side" \
-command [list copyRow $top $other $row]
} else {
# Range is that row
set range [list $row.0 $row.end]
set rangeo [list $row.0 $row.end]
} elseif {$changeIndex eq ""} {
# The popup is on selected text.
# Get the row that was clicked
set index [$dW index @$x,$y]
set row [lindex [split $index "."] 0]
# Figure out the rows involved in the selection.
set range [$dW tag ranges sel]
set from [lindex $range 0]
set to [lindex $range 1]
lassign [split $from "."] froml fromi
lassign [split $to "."] tol toi
if {$toi == 0} {incr tol -1}
set range [list $froml.0 $tol.end]
set rangeo [list $froml.0 $tol.end]
} else {
$mW add command -label "Delete Row" \
-command [list deleteBlock $top $side $row]
}
if {$line ne "" && $editOther} {
$mW add command -label "Copy Row to other side" \
# The popup is on a change block in line numbers
# Get the row that was clicked
-command [list copyRow $top $side $row]
}
set index [$lW index @$x,$y]
set row [lindex [split $index "."] 0]
# Get ranges for the change block
set range [$W tag ranges hl$changeIndex]
set range [$lW tag ranges hl$changeIndex]
set rangeo [$oW tag ranges hl$changeIndex]
}
set line [regexp -inline {\d+} [$lW get $row.0 $row.end]]
set lineo [regexp -inline {\d+} [$oW get $row.0 $row.end]]
# Row copy
if {$lineo ne ""} {
$mW add command -label "Copy Row from other side" \
-command [list copyRow $top $other $row]
}
$mW add command -label "Delete Row" \
-command [list deleteBlock $top $side $row]
if {$line ne "" && $editOther && $changed} {
$mW add command -label "Copy Row to other side" \
-command [list copyRow $top $side $row]
}
if {$changed} {
# Get the lines involved in the block
lassign [getLinesFromRange $W $range ] from to froml tol
lassign [getLinesFromRange $lW $range ] from to froml tol
lassign [getLinesFromRange $oW $rangeo] fromo too fromlo tolo
# More than one line in the block?
set thisSize 0
set otherSize 0
if {$froml ne "" && $tol ne ""} {
set thisSize [expr {$tol - $froml + 1}]
|
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
|
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
|
+
+
|
cloneDiff $top [concat $::eskil($top,separatelines1) \
$::eskil($top,separatelines2)]
unset ::eskil($top,separate1)
unset ::eskil($top,separate2)
}
}
# No changeIndex means that the popup is over selected text rather than
# line numbers.
proc hlPopup {top side changeIndex X Y x y} {
if {[info exists ::eskil($top,nopopup)] && $::eskil($top,nopopup)} return
destroy .lpm
menu .lpm
if { ! [editMenu .lpm $top $side $changeIndex $x $y]} {
.lpm add separator
|
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
|
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
|
-
+
|
proc rowPopup {W X Y x y} {
set top [winfo toplevel $W]
if {[info exists ::eskil($top,nopopup)] && $::eskil($top,nopopup)} return
destroy .lpm
menu .lpm
regexp {(\d+)\D*$} $W -> side
set tmp1 [editMenu .lpm $top $side "" $x $y]
set tmp1 [editMenu .lpm $top $side "_" $x $y]
if { ! $tmp1} {.lpm add separator}
set tmp2 [alignMenu .lpm $top $side $x $y]
if {$tmp1 && $tmp2} {
# Nothing in the menu
return
}
if { ! $tmp1 && $tmp2} {.lpm delete last}
|