@NotNull @Override public VisualPosition build(@NotNull EditorPosition position) { int diff = myTargetLogical.column - position.logicalColumn; position.logicalColumn += diff; position.visualColumn += diff; position.offset += diff; return position.buildVisualPosition(); }
@Override public VisualPosition processSoftWrap(@NotNull EditorPosition position, SoftWrap softWrap) { position.visualColumn = softWrap.getIndentInColumns(); position.softWrapColumnDiff += softWrap.getIndentInColumns(); if (position.logicalLine < myTargetLogical.line || position.logicalColumn != myTargetLogical.column) { return null; } return position.buildVisualPosition(); }
@Override protected VisualPosition buildIfExceeds(EditorPosition context, TabData tabData) { if (context.logicalLine < myTargetLogical.line) { return null; } int diff = myTargetLogical.column - context.logicalColumn; if (diff >= tabData.widthInColumns) { return null; } context.logicalColumn += diff; context.visualColumn += diff; return context.buildVisualPosition(); }
@Override protected VisualPosition buildIfExceeds(EditorPosition position, int offset) { if (position.logicalLine < myTargetLogical.line) { return null; } int diff = myTargetLogical.column - position.logicalColumn; if (offset - position.offset < diff) { return null; } position.visualColumn += diff; // Don't update other dimensions like logical position and offset because we need only visual // position here. return position.buildVisualPosition(); }
@Override protected VisualPosition buildIfExceeds( @NotNull EditorPosition context, @NotNull FoldRegion foldRegion) { int foldEndLine = myEditor.getDocument().getLineNumber(foldRegion.getEndOffset()); if (myTargetLogical.line > foldEndLine) { return null; } if (myTargetLogical.line < foldEndLine) { // Map all logical position that point inside collapsed fold region to visual position of its // start. return context.buildVisualPosition(); } FoldingData data = getFoldRegionData(foldRegion); int foldEndColumn; if (data == null) { int xStart = myEditor.getDocument().getLineNumber(foldRegion.getStartOffset()) == foldEndLine ? context.x : 0; foldEndColumn = myRepresentationHelper.toVisualColumnSymbolsNumber( myEditor.getDocument().getCharsSequence(), foldRegion.getStartOffset(), foldRegion.getEndOffset(), xStart); } else { foldEndColumn = data.getCollapsedSymbolsWidthInColumns(); } if (foldEndLine == context.logicalLine) { // Single-line fold region. foldEndColumn += context.logicalColumn; } if (foldEndColumn <= myTargetLogical.column) { return null; } // Map all logical position that point inside collapsed fold region to visual position of its // start. return context.buildVisualPosition(); }