diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-28 13:26:57 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-28 13:26:57 (GMT) |
commit | a49d6e52a72b1f086503ae32cb28b0da62e5fa99 (patch) | |
tree | 0f285068f70fcc13245f17b6bdafea1facf33d40 | |
parent | 53c3528bef55541b6033d2c2e77ba804a0a80141 (diff) | |
download | tk-a49d6e52a72b1f086503ae32cb28b0da62e5fa99.zip tk-a49d6e52a72b1f086503ae32cb28b0da62e5fa99.tar.gz tk-a49d6e52a72b1f086503ae32cb28b0da62e5fa99.tar.bz2 |
Slight definition change in ::tk::endOfGlyphCluster. It now returns the index _after_ the boundary not the one before. Also, the spinbox is now fully working.
-rw-r--r-- | library/entry.tcl | 8 | ||||
-rw-r--r-- | library/spinbox.tcl | 14 | ||||
-rw-r--r-- | library/text.tcl | 6 | ||||
-rw-r--r-- | library/tk.tcl | 1 | ||||
-rw-r--r-- | library/ttk/entry.tcl | 6 |
5 files changed, 18 insertions, 17 deletions
diff --git a/library/entry.tcl b/library/entry.tcl index 85127fa..7a5ef2b 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -165,7 +165,7 @@ bind Entry <Delete> { if {[%W selection present]} { %W delete sel.first sel.last } else { - %W delete [::tk::startOfGlyphCluster [%W get] [%W index insert]]] [expr {[::tk::endOfGlyphCluster [%W get] [%W index insert]]+1}]] + %W delete [::tk::startOfGlyphCluster [%W get] [%W index insert]] [::tk::endOfGlyphCluster [%W get] [%W index insert]] } } bind Entry <BackSpace> { @@ -520,7 +520,7 @@ proc ::tk::EntryBackspace w { } else { set x [expr {[$w index insert] - 1}] if {$x >= 0} { - $w delete [::tk::startOfGlyphCluster [$w get] $x] [expr {[::tk::endOfGlyphCluster [$w get] $x]+1}] + $w delete [::tk::startOfGlyphCluster [$w get] $x] [::tk::endOfGlyphCluster [$w get] $x] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] @@ -635,7 +635,7 @@ proc ::tk::EntryPreviousWord {w start} { } proc ::tk::EntryNextChar {w start} { - set pos [::tk::endOfGlyphCluster [$w get] [expr {[$w index $start]+1}]] + set pos [::tk::endOfGlyphCluster [$w get] [$w index $start]] if {$pos < 0} { return end } @@ -651,7 +651,7 @@ proc ::tk::EntryPreviousChar {w start} { } proc ::tk::EntryInsertChar {w start} { - set pos [::tk::endOfGlyphCluster [$w get] [expr {[$w index $start]+1}]] + set pos [::tk::endOfGlyphCluster [$w get] [$w index $start]] if {$pos < 0} { return end } diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 909405e..15330e9 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -129,18 +129,18 @@ bind Spinbox <<NextLine>> { } bind Spinbox <<PrevChar>> { - ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert] } bind Spinbox <<NextChar>> { - ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [tk::EntryNextChar %W insert] } bind Spinbox <<SelectPrevChar>> { - ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}] - ::tk::EntrySeeInsert %W + tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert] + tk::EntrySeeInsert %W } bind Spinbox <<SelectNextChar>> { - ::tk::EntryKeySelect %W [expr {[%W index insert] + 1}] - ::tk::EntrySeeInsert %W + tk::EntryKeySelect %W [tk::EntryNextChar %W insert] + tk::EntrySeeInsert %W } bind Spinbox <<PrevWord>> { ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert] @@ -175,7 +175,7 @@ bind Spinbox <Delete> { if {[%W selection present]} { %W delete sel.first sel.last } else { - %W delete insert + %W delete [::tk::startOfGlyphCluster [%W get] [%W index insert]] [::tk::endOfGlyphCluster [%W get] [%W index insert]] } } bind Spinbox <BackSpace> { diff --git a/library/text.tcl b/library/text.tcl index 9fb9a79..1c84b40 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -102,7 +102,7 @@ bind Text <<PrevChar>> { tk::TextSetCursor %W [tk::TextPrevPos %W insert ::tk::startOfGlyphCluster] } bind Text <<NextChar>> { - tk::TextSetCursor %W [tk::TextNextPos %W insert+1c ::tk::endOfGlyphCluster] + tk::TextSetCursor %W [tk::TextNextPos %W insert ::tk::endOfGlyphCluster] } bind Text <<PrevLine>> { tk::TextSetCursor %W [tk::TextUpDownLine %W -1] @@ -222,7 +222,7 @@ bind Text <Delete> { %W delete sel.first sel.last } else { if {[%W compare end != insert+1c]} { - %W delete [tk::TextPrevPos %W insert+1c ::tk::startOfGlyphCluster] "[tk::TextNextPos %W insert ::tk::endOfGlyphCluster]+1c" + %W delete [tk::TextPrevPos %W insert+1c ::tk::startOfGlyphCluster] [tk::TextNextPos %W insert ::tk::endOfGlyphCluster] } %W see insert } @@ -232,7 +232,7 @@ bind Text <BackSpace> { %W delete sel.first sel.last } else { if {[%W compare insert != 1.0]} { - %W delete [tk::TextPrevPos %W insert ::tk::startOfGlyphCluster] "[tk::TextNextPos %W insert-1c ::tk::endOfGlyphCluster]+1c" + %W delete [tk::TextPrevPos %W insert ::tk::startOfGlyphCluster] [tk::TextNextPos %W insert-1c ::tk::endOfGlyphCluster] } %W see insert } diff --git a/library/tk.tcl b/library/tk.tcl index 3b358ca..66b8a87 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -701,6 +701,7 @@ proc ::tk::endOfGlyphCluster {str start} { if {[string length [string index $str $start]] > 1} { set start [expr {$start+1}] } + set start [expr {$start+1}] if {[string index $str $start] eq {^}} { set start [expr {$start+1}];# For demo purposes only } diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 44a190d..6723833 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -278,7 +278,7 @@ proc ttk::entry::PrevWord {w start} { # proc ttk::entry::NextChar {w start} { variable State - set pos [::tk::endOfGlyphCluster [$w get] [expr {[$w index $start]+1}]] + set pos [::tk::endOfGlyphCluster [$w get] [$w index $start]] if {$pos < 0} { return end } @@ -631,7 +631,7 @@ proc ttk::entry::Backspace {w} { set x [expr {[$w index insert] - 1}] if {$x < 0} { return } - $w delete [::tk::startOfGlyphCluster [$w get] $x] [expr {[::tk::endOfGlyphCluster [$w get] $x]+1}] + $w delete [::tk::startOfGlyphCluster [$w get] $x] [::tk::endOfGlyphCluster [$w get] $x] if {[$w index @0] >= [$w index insert]} { set range [$w xview] @@ -646,7 +646,7 @@ proc ttk::entry::Backspace {w} { # proc ttk::entry::Delete {w} { if {![PendingDelete $w]} { - $w delete [::tk::startOfGlyphCluster [$w get] [$w index insert]] [expr {[::tk::endOfGlyphCluster [$w get] [$w index insert]]+1}] + $w delete [::tk::startOfGlyphCluster [$w get] [$w index insert]] [::tk::endOfGlyphCluster [$w get] [$w index insert]] } } |