Common API

This section outlines API changes and enhancements which may affect both plugins and macros.

Syntax Highlighting

The org.gjt.sp.jedit.syntax package can now be used in other programs. All you need to provide is error handling and logic for locating the XML mode files. See the package documentation for details.

Text Area and Folding

The JEditTextArea class has a new addToLeftOfScrollBar() method that adds a component to the left of the scroll bar. Previously plugins like JDiff had to resort to undocumented hacks to do this.

The code that displays lines of text on screen has been overhauled for improved performance and correctness. As a result, two methods in JEditTextArea that have been deprecated since jEdit 4.0 were removed:

  • xToOffset()

  • offsetToX()

As in jEdit 4.0 and 4.1, the xyToOffset() and offseToXY() methods replace these two.

Also, the way folds are handled has changed. The FoldVisibilityManager class has been removed, and a number of methods in the JEditTextArea class have been removed also:

  • virtualToPhysical()

  • physicalToVirtual()

  • getVirtualLineCount()

The replacement for the FoldVisibilityManager class is a class named DisplayManager, with a similar but not identical API.

Previously, a “virtual line number” was a line number such that each physical line (delimited by \n) counted as 1 if it was visible, and 0 if it was not. They did not take into account lines that were split on screen as a result of soft wrap, and this made the soft wrap scrolling code rather complicated.

In jEdit 4.2, virtual line numbers are no longer used internally; now, similar “scroll line numbers” are used. Scroll line numbers take both hidden lines and soft wrap into account. The getFirstLine() and setFirstLine() methods of the JEditTextArea class now work with scroll line numbers.

An internal API for converting between scroll line numbers and physical line numbers exists, but it is rather complicated and it will not be made public. Instead, if you want the text area to scroll to a given physical line number, use the new setFirstPhysicalLine() method in the JEditTextArea class.

Miscellaneous API Changes

A new View.goToBuffer() method has been added. If the specified buffer is already visible in one of the view's edit panes, it sends focus to that edit pane. Otherwise, it calls setBuffer() on the current edit pane.

The constructor of the EBMessage class now takes an Object, as opposed to an EBComponent. Plugins that provide custom message types will need to be recompiled.

The following deprecated method was removed from the GUIUtilities class:

void loadMenu(View view, String name);