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 (https://github.com/Insubstantial/insubstantial). 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.

RText 2.0.5 Released

November 29th, 2012

RText 2.0.5 has been released!  This release brings it up to date with all of the reatures added to RSyntaxTextArea 2.0.5, plus more cool stuff.  Here’s what’s new:

  • Code folding added for HTML, JSP, and PHP.
  • Added NSIS syntax highlighting and code folding.
  • Added a “Projects” docked window. Useful for organizing small programming projects while working in RText.
  • Added code folding and highlighting of multi-line strings for Scala.
  • Added Java 7 features to Groovy highlighting (underscores in numeric literals, binary literals, and new core classes/interfaces/enums).
  • Fixed an issue with CompleteMarkupTagAction and ToggleLineCommentAction conflicting with each other only on *nix (Windows and OS X didn’t have this issue).
  • Fixed possible NPE when editing XML on Linux only (!).
  • RText is now building on OS X once again.
  • Now ships with Groovy 1.8.8, so you no longer have to drop in your own groovy-all-xxx.jar to run Groovy macros in RText.
  • Wildcards are now permitted in the Go To Member dialog.
  • Added keyboard shortcuts for moving through docked window groups (Ctrl+Alt+arrow keys).
  • Updated translations – Chinese (peter_barnes), Russian (Nadiya), Italian (Argaar), German (Domenic), Korean (Changkyoon), Japanese (Josh), and Hungarian (Zityi).

Go check it out!

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!