From a49d6e52a72b1f086503ae32cb28b0da62e5fa99 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 28 May 2020 13:26:57 +0000 Subject: 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. --- library/entry.tcl | 8 ++++---- library/spinbox.tcl | 14 +++++++------- library/text.tcl | 6 +++--- library/tk.tcl | 1 + 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 { 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 { @@ -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 <> { } bind Spinbox <> { - ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert] } bind Spinbox <> { - ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [tk::EntryNextChar %W insert] } bind Spinbox <> { - ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}] - ::tk::EntrySeeInsert %W + tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert] + tk::EntrySeeInsert %W } bind Spinbox <> { - ::tk::EntryKeySelect %W [expr {[%W index insert] + 1}] - ::tk::EntrySeeInsert %W + tk::EntryKeySelect %W [tk::EntryNextChar %W insert] + tk::EntrySeeInsert %W } bind Spinbox <> { ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert] @@ -175,7 +175,7 @@ bind Spinbox { 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 { 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 <> { tk::TextSetCursor %W [tk::TextPrevPos %W insert ::tk::startOfGlyphCluster] } bind Text <> { - tk::TextSetCursor %W [tk::TextNextPos %W insert+1c ::tk::endOfGlyphCluster] + tk::TextSetCursor %W [tk::TextNextPos %W insert ::tk::endOfGlyphCluster] } bind Text <> { tk::TextSetCursor %W [tk::TextUpDownLine %W -1] @@ -222,7 +222,7 @@ bind Text { %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 { %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]] } } -- cgit v0.12