summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-02-19 08:40:41 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-02-19 08:40:41 (GMT)
commitfbc43284e28780ef359f599b6da2f7f3ed1d930a (patch)
treec21d99dfb178ca12910a520549c8e8d9ff1ec46a /library
parentefc3f3d42f6cf994cace9d7c010e9df68d37f8db (diff)
parentabc232173f3047e842ac38f26ec31e3a4acafc77 (diff)
downloadtk-fbc43284e28780ef359f599b6da2f7f3ed1d930a.zip
tk-fbc43284e28780ef359f599b6da2f7f3ed1d930a.tar.gz
tk-fbc43284e28780ef359f599b6da2f7f3ed1d930a.tar.bz2
Rebase to latest trunk
Diffstat (limited to 'library')
-rw-r--r--library/entry.tcl64
-rw-r--r--library/spinbox.tcl2
-rw-r--r--library/text.tcl33
-rw-r--r--library/ttk/entry.tcl32
4 files changed, 76 insertions, 55 deletions
diff --git a/library/entry.tcl b/library/entry.tcl
index 0509063..b344a63 100644
--- a/library/entry.tcl
+++ b/library/entry.tcl
@@ -143,7 +143,7 @@ bind Entry <<SelectPrevWord>> {
tk::EntrySeeInsert %W
}
bind Entry <<SelectNextWord>> {
- tk::EntryKeySelect %W [tk::EntryNextWord %W insert]
+ tk::EntryKeySelect %W [tk::EntrySelectNextWord %W insert]
tk::EntrySeeInsert %W
}
bind Entry <<LineStart>> {
@@ -588,42 +588,46 @@ proc ::tk::EntryTranspose w {
}
# ::tk::EntryNextWord --
-# Returns the index of the next word position after a given position in the
-# entry. The next word is platform dependent and may be either the next
-# end-of-word position or the next start-of-word position after the next
-# end-of-word position.
+# Returns the index of the next start-of-word position after the next
+# end-of-word position after a given position in the text.
#
# Arguments:
# w - The entry window in which the cursor is to move.
# start - Position at which to start search.
-if {[tk windowingsystem] eq "win32"} {
- proc ::tk::EntryNextWord {w start} {
- # the check on [winfo class] is because the spinbox also uses this proc
- if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
- return end
- }
- set pos [tk::endOfWord [$w get] [$w index $start]]
- if {$pos >= 0} {
- set pos [tk::startOfNextWord [$w get] $pos]
- }
- if {$pos < 0} {
- return end
- }
- return $pos
+proc ::tk::EntryNextWord {w start} {
+ # the check on [winfo class] is because the spinbox also uses this proc
+ if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
+ return end
}
-} else {
- proc ::tk::EntryNextWord {w start} {
- # the check on [winfo class] is because the spinbox also uses this proc
- if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
- return end
- }
- set pos [tk::endOfWord [$w get] [$w index $start]]
- if {$pos < 0} {
- return end
- }
- return $pos
+ set pos [tk::endOfWord [$w get] [$w index $start]]
+ if {$pos >= 0} {
+ set pos [tk::startOfNextWord [$w get] $pos]
}
+ if {$pos < 0} {
+ return end
+ }
+ return $pos
+}
+
+# ::tk::EntrySelectNextWord --
+# Returns the index of the next end-of-word position after a given
+# position in the text.
+#
+# Arguments:
+# w - The entry window in which the cursor is to move.
+# start - Position at which to start search.
+
+proc ::tk::EntrySelectNextWord {w start} {
+ # the check on [winfo class] is because the spinbox also uses this proc
+ if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
+ return end
+ }
+ set pos [tk::endOfWord [$w get] [$w index $start]]
+ if {$pos < 0} {
+ return end
+ }
+ return $pos
}
# ::tk::EntryPreviousWord --
diff --git a/library/spinbox.tcl b/library/spinbox.tcl
index ce200a0..4303141 100644
--- a/library/spinbox.tcl
+++ b/library/spinbox.tcl
@@ -153,7 +153,7 @@ bind Spinbox <<SelectPrevWord>> {
::tk::EntrySeeInsert %W
}
bind Spinbox <<SelectNextWord>> {
- ::tk::EntryKeySelect %W [::tk::EntryNextWord %W insert]
+ ::tk::EntryKeySelect %W [::tk::EntrySelectNextWord %W insert]
::tk::EntrySeeInsert %W
}
bind Spinbox <<LineStart>> {
diff --git a/library/text.tcl b/library/text.tcl
index 99d5841..15bdef2 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -138,7 +138,7 @@ bind Text <<SelectPrevWord>> {
tk::TextKeySelect %W [tk::TextPrevPos %W insert tk::startOfPreviousWord]
}
bind Text <<SelectNextWord>> {
- tk::TextKeySelect %W [tk::TextNextWord %W insert]
+ tk::TextKeySelect %W [tk::TextSelectNextWord %W insert]
}
bind Text <<SelectPrevPara>> {
tk::TextKeySelect %W [tk::TextPrevPara %W insert]
@@ -1086,26 +1086,31 @@ proc ::tk_textPaste w {
}
# ::tk::TextNextWord --
-# Returns the index of the next word position after a given position in the
-# text. The next word is platform dependent and may be either the next
-# end-of-word position or the next start-of-word position after the next
-# end-of-word position.
+# Returns the index of the next start-of-word position after the next
+# end-of-word position after a given position in the text.
#
# Arguments:
# w - The text window in which the cursor is to move.
# start - Position at which to start search.
-if {[tk windowingsystem] eq "win32"} {
- proc ::tk::TextNextWord {w start} {
- TextNextPos $w [TextNextPos $w $start tk::endOfWord] \
- tk::startOfNextWord
- }
-} else {
- proc ::tk::TextNextWord {w start} {
- TextNextPos $w $start tk::endOfWord
- }
+proc ::tk::TextNextWord {w start} {
+ TextNextPos $w [TextNextPos $w $start tk::endOfWord] \
+ tk::startOfNextWord
+}
+
+# ::tk::TextSelectNextWord --
+# Returns the index of the next end-of-word position after a given
+# position in the text.
+#
+# Arguments:
+# w - The text window in which the cursor is to move.
+# start - Position at which to start search.
+
+proc ::tk::TextSelectNextWord {w start} {
+ TextNextPos $w $start tk::endOfWord
}
+
# ::tk::TextNextPos --
# Returns the index of the next position after the given starting
# position in the text as computed by a specified function.
diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl
index 2d9cd32..3d2ef90 100644
--- a/library/ttk/entry.tcl
+++ b/library/ttk/entry.tcl
@@ -104,7 +104,7 @@ bind TEntry <<LineEnd>> { ttk::entry::Move %W end }
bind TEntry <<SelectPrevChar>> { ttk::entry::Extend %W prevchar }
bind TEntry <<SelectNextChar>> { ttk::entry::Extend %W nextchar }
bind TEntry <<SelectPrevWord>> { ttk::entry::Extend %W prevword }
-bind TEntry <<SelectNextWord>> { ttk::entry::Extend %W nextword }
+bind TEntry <<SelectNextWord>> { ttk::entry::Extend %W selectnextword }
bind TEntry <<SelectLineStart>> { ttk::entry::Extend %W home }
bind TEntry <<SelectLineEnd>> { ttk::entry::Extend %W end }
@@ -248,22 +248,17 @@ proc ttk::entry::See {w {index insert}} {
}
}
-## NextWord -- Find the next word position.
-# Note: The "next word position" follows platform conventions:
-# either the next end-of-word position, or the start-of-word
-# position following the next end-of-word position.
+## NextWord --
+# Returns the index of the next start-of-word position after the next
+# end-of-word position after a given position in the text.
#
-set ::ttk::entry::State(startNext) \
- [string equal [tk windowingsystem] "win32"]
-
proc ttk::entry::NextWord {w start} {
# the check on [winfo class] is because the spinbox and combobox also use this proc
if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} {
return end
}
- variable State
set pos [tk::endOfWord [$w get] [$w index $start]]
- if {$pos >= 0 && $State(startNext)} {
+ if {$pos >= 0} {
set pos [tk::startOfNextWord [$w get] $pos]
}
if {$pos < 0} {
@@ -272,6 +267,22 @@ proc ttk::entry::NextWord {w start} {
return $pos
}
+## SelectNextWord --
+# Returns the index of the next end-of-word position after a given
+# position in the text.
+#
+proc ttk::entry::SelectNextWord {w start} {
+ # the check on [winfo class] is because the spinbox and combobox also use this proc
+ if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} {
+ return end
+ }
+ set pos [tk::endOfWord [$w get] [$w index $start]]
+ if {$pos < 0} {
+ return end
+ }
+ return $pos
+}
+
## PrevWord -- Find the previous word position.
#
proc ttk::entry::PrevWord {w start} {
@@ -315,6 +326,7 @@ proc ttk::entry::RelIndex {w where {index insert}} {
nextchar { NextChar $w $index }
prevword { PrevWord $w $index }
nextword { NextWord $w $index }
+ selectnextword { SelectNextWord $w $index }
home { return 0 }
end { $w index end }
default { error "Bad relative index $index" }