RSyntaxTextArea 2.0.5 Released

November 21st, 2012

RSyntaxTextArea 2.0.5 was just released on SourceForge!  Here’s a recap of what’s new:


  1. Code folding added for HTML, JSP, and PHP.
  2. Added NSIS syntax highlighting and code folding.
  3. Added code folding and highlighting of multi-line strings for Scala.
  4. Added Java 7 features to Groovy highlighting (underscores in numeric literals, binary literals, and new core classes/interfaces/enums).
  5. Wildcards can be specified in Go to Member dialogs.
  6. Tool tips can now be specified for icons in IconRowHeader.
  7. Fixed an issue with CompleteMarkupTagAction and ToggleLineCommentAction conflicting with each other only on *nix (Windows and OS X didn’t have this issue).
  8. Allow for non-ConfigurableCarets to be set via setCaret(), to allow for Swing’s “composed text” changes (hidden in private API).
  9. Fixed possible NPE in XmlTreeCellUI for environments where desktop AA hints cannot be determined.
  10. Updated translations – Italian (Argaar), German (Domenic), Korean (Changkyoon), Japanese (Josh), and Hungarian (Zityi).


Code Folding for HTML and PHP, Syntax Highlighting & Folding for NSIS

October 14th, 2012

HTML and PHP finally got code folding added!  The current implementation only adds fold regions for tags that require being closed.  Inline JavaScript and PHP code are not currently checked for fold regions.  JSP will likely soon follow.

HTML Code Folding

HTML Code Folding

Also, support for NSIS scripts has been added.  I’m sure most developers are familiar with NSIS, which makes it super easy to create installers for your Windows applications.  RSTA now supports full syntax highlighting and code folding for NSIS scripts:

NSIS Code Highlighting and Folding

NSIS Code Highlighting and Folding

Wildcards in Go to Member Dialog

October 1st, 2012

The Go to Member dialog (Ctrl+Shift+O) allows you to jump to a method or field simply by typing its name.  It’s a great way to quickly navigate through code.  It’s currently available in RSTALanguageSupport for Java, JavaScript, and XML, and it just got a nice enhancement:  it now allows you to type wildcards as part of the identifier to search for:

Wildcards in Go to Member Dialog

Wildcards in Go to Member Dialog


Project Support in RText

September 18th, 2012

The next release of RText will include support for projects.  Projects are collections of files logically grouped together, usually a part of the same application if you’re a developer.

The project support will be not be of the same scope as projects in Eclipse, NetBeans, or Visual Studio.  Rather, RText will take the approach used by other “programmer’s editors.”

The main UI component of projects support is the “Projects” docked window.  By default it is docked on the left-hand side of RText:

Projects Support Main Panel

Projects Support Main Panel

The root node in the tree view is the current workspace.  A workspace is simply a collection of zero or more projects.  This allows you to logically group projects that are related, for example.

Workspaces are loaded and saved as XML files.  On startup, RText loads the last project you had open.  You can create a new workspace, or open an existing one, via the docked window’s popup menu:

Open an Existing Project

Open an Existing Project

Opening another workspace  automatically saves the currently open one; this way, you don’t have to worry about manually saving your workspaces or projects.

Adding a new Project to the workspace is as easy as right-clicking, selecting “New Project…”, and giving the project a name.  You can use any characters you want in project names, as they aren’t represented by a physical file or folder (they’re simply “metadata” in the parent workspace’s XML).

In each project you create, you can add Files, Folders, and Logical Folders via the context menu:

Adding an Item to a Project

Adding an Item to a Project

The “Add Files…” menu item allows you to add one or more files to the project.  Again, the files in a project don’t need to live in a common parent directory, since the project is a logical grouping of files and folders.

The “Add Folder…” menu item allows you to add an entire folder to the project.  Not only that, but you can filter what files are displayed in the project UI.  So you could only dispaly *c, *.cpp, and *.h files, for example, or filter out “CVS” folders or *.bak files.

Finally, “Add Logical Folder…” adds a folder to the project that doesn’t actually exist on disk, but you can still add files, folders, and other logical folders to it.  Think of it as an extra organizational tool; you can logically group files in the UI with logical folders.

That’s it in a nutshell.  The plugin is fully integrated with RText – double-clicking a file opens it in an editor, you can delete or rename files directly from the plugin tree view, etc.  It’s already in SVN, so check it out and see what you think!

RText 2.0.4 Released!

September 7th, 2012

