RSyntaxTextArea Developer Documentation Started

May 8th, 2013

Have you ever been interested in integrating syntax highlighting for your own, custom language into RSyntaxTextArea?  Now there’s finally a guide to help you do just that!

This “developers documentation” section describes in detail how syntax highlighting is implemented in RSTA, and multiple ways that you can add your own.  In the future, it’ll have similar documentation on adding code folding, code folding, and squiggle-underline parsing.

Feedback is welcome!


RText 2.0.7 Released

May 7th, 2013

RText 2.0.7 was released last weekend on SourceForge!  Here’s a list of what changed:

  1. Pretty-printing now works for JSON in addition to XML and HTML.
  2. The system console plugin now auto-completes file names on pressing tab.
  3. HTML, PHP, and JSP have new option, “Automatically add closing tags for HTML tags that require them,” as well as enhanced syntax highlighting.
  4. The text editor now includes an option to use the system selection colors for selected text and its background.
  5. The file chooser and File System Tree plugin now include “Paste” option to copy/paste file lists.
  6. Added Visual Basic syntax highlighting.
  7. Various code editor fixes and performance improvements.

Happy coding!


RSyntaxTextArea 2.0.7 Released

April 28th, 2013

RSyntaxTextArea 2.0.7 was just released on SourceForge!  Here’s a list of the cool new stuff:

  • setBracketMatchingEnabled(boolean) now checks for brackets “to the right” of the caret if one is not found “to the left.”
  • Added API for applications to create custom hyperlinks in RSyntaxTextArea, though this API should not be considered stable.
  • Added “mark occurrences” support for XML. Currently just highlights the tag name at the current caret position and its match.
  • Fixed issue when auto-inserting spaces for tabs.
  • Major refactoring of rendering code.
  • “Traditional” selection rendering is now supported; that is, selected text can now be rendered as syntax highlighted tokens with a “selection” background (as it was previously), or as text as a single color with the “selection” background (as standard text components do). See RSyntaxTextArea.setUseSelectedTextColor(boolean).
  • Fixed performance issue in FoldingAwareIconRowHeader when it paints “active regions.”
  • Added some new token types to better differentiate markup tokens from “regular” language tokens. This allows for better syntax highlighting for stuff like HTML, JSP, and PHP.
  • JavaScript highlighting now highlights JSDoc.
  • Added Visual Basic syntax highlighting.
  • In RSTAUI, a new TextFilePropertiesDialog was added.  This dialog shows the currently edited text file’s path, size, word count, encoding, line terminator, and more.  Further, when using a TextEditorPane, you can modify the file’s encoding or line terminator directly from the dialog.
  • RSTALanguageSupport: Miscellaneous JavaScript code completion improvements (thanks Steve).
  • RSTALanguageSupport: JavaScript code now syntax highlights JSDoc.
  • RSTALanguageSupport: JavaScript code completion now offers suggestions for JSDoc when in documentation comments.
  • RSTALanguageSupport: HTML, PHP, JSP and XML now have an option to automatically add closing tags when opening tags are typed (e.g. add “</foo>” when “<foo>” is typed). By default this option is enabled. HTML, PHP and JSP only auto-close tags closeable in the HTML 5 spec; XML closes all tags. This option is separate from the XML “auto-complete closing tag name when ‘</’ is typed” option.

Below are a couple of screenshots showing off the new JSDoc syntax highlighting and code completion.  The first one shows auto-completion kicking in after typing “@” in a documentation comment.  The second screenshot shows the parameterized assistance you get for “@param”:

JSDoc Code Completion

JSDoc Code Completion

JSDoc Parameterized Completion in action

JSDoc Parameterized Completion in action

Go check it out!

Visual Basic Syntax Highlighting

March 31st, 2013

Syntax highlighting for Visual Basic was just added into SVN.  I probably won’t bother with code folding support for VB any time soon, since I don’t ever write code in it, but if you’re itching to contribute, I’m always willing to take patches!

Visual Basic Highlighting

Visual Basic Highlighting

Improved Syntax Highlighting and Theming Support

March 23rd, 2013

If you grab the latest from SVN, RSyntaxTextArea has improved theming support.  First, RSTA supports the following new token styles:

  • Markup language comments (i.e. “<!– … –>”)
  • DTDs
  • CDATA delimiters, separate from the CDATA content itself (e.g. “<![CDATA[" and "]]>”)
  • Entity references

Note that all of these are related to markup languages, such as XML, HTML, JSP and PHP.  Previously, the lexers for each of these languages identified and colorized all of these constructs, but re-used token styles for other token types when rendering them.  For example, entity references were previously rendered using the “variable” token style.  This wasn’t optimal, as it meant that theme designers had to be aware of this token-style re-use when creating custom Themes, if they wanted their Themes to be as pretty as possible.  Not so any longer!

Another new feature is that RSyntaxTextArea now supports the standard editor behavior of selected text using a different font color than unselected text.  Previously, selected text always still rendered using the proper syntax highlighting styles.  Now, this is configurable via the setUseSelectedTextColor(boolean)/getUseSelectedTextColor() API.  Theme XML can also specify how a theme wants this property set.  Below is a screenshot that compare the “dark” default theme, which has this property set to false, and the “eclipse” default theme, which has this property set to true:

Selected Text Rendering

Selected Text Rendering

Themes can also now use a special value “default” for selection foreground and background colors, which means “use the LookAndFeel’s (not system’s!) default for these values).  Check out the theme DTD for specifics.

These changes do unfortunately mean that themes created for older RSyntaxTextArea versions will no longer work with (the upcoming) 2.0.7+, as they will not pass validation against the DTD.  They can be easily updated however, so I don’t see this as much of an issue.

Finally, all of the sample themes have been updated to use the new features above.  Also, a new sample theme was added to the mix:  idea!  Thanks to Mikle Garin for this theme.  This is  obviously based off of IntelliJ IDEA‘s default theme.

IDEA Theme

IDEA Theme

Who knows, maybe a theme based off of its new Darcula will show up next.

JSON Pretty-Printing

February 24th, 2013

If you do any work with JSON, you may well run into scenarios where you’re looking at some data for debugging purposes, but can’t make heads or tails of it because it’s either all on one line, not indented, or otherwise simply poorly formatted.  With the upcoming RText 2.0.7 release, this will no longer be a problem.  Its “Tidy” plugin (now being rebranded to “Pretty Printing”, since it’s a more general term) is gaining JSON pretty-printing support, powered by the jsonbeans library.

You’ll be able to control the indentation style (either tabs, or some number of spaces), as well as the actual format of the output.  The format choices are:

  • JSON:  Strict adherence to the JSON standard, keys wrapped in double quotes.
  • JavaScript:  Formatting appropriate for a JavaScript object – quotes around appropriate values, but not around keys.
  • Minimal:  No double quotes around anything.  Useful if you want the data in as simple of a format as possible, even if it isn’t technically valid.

Simply set up your formatting preferences in the Pretty Printing Options dialog panel:

JSON Formatting Options

JSON Formatting Options

And when editing JSON, simply select Edit -> Pretty Printing.  Simple as that.  Don’t forget that a shortcut can be assigned to this menu item via the “Shortcuts” panel in the Options dialog if you use it frequently.

RText 2.0.6 Released

January 26th, 2013

RText 2.0.6 was just released!  Here’s a rundown of the major changes:

Syntax highlighting and code folding for JSON.  Folks doing a lot of work with web applications will appreciate this.

JSON Support in RText

JSON Support in RText

Improvements to the UI when a Substance Look and Feel is installed.  All trees and lists now use Substance’s striping and rollover effects, and colors used in miscellaneous custom components were tweaked to better fit in with the current Substance skin.

Substance in AutoComplete Popups

Substance in AutoComplete Popups

Fixed a ClassCastException when adding a JRE in the Java options panel.  This was bug 3600567, and was accidentally introduced with the last refactoring of the Java language support.

Updated the Turkish and French localizations.  Thanks to Burak and Pat!

A major side effect of the improved Substance support is that compilation is now done in two phases.  RText has always only required Java 1.4, but Substance requires Java 6 or newer (we’re actually shipping with Insubstantial, which is an active fork of Substance, since the original author stopped working on it).  To get around this, all of the “core” RText classes are built with Java 1.4, and all of the classes requiring Substance are built with Java 6; these classes are only referenced from the application via reflection to avoid a hard dependency.  If Java 1.4 or Java 5 is detected, RText will never load anything Substance related.

When will RText drop support for 1.4?  Probably not for awhile, especially when I can easily use functionality in newer versions easily enough via reflection as I’m currently doing (and only then for Substance, opening a browser/system editors for files, and for the scripting API).  And performance improvements are received via simply running in a newer JVM, not from compiling with one.  Perhaps when Java 8 GA is released this September, it might be time to consider moving to Java 5.  :)

Anyway, the list of new features going into the next release is already growing!  More on that soon.


RSyntaxTextArea 2.0.6 Released

January 23rd, 2013

RSyntaxTextArea 2.0.6 was just released on SourceForge!  Included are new versions of AutoComplete, RSTALanguageSupport, and SpellChecker.

RSTA now provides syntax highlighting and code folding for JSON:

JSON Support

JSON highlighting and code folding in RSTA

Further, the AutoComplete and RSTALanguageSupport libraries now look good in Substance (in particular, Insubstantial).  Previously, these libraries used DefaultListCellRenderer for their completion choices.  Substance, being the barrel of fun that it is, forces libraries to extend its own DefaultSubstanceListCellRenderer, otherwise they aren’t rendered with Substance’s striping, gradients and rollover effects.  Now, RSTA and its cousins detect when Substance is the current Look and Feel, and render with a DefaultSubstanceListCellRenderer when necessary.  Easy peasy!


Substance in AutoComplete Popups

Substance in AutoComplete Popups

(Pardon the fact that I didn’t update the editor color scheme to be dark as well!).  This is done via reflection, so there is still no build dependency on Substance.  This of course assumes that the DefaultSubstanceListCellRenderer class name and package don’t change in future releases of Insubstantial, but I highly doubt that’ll happen, considering it’s a maintenance fork of the original Substance.  And if something goes horribly wrong, the library should fall back into its default rendering path anyway.

The outline trees (JavaOutlineTree, XmlOutlineTree, etc.) still use DefaultTreeCellRenderer, but applications can use the same technique here – wrap the standard renderers for these components with SubstanceDefaultTreeCellRenderer, call delegate.getTreeCellRendererComponent(), then set the Substance renderer’s icon and text based on the delegate’s values.  Come to think of it, I’m not sure why I didn’t have the libraries automatically delegate like I did with the completion choices lists… maybe next release.  One thing you do lose from this delegation is the rollover effect – the render “looks” the same, but the animated rollover effect depends on the actual renderer being a DefaultSubstance*Renderer.  Since we’re only *delegating* to one, we’ll look like it, but won’t get the rollover effect.

RText Released

December 24th, 2012

RText was released earlier this week on SourceForge.  This was a minor release (no real new features) that will nevertheless be a very important update for some users.  Here’s what was new:

  1. Updated to RSyntaxTextArea, which fixes a keyboard issue with non-QWERTY keyboards.
  2. Several Substance skins are now available as LookAndFeels. Thanks to the Insubstantial project ( These Look and Feels are only available when running RText with Java 6 or newer.
  3. Updated the Spanish (Leonardo) and Arabic (Mawaheb) translations.

Basically, this release was just to have an RText that fixed the keyboard issue introduced with RSTA 2.0.5.  Including Insubstantial (i.e. Substance) was just a bonus.  Only very recently had a couple of important issues been fixed that made it usable in a project such as RText.  I’m hesitant to ship Substance with any project, since in my (albeit limited) experience it’s been very touchy (stuff like breaking in *point releases*, not even major ones), but since the core Swing library isn’t really updated any longer, I think things are stable enough these days to give it a try.

RSyntaxTextArea Released

December 17th, 2012

RSyntaxTextArea was just released on SourceForge!  This release fixes the problem with typing the ‘/’ character on non-QWERTY keyboards, so is a must-upgrade if you’re using 2.0.5 (2.0.4 did not have this bug).  It also updates the Arabic translation (thanks Mawaheb!).

The AutoComplete, SpellChecker, and RSTAUI add-on libraries were also updated with Arabic translation updates.