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 2.0.4.1) 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 2.0.4.1 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 2.0.4.1 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:

All:

  • 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).

RSyntaxTextArea:

  • 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.

AutoComplete:

  • 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.

RSTALanguageSupport:

  • 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.

RSTAUI:

  • 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++) {
    <cursor>
   }

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.

 

 

RText 2.0.3 Released

May 5th, 2012

RText 2.0.3 was just released on SourceForge!  It’s based off of the recent 2.0.3 release of RSyntaxTextArea.  Here’s what’s new:

  • Added code folding for several languages, including C, C++, Java, Perl, XML, Groovy, C#, JavaScript, MXML, CSS and LaTeX.
  • Dockable window panels are now collapsible, allowing you to allot more screen real estate to the editors when necessary.
  • Added LaTeX syntax highlighting and code folding.
  • Added DTD syntax highlighting.
  • Added “Go to Member” shortcut (Ctrl+Shift+O) similar to Eclipse. Currently only for Java, JavaScript, and XML.
  • The Source Browser’s tree view of source code is now sortable.
  • License changed to modified BSD from GPL.  This allows folks to use pieces of RText without making their entire application GPL.

In short: code folding, more languages supported, and more liberal license.

Unfortunately, my MacBook is on the fritz, so I can’t create a Mac app bundle at the moment.  As soon as I can get this resolved, a Mac bundle will get uploaded to SourceForge.  Until then, folks on OS X can use the *nix bundle if necessary (it’s just a gzipped install).

RSyntaxTextArea 2.0.3 Released

May 1st, 2012

RSyntaxTextArea 2.0.3 was just released on SourceForge!  Here’s what’s new:

 

  • LaTeX syntax highlighting and code folding:

    LaTeX Support

    LaTeX Support

  • DTD syntax highlighting:

    DTD Highlighting

    DTD Highlighting

  • Fixed an issue with RTextScrollPane, allowing it to be used in NetBeans’s visual editor
  • Fixed a bug in cold folding under certain cirumstances
  • RSTA now has anti-aliasing enabled by default (previously you had to call setAntiAliasEnabled(true) yourself)
  • TextEditorPane now fires FULL_PATH_PROPERTY from its load() method like it does from saveAs().

Download it today!

OfficeLnFs 3.0 Released

April 22nd, 2012

After a very long hiatus, a new 3.0 release for OfficeLnFs has been uploaded on SourceForge.  This release includes 3 fixes that have been in the project’s SVN repository for years now, but never made it into a “real” release for some reason:

  • JCheckBoxMenuItem/JRadioButtonMenuItem offsets wrong in Vista & Windows 7.
  • Improved background painting of uneditable JComboBox’s selected items in Vista & 7.
  • Fix for HTML tags being taken into account when calculating menu item width.

Moving forward, the VS2005 LookAndFeel may get a little bit more love; it’s inflexible in the customization of its tabbed pane and that may get rectified.

Enjoy!