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!
Archive for the ‘RSyntaxTextArea’ Category
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. “<!– … –>”)
- 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:
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.
Who knows, maybe a theme based off of its new Darcula will show up next.
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:
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!
(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.
RSyntaxTextArea 184.108.40.206 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.
RSyntaxTextArea 2.0.5 was just released on SourceForge! Here’s a recap of what’s new:
- Code folding added for HTML, JSP, and PHP.
- Added NSIS syntax highlighting and code folding.
- 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).
- Wildcards can be specified in Go to Member dialogs.
- Tool tips can now be specified for icons in IconRowHeader.
- Fixed an issue with CompleteMarkupTagAction and ToggleLineCommentAction conflicting with each other only on *nix (Windows and OS X didn’t have this issue).
- Allow for non-ConfigurableCarets to be set via setCaret(), to allow for Swing’s “composed text” changes (hidden in private API).
- Fixed possible NPE in XmlTreeCellUI for environments where desktop AA hints cannot be determined.
- Updated translations – Italian (Argaar), German (Domenic), Korean (Changkyoon), Japanese (Josh), and Hungarian (Zityi).
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:
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 220.127.116.11 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 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 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.
- 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!
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.
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.
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.