RText 2.0.4 was released today on SourceForge!  See also the Javadoc and SVN repository.  This release basically provides all the new functionality in the 2.0.4 release of RSyntaxTextArea (including the Asian language fix in and fixes a couple of bugs.

I’ve been coming up with a list of changes in the 2.0.5 releases of RSTA and RText.  Look for a blog outlining them in a week or so.  Suggestions are of course welcome!

RSyntaxTextArea Released

September 7th, 2012

I usually don’t do such quick follow-up releases, but 2.0.4 introduced a font rendering bug that caused many Asian fonts to not be rendered properly out-of-the-box (at least on Windows).  This has been corrected in release on SourceForge.  If your product has non-English speaking users it’s probably a good idea to upgrade to this release.

RSyntaxTextArea 2.0.4 Released

September 2nd, 2012

RSyntaxTextArea 2.0.4 was just released!  Grab it either from SourceForge or SVN (see also web viewer, javadoc).  This release updates RSTA as well as the sister projects AutoComplete, RSTALanguageSupport, and SpellChecker, and adds yet another sister project:  RSTAUI!  Here’s the complete list of what’s new:


  • Updated translations:  Chinese (peter_barnes), Russian (Nadiya), Polish (Chris), Spanish (Leonardo), Brazilian Portuguese (Pat), and Korean (Changkyoon).
  • Removed superfluous build warnings from projects when building with Ant 1.8+ (includeantruntime).


  • HTML, JSP, and PHP syntax highlighting now also highlight embedded CSS.
  • Background color highlighting for “secondary” languages (such as CSS and JS in HTML, JSP, and PHP).
  • Added code folding for Lisp and Clojure.
  • Minor Clojure syntax highlighting updates.
  • Changed default font to Consolas on Windows Vista and 7.
  • Decreased memory usage required for regex find and replace operations.
  • Improved performance of Mark Occurrences, especially when there are lots and lots of marked occurrences.
  • Added E4X highlighting to JavaScriptTokenMaker (can toggle on and off via a static property).
  • Added a property so that, when bracket matching is enabled, you can choose to have both brackets highlighted instead of just the “opposite” one.
  • Fix to RTextScrollPane class to facilitate using it in the NetBeans GUI designer.
  • Fixed misaligned icons in row header when code folding is enabled.
  • Fixed bug: FoldManager incorrectly auto-expanded deeply-nested folds for some edits that did not affect those folds.
  • Fixed bug: wrong initial width of line number margin when calling Gutter#setLineNumberingStartIndex(int).
  • GoToMemberWindow: Fixed occasional NPE.
  • TextEditorPane: Fixed bug: clear undo stack and dirty state when “loading” a new file.
  • TextEditorPane: Now automatically scrolls to top of file on load().
  • Fixed bug: NPE in DumbCompleteWordAction in some circumstances (whitespace at beginning of file).
  • TokenMakerFactory now allows user-defined TokenMakers to be loaded via different ClassLoaders.


  • Added template completions.  You can now create completions for constructs that have arbitrary structure and take any number of parameters, such as for-loops and other common boilerplate code.
  • Fixed memory leak when uninstalling AutoCompletes from text areas.


  • Tremendous updates to JavaScript code completion and syntax checking, all done by steve.  We now use Rhino 1.7R4 for parsing.  JS is now by far the best-supported language in RSTALanguageSupport.
  • JavaLanguageSupport: Much better display of Javadoc links in Javadoc completion popup.


  • New (optional) library providing fully functional, localized dialogs for Find and Replace operations in RSyntaxTextArea.  Supports searching forward and backward, regex searching, match case, mark all, and replace all.  The actual search operations are delegated to the RSTA library’s built-in SearchEngine class.
  • More common dialogs will be added to this library in the next release.  More information about this in a future blog post!

Bracket Matching Improvements

August 21st, 2012

Just pushed to SVN, whenever you move the caret over a bracket, you now have the ability to highlight both brackets, not just the matched one.  Some folks find this useful, as the bracket at the caret position will not highlight if they forgot to insert the closing bracket, for example.  It can also be useful to visually identify the scope of a code block.


Matching both brackets

Matching both brackets

To further help with scope identification, I hope to implement a standard range painter for the gutter, for C-style languages that use curly braces to denote code blocks.  This range painter would highlight the deepest code block of the caret as you moved around the code.  The basic API for this already exists, and in fact, the Java language support in RSTALanguageSupport uses it to highlight the method the caret is in (if any).  But it would be nice if there was a more generic one for C, JavaScript, C#, etc.

Scope Highlighting in the Gutter with Java Language Support

Scope Highlighting in the Gutter with Java Language Support

Secondary Language Highlighting, CSS in web languages

July 11th, 2012

Two improvements have recently been pushed to RSTA.  First, inline CSS is highlighted in HTML, PHP, and JSP files.  Previously, inline CSS was rendered as plain text; now it’s rendered just as if CSS highlighting were enabled.

Secondary Language Highlighting

CSS Highlighting in an HTML document

These days, TokenMakers for web-based languages are each actually highlighting several languages – JavaScript, CSS, HTML, and possibly JSP/PHP.  This means in documents with lots of inline scripts and styles, it’s not immediately obvious with a visual scan what you’re looking at with syntax highlighting alone.  Which brings me to the second new feature – secondary language highlighting.  When enabled, this allows TokenMakers to specify Tokens as belonging to specific “secondary” languages.  When secondary language highlighting is enabled, such Tokens are painted with a special background color.  This results in regions of code such as JavaScript and CSS blocks to be painted with a different background, as seen in the screenshot above.  It can be extra useful when viewing generated HTML with poor formatting:

Secondary Language Highlighting 2

Secondary Language Highlighting – JS and CSS in HTML

The bad news is, this feature comes at a fair performance penalty (since the background is painted for each individual Token, not for the entire region at once).  On good hardware (especially Windows machines) this shouldn’t really be a problem, but for this reason, this feature is disabled by default.  To enable and query it, use these methods in the RSyntaxTextArea class:

public boolean getHighlightSecondaryLanguages();
public void setHighlightSecondaryLanguages(boolean highlight);
public int getSecondaryLanguageCount();
public Color getSecondaryLanguageBackground(int index);
public void setSecondaryLanguageBackground(int index, Color color);

There are currently three secondary language backgrounds, which I’m assuming is a sufficient and practical number until someone proves otherwise.  :)  The Theme DTD and API have been updated so that themes specify the background colors for secondary languages as well.

Template Completions

June 30th, 2012

A new feature has been added to the AutoComplete library trunk, and will be in 2.0.4 when it’s released:  template completions.  Equivalent to JDT’s editor templates in Eclipse, templates are an easy way to insert (usually, but not required) parameterized code into RSTA.

A common use case for TemplateCompletions is for inserting boilerplate code.  Take for example a for-loop that iterates through an array in Java.  The code always has the following structure:

   for (int i = 0; i < array.length; i++) {

The only thing that changes (sans formatting) is the name of the index variable and the name of the array being iterated through.  The ending cursor position should be inside the curly braces so the user can insert code into the looped-over code block.  TemplateCompletions provide a simple syntax for creating a code completion choice for inserting such a construct:

   String template =
      "for (int ${i} = 0; ${i} < ${array}.length; ${i}++) {\n\t${cursor}\n}";
   Completion tc = new TemplateCompletion(this, "for", "for-loop", template);

As you can see, a TemplateComletion takes a String representation of the code to be inserted.  Parameters are represented by substrings with the format “${foo}”.  These parameters are replaced by the user, similar to parameters in FunctionCompletions.  For parameters listed more than once in a template, only the first one can be edited by the user; during editing, all subsequent parameters with the same name will be automatically replaced with whatever the user types.

Parameters are cycled through via pressing Tab and Shift+Tab, or just by using the arrow keys.

The special parameter “${cursor}” denotes where the cursor will be placed upon pressing Enter or otherwise exiting template completion mode.  Specifying more than one ${cursor} in a single template results in undefined behavior.

Here’s an example of the above template actually being used:

Selecting the TemplateCompletion

Selecting the TemplateCompletion

Upon selecting the for-loop TemplateCompletion:

Inserting a TemplateCompletion

Inserting a TemplateCompletion

Editing the first “${i}” parameter:

Editing parameters

Editing parameters

Tabbing to (or pressing Enter to move directly to) the cursor end position:

End cursor position

End cursor position

All of the colors involved in marking parameters, etc. are configurable by the new org.fife.ui.autocomplete.AutoCompletionStyleContext class.

What’s next for this feature?  Well, again following in the footsteps of Eclipse, you should be able to specify the “data type” associated with each parameter, if any.  The AutoComplete library could then use that information to present the user with parameterized completion suggestions as it currently does for FunctionCompletions.