use of com.intellij.openapi.editor.VisualPosition in project intellij-community by JetBrains.
the class MoveCaretLeftOrRightWithSelectionHandler method doExecute.
@Override
protected void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
assert caret != null;
VisualPosition currentPosition = caret.getVisualPosition();
if (caret.isAtBidiRunBoundary() && (myMoveRight ^ currentPosition.leansRight)) {
int selectionStartToUse = caret.getLeadSelectionOffset();
VisualPosition selectionStartPositionToUse = caret.getLeadSelectionPosition();
caret.moveToVisualPosition(currentPosition.leanRight(!currentPosition.leansRight));
caret.setSelection(selectionStartPositionToUse, selectionStartToUse, caret.getVisualPosition(), caret.getOffset());
} else {
editor.getCaretModel().moveCaretRelatively(myMoveRight ? 1 : -1, 0, true, editor.isColumnMode(), caret == editor.getCaretModel().getPrimaryCaret());
}
}
use of com.intellij.openapi.editor.VisualPosition in project intellij-community by JetBrains.
the class EditorActionTest method testMoveRightAtFoldedLineEnd.
public void testMoveRightAtFoldedLineEnd() throws Exception {
init("line1<caret>\nline2\nline3", TestFileType.TEXT);
addCollapsedFoldRegion(5, 7, "...");
executeAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT);
assertEquals(new VisualPosition(0, 6), myEditor.getCaretModel().getVisualPosition());
}
use of com.intellij.openapi.editor.VisualPosition in project intellij-community by JetBrains.
the class FileInEditorProcessor method isCaretAboveTop.
private static boolean isCaretAboveTop(Editor editor, Rectangle area) {
Caret caret = editor.getCaretModel().getCurrentCaret();
VisualPosition caretVisualPosition = caret.getVisualPosition();
int caretY = editor.visualPositionToXY(caretVisualPosition).y;
return caretY < area.y;
}
use of com.intellij.openapi.editor.VisualPosition in project intellij-community by JetBrains.
the class IntentionHintComponent method canPlaceBulbOnTheSameLine.
private static boolean canPlaceBulbOnTheSameLine(Editor editor) {
if (ApplicationManager.getApplication().isUnitTestMode() || editor.isOneLineMode())
return false;
final int offset = editor.getCaretModel().getOffset();
final VisualPosition pos = editor.offsetToVisualPosition(offset);
int line = pos.line;
final int firstNonSpaceColumnOnTheLine = EditorActionUtil.findFirstNonSpaceColumnOnTheLine(editor, line);
if (firstNonSpaceColumnOnTheLine == -1)
return false;
final Point point = editor.visualPositionToXY(new VisualPosition(line, firstNonSpaceColumnOnTheLine));
return point.x > AllIcons.Actions.RealIntentionBulb.getIconWidth() + (editor.isOneLineMode() ? SMALL_BORDER_SIZE : NORMAL_BORDER_SIZE) * 2;
}
use of com.intellij.openapi.editor.VisualPosition in project intellij-community by JetBrains.
the class ConsoleGutterComponent method paintAnnotations.
private void paintAnnotations(Graphics g, Rectangle clip) {
int lineHeight = editor.getLineHeight();
int startLine = clip.y / lineHeight;
int endLine = Math.min(((clip.y + clip.height) / lineHeight) + 1, editor.getVisibleLineCount());
if (startLine >= endLine) {
return;
}
if (!atLineStart) {
g.setColor(JBColor.BLUE);
}
g.setFont(editor.getColorsScheme().getFont(EditorFontType.PLAIN));
int y = ((startLine + 1) * lineHeight) - editor.getDescent();
FontMetrics fontMetrics = editor.getFontMetrics(Font.PLAIN);
for (int line = startLine; line < endLine; line++) {
int logicalLine = editor.visualToLogicalPosition(new VisualPosition(line, 0)).line;
if (atLineStart) {
gutterContentProvider.drawIcon(logicalLine, g, y, editor);
} else {
String text = gutterContentProvider.getText(logicalLine, editor);
if (text != null) {
// right-aligned
g.drawString(text, maxContentWidth - gap - fontMetrics.stringWidth(text), y);
}
}
y += lineHeight;
}
}
Aggregations