Archive for the ‘AutoComplete’ Category

RSyntaxTextArea 2.0.3 Released

Tuesday, 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!

RSyntaxTextArea & RText updated in Maven

Thursday, April 19th, 2012

Just a quick note that a user has kindly updated the RSyntaxTextArea and RText artifacts available in Maven:

http://search.maven.org/#search|ga|1|g%3A%22com.fifesoft%22%20OR%20g%3A%22com.fifesoft.rtext%22

As usual, please report any issues in the forums.

RSyntaxTextArea 2.0.2 Released

Wednesday, March 14th, 2012

RSyntaxTextArea 2.0.2 was released yesterday on SourceForge!  This release includes some good bug fixes, and is recommended for anyone ready and willing to upgrade.  Here are the highlights:

  • The license was changed from LGPL to modified BSD.  There are folks afraid of anything with “GPL” in the title, perhaps rightfully so, so now RSTA is using a non-viral license.  This also clears up any confusion about a user’s ability to use a modified version of the library.
  • Added a cool new keyboard shortcut: select some text, and pressing Ctrl+K/Ctrl+Shift+K (Cmd on OS X) is “go to occurrence” like in Eclipse.  A quick and easy way to traverse through all instances of specific text in the editor.
  • Ctrl+/ inserts line comments when editing JavaScript, to match the “insert line comment” action in many other languages.
  • Fixed performance issue: Pressing “End” to go to the end of a very long line (thousands of characters) is no longer slow.
  • Fixed bug: Icon row header should automatically move icons around when folds are expanded and collapsed.  This is very important for folks looking to implement custom Parsers that show error markers in the Gutter, for example.
  • Fixed bug: When going to a bookmark via Ctrl+F2/Ctrl+ShiftF2, we should ensure that any collapsed folds enclosing the bookmark are opened.  Previously, the caret would be moved to the line containing the next bookmark, even if it was in a collapsed fold.
  • Other small tweaks.

As mentioned, the RSyntaxTextArea, AutoComplete, and RSTALanguageSupport libraries are all under a modified BSD license now.  The SpellChecker add-on library had to stay LGPL due to its dependency on a modified version of Jazzy.  I don’t see this as a huge problem since folks using SpellChecker aren’t as likely to want to modify it as they would with say the main RSyntaxTextArea project.

Enjoy!

RSyntaxTextArea 1.5.2 Released

Saturday, August 27th, 2011

A minor update of RSyntaxTextArea and AutoComplete are now available on SourceForge and the Subversion repository.  Here’s what’s new:

  • Simplified the anti-aliasing API.
  • Java syntax highlighting updates to support Java 7 (binary literals, underscores in int literals).
  • Added an API to render tab lines (aka indent guides).
  • Fixed single-quoted strings in MXML.
  • Added miscellaneous keywords to Unix shell and Windows batch scanners.
  • Minor bug fixes.

Nothing earth-shattering.  The most noticeable update (and it’s not that noticeable, to me at least) is the anti-aliasing updates.  Not only is the API simplified (don’t know what I was thinking when I originally created it), but RSTA will now automatically pick the “best” anti-aliasing method to match the AA done by your OS, according to Java2D.  Font rendering has always been a sore spot for Swing applications, but with the later Java 6 updates, it’s actually gotten really, really good (at least on Windows).  Text rendering now (practically) matches that seen in native apps.  RSTA now handles specifying the AA hints the “right” way to look at nice as possible.

The next release will likely see more drastic changes, and will come along-side updates to the RSTALanguageSupport library as well.

JSP Code Completion

Tuesday, July 19th, 2011

Some degree of JSP code completion is working its way into RSTALanguageSupport.  Currently only code completion/inline documentation for the standard JSP tags are baked in, but coming soon will be support for importing taglibs.  The code is actually mostly there; the problem is figuring out how to expose it in the API in a simple, clean way.  It’s a little tough since RSTA is just a text editor component; for an editor application with the concept of a project or workspace, things would be a little easier.

As with HTML code completion, only attributes appropriate for the tag at the caret position are suggested.

JSP Code Completion

JSP Code Completion

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!

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.

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!

Auto-Activation added to AutoComplete

Sunday, June 6th, 2010

Sorry for the overloading of the “auto” prefix here… The “AutoComplete” library should probably have been named “CodeComplete”, but the point was to emphasize that it was usable for more scenarios than just code completion…

Anyway, after a few requests, I’m adding what Eclipse refers to as Auto-Activation.  This means that you can have the completion popup appear automatically after certain characters are typed.  For example, typing a ‘.’ character in Java could cause the completion popup to appear after a small delay, removing the need to keep pressing Ctrl+Space.

The new methods are added to the AutoCompletion class, and look like this:

public void setAutoActivationEnabled(boolean enabled)
public boolean isAutoActivationEnabled()
public void setAutoActivationDelay(int millis)
public int getAutoActivationDelay()


These methods allow you to toggle not only whether auto-activation is enabled, but also how long the delay should be between when they stop typing and when the popup appears.  It can be set to 0, meaning to always appear when possible, but often users want a small delay (maybe 200 milliseconds), so that it only shows up if they genuinely need it and stop typing.

Note that auto-activation depends on auto-completion itself being enabled.  If you’ve called setAutoCompleteEnabled(false) on an AutoCompletion, it will not honor the auto-activation property.

As to what characters trigger auto-activation, that is done on a per-CompletionProvider basis, since this can (and should) vary depending on what programming language is being edited.  The CompletionProvider interface now has a method:

public boolean isAutoActivateOkay(JTextComponent)

that should return true or false, depending on whether the text at the current caret position is something that auto-activation should occur at.  The concrete base class, CompletionProviderBase (what all CompletionProviders actually extend from, allow you to set exactly what characters this method checks for:

public void setAutoActivationRules(boolean letters, String others)

The first parameter allows you to have auto-activation occur after any standard letter (e.g. Ascii).  I personally think this is annoying, but I have seen editors do it in the past (Visual Studio?).  The second parameter is a string, each char of which is treated as a char to auto-activate after.  So for example, with Java you could call “setAutoActivationRules(false, “.”)” to auto-activate after the user types a period.  For markup languages you could pass “<” as the “others” String to auto-activate for tag names after ‘<” is typed.

The RSTALanguageSupport library is already taking advantage of this new feature.  The Java, HTML, and PHP supports all now auto-activate after appropriate characters by default.  They’re extra smart, and won’t auto-activate when not appropriate (e.g. typing “foo.” while in Javadoc won’t start auto-completion in Java, or typing ‘<’ while in a comment or attribute in HTML – while invalid in and of itself – will not cause code completion either).  If you’re an early adopter, be sure to check out out!  It was first added in revision 209.