mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reverted
This commit is contained in:
@@ -306,7 +306,7 @@ public class EditorUtil {
|
||||
// hence, we need to perform special calculations to get know that.
|
||||
EditorEx editorImpl = (EditorEx)editor;
|
||||
int offset = start;
|
||||
IterationState state = new IterationState(editorImpl, start, end, false);
|
||||
IterationState state = new IterationState(editorImpl, offset, false);
|
||||
int fontType = state.getMergedAttributes().getFontType();
|
||||
int column = currentColumn[0];
|
||||
int spaceSize = getSpaceWidth(fontType, editorImpl);
|
||||
|
||||
@@ -929,25 +929,24 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
int textLength = myDocument.getTextLength();
|
||||
LogicalPosition logicalPosition = visualToLogicalPosition(new VisualPosition(line, 0));
|
||||
int offset = logicalPositionToOffset(logicalPosition);
|
||||
int textLength = myDocument.getTextLength();
|
||||
|
||||
if (offset >= textLength) return new VisualPosition(line, EditorUtil.columnsNumber(p.x, EditorUtil.getSpaceWidth(Font.PLAIN, this)));
|
||||
|
||||
// There is a possible case that starting logical line is split by soft-wraps and it's part after the split should be drawn.
|
||||
// We mark that we're under such circumstances then.
|
||||
boolean activeSoftWrapProcessed = logicalPosition.softWrapLinesOnCurrentLogicalLine <= 0;
|
||||
boolean activeSoftWrapProcessed = true;
|
||||
if (logicalPosition.softWrapLinesOnCurrentLogicalLine > 0) {
|
||||
activeSoftWrapProcessed = false;
|
||||
}
|
||||
|
||||
int column = 0;
|
||||
int prevX = 0;
|
||||
CharSequence text = myDocument.getCharsNoThreadCheck();
|
||||
char c = ' ';
|
||||
|
||||
LogicalPosition endLogicalPosition = visualToLogicalPosition(new VisualPosition(line+1, 0));
|
||||
int endOffset = logicalPositionToOffset(endLogicalPosition);
|
||||
|
||||
IterationState state = new IterationState(this, offset, endOffset, false);
|
||||
IterationState state = new IterationState(this, offset, false);
|
||||
|
||||
int fontType = state.getMergedAttributes().getFontType();
|
||||
int spaceSize = EditorUtil.getSpaceWidth(fontType, this);
|
||||
@@ -1246,7 +1245,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int offset = startOffset;
|
||||
CharSequence text = myDocument.getCharsNoThreadCheck();
|
||||
int textLength = myDocument.getTextLength();
|
||||
IterationState state = new IterationState(this, startOffset, startOffset + length, false);
|
||||
IterationState state = new IterationState(this, offset, false);
|
||||
int fontType = state.getMergedAttributes().getFontType();
|
||||
int spaceSize = EditorUtil.getSpaceWidth(fontType, this);
|
||||
|
||||
@@ -1810,9 +1809,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int visibleLineNumber = clip.y / lineHeight;
|
||||
|
||||
VisualPosition visualPosition = xyToVisualPosition(new Point(0, clip.y));
|
||||
VisualPosition endVisualPosition = xyToVisualPosition(new Point(0, clip.y+clip.height));
|
||||
LogicalPosition logicalPosition = visualToLogicalPosition(visualPosition);
|
||||
LogicalPosition endLogicalPosition = visualToLogicalPosition(endVisualPosition);
|
||||
|
||||
Point position = new Point(0, visibleLineNumber * lineHeight);
|
||||
if (visualPosition.line == 0 && myPrefixText != null) {
|
||||
@@ -1830,10 +1827,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
|
||||
boolean locateBeforeSoftWrap = !SoftWrapHelper.isCaretAfterSoftWrap(this);
|
||||
int start = logicalPositionToOffset(logicalPosition);
|
||||
int end = logicalPositionToOffset(endLogicalPosition);
|
||||
getSoftWrapModel().registerSoftWrapsIfNecessary();
|
||||
|
||||
IterationState iterationState = new IterationState(this, start, end, paintSelection());
|
||||
IterationState iterationState = new IterationState(this, start, paintSelection());
|
||||
|
||||
LineIterator lIterator = createLineIterator();
|
||||
lIterator.start(start);
|
||||
@@ -2262,10 +2258,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
// position is expected to be set to null as an indication that no soft wrap-introduced visual lines should be skipped on
|
||||
// current painting iteration.
|
||||
Ref<LogicalPosition> logicalPosition = new Ref<LogicalPosition>(xyToLogicalPosition(new Point(0, clip.y)));
|
||||
LogicalPosition endLogicalPosition = xyToLogicalPosition(new Point(0, clip.y + clip.height));
|
||||
int startLineNumber = logicalPosition.get().line;
|
||||
int start = logicalPositionToOffset(logicalPosition.get());
|
||||
int end = logicalPositionToOffset(endLogicalPosition);
|
||||
|
||||
Point position = new Point(0, visibleLineNumber * lineHeight);
|
||||
if (startLineNumber == 0 && myPrefixText != null) {
|
||||
@@ -2278,7 +2272,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
return;
|
||||
}
|
||||
|
||||
IterationState iterationState = new IterationState(this, start, end, paintSelection());
|
||||
IterationState iterationState = new IterationState(this, start, paintSelection());
|
||||
LineIterator lIterator = createLineIterator();
|
||||
lIterator.start(start);
|
||||
if (lIterator.atEnd()) {
|
||||
@@ -2336,8 +2330,14 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
|
||||
}
|
||||
else {
|
||||
position.x = drawStringWithSoftWraps(g, chars, start, Math.min(hEnd, lEnd - lIterator.getSeparatorLength()) , position, clip,
|
||||
effectColor, effectType, fontType, currentColor, logicalPosition);
|
||||
if (hEnd > lEnd - lIterator.getSeparatorLength()) {
|
||||
position.x = drawStringWithSoftWraps(g, chars, start, lEnd - lIterator.getSeparatorLength(), position, clip,
|
||||
effectColor, effectType, fontType, currentColor, logicalPosition);
|
||||
}
|
||||
else {
|
||||
position.x = drawStringWithSoftWraps(g, chars, start, hEnd, position, clip, effectColor, effectType, fontType,
|
||||
currentColor, logicalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
iterationState.advance();
|
||||
@@ -3054,11 +3054,11 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
int start = myDocument.getLineStartOffset(pos.line);
|
||||
if (pos.column == 0) return start;
|
||||
int end = myDocument.getLineEndOffset(pos.line);
|
||||
|
||||
CharSequence text = myDocument.getCharsNoThreadCheck();
|
||||
|
||||
if (pos.column == 0) return start;
|
||||
return EditorUtil.calcOffset(this, text, start, end, pos.column, EditorUtil.getTabSize(this));
|
||||
}
|
||||
|
||||
@@ -5518,7 +5518,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
final CharSequence text = myDocument.getCharsNoThreadCheck();
|
||||
int documentLength = myDocument.getTextLength();
|
||||
int end = myDocument.getTextLength();
|
||||
int x = 0;
|
||||
boolean lastLineLengthCalculated = false;
|
||||
final int fontSize = myScheme.getEditorFontSize();
|
||||
@@ -5548,19 +5548,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
int endLine;
|
||||
for (endLine=line+1; endLine<lineCount;endLine++) {
|
||||
if (myLineWidths.getQuick(endLine) != -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int endOffset = endLine==lineCount ? documentLength : myDocument.getLineEndOffset(endLine);
|
||||
IterationState state = new IterationState(EditorImpl.this, offset, endOffset, false);
|
||||
IterationState state = new IterationState(EditorImpl.this, offset, false);
|
||||
int fontType = state.getMergedAttributes().getFontType();
|
||||
|
||||
int maxPreviousSoftWrappedWidth = -1;
|
||||
|
||||
while (offset < documentLength && line < lineCount) {
|
||||
while (offset < end && line < lineCount) {
|
||||
char c = text.charAt(offset);
|
||||
if (offset >= state.getEndOffset()) {
|
||||
state.advance();
|
||||
@@ -5662,7 +5655,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
public int calcColumnNumber(CharSequence text, int start, int offset, int tabSize) {
|
||||
IterationState state = new IterationState(this, start, start+offset, false);
|
||||
IterationState state = new IterationState(this, start, false);
|
||||
int fontType = state.getMergedAttributes().getFontType();
|
||||
int column = 0;
|
||||
int x = 0;
|
||||
|
||||
@@ -73,14 +73,11 @@ public final class IterationState {
|
||||
private final EditorEx myEditor;
|
||||
private final Color myReadOnlyColor;
|
||||
|
||||
public IterationState(@NotNull EditorEx editor, int start, boolean useCaretAndSelection) {
|
||||
this(editor, start, editor.getDocument().getTextLength(), useCaretAndSelection);
|
||||
}
|
||||
public IterationState(@NotNull EditorEx editor, int start, int end, boolean useCaretAndSelection) {
|
||||
public IterationState(EditorEx editor, int start, boolean useCaretAndSelection) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
myDocument = (DocumentEx)editor.getDocument();
|
||||
myStartOffset = start;
|
||||
myEnd = end;
|
||||
myEnd = editor.getDocument().getTextLength();
|
||||
myEditor = editor;
|
||||
|
||||
LOG.assertTrue(myStartOffset <= myEnd);
|
||||
@@ -108,10 +105,10 @@ public final class IterationState {
|
||||
myCurrentHighlighters = new ArrayList<RangeHighlighterEx>();
|
||||
|
||||
MarkupModelEx editorMarkup = (MarkupModelEx)editor.getMarkupModel();
|
||||
myView.init(editorMarkup, start, myEnd);
|
||||
myView.init(editorMarkup, start);
|
||||
|
||||
final MarkupModelEx docMarkup = (MarkupModelEx)editor.getDocument().getMarkupModel(editor.getProject());
|
||||
myDoc.init(docMarkup, start, myEnd);
|
||||
myDoc.init(docMarkup, start);
|
||||
|
||||
myEndOffset = myStartOffset;
|
||||
|
||||
@@ -122,8 +119,8 @@ public final class IterationState {
|
||||
private RangeHighlighterEx myNextHighlighter = null;
|
||||
private Iterator<RangeHighlighterEx> myIterator;
|
||||
|
||||
private void init(@NotNull MarkupModelEx markupModel, int start, int end) {
|
||||
myIterator = markupModel.overlappingIterator(start, end);
|
||||
private void init(MarkupModelEx markupModel, int start) {
|
||||
myIterator = markupModel.overlappingIterator(start, myDocument.getTextLength());
|
||||
int skipped = 0;
|
||||
while (myIterator.hasNext()) {
|
||||
RangeHighlighterEx highlighter = myIterator.next();
|
||||
@@ -133,10 +130,7 @@ public final class IterationState {
|
||||
}
|
||||
skipped++;
|
||||
}
|
||||
if (skipped > Math.min(1000, markupModel.getDocument().getTextLength())) {
|
||||
int i = 0;
|
||||
//LOG.error("Inefficient iteration, use 'new IterationState(start, end)' constructor to limit the number of highlighters to iterate");
|
||||
}
|
||||
int i = skipped;
|
||||
}
|
||||
|
||||
private void advance() {
|
||||
|
||||
Reference in New Issue
Block a user