Y’know how textmate calculates which row and column you are on? I’ve been struggling to do this with jQuery and a textarea.
To those who haven’t use textmate, is there any possible way I can get the row number of the current textarea position?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the Caret Range plugin for this, like this:
This only works on a fixed-width font though, if it wasn’t fixed-width, you’ll have to search for line returns and calculate it out that way, but the selection/range is the tricky part…you can use the plugin or see how it gets the selection here.
Side note: It’s very non-cross-browser, all plugins/editors like this (currently) have browser-specific case handlers, as older browsers drop out of sight this can be slimmed down a bit.