Archive for the ‘RSyntaxTextArea’ Category

Java Code Completion Updates

Friday, June 24th, 2011

A couple of minor fixes to Java code completion support in RSTALanguageSupport have just been added:

1. Member completion for string literals has been added.  If you’re like me, and are a fan of putting String literals first in string comparisons, i.e.

   if ("PROPERTY_FOO".equals(value)) {
     // ...
   }

then you can see this feature in action.

String Literal Code Completion

String Literal Code Completion

2. Fixed a bug where, if multiple local variables of the same type were declared, and some initialized, in the same statement, some of them would not get parsed.  In the example below, “two” and “three” were not parsed previously, but now they are.

Multiple grouped local var declarations

Multiple grouped local var declarations

Many consider declaring variables like this to be poor form, but it’s valid syntax nonetheless, so the parser should handle it properly!

Tab Lines in RSyntaxTextArea

Saturday, April 30th, 2011

The next release of RSyntaxTextArea will sport a new feature:  tab lines.  A user in the forums prodded me enough to look into this feature, and it’s really cool.  It’s little dotted lines helping you visually know where code blocks start and end.  An example screenshot:

Tab Lines

Tab Lines

The implementation will probably change before the next RSTA release, but the API will likely stay the same:

   public void setPaintTabLines(boolean paint);
   public void setTabLineColor(Color color);
   public boolean getPaintTabLines();
   public Color getTabLineColor();

Feel free to check it out from SVN and play around!

RSyntaxTextArea 1.5.1 Released!

Friday, March 25th, 2011

RSyntaxTextArea and AutoComplete 1.5.1 have both just been released on SourceForge!  This is a maintenance release, fixing minor issues and adding a few small improvements here and there.  Changes in this release include:

  • Fixed bug in properties file highlighting’s handling of single quotes.
  • Improvements to Windows batch file highlighting.
  • Adding a few more shell commands to Unix Shell syntax highlighting.
  • Fixed bug when pressing Enter at the start of an MLC or documentation comment in some C-style languages.
  • Changed “dumb complete word action” from shift+space to ctrl+enter, to eliminate annoying accidental activations.
  • Added a license header for those files that didn’t have one yet.

The SpellChecker library is still at 1.5.0.  All RSTA add-ons in the “1.5.x” family should be binary compatible with one another; just use the latest release of each (1.5.1 of RSyntaxTextArea and AutoComplete, 1.5.0 of SpellChecker).

Generics support added to Java Code Completion

Sunday, January 23rd, 2011

Support for generics (added in Java 5) is something that was sorely lacking from the Java code completion in RSTALanguageSupport.  That is, until the latest Subversion changes!  This is a very early implementation, and like a lot of the recent Java support changes, there may be bugs and performance issues.  But it’s there!  And things look good for simple usage of the java.util Collecitons classes:

Generics Support

Generics Support

Previously, methods such as List#add() and List#get() would always say that their parameter/return types were of type Object.  Now, if you specify type arguments to classes that accept them, code completion will reflect those type arguments.

As before, please be bleeding edge, try this out, and report back bugs!  You can do so either here, or in the RSyntaxTextArea forums.  There is also currently no way to turn this feature off (i.e. if you want to program with “-source 1.4″ effectively enabled), but that will come soon.

Javadoc/Multi-line comments now automatically closed

Tuesday, January 4th, 2011

The latest SVN contains a cool new feature that took me awhile to get used to in Eclipse.  In Java, C, and similar languages, multi-line comments and Javadoc comments are now automatically closed as you type.

Adding a new doc comment...

Adding a new doc comment...

... and after pressing Enter

... and after pressing Enter

I’ll make this an option, but for now there’s no way to turn it off.  Feedback welcome!

“Block Selection” branch added to RSyntaxTextArea SVN

Tuesday, September 7th, 2010

An oft-requested feature is block selection.  Unfortunately, this is pretty difficult to implement in Swing, for a couple of reasons.

  1. Swing’s text package keeps a lot of handy implementation hooks private and package-private.
  2. Swing’s text package’s idea of “selection” is pretty much hard-coded to mean “a contiguous range of text.”

In Java 6, #1 above has been (mostly) remedied, making it a good deal easier to implement this feature completely if your text component only supports Java 6+.  Unfortunately for us, RSyntaxTextArea supports from 1.4 up!

Because of this, adding block selection to RSTA will be tricky.  Fortunately, I’ve been motivated to finally put forth some effort to make this a reality.  I’ve added a branch in SVN specifically for exploring block selection, and already, a little progress has been made:

Block Selection

Block Selection

Obvious issues include:

  • Cut doesn’t work properly (though Copy does)
  • Drag-and-drop of a block selection doesn’t work (not sure this is possible, at least with pre-1.6)
  • Typing over a block selection doesn’t have the “expected” behavior of typing on all block-selected lines

Hopefully more progress will be made soon!

RSyntaxTextArea 1.4.2 Released!

Monday, August 2nd, 2010

Last night, RSyntaxTextArea 1.4.2 was released on SourceForge!  That includes new releases of RSyntaxTextArea as well as AutoComplete and SpellChecker.  This release was mostly about bug fixes and improvements in code completion behavior.  Here’s a quick list of all of the changes in this release.

  • Groovy syntax highlighting updates (GDK Object methods, Java 5/6 java.lang classes, URL’s in comments)
  • A fix to prevent security exception when setting AA hint in an applet (thanks to Frederic in the forums)
  • Fixing positioning of FocusableTips and code completion windows on multi-monitor setups (thanks to grzlbrmft in the forums for the bug report and testing).  I’m personally jealous of everybody out there with a dual monitor setup, who got to experience this bug.  :)

    AutoComplete Windows

    AutoComplete Windows

  • AutoComplete’s description window now updates itself in response to a selection change after a small delay (120ms) instead of immediately, to help performance for language supports with slower descriptions (e.g. file IO).  This mimics Eclipse’s behavior.
  • Added ActionScript syntax highlighting.  Perhaps now I have no excuse to play with this language.

    ActionScript

    ActionScript

  • Improved performance of auto-completion list cell renderer for huge completion lists.  Helps with languages with huge amounts of functions, such as PHP.
  • When using SearchEngine, if the next match isn’t currently visible, center the found/replaced text after the search operation.  This is a seemingly small change but is a nice usability improvement, and is seen in better editors like Eclipse.  For example, if your cursor is here:
    Starting to Search

    Starting to Search

    And you used SearchEngine#find() in RSTA 1.4.1 to find the next instance of “clip”, the next instance would be selected and brought into the visible area like so:

    SearchEngine#find() result before 1.4.2

    SearchEngine#find() result before 1.4.2

    Note that the next instance is selected, but is barely scrolled into the view.  Starting with 1.4.2, the next match is scrolled to the center of the text area, vertically:

    SearchEngine#find(), after 1.4.2

    SearchEngine#find(), after 1.4.2

    If the next instance of the text you’re searching for is already visible, the editor is not scrolled, the text is merely selected.  If the next match is not currently visible, however, that’s when it will be scrolled to the center of the view.

  • Fix for SourceForge bug 2998448: regex “replace all” is always case-sensitive.
  • SearchEngine’s concept of “whole word” is more accurate now (allows for punctuation, such as ‘,’, at the end of words, for example).  Previously, a “whole word” had to be completely surrounded by whitespace.
  • Added start of JUnit tests for SearchEngine.java.
  • SearchEngine bug fixes for replaceAll() with regex and match case/whole word enabled.
  • Fixed auto-complete bug with overloaded functions.
  • Fixed auto-complete bug – capitalization should be corrected when completing a parameterized completion.
  • Improved properties file syntax highlighting: ‘:’ can divide name/value pairs.
  • Added “our” keyword to Perl syntax highlighting.

Grab it on the SourceForge page today!

Integrating Language Support into RText

Saturday, May 22nd, 2010

I’ve spent the last week or so doing tedious, but important, stuff – making sure the RSTALangaugeSupport API is robust enough to be used in other applications.  The hard work is starting to pay off: Perl support is almost completely integrated already!

Perl options in RText

Perl options in RText

Here’s RText’s Options dialog, showing all the features related to Perl support that you can currently toggle.  As you can see, you can currently fiddle with both the code completion as well as the on-the-fly syntax checking I recently blogged about.  For the latter, you have to have a Perl install somewhere on your machine.  RText will scan your PATH for a Perl install, and default to using that, but you can change it to another installation if you want.  Still pending is the ability to add modules to the @INC path.

Language support will be fully integrated into all aspects of RText.  For example, compile errors and warnings will show up in the Error Strip component:

Compiler errors in Error Strip

Compiler errors in Error Strip

Also, function descriptions are displayed simply by hovering the mouse over them.  For example, below, my mouse is over the “print” function (sorry screen captures in Windows don’t capture the mouse pointer):

Function descriptions on mouse hover

Function descriptions on mouse hover

Perl is one of the harder languages to integrate, simply because its language support has so many features (runtime compilation, etc.) that others don’t have.  Hopefully other language supports will be integrated into RText shortly.  Stay tuned!

Perl Syntax Checking

Wednesday, May 12th, 2010

Perl syntax checking has been added to RSTALanguageSupport.  You can configure it with the location of a Perl install on your system (by default it scans your PATH for a Perl binary), and then PerlLanguageSupport will automatically begin scanning your code for errors as you type:

Perl Syntax Checking

Perl Syntax Checking

Next will be the ability to muck with the @INC path to add other libraries.  Currently it only uses the default @INC of your Perl install.

RSTALanguageSupport Progress

Sunday, May 2nd, 2010

The RSTALangaugeSupport library I’ve blogged about for so long has finally been added to the Subversion repository, but do note that it isn’t ready for prime time yet.  Use it at your own risk!  And send feedback when you do!  :)

If you check out the project, please read the readme file first.  It’s fairly up to date and explains how to compile and use the library.

The library currently includes code completion for the standard C library, and despite a couple of rough edges, should be mostly complete:

C code completion

C code completion

C support takes advantage of the parameter assistance feature of the AutoComplete library as well:

Parameter assistance for C functions

Parameter assistance for C functions

There’s also the start of decent support for Java, which is much more robust and dynamic than the support for other languages such as C.  It actually evaluates your code when you hit ctrl+space, and gives you accurate completion choices based on your current location in the code, based on classes you’ve imported (referencing jars on your “classpath”), local variables if you’re in a method, etc.  This has been discussed in several previous blog posts.

Java code completion

Java code completion

Yes, that tree widget on the left is actually included in RSTALanguageSupport as well!  However, it is currently Java-specific, and will not display an outline of source code in any other language.  It’s not high priority at the moment to generalize it, but it should probably happen sooner or later.  Java also supports parameter assistance when completing methods, like C does with its standard library.

There’s also code completion for Perl, supporting all built-in functions in Perl 5.10.x.  Rudimentary support for completions of variable names will appear for Perl in the next couple of days.

Perl code completion

Perl code completion

There’s also excellent support for HTML 5 – completion for all valid tag names, and attributes are suggested as well (only those attributes valid for the tag they are describing).  The description information displayed in the tool tip-style side window is rather lacking, however (as you can tell from the screenshot), so help improving this documentation is more than welcome!

HTML Completion

HTML Completion

PHP code completion is also included.  It uses the built-in HTML support when editing HTML, but when the caret is within PHP tags, PHP functions are suggested instead.  There is no documentation for PHP functions in the description window like there is for other languages just yet.

PHP code completion

PHP code completion

Similar to the C and Java support, parameter assistance is included for PHP functions:

Parameter assistance for PHP

Parameter assistance for PHP

Hopefully that is enough to whet some appetites!  Please discuss and ask questions over in the forums.