Element root = doc.getDefaultRootElement();
int topPosition = textArea.viewToModel(
new Point(visibleRect.x,visibleRect.y));
int topLine = root.getElementIndex(topPosition);
int cellHeight = textArea.getLineHeight();
FoldManager fm = ((RSyntaxTextArea)textArea).getFoldManager();
// Compute the y at which to begin painting text, taking into account
// that 1 logical line => at least 1 physical line, so it may be that
// y<0. The computed y-value is the y-value of the top of the first
// (possibly) partially-visible view.
Rectangle visibleEditorRect = ui.getVisibleEditorRect();
Rectangle r = LineNumberList.getChildViewBounds(v, topLine,
visibleEditorRect);
int y = r.y;
y += (cellHeight-collapsedFoldIcon.getIconHeight())/2;
int visibleBottom = visibleRect.y + visibleRect.height;
int x = width - 10;
int line = topLine;
boolean paintingOutlineLine = foldWithOutlineShowing!=null &&
foldWithOutlineShowing.containsLine(line);
int lineCount = root.getElementCount();
while (y<visibleBottom && line<lineCount) {
int curLineH = LineNumberList.getChildViewBounds(v, line,
visibleEditorRect).height;
if (paintingOutlineLine) {
g.setColor(getForeground());
int w2 = width/2;
if (line==foldWithOutlineShowing.getEndLine()) {
int y2 = y + curLineH - cellHeight/2;
g.drawLine(w2,y, w2,y2);
g.drawLine(w2,y2, width-2,y2);
paintingOutlineLine = false;
}
else {
g.drawLine(w2,y, w2,y+curLineH);
}
}
Fold fold = fm.getFoldForLine(line);
if (fold!=null) {
if (fold==foldWithOutlineShowing && !fold.isCollapsed()) {
g.setColor(getForeground());
int w2 = width/2;
g.drawLine(w2,y+cellHeight/2, w2,y+curLineH);