yes and no… if the character to the left and/or right of the cursor is a LETTER (or number) then yes
if it is between two spaces, then the run of spaces the cursor is in should be selected
it is when left is non-letter and right is non-letter… what (if anything) should happen
I’ve been playing with a few text editors they seem to do nothing if you are just selecting, but consider somethings a “word” if you are doing a “word delete”, but I can’t grasp the pattern.
I want this app to react the way most people would expect…
In the end I need to
Select current word (as described above)
Delete current word (ok, select it, then delete)
Select or Delete Word - right
Select or Delete Word - Left
the last two are strange…
for example
take this text
where | is the cursor
in UltraEdit, doing WORD SELECT does nothing, but DELETE WORD LEFT takes out the first 3 commas, and DELETE WORD RIGHT takes out the right 3. So the non-letters are a “word” sometimes…
Instead of breaking it down to an algorithm for each case, make an algorithm for the activity whose behavior is modified for the case.
So the activity is to move out from a starting position until some type of character blocks it. Since non-letters always block that doesn’t have to be optional. Really the only variant behavior I see is when it’s between spaces. Maybe this sketch explains the idea better…
[code]given SelStart
if character on left and right is a space then
blockingType = letters
travelType = spaces
else
blockingType = spaces
travelType = letters
end
start = selStart
stop = selStart
do
if there’s a character left of start and it’s of travelType then
start = start - 1
else
exit do
end
loop
do
if there’s a character right of stop and it’s of travelType then
stop = stop + 1
else
exit do
end
loop
SelStart = start
SelLength = stop - start[/code]
edit: I didn’t see your second post Dave and think maybe I’m on about something else
Suggestion: when the user hits that key, start finding words using a regular expression \\b\\w+\\b. When the match surrounds or touches your cursor, use the data to select the word. If the match start point is suddenly beyond your cursor, beep at the user.
(Note that the \\w token includes underscore. If you really don’t want that, it would be \\b[a-z0-9]+\\b.)