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

Instead of calling `FoldHandler.registerFoldHandler()` in your plugin's `start()` method, add entries in the `services.xml` file that look like so:

    <SERVICE CLASS="org.gjt.sp.jedit.buffer.FoldHandler" NAME="sidekick">
        new sidekick.SideKickFoldHandler()
    </SERVICE>