diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-02-19 12:48:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-02-19 12:48:32 (GMT) |
commit | 76acfc3d9d190b8c24dfddc364e45f0ecf5eb5c1 (patch) | |
tree | d37e3fddbc707331cd8ba2f5f2f6f3649cd5239b /library/text.tcl | |
parent | dce78bcb0455e180116b61b634496b64c6e5254d (diff) | |
parent | fbc43284e28780ef359f599b6da2f7f3ed1d930a (diff) | |
download | tk-76acfc3d9d190b8c24dfddc364e45f0ecf5eb5c1.zip tk-76acfc3d9d190b8c24dfddc364e45f0ecf5eb5c1.tar.gz tk-76acfc3d9d190b8c24dfddc364e45f0ecf5eb5c1.tar.bz2 |
TIP #686: Make NextWord/SelectNextWord behavior platform-independant
Diffstat (limited to 'library/text.tcl')
-rw-r--r-- | library/text.tcl | 33 |
1 files changed, 19 insertions, 14 deletions
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. |