use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class HintManagerImpl method showQuestionHint.
public void showQuestionHint(@NotNull final Editor editor, final int offset1, final int offset2, @NotNull final LightweightHint hint, @NotNull final QuestionAction action, @PositionFlags short constraint) {
final LogicalPosition pos1 = editor.offsetToLogicalPosition(offset1);
final LogicalPosition pos2 = editor.offsetToLogicalPosition(offset2);
final Point p = getHintPosition(hint, editor, pos1, pos2, constraint);
showQuestionHint(editor, p, offset1, offset2, hint, action, constraint);
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class SyncScrollSupport method syncVerticalScroll.
private static void syncVerticalScroll(@NotNull ScrollingContext context, @NotNull Rectangle newRectangle, @NotNull Rectangle oldRectangle) {
if (newRectangle.y == oldRectangle.y)
return;
EditingSides sidesContainer = context.getSidesContainer();
FragmentSide masterSide = context.getMasterSide();
FragmentSide masterDiffSide = context.getMasterDiffSide();
Editor master = sidesContainer.getEditor(masterSide);
Editor slave = sidesContainer.getEditor(masterSide.otherSide());
if (master == null || slave == null)
return;
if (master.isDisposed() || slave.isDisposed())
return;
int masterVerticalScrollOffset = master.getScrollingModel().getVerticalScrollOffset();
int slaveVerticalScrollOffset = slave.getScrollingModel().getVerticalScrollOffset();
Rectangle viewRect = master.getScrollingModel().getVisibleArea();
int middleY = viewRect.height / 3;
if (master.getDocument().getTextLength() == 0)
return;
LogicalPosition masterPos = master.xyToLogicalPosition(new Point(viewRect.x, masterVerticalScrollOffset + middleY));
int masterCenterLine = masterPos.line;
int scrollToLine = sidesContainer.getLineBlocks().transform(masterDiffSide, masterCenterLine);
int offset;
if (scrollToLine < 0) {
offset = slaveVerticalScrollOffset + newRectangle.y - oldRectangle.y;
} else {
int correction = (masterVerticalScrollOffset + middleY) % master.getLineHeight();
Point point = slave.logicalPositionToXY(new LogicalPosition(scrollToLine, masterPos.column));
offset = point.y - middleY + correction;
}
int deltaHeaderOffset = getHeaderOffset(slave) - getHeaderOffset(master);
doScrollVertically(slave.getScrollingModel(), offset + deltaHeaderOffset);
}
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 DiffWalkerAction method actionPerformed.
public void actionPerformed(AnActionEvent event) {
FocusDiffSide side = DiffUtil.getFocusDiffSide(event.getDataContext());
if (side == null)
return;
int line = getLineNumberToGo(side);
Editor editor = side.getEditor();
if (line >= 0 && editor != null) {
LogicalPosition pos = new LogicalPosition(line, 0);
editor.getCaretModel().removeSecondaryCarets();
editor.getCaretModel().moveToLogicalPosition(pos);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}
Aggregations