Archive for October, 2011

Code Folding Progress

Saturday, October 29th, 2011

I’m still making progress with code folding support in RSyntaxTextArea.  Several visual bugs were squashed (current line highlight, matched bracket painting when toggling folds), as well as a couple of “real” issues with the functionality.  The coolest thing that’s been added is folding support for XML:

XML Code Folding

XML Code Folding

Again, the actual rendering of the folded lines (color, the annotation at the end, etc.) is subject to change.  There are now also ways to do various folding stuff in the editor’s popup menu:

New Context Menu Items

New Context Menu Items

I’ll give these actions keyboard shortcuts moving forward, like those for Cut, Copy, etc.

Finally, note that, for any folded region, hovering the mouse over the “+” icon gives you a preview of the folded section, over-top where it would be in the editor:

Folded Content in Tool Tip

Folded Content in Tool Tip

Unfortunately, Ctrl+Print Screen in Windows doesn’t capture the mouse pointer, but you get the point!

Again, please try all this out by grabbing the latest from SVN!  Just call “textArea.setCodeFoldingEnabled(true)” and start tinkering with it.  Let me know any and all bugs you find!

Code Folding alpha added to SVN

Saturday, October 8th, 2011

Check out the lastest from Subversion to try out the WIP code folding in RSyntaxTextArea.  Simply call:

textArea.setCodeFoldingEnabled(true);

The fold indicator will be added to the gutter, and fold markers will appear where appropriate.  Currently supported languages include:

  • C, C++, C#
  • Java
  • Groovy
  • Perl

For other languages, there is no fold parser, so the editor won’t behave any differently than it used to (or shouldn’t!).  For the languages above, code blocks and multi-line comments are fold-able.  For Java, all import statements are also grouped together into a fold-able region.  Folding only currently works when line wrap is disabled – you won’t get any fold indicators if you enable word wrap.

Check it out and give it a go, but please keep in mind that this is an alpha feature!  There are likely lots of bugs.  Please report ‘em either by replying to this post or, even better, by posting them in the forums.

Also, I’m still playing around with the appearance of folded lines.  The little icon-ish thing at the end of folded lines (a la NetBeans) is temporary and probably won’t exist in the final version.  I’m trying to decide whether coloring the background of folded lines looks better than simply drawing a line across the editor.

Enjoy!