Code Folding in disabled text areas

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Code Folding in disabled text areas

Postby Rymek » Wed Dec 28, 2011 11:20 pm

Hey there!

I've already posted this in comment on the main site, but will repost here. Is there a way to enable code folding in edit-disabled text areas? I'm displaying XML files in my project (mostly SOAP messages) and I don't want user to be able to change them.

Thanks for answer and great work you put into this project ;)
Rymek
 
Posts: 6
Joined: Wed Dec 28, 2011 11:17 pm

Re: Code Folding in disabled text areas

Postby robert » Thu Dec 29, 2011 12:02 am

Hmm... code folding seems to work for me even if I call setEditable(false) and/or setEnabled(false). Can you provide a code snippet showing how you're creating your text areas?
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Code Folding in disabled text areas

Postby Rymek » Fri Dec 30, 2011 9:24 am

it's a simple Factory method for me:

Code: Select all
public static RSyntaxTextArea createXMLFormattedArea() {

        RSyntaxTextArea rSyntaxTextArea = new RSyntaxTextArea();
        rSyntaxTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        rSyntaxTextArea.setHighlightCurrentLine(false);
        rSyntaxTextArea.setEditable(false);
        rSyntaxTextArea.setWrapStyleWord(true);
        rSyntaxTextArea.setLineWrap(true);
        rSyntaxTextArea.setCodeFoldingEnabled(true);

        return rSyntaxTextArea;
    }


in situations where I need the area t obe editable I use the factory and then call setEditable on returned object, and code folding seems to be working here:
Code: Select all
this.requestBody = RSyntaxTextAreaFactory.createXMLFormattedArea();
this.requestBody.setEditable(true);


All areas are wrapped by RTextScrollPane

maybe it's a problem with my XML string? I'll PM the XML to you, would preffer not make it publicly available :)

oh and also it seems there's a problem with folding multiline comments :) (<!--- -->)
Rymek
 
Posts: 6
Joined: Wed Dec 28, 2011 11:17 pm

Re: Code Folding in disabled text areas

Postby robert » Sat Dec 31, 2011 10:17 pm

Ah, I see the problem - code folding isn't yet supported when word wrap is enabled. I'm surprised that calling setEditable(true) would make it start working though. Are you using the latest from Subversion, or the 2.0.0-beta1 jar? In either case I'd expect folding to never work when word wrap is enabled (in fact, it should hide the fold marker region of the gutter).

I need more time to get folding working with line wrap. The line wrapping code is much more touchy than the non-wrapping code. For performance reasons, I'm currently cheating and caching info about the logical height of lines when wrapping is enabled, which caused some problems when expanding/collapsing fold regions. I hope to get that working sometime in the near future.

As for the folding of multi-line comments, that's just because it isn't implemented yet for XML :D It should be easy enough to add.
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Code Folding in disabled text areas

Postby Guest » Mon Jan 02, 2012 9:06 am

ah :)

well, i've just noticed by saying 'working' I meant the squares for folding are displayed ;) But they do nothing when pressed (with word wrap). Sometimes they don't show though which is weird.

Anyway, can't wait for stable version release :)
Guest
 

Re: Code Folding in disabled text areas

Postby robert » Tue Jan 03, 2012 3:04 am

The fold parsing code is the same for both word wrap and non-word wrap, so if you use the beta-1 release (which displays the fold markers in word wrap mode even though they don't work), and see fold icons in the wrong places, please do send me steps to reproduce it (as simplified as possible!).
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Code Folding in disabled text areas

Postby Rymek » Tue Jan 03, 2012 8:57 am

just noticed it was my mistake with placing some components on the JFrame :) Now everything looks perfect

Also I've disabled wrapping to check if folding is working, and you were right - doh! - it's working :p I'm waiting for word wrap with code folding though :)
Rymek
 
Posts: 6
Joined: Wed Dec 28, 2011 11:17 pm

Re: Code Folding in disabled text areas

Postby robert » Wed Jan 04, 2012 3:58 am

Excellent, you'll definitely be hearing from me then. The more people testing out the folding code the better!
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Code Folding in disabled text areas

Postby robert » Sat Jan 07, 2012 9:18 pm

Just an FYI that a first pass at code folding with word wrap is now in SVN. Can you grab the latest from there and try it out? I'll email you as you're probably not watching the forum, but just in case anyone else is watching this and is interested...
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Code Folding in disabled text areas

Postby Rymek » Mon Jan 09, 2012 9:18 am

Hey there.

I've just briefly tested folding with word wrap - it seems to be working without any problems :) Haven't got time for deeper tests yet, but so far so good :) If I notice anything i'll let You know.
Rymek
 
Posts: 6
Joined: Wed Dec 28, 2011 11:17 pm

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron