Closed rm-code closed 8 years ago
Very nice.
@rm-code, quick question. On most non-Mac systems I've seen, ctrl-left and ctrl-right move the caret one word at a time, and ctrl-shift-left and ctrl-shift-left move the end of the selection range one word at a time (see bottom of #23). What's the usual key combo for this on Mac?
On OSX you'd usually use the alt- (also know as "option"-) key to move one word at a time. Same goes for moving the selection (alt-shift-left / right).
I've actually been working on this, but it didn't turn out as good as I wanted it to be :grin:
Basically tried it like this:
local function jumpWordLeft (self, alterRange)
trimRange(self)
local text, endIndex = self.value:reverse(), self.endIndex
local pos = text:find('%s', #text - endIndex + 1)
if pos then
selectRange(self, not alterRange and #text - pos, #text - pos)
end
end
I guess looking for non-whitespace chars would've made more sense ^^
I also couldn't decide whether to break words only on whitespace, or on any non-alphanumeric character. I've seen both behaviors and I'm not sure which I prefer. I guess either behavior is better than nothing, though. I'll take a closer look at your solution when I get a chance :)
On Windows the user can press the 'home' or 'end' key to jump around. On OSX he has to use cmd+arrow keys to move around.
If the user holds down shift while performing the above operations the whole line will be selected from where the caret was currently placed.