Archive for the ‘RSyntaxTextArea’ Category

RSyntaxTextArea 2.5.4 Now Available

Wednesday, November 26th, 2014

RSyntaxTextArea 2.5.4 (and all of its sister projects) are now available on GitHub, Maven and SourceForge!  The biggest change for all projects is the migration from Ant to Gradle for builds.  The primary motivation for this was to make it easier to create artifacts to put into Maven Central, as well as to tinker with something new.  Thus, this is the first release where everything is available in Maven on day 1!  Moving forward, artifacts in Maven will be a standard part of the RSTA release process.

But besides Maven integration, some other goodies were added too, such as syntax highlighting and code folding for Dart and D, as well as simple code completion for XML files.  Check it out!

Code Completion in XML

Friday, October 10th, 2014

I’ve been really, really lazy with adding code completion via DTDs and/or schemas for XML in RSTALanguageSupport, so in the meantime I decoded to add a simpler element/attribute completion scheme.

If you grab the latest from Git, RSTALanguageSupport’s XML support will now offer code completion suggestions for XML element and attribute names:

XML Element Completion

XML Element Completion

How does it decide what to suggest?

For element names, it scans the editor’s contents for any other elements that start with the prefix you’ve typed so far.  For attributes, it scans for other places where you’ve completed an element of the type you’re adding an attribute for; it then suggests any attributes you’ve used for that element elsewhere in the file (and haven’t currently used in the current element):

XML Attribute Completion

XML Attribute Completion

This kind of completion support is pretty handy when you’re editing a larger document, and know you’ve done “the right thing” elsewhere in the file, but cannot recall what it is offhand.  Just let RSTA tell you what to type.  :)

 

D support added to RSyntaxTextArea

Saturday, September 13th, 2014

RSyntaxTextArea now supports syntax highlighting and code folding for D.  Nestable comments are handled properly.  The screenshot below shows some of D’s unique syntax features:

D syntax highlighting

D syntax highlighting

Dart Support added to RSyntaxTextArea

Monday, September 1st, 2014

Syntax highlighting and code folding has just been added for Dart.  Dart aficionados, clone the RSTA repo and let me know if I’ve missed anything with the highlighting!

Dart Support

Dart Support

RSyntaxTextArea 2.5.3 Released!

Sunday, June 29th, 2014

RSyntaxTextArea 2.5.3 was just released on GitHub!  Here’s what’s new:

RSyntaxTextArea:

  1. Improvements to PHP syntax highlighting.
  2. In HTML and XML, “mark occurrences” should match tag names even when the caret is in an attribute, not just when it is in the tag name itself.
  3. Java syntax highlighting updated for Java 8 classes, interfaces, and enums.
  4. SQL: matching opening/closing parens are now highlighted.
  5. Fixed several bugs.

AutoComplete:

  • Only minor changes to support/stay in sync with RSyntaxTextArea 2.5.3.

RSTAUI:

  • Only minor changes to support/stay in sync with RSyntaxTextArea 2.5.3.

RSTALanguageSupport:

  1. Improvements to CSS code completion.
  2. Improvements to PHP code completion.  Documentation for many functions is now included.
  3. JavaScriptOutlineTree now understands basic JavaScript OO paradigms much better.

SpellChecker:

  • Only minor changes to support/stay in sync with RSyntaxTextArea 2.5.3.

TokenMakerMaker:

  • Added “Recent Files” sub-menu to the File menu.
  • Added an option to install a theme on the RSTA editor when previewing changes to a TokenMaker.
  • Bumped version number in the About dialog to “1.0″ to match that in the documentation.

Enjoy!

 

JavaScript Outline Tree is getting smarter

Sunday, June 8th, 2014

The JavaScriptOutlineTree class is getting smarter in the next release of RSTALanguageSupport.

As previously reported a little while ago, the outline tree has recently been able to recognize JS classes created by defining members on a prototype.  That functionality has just been extended in a couple of ways:  first, defining an entire prototype at once is now handled correctly (e.g. adding all fields to a prototype at once):

Recognizing prototypes

Recognizing prototypes

Next, Object.create() is parsed properly; all property descriptors passed in as the second argument to the method are properly added to the desired prototype:

Recognizing Object.create()

Recognizing Object.create()

Further, as the JS parser is smart enough to figure this stuff out now, you can quickly navigate to these newly-identified class members via Ctrl+Shift+O.  Pretty nice!

Only a couple of new things might get added before the next release – code completion for built-in objects such as Math, Object, JSON, etc.  Beyond that, I’d like to add some form of language support for Angular and possibly jQuery, but we’ll see.  As a large part of the JS language support was written by someone other than myself, who hasn’t been active recently, it might take a little bit of time for me to figure out the best way to add such features in (the JS language support is currently designed to support code completion for server-side scripting as well as browser-based JS work, so things aren’t as simple as they might seem).

RSyntaxTextArea 2.5.2 Released!

Sunday, March 9th, 2014

RSyntaxTexArea 2.5.2 was just released on GitHub!  Here’s what’s new:

RSyntaxTextArea:

  1. Whether or not curly braces denote code blocks is now handled on a language-index level, not per TokenMaker. This means TokenMakers such as HTML, JSP, and PHP can provide auto-indentation and curly brace closing for ‘sub-languages’ such as JSP and CSS.
  2. Java syntax highlighting updated for Java 8 classes, interfaces, and enums.
  3. Added “mark occurrences” support for HTML.
  4. Curly braces can now be automatically closed when editing CSS.
  5. The SearchEngine class now automatically selects the next match after a Replace operation.
  6. Fixed errors when loading/saving Theme XML.
  7. Fixed several bugs.

AutoComplete:

  • Only minor changes to support/stay in sync with RSyntaxTextArea 2.5.2.

RSTAUI:

  • After doing a “replace” operation with the Replace tool bar, the next valid replacement region is selected in the editor.

RSTALanguageSupport:

  1. The JavaScript language support can now use JSHint for its squiggle underlining of errors and warnings. A .jshintrc file can be specified to override the default JSHint behavior.
  2. CSS code completion.
  3. Fixing bug in XML outline tree for XML files with DTDs specified.

The SpellChecker library was not updated; the 2.5.1 release is still the most current, and is compatible with RSTA 2.5.2.  The idea is that the most recent 2.5.x versions of all of the sister libraries are all compatible with one another.

Enjoy!

CSS Code Completion

Tuesday, December 24th, 2013

Code completion for CSS files has been added to RSTALanguageSupport.  Icons were graciously borrowed from Eclipse (as usual).

You get code completion for at-rules and HTML tags for selectors:

at-rules and HTML tags

at-rules and HTML tags

As well as property names:

Property Completions

Property Completions

And for certain properties, you’ll also get code completion for their values:

Value Completions

Value Completions

By default, the completion popup is automatically triggered (after a delay) when typing the “@” character for at-rules, and when typing ‘:’ or a space after a property name.  As always, this is configurable.

Moving forward, short documentation for each CSS property (and values too!) would be awesome.  If anyone has time or motivation and wants to contribute, pull requests or patches are welcome!

RSyntaxTextArea and RText 2.5.1 released!

Wednesday, November 13th, 2013

Both RSyntaxTextArea (and its sister projects) and RText have brand new 2.5.1 releases available on GitHub and SourceForge!  The RSTA updates fixed a couple of bugs that had crept into the library in the 2.5.0 release.  RText (which hasn’t seen an update in a few months) is now using the latest, greatest RSTA libraries, which also means it’s using the slick new search toolbars I blogged about previously.

Check ‘em out!

Search API Updates

Sunday, September 22nd, 2013

The next release of RSyntaxTextArea and RSTAUI will feature some enhancements to the Search API.

Find and Replace operations were always done through the SearchEngine class.  This class contained the following static methods:


   public static boolean find(JTextArea textArea, SearchContext context)
   public static boolean replace(RTextArea textArea, SearchContext context)
   public static int replaceAll(RTextArea textArea, SearchContext context)

The find() and replace() methods returned whether a match was found/replaced, and the replaceAll() method returned the number of replacements performed.

In order to do a “mark all”, you had to call a method on an RTextArea instance:


   public int markAll(String toMark, boolean matchCase, boolean wholeWord, boolean regex)
   public void clearMarkAllHighlights()

In the next release of RSTA, the “mark all” API will be moved into SearchEngine, so that it is a one-stop shop for everything related to search. Further, these methods will return a new SearchResult object, containing more uniform, detailed information on the result of the operation.

The find() and replace() methods will now check context.getMarkAll(), and if it returns true, they will automatically perform a “mark all” operation along with the find/replace requested. This is very useful because often, people want to visually see what other matches are nearby the one actually found and selected.

The search-related components in RSTAUI have been updated as well. Besides the existing Find and Replace dialogs, there are now two new components – FindToolBar and ReplaceToolBar. When wrapped in a CollapsibleSectionPanel, these tool bars can provide a search UI integrated into an application’s main window, as opposed to the standard approach of modal dialogs. This is the trendy new way of doing things. In addition, these components use an animation to “slide” in and out of the UI, breathing a little bit of life into a Swing application.

Below is an example of setting up a window where Ctrl+F and Ctrl+H will bring up a FindToolBar and ReplaceToolBar, respectively:

   JPanel contentPane = new JPanel(new BorderLayout());
   frame.setContentPane(contentPane);
   JMenuBar mb = new JMenuBar();
   frame.setJMenuBar(mb);
   JMenu menu = new JMenu("Search");
   mb.add(menu);
   // Create our search tool bars and tie their search contexts together.
   findToolBar = new FindToolBar(this);
   replaceToolBar = new ReplaceToolBar(this);
   replaceToolBar.setSearchContext(findToolBar.getSearchContext());
   // Add our search tool bars to the "collapsible section panel."
   // Ctrl+F and Ctrl+H will display these tool bars. Use the returned actions to
   // create menu items for our application menu bar.
   CollapsibleSectionPanel csp = new CollapsibleSectionPanel();
   contentPane.add(csp);
   int ctrl = getToolkit().getMenuShortcutKeyMask();
   KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F, ctrl);
   Action a = csp.addBottomComponent(ks, findToolBar);
   a.putValue(Action.NAME, "Find...");
   menu.add(new JMenuItem(a));
   ks = KeyStroke.getKeyStroke(KeyEvent.VK_H, ctrl);
   a = csp.addBottomComponent(ks, replaceToolBar);
   a.putValue(Action.NAME, "Replace...");
   menu.add(new JMenuItem(a));

Here’s an example of what the tool bars look like:

 

Find Tool Bar

Find Tool Bar

Replace Tool Bar

Replace Tool Bar

Ctrl+F/Ctrl+H toggles between them, and Escape hides the currently visible one, if any.  If “Mark All” is enabled, all matches are selected in the editor as you type, which is a very nice feature.  The “mark all” event waits for a short time after you stop typing before it fires (defaulting to 200 ms).  That way, it doesn’t perform a mark-all operation for each letter you type if you type really quickly.

Just like the older Find and Replace dialogs, the Find and Replace tool bars will offer code completion for regular expressions:

 

Regex assistance

Regex assistance

This code is already pushed to GitHub; all I have left to do is some more testing.  I also plan on improving the performance of “mark all;” it’s slower than the “mark occurrences” support in RSTA and there’s no reason for that.  And since these new components make it so easy and handy to have “mark all” enabled all the time, I figured I’d go ahead and knock that out sooner rather than later.