Extending CurlyFoldParser

General Discussion on RSyntaxTextArea.

Moderator: robert

Extending CurlyFoldParser

Postby Tom K. » Fri Mar 16, 2012 6:08 pm

I was able to extend CurlyFoldParser to parse non-curly-brace
code by overriding the isLeftCurly(Token) and isRightCurly(Token) methods,
but I also had to add a way to bypass the "do curly braces denote code blocks"
check in the getFolds() method, e.g.,

java code:

public List getFolds(RSyntaxTextArea textArea) {
List folds = new ArrayList();

//RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
//if (doc.getCurlyBracesDenoteCodeBlocks()) {

if (curlyBracesDenoteCodeBlocks(textArea)) {
...
}
}

public boolean curlyBracesDenoteCodeBlocks(RSyntaxTextArea textArea) {
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
return doc.getCurlyBracesDenoteCodeBlocks();
}


Would it be possible for you to add such an override method to
CurlyFoldParser?

This is a very useful library, thanks for making it available.
Tom K.
 

Re: Extending CurlyFoldParser

Postby robert » Sun Mar 18, 2012 12:39 pm

Sure thing, I'll look into it.
User avatar
robert
 
Posts: 760
Joined: Sat May 10, 2008 5:16 pm

Re: Extending CurlyFoldParser

Postby robert » Sun Mar 18, 2012 10:46 pm

I did one better, and removed the "getCurlyBracesDenoteCodeBlocks()" check altogether, since in theory you wouldn't be using the FoldParser unless it was appropriate for your language. I'm assuming you wanted to override this behavior since you needed the RSTA property to be false, since it's assumed to refer to literal '{' and '}' chars elsewhere. Let me know if this doesn't meet your needs.

Check out the latest from SVN and make sure things look better for you.
User avatar
robert
 
Posts: 760
Joined: Sat May 10, 2008 5:16 pm

Re: Extending CurlyFoldParser

Postby Tom K. » Mon Mar 19, 2012 5:43 pm

Yes, that suits my need perfectly. I tried the new code and it works great.

Thanks for the quick modification.
Tom K.
 


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron