jEdit Community - Resources for users of the jEdit Text Editor
Updating plugins to work with soft wrap
Submitted by slava on Saturday, 12 January, 2002 - 09:08
Converting offsets to screen locations
The following methods have been deprecated: yToLine(), lineToY(), xToOffset(), offsetToX(). These methods do not support the concept of one "physical" line being split over several "screen" lines.

Instead, you should now use the xyToOffset() and offsetToXY() methods.
A bonus of using these methods is that in most cases, there is no need to perform physical to virtual translation; these methods operate on offsets from the beginning of the buffer.

Text area extension API replaces highlighter API
The TextAreaHighlight class, and the addCustomHighlight() method in the TextAreaPainter and Gutter have been deprecated.

They have been replaced by a new TextAreaExtension class; yes, class, not interface, so methods can be added in the future without breaking compatibility. It has the following methods defined:

  • paintValidLine(Graphics2D gfx, int physicalLine, int start, int end, int y)
  • paintInvalidLine(Graphics2D gfx, int screenLine, int y)
  • getToolTipText(int x, int y)

A "valid" line is one that is in the buffer; "invalid" lines result when, for example, the buffer is shorter than the height of the text area. Most plugins will only paint stuff on valid lines, but some, like LineGuides, will want to paint over the whole text area.

The addCustomHighlight() method is replaced with an addExtension() method.

Physical, virtual and screen line numbers
Confused about physical, virtual and screen line numbers mentioned above? Here is a short description:

Ever since folding was added in jEdit 3.1, there have been two ways to number lines; "physical" and "virtual". Physical line numbers are counted from the beginning of the buffer in terms of newline characters; virtual line numbers are what's left after lines are hidden due to folding. And now, with 4.0pre4, you have "screen lines"; a single virtual line may be split into several screen lines, due to soft wrap. Furthermore, screen lines are numbered from the first visible line, not from the beginning of the buffer.

Most plugins will not need to deal with screen lines. Having said that, there are methods for working with screen lines in the JEditTextArea class, in the unlikely case you will need them:

  • getScreenLineOfOffset(int offset)
  • getScreenLineStartOffset(int line)
  • getScreenLineEndOffset(int line)
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300