summaryrefslogtreecommitdiffstats
path: root/library/tk.tcl
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-03-30 08:32:35 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-03-30 08:32:35 (GMT)
commitce86b59a3171bcce43aaeb65728730cc72200ed8 (patch)
treebc6da8787e6666abe4e95e3a6a6b14fb33f2ec63 /library/tk.tcl
parent3c3e58351a1441181863aa015487e10307e5d6de (diff)
downloadtk-ce86b59a3171bcce43aaeb65728730cc72200ed8.zip
tk-ce86b59a3171bcce43aaeb65728730cc72200ed8.tar.gz
tk-ce86b59a3171bcce43aaeb65728730cc72200ed8.tar.bz2
Teach wrapper functions like ::tk::endOfCluster how to handle "end-1"
Diffstat (limited to 'library/tk.tcl')
-rw-r--r--library/tk.tcl27
1 files changed, 24 insertions, 3 deletions
diff --git a/library/tk.tcl b/library/tk.tcl
index 5edafc2..b28cf12 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -703,6 +703,9 @@ if {[tk windowingsystem] eq "aqua"} {
if {[info commands ::tk::endOfWord] eq ""} {
proc ::tk::endOfWord {str start {locale {}}} {
+ if {$start < 0} {
+ set start -1
+ }
set start [tcl_endOfWord $str $start]
if {$start < 0} {
set start ""
@@ -712,6 +715,11 @@ if {[info commands ::tk::endOfWord] eq ""} {
}
if {[info commands ::tk::startOfNextWord] eq ""} {
proc ::tk::startOfNextWord {str start {locale {}}} {
+ if {$start < 0} {
+ set start -1
+ } elseif {[string match end-* $start]} {
+ set start [expr {[string length $str]-1-[string range $start 4 end]}]
+ }
set start [tcl_startOfNextWord $str $start]
if {$start < 0} {
set start ""
@@ -721,6 +729,11 @@ if {[info commands ::tk::startOfNextWord] eq ""} {
}
if {[info commands ::tk::startOfPreviousWord] eq ""} {
proc ::tk::startOfPreviousWord {str start {locale {}}} {
+ if {$start < 0} {
+ set start -1
+ } elseif {[string match end-* $start]} {
+ set start [expr {[string length $str]-1-[string range $start 4 end]}]
+ }
set start [tcl_startOfPreviousWord $str $start]
if {$start < 0} {
set start ""
@@ -730,8 +743,12 @@ if {[info commands ::tk::startOfPreviousWord] eq ""} {
}
if {[info commands ::tk::endOfCluster] eq ""} {
proc ::tk::endOfCluster {str start {locale {}}} {
- if {$start eq "end"} {
- return [string length $str]
+ if {$start < 0} {
+ set start -1
+ } elseif {$start eq "end"} {
+ set start [expr {[string length $str]-1}]
+ } elseif {[string match end-* $start]} {
+ set start [expr {[string length $str]-1-[string range $start 4 end]}]
} elseif {$start >= [string length $str]} {
return ""
}
@@ -744,8 +761,12 @@ if {[info commands ::tk::endOfCluster] eq ""} {
}
if {[info commands ::tk::startOfCluster] eq ""} {
proc ::tk::startOfCluster {str start {locale {}}} {
- if {$start eq "end"} {
+ if {$start < 0} {
+ set start -1
+ } elseif {$start eq "end"} {
set start [expr {[string length $str]-1}]
+ } elseif {[string match end-* $start]} {
+ set start [expr {[string length $str]-1-[string range $start 4 end]}]
} elseif {$start >= [string length $str]} {
return [string length $str]
}