more sophisticated 'select between quotes'
Submitted by Saturday, 29 April, 2006 - 05:17
on
I was playing around with Lee Turner's script (which appears to have started here: http://community.jedit.org/?q=node/view/1128), and because I work with PHP I wanted one to recognise both single and double quotes, and there's also the problem with his that if the caret is between quotations, the space between them gets selected. The latter's not that big of a problem, but trying to allow for both types of quotes is tough.
I thought I had it with this: basically track all openings and closings of quotes in the buffer prior to the caret (in PHP a ' inside "..." doesn't count and vice-versa), and if a quote is open at the caret, search after the caret to find its mate, and select between them. But then if a comment contains apostrophes or irregular double-quotes, this won't work! I could get very complicated and detect comments, but this is language-specific and what I've been thinking from the start is that it would be nice to abstract the searching from the quote syntax.
So my real question is: is there a way for a macro to interact with jEdit's syntax highlighter? It's a waste for my macro to do the work of finding quoted sections when jEdit has obviously already done the work. I'm envisioning methods get the token type of the text under the caret, get the boundaries of a given token section, etc. I've tried looking through the API docs, but (1) I'm don't really understand how the highlighting engine works, and (2) it all feels a little over my head. I am pretty green with Java.
Thanks for reading!
I thought I had it with this: basically track all openings and closings of quotes in the buffer prior to the caret (in PHP a ' inside "..." doesn't count and vice-versa), and if a quote is open at the caret, search after the caret to find its mate, and select between them. But then if a comment contains apostrophes or irregular double-quotes, this won't work! I could get very complicated and detect comments, but this is language-specific and what I've been thinking from the start is that it would be nice to abstract the searching from the quote syntax.
So my real question is: is there a way for a macro to interact with jEdit's syntax highlighter? It's a waste for my macro to do the work of finding quoted sections when jEdit has obviously already done the work. I'm envisioning methods get the token type of the text under the caret, get the boundaries of a given token section, etc. I've tried looking through the API docs, but (1) I'm don't really understand how the highlighting engine works, and (2) it all feels a little over my head. I am pretty green with Java.
Thanks for reading!