Archive for the ‘RSyntaxTextArea’ Category

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

Javadoc assistance for Java Code Completion

Sunday, April 11th, 2010

I’ve added the ability to add “source attachments” to jars on the “class path” or “build path” (not sure what to call that, Eclipse uses “build path,” but RSTA isn’t compiling anything, since it’s just an editor…).  You can now get Javadoc in the description window alongside code completion choices.  In the example below, I’m editing java/lang/String.java, and I’ve attached the src.zip that comes with the JDK.  You’ll see that the Javadoc for the relevant String method is shown:

Source Attachments working

Source Attachments working

Beyond that, I’ve been working on the API, using RText as the test application.

Also, not the source outline tree on the left.  I’m working on getting this component simple and usable as well.  I’m tempted to shove it into the RSTALanguageSupport library, since it would only be used with RSTA instances using the library, but since it isn’t specifically related to the editor, it may just end up in RText itself.  It’s really nice – it displays the outline of the source as parsed by the code completion parser, and clicking on an item in the tree jumps to that item in the source code.  However, it is Java-specific and is not currently meant to be used for outlining just any language.

Java Code Completion Status

Thursday, April 1st, 2010

The code completion library for standard programming languages for RSyntaxTextArea is almost ready for a public repository.  I plan on calling this library “RSTALanguageSupport” (nice name, huh?), as it contains support for editing common programming languages with RSyntaxTextArea.

In getting this library tidied up, I’ve picked up the Java code completion yet again, since it’s by far the most complex.  I thought I’d give a status update now so people don’t have unrealistic expectations about the library when it’s first released.

Assuming you’ve added any jars you want on your “build path” (to use Eclipse terminology), the Java code completion support can handle:

  1. Class fields and methods:
    Completion of fields and methods

    Completion of fields and methods

  2. Local variables in scope in the current method:

    Completion for local variables

    Completion for local variables

  3. Methods and static fields of non-primitive fields and local variables:

    More local variable completion

    More local variable completion

  4. Common Javadoc completions that I personally find extremely useful in Eclipse:

    Javadoc completions

    Javadoc completions

It does not currently handle completions for return types of methods:

Can't do this just yet

Can't do this just yet

This is the single issue that will take the longest to resolve, as it’ll take a re-hashing of how the code completion is parsing the code.  Other features and bug fixes will appear before this one is fixed.

Also, please note that the Java code completion should not be considered “good design.”  I am (poorly) self-taught in lexing/parsing, and so what I have now is certainly not optimized, easy to read, or using the latest design techniques.  It is what it is.  :)   I consider this to be a learning experience, and that the library will improve over time.

That said, it seems reasonably performant (only a pause when it has to initially load completions for many new classes, such as multiple imports of large packages, such as “javax.swing.*”), and is more than usable on the machines I’ve tested on.  Memory usage could certainly be improved (stuff isn’t shared between multiple editors implementing Java completion that should be) but I plan to fix that soon.

As a side note – as you can see from the first screenshot, I’m also working on tying Javadoc into the description window.  Notice that the Javadoc for the “str” field is nicely formatted in the tool tip-style side window?  That happens for all fields and methods in the current source file.  I’m also working on the ability to add “source attachments” for jars on the “classpath,” just like Eclipse, which will be used for assistance with libraries.  So for example, you can point to the src.zip included with your JDK, and get a nice description of each class, field and method in the JDK, just like in your favorite real IDE!

Integration of this library into RText as a plugin is already underway.  As always, RText will be a showcase of all the cool stuff you can do with RSyntaxTextArea.

RSyntaxTextArea 1.4.1 Released

Friday, March 12th, 2010

We’re proud to announce that RSyntaxTextArea 1.4.1 has been released!  This release touches the text component, as well as the AutoComplete and SpellChecker libraries.  It is mainly a bug fix/usability release, with relatively minor new features.  Here’s a recap of what’s new:

  1. Made the default font be Monaco on OS X 10.4/10.5, and Menlo on Snow Leopard.
  2. Syntax schemes are now smarter and automatically pick up on when you change the base font of the editor, adjusting themselves accordingly.
  3. Better cursor navigation with Ctrl+left/right arrows (now behaves like
    Eclipse). Also improved word selection via double-clicking behavior.
  4. Added method to toggle whether an EOL marker is painted for each line.
  5. New keymapping: shift+space does a “dumb complete word” action where the last word in the document that matches the “word” up to the caret position
    is auto-completed. Keep pressing shift+space to go back further in the
    document. Again, this is mimicking Eclipse’s action (that has no default key mapping).
  6. You can now configure what constitutes a “task” identifier for TaskTagParser.
  7. Improved XML auto-closing tags (accepts ‘:’ and ‘-’ chars in tag names, as it always should have).
  8. Fixed an exception when spell checking plain text files (no syntax highlighting)

The keyboard navigation updates and shift+space are my personal favorite changes.  They’re excellent if you’re really keyboard/shortcut heavy and not a mouse user.  And the OS X font changes keep things looking as nice and “native” as possible out-of-the-box on that platform.

The AutoComplete library‘s version number was bumped from 0.4 to 1.4.1 so that it coincides with RSTA itself (just like SpellChecker).  This is to help facilitate the “use the version of the add-on library that is closest to your version of RSyntaxTextArea” idea.

Go grab it today and see what you think!

Yet more Improvements to RSyntaxTextArea

Sunday, January 10th, 2010

Happy New Year!  After a nice long break, it’s time to get the ball rolling on the Fifesoft projects again!

First, some low-lying fruit has been picked for RSTA.  You can now toggle whether end-of-line markers are rendered at the end of each line.  This can be useful for things such as seeing extra whitespace at the end of lines.  Here’s a preview of this feature being used in RText, where it is already integrated in SVN:

EOL Markers in RSyntaxTextArea

EOL Markers in RSyntaxTextArea

Also, and perhaps more importantly, there have been improvements in RSTA’s keyboard navigation.  Ctrl+left/right arrow have always skipped words, but until now, it’s used Java’s default “word skip” behavior (e.g. BreakIterator.getWordInstance()).  This isn’t really optimal for skipping “words” in source code, so this functionality has been revamped to behave like Eclipse does.  The only difference is that the caret does not stop at capital letters in camelCaseIdentifiers.  I despise this behavior, and I don’t know why the Eclipse devs think it’s a good idea.  Besides this, double-clicking on a word does a better “select word” for source code than before.  These are little things that make a big usability difference.

Finally, external tool support is being added into RText.  This will allow you to run things such as Ant, compilers, or whatever else from directly inside RText.  Nothing really to show at the moment though, just the framework has been put in.

Java Field and Local Variable Completion

Thursday, December 10th, 2009

The Java code completion I’m working on has hit a new milestone.  Code completion for fields and local variables is starting to work:

Field Completion

Field Completion