use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class SyncScrollSupport method scrollEditor.
public static void scrollEditor(@NotNull Editor editor, int logicalLine) {
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalLine, 0));
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.CENTER);
scrollingModel.enableAnimation();
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class FoldingTransformation method transform.
public int transform(int line) {
FoldRegion foldRegion = findFoldRegion(line);
int yOffset = 0;
if (foldRegion != null) {
int startLine = getStartLine(foldRegion);
yOffset = (int) ((double) (line - startLine) / getLineLength(foldRegion) * myEditor.getLineHeight());
line = startLine;
}
yOffset += myEditor.logicalPositionToXY(new LogicalPosition(line, 0)).y;
final JComponent header = myEditor.getHeaderComponent();
int headerOffset = header == null ? 0 : header.getHeight();
return yOffset - myEditor.getScrollingModel().getVerticalScrollOffset() + headerOffset;
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class EditorGotoLineNumberDialog method doOKAction.
protected void doOKAction() {
Coordinates coordinates = getCoordinates();
if (coordinates == null)
return;
LogicalPosition position = new LogicalPosition(coordinates.row, coordinates.column);
myEditor.getCaretModel().removeSecondaryCarets();
myEditor.getCaretModel().moveToLogicalPosition(position);
myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
myEditor.getSelectionModel().removeSelection();
IdeFocusManager.getGlobalInstance().requestFocus(myEditor.getContentComponent(), true);
super.doOKAction();
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class EditorView method isRtlLocation.
public boolean isRtlLocation(@NotNull VisualPosition visualPosition) {
assertIsDispatchThread();
if (myDocument.getTextLength() == 0)
return false;
LogicalPosition logicalPosition = visualToLogicalPosition(visualPosition);
int offset = logicalPositionToOffset(logicalPosition);
if (myEditor.getSoftWrapModel().getSoftWrap(offset) != null) {
VisualPosition beforeWrapPosition = offsetToVisualPosition(offset, true, true);
if (visualPosition.line == beforeWrapPosition.line && (visualPosition.column > beforeWrapPosition.column || visualPosition.column == beforeWrapPosition.column && visualPosition.leansRight)) {
return false;
}
VisualPosition afterWrapPosition = offsetToVisualPosition(offset, false, false);
if (visualPosition.line == afterWrapPosition.line && (visualPosition.column < afterWrapPosition.column || visualPosition.column == afterWrapPosition.column && !visualPosition.leansRight)) {
return false;
}
}
int line = myDocument.getLineNumber(offset);
LineLayout layout = myTextLayoutCache.getLineLayout(line);
return layout.isRtlLocation(offset - myDocument.getLineStartOffset(line), logicalPosition.leansForward);
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class IndentsModelImpl method getCaretIndentGuide.
@Override
public IndentGuideDescriptor getCaretIndentGuide() {
final LogicalPosition pos = myEditor.getCaretModel().getLogicalPosition();
final int column = pos.column;
final int line = pos.line;
if (column > 0) {
for (IndentGuideDescriptor indent : myIndents) {
if (column == indent.indentLevel && line >= indent.startLine && line < indent.endLine) {
return indent;
}
}
}
return null;
}
Aggregations