Search in sources :

Example 86 with LogicalPosition

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();
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) ScrollingModel(com.intellij.openapi.editor.ScrollingModel)

Example 87 with LogicalPosition

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;
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) FoldRegion(com.intellij.openapi.editor.FoldRegion)

Example 88 with LogicalPosition

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();
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition)

Example 89 with LogicalPosition

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);
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) VisualPosition(com.intellij.openapi.editor.VisualPosition)

Example 90 with LogicalPosition

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;
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) IndentGuideDescriptor(com.intellij.openapi.editor.IndentGuideDescriptor)

Aggregations

LogicalPosition (com.intellij.openapi.editor.LogicalPosition)97 Document (com.intellij.openapi.editor.Document)12 PsiElement (com.intellij.psi.PsiElement)12 Editor (com.intellij.openapi.editor.Editor)11 TextRange (com.intellij.openapi.util.TextRange)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 EditorEx (com.intellij.openapi.editor.ex.EditorEx)7 NotNull (org.jetbrains.annotations.NotNull)6 CaretModel (com.intellij.openapi.editor.CaretModel)5 RelativePoint (com.intellij.ui.awt.RelativePoint)5 JSFile (com.intellij.lang.javascript.psi.JSFile)4 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)4 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)4 Project (com.intellij.openapi.project.Project)4 PsiFile (com.intellij.psi.PsiFile)4 PsiReference (com.intellij.psi.PsiReference)4 PsiMultiReference (com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference)4 Mark (com.maddyhome.idea.vim.common.Mark)4 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)3 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)3