summaryrefslogtreecommitdiffstats
path: root/library/entry.tcl
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-26 20:41:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-26 20:41:13 (GMT)
commit970a72bb92857f54d7fedccfad37d2a5b03c5e4f (patch)
treecf845f4252d36e975176a628758536c365a86931 /library/entry.tcl
parentb24734f447464d9b41cb0aaaf478615872427a8e (diff)
downloadtk-970a72bb92857f54d7fedccfad37d2a5b03c5e4f.zip
tk-970a72bb92857f54d7fedccfad37d2a5b03c5e4f.tar.gz
tk-970a72bb92857f54d7fedccfad37d2a5b03c5e4f.tar.bz2
A different approach to glyph indexing
Diffstat (limited to 'library/entry.tcl')
-rw-r--r--library/entry.tcl26
1 files changed, 21 insertions, 5 deletions
diff --git a/library/entry.tcl b/library/entry.tcl
index 02384da..a750b34 100644
--- a/library/entry.tcl
+++ b/library/entry.tcl
@@ -119,17 +119,17 @@ bind Entry <Control-Button-1> {
}
bind Entry <<PrevChar>> {
- tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
+ tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert]
}
bind Entry <<NextChar>> {
- tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
+ tk::EntrySetCursor %W [tk::EntryNextChar %W insert]
}
bind Entry <<SelectPrevChar>> {
- tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
+ tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert]
tk::EntrySeeInsert %W
}
bind Entry <<SelectNextChar>> {
- tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
+ tk::EntryKeySelect %W [tk::EntryNextChar %W insert]
tk::EntrySeeInsert %W
}
bind Entry <<PrevWord>> {
@@ -518,7 +518,7 @@ proc ::tk::EntryBackspace w {
if {[$w selection present]} {
$w delete sel.first sel.last
} else {
- set x [expr {[$w index insert] - 1}]
+ set x [tcl_startOfChar [$w get] [$w index insert]]
if {$x >= 0} {
$w delete $x
}
@@ -634,6 +634,22 @@ proc ::tk::EntryPreviousWord {w start} {
return $pos
}
+proc ::tk::EntryNextChar {w start} {
+ set pos [tcl_endOfChar [$w get] [expr {[$w index $start]+1}]]
+ if {$pos < 0} {
+ return end
+ }
+ return $pos
+}
+
+proc ::tk::EntryPreviousChar {w start} {
+ set pos [tcl_startOfChar [$w get] [expr {[$w index $start]-1}]]
+ if {$pos < 0} {
+ return 0
+ }
+ return $pos
+}
+
# ::tk::EntryScanMark --
#
# Marks the start of a possible scan drag operation