use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class DebuggerUIUtil method calcPopupLocation.
@Deprecated
public static RelativePoint calcPopupLocation(@NotNull Editor editor, final int line) {
Point p = editor.logicalPositionToXY(new LogicalPosition(line + 1, 0));
final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
if (!visibleArea.contains(p)) {
p = new Point((visibleArea.x + visibleArea.width) / 2, (visibleArea.y + visibleArea.height) / 2);
}
return new RelativePoint(editor.getContentComponent(), p);
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class VisibleHighlightingPassFactory method calculateVisibleRange.
@NotNull
public static ProperTextRange calculateVisibleRange(@NotNull Editor editor) {
Rectangle rect = editor.getScrollingModel().getVisibleArea();
LogicalPosition startPosition = editor.xyToLogicalPosition(new Point(rect.x, rect.y));
int visibleStart = editor.logicalPositionToOffset(startPosition);
LogicalPosition endPosition = editor.xyToLogicalPosition(new Point(rect.x + rect.width, rect.y + rect.height));
int visibleEnd = editor.logicalPositionToOffset(new LogicalPosition(endPosition.line + 1, 0));
return new ProperTextRange(visibleStart, Math.max(visibleEnd, visibleStart));
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class MergeSearchHelper method findChangeAt.
public static Change findChangeAt(EditorMouseEvent e, MergePanel2 mergePanel, int index) {
if (mergePanel.getMergeList() == null)
return null;
Editor editor = e.getEditor();
LOG.assertTrue(editor == mergePanel.getEditor(index));
LogicalPosition logicalPosition = editor.xyToLogicalPosition(e.getMouseEvent().getPoint());
int offset = editor.logicalPositionToOffset(logicalPosition);
return forMergeList(mergePanel.getMergeList(), index).findChangeAt(offset);
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class ScrollToTheEndToolbarAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
if (state) {
EditorUtil.scrollToTheEnd(myEditor);
} else {
int lastLine = Math.max(0, myEditor.getDocument().getLineCount() - 1);
LogicalPosition currentPosition = myEditor.getCaretModel().getLogicalPosition();
LogicalPosition position = new LogicalPosition(Math.max(0, Math.min(currentPosition.line, lastLine - 1)), currentPosition.column);
myEditor.getCaretModel().moveToLogicalPosition(position);
}
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-community by JetBrains.
the class ToggleColumnModeAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
final EditorEx editor = getEditor(e);
final SelectionModel selectionModel = editor.getSelectionModel();
final CaretModel caretModel = editor.getCaretModel();
if (state) {
caretModel.removeSecondaryCarets();
boolean hasSelection = selectionModel.hasSelection();
int selStart = selectionModel.getSelectionStart();
int selEnd = selectionModel.getSelectionEnd();
LogicalPosition blockStart, blockEnd;
if (caretModel.supportsMultipleCarets()) {
LogicalPosition logicalSelStart = editor.offsetToLogicalPosition(selStart);
LogicalPosition logicalSelEnd = editor.offsetToLogicalPosition(selEnd);
int caretOffset = caretModel.getOffset();
blockStart = selStart == caretOffset ? logicalSelEnd : logicalSelStart;
blockEnd = selStart == caretOffset ? logicalSelStart : logicalSelEnd;
} else {
blockStart = selStart == caretModel.getOffset() ? caretModel.getLogicalPosition() : editor.offsetToLogicalPosition(selStart);
blockEnd = selEnd == caretModel.getOffset() ? caretModel.getLogicalPosition() : editor.offsetToLogicalPosition(selEnd);
}
editor.setColumnMode(true);
if (hasSelection) {
selectionModel.setBlockSelection(blockStart, blockEnd);
} else {
selectionModel.removeSelection();
}
} else {
boolean hasSelection = false;
int selStart = 0;
int selEnd = 0;
if (caretModel.supportsMultipleCarets()) {
hasSelection = true;
List<Caret> allCarets = caretModel.getAllCarets();
Caret fromCaret = allCarets.get(0);
Caret toCaret = allCarets.get(allCarets.size() - 1);
if (fromCaret == caretModel.getPrimaryCaret()) {
Caret tmp = fromCaret;
fromCaret = toCaret;
toCaret = tmp;
}
selStart = fromCaret.getLeadSelectionOffset();
selEnd = toCaret.getSelectionStart() == toCaret.getLeadSelectionOffset() ? toCaret.getSelectionEnd() : toCaret.getSelectionStart();
}
editor.setColumnMode(false);
caretModel.removeSecondaryCarets();
if (hasSelection) {
selectionModel.setSelection(selStart, selEnd);
} else {
selectionModel.removeSelection();
}
}
}
Aggregations