summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2015-10-09 19:06:03 (GMT)
committerfvogel <fvogelnew1@free.fr>2015-10-09 19:06:03 (GMT)
commit1ae4153f65c8bb705a1216a65bc06ab63b3458e6 (patch)
treed00d43765d61579e55615b94c75105a771381936 /library
parent83fb4913058e62e5032695b3a8cd1ad14c7398c6 (diff)
parent8b801ee48d016fb44dee5bcc272a19b43d180d6c (diff)
downloadtk-1ae4153f65c8bb705a1216a65bc06ab63b3458e6.zip
tk-1ae4153f65c8bb705a1216a65bc06ab63b3458e6.tar.gz
tk-1ae4153f65c8bb705a1216a65bc06ab63b3458e6.tar.bz2
Fixed bug [1669632fff] - text widget: autoseparator placement, <Control-1> cleanup
Diffstat (limited to 'library')
-rw-r--r--library/text.tcl40
1 files changed, 40 insertions, 0 deletions
diff --git a/library/text.tcl b/library/text.tcl
index 18fed2c..2bf1b2b 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -85,7 +85,16 @@ bind Text <ButtonRelease-1> {
}
bind Text <Control-1> {
%W mark set insert @%x,%y
+ # An operation that moves the insert mark without making it
+ # one end of the selection must insert an autoseparator
+ if {[%W cget -autoseparators]} {
+ %W edit separator
+ }
}
+# stop an accidental double click triggering <Double-Button-1>
+bind Text <Double-Control-1> { # nothing }
+# stop an accidental movement triggering <B1-Motion>
+bind Text <Control-B1-Motion> { # nothing }
bind Text <<PrevChar>> {
tk::TextSetCursor %W insert-1displayindices
}
@@ -245,6 +254,11 @@ bind Text <<SelectAll>> {
}
bind Text <<SelectNone>> {
%W tag remove sel 1.0 end
+ # An operation that clears the selection must insert an autoseparator,
+ # because the selection operation may have moved the insert mark
+ if {[%W cget -autoseparators]} {
+ %W edit separator
+ }
}
bind Text <<Cut>> {
tk_textCut %W
@@ -256,7 +270,15 @@ bind Text <<Paste>> {
tk_textPaste %W
}
bind Text <<Clear>> {
+ # Make <<Clear>> an atomic operation on the Undo stack,
+ # i.e. separate it from other delete operations on either side
+ if {[%W cget -autoseparators]} {
+ %W edit separator
+ }
catch {%W delete sel.first sel.last}
+ if {[%W cget -autoseparators]} {
+ %W edit separator
+ }
}
bind Text <<PasteSelection>> {
if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)]
@@ -314,7 +336,16 @@ bind Text <Control-t> {
}
bind Text <<Undo>> {
+ # An Undo operation may remove the separator at the top of the Undo stack.
+ # Then the item at the top of the stack gets merged with the subsequent changes.
+ # Place separators before and after Undo to prevent this.
+ if {[%W cget -autoseparators]} {
+ %W edit separator
+ }
catch { %W edit undo }
+ if {[%W cget -autoseparators]} {
+ %W edit separator
+ }
}
bind Text <<Redo>> {
@@ -1021,9 +1052,18 @@ proc ::tk_textCopy w {
proc ::tk_textCut w {
if {![catch {set data [$w get sel.first sel.last]}]} {
+ # make <<Cut>> an atomic operation on the Undo stack,
+ # i.e. separate it from other delete operations on either side
+ set oldSeparator [$w cget -autoseparators]
+ if {$oldSeparator} {
+ $w edit separator
+ }
clipboard clear -displayof $w
clipboard append -displayof $w $data
$w delete sel.first sel.last
+ if {$oldSeparator} {
+ $w edit separator
+ }
}
}