Archive for the ‘AutoComplete’ Category

RSyntaxTextArea 2.0.5 Released

Wednesday, November 21st, 2012

RSyntaxTextArea 2.0.5 was just released on SourceForge!  Here’s a recap of what’s new:

 

  1. Code folding added for HTML, JSP, and PHP.
  2. Added NSIS syntax highlighting and code folding.
  3. Added code folding and highlighting of multi-line strings for Scala.
  4. Added Java 7 features to Groovy highlighting (underscores in numeric literals, binary literals, and new core classes/interfaces/enums).
  5. Wildcards can be specified in Go to Member dialogs.
  6. Tool tips can now be specified for icons in IconRowHeader.
  7. Fixed an issue with CompleteMarkupTagAction and ToggleLineCommentAction conflicting with each other only on *nix (Windows and OS X didn’t have this issue).
  8. Allow for non-ConfigurableCarets to be set via setCaret(), to allow for Swing’s “composed text” changes (hidden in private API).
  9. Fixed possible NPE in XmlTreeCellUI for environments where desktop AA hints cannot be determined.
  10. Updated translations – Italian (Argaar), German (Domenic), Korean (Changkyoon), Japanese (Josh), and Hungarian (Zityi).

Enjoy!

RSyntaxTextArea 2.0.4 Released

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

Template Completions

Saturday, 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.

 

 

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