Performing caret row background repainting at soft wrap-introduced virutal space if necessary

This commit is contained in:
Denis Zhdanov
2010-12-02 16:55:09 +03:00
parent fc322a6228
commit 2ad71fb92a
@@ -1456,7 +1456,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
borderEffect.paintHighlighters(docMarkup.getAllHighlighters());
borderEffect.paintHighlighters(getMarkupModel().getAllHighlighters());
paintCaretCursor(g);
paintComposedTextDecoration((Graphics2D)g);
}
@@ -1672,9 +1672,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return;
}
myLastBackgroundPosition = null;
myLastBackgroundColor = null;
boolean locateBeforeSoftWrap = !SoftWrapHelper.isCaretAfterSoftWrap(this);
int start = logicalPositionToOffset(logicalPosition);
getSoftWrapModel().registerSoftWrapsIfNecessary(clip, start);
getSoftWrapModel().registerSoftWrapsIfNecessary();
// There is a possible case that we need to draw background from the start of soft wrap-introduced visual line. Given position
// has valid 'y' coordinate then at it shouldn't be affected by soft wrap that corresponds to the visual line start offset.
@@ -1682,8 +1685,15 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
TIntHashSet softWrapsToSkip = new TIntHashSet();
SoftWrap softWrap = getSoftWrapModel().getSoftWrap(start);
if (softWrap != null) {
position.x = softWrap.getIndentInPixels();
softWrapsToSkip.add(softWrap.getStart());
if (position.y == getCaretModel().getVisualPosition().line * getLineHeight()) {
// There is a possible case that target clip points to soft wrap-introduced visual line and that it's an active
// line (caret cursor is located on it). We want to draw corresponding 'caret line' background for soft wraps-introduced
// virtual space then.
Color caretRowColor = getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR);
drawBackground(g, caretRowColor, softWrap.getIndentInPixels(), position, defaultBackground, clip);
}
position.x = softWrap.getIndentInPixels();
}
IterationState iterationState = new IterationState(this, start, paintSelection());
@@ -1694,9 +1704,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return;
}
myLastBackgroundPosition = null;
myLastBackgroundColor = null;
TextAttributes attributes = iterationState.getMergedAttributes();
Color backColor = getBackgroundColor(attributes);
int fontType = attributes.getFontType();
@@ -1842,7 +1849,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
private int drawSoftWrapAwareBackground(Graphics g, Color backColor, CharSequence text, int start, int end, Point position,
int fontType, Color defaultBackground, Rectangle clip, TIntHashSet processSoftWrap,
int fontType, Color defaultBackground, Rectangle clip, TIntHashSet softWrapsToSkip,
boolean[] caretRowPainted)
{
int startToUse = start;
@@ -1856,7 +1863,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
List<? extends SoftWrap> softWraps = getSoftWrapModel().getSoftWrapsForRange(start, softWrapRetrievalEndOffset);
for (SoftWrap softWrap : softWraps) {
int softWrapStart = softWrap.getStart();
if (processSoftWrap.contains(softWrapStart)) {
if (softWrapsToSkip.contains(softWrapStart)) {
continue;
}
if (startToUse < softWrapStart) {