RSyntaxTextArea
Quick Links
- Try the applet demo.
- Download the latest stable release at its SourceForge page.
- Browse the Javadoc.
- View the source code online.
- Check out a copy from the Subversion repository.
- Peruse the examples and tutorials page. Eclipse project source code is included for the examples. Please be aware that this is a work in progress, and we're adding to it whenever we can!
What is it?
RSyntaxTextArea was originally part of the RText programmer's text editor, but is currently being made into a separate component, reusable in any Swing application.
Requires Java 1.4 or greater.
A forum is now available for questions, comments and feedback. Bug reports should probably go to the project's SourceForge page.
Downloads can be found on SourceForge, or you can grab the bleeding edge from the Subversion repository.
It is available under the LGPL.
For a simple example of using RSyntaxTextArea in a Java application, look here.Features
RSyntaxTextArea's feature set includes:
- Syntax highlighting for over 20 programming languages
- Code completion
- Find/Replace with standard options (regex, match case, etc.).
- Loading and saving of local or remote files (via FTP).
- User-defined macros
- Code templates
- Unlimited undo/redo
- Drag and drop
- Edit with multiple fonts simultaneously
- Bracket matching
- Current line highlighting
- Clickable hyperlinks (only certain languages)
What's New
12/29/2008:
- A code completion add-on library has been added to Subversion. While in its early stages, this library still provides an incredible usability boost for people writing IDE's or editors for languages with many keywords, constructs, etc. I hope to have ctags file parsing support integrated into code completion soon.
12/19/2008:
- I wasn't planning on doing another "official" release so quickly, but there have been some important enhancements in the flexibility department lately, so I decided to go ahead and get them out there before the holidays in case I get busy. Version 1.2 is not available on SourceForge. This release also fixes an input bug on Macs using a non-English keyboard layout. Thanks to David at Jalbum for pointing out the issue!
- RSyntaxDocument is no longer hard-coded with what syntax styles it knows about. It now uses a TokenMakerFactory. These factories can be installed on RSyntaxDocuments to change what languages can be syntax highlighted. This helps facilitate adding custom languages, as well as removing built-in languages that are not needed.
- Since syntax styles are no longer hard-coded into the editor, users can remove any *TokenMaker classes from rsyntaxtextarea.jar that they do not use in their application. This makes for a smaller footprint for the library in many use cases.
- More changes in SVN to make the editor more configurable. The popup menu is now modifiable via the createPopupMenu() and sePopupMenu() methods. There is also a configurePopupMenu() method that is called whever the popup is about to be displayed, for context-specific modifications, etc. Note that we don't use the 1.5 context menu API added to JComponent since RSyntaxTextArea also runs on 1.4, but our API is slightly more flexible.
- Code templates can be removed at runtime, not just added.
- The demo jar is now executable, so double-clicking on it in Windows should launch a standalone version of the demo (it used to be just an applet, so downloading it wasn't very useful).
- Version 1.1 has been released! You can download it directly from SourceForge. This release includes all of the changes I've outlined in the past couple of months. I've updated the javadoc to reflext this release.
- Code cleanup.
- Preparation for smart indent.
- Expect a 1.1 release very soon.
- Changing the encoding or line separator of a TextEditorPane now marks the editor as dirty, and listeners are notified.
- RSyntaxTextAreaDemo changes the source being displayed to match the language being displayed (e.g. Perl source is displayed when "Perl" is selected, etc.).
- Other minor cleanup.
- Big changes this time. Don't know how stable SVN is at the moment, but feel free to try it out.
- Added TextEditorPane class. This is basically a wrapper around RSyntaxTextArea that provides functionality needed in virtually all text editors - loading & saving, managing dirty state of editor, etc. Properties are fired to allow for hosting applications to react to these events.
- Remote URL's can be loaded & edited in TextEditorPanes, not just local files. This allows for editing files on another machine via FTP, for example. This functionality is not well tested and is not yet guaranteed to always work.
- Fixed a bug in reading Unicode files if "UTF-16" was the encoding specified to UnicodeReader ("UTF-16LE" and "UTF-16BE" were always fine).
- Improved hyperlink support. URL highlighting now follows URL spec and should now highlight all (?) hyperlinks. C++ also now supports hyperlinks in comments.
- Added initial hyperlink support in SVN. Host applications can add javax.swing.text.HyperlinkListeners to the editor and get notified when the user clicks on a hyperlink (e.g. Ctrl+Click). This is done on a per-syntax basis and currently only C and Java support hyperlinks..
- Added makefile and Ruby syntax highlighting in SVN.
- Removed from RText and made into its own separate project.