@NotNull public TextRange getVisualRange(@NotNull Caret caret) { return new TextRange(caret.getSelectionStart(), caret.getSelectionEnd()); }
int max = EditorHelper.getFileSize(editor); int offset = caret.getOffset(); int ssel = caret.getSelectionStart(); int esel = caret.getSelectionEnd(); if (Math.abs(esel - ssel) > 1) {
CharSequence chars = editor.getDocument().getCharsSequence(); int pos = caret.getOffset(); int start = caret.getSelectionStart(); int end = caret.getSelectionEnd(); if (start != end) {
private void updateVisualCaretData(@NotNull Editor editor, @NotNull Caret caret) { if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) { int selectionStart = caret.getSelectionStart(); int selectionEnd = caret.getSelectionEnd(); int caretOffset = caret.getOffset();
CaretData.setVisualStart(caret, caret.getSelectionStart()); int visualEnd = caret.getSelectionEnd(); if (CommandState.getInstance(editor).getSubMode() == CommandState.SubMode.VISUAL_CHARACTER) {
private void updateBlockSelection(@NotNull Editor editor, int offset) { EditorData.setVisualBlockEnd(editor, offset); EditorData.setVisualBlockOffset(editor, offset); int start = EditorData.getVisualBlockStart(editor); int end = EditorData.getVisualBlockEnd(editor); LogicalPosition blockStart = editor.offsetToLogicalPosition(start); LogicalPosition blockEnd = editor.offsetToLogicalPosition(end); if (blockStart.column < blockEnd.column) { blockEnd = new LogicalPosition(blockEnd.line, blockEnd.column + 1); } else { blockStart = new LogicalPosition(blockStart.line, blockStart.column + 1); } editor.getSelectionModel().setBlockSelection(blockStart, blockEnd); for (Caret caret : editor.getCaretModel().getAllCarets()) { int line = caret.getLogicalPosition().line; int lineEndOffset = EditorHelper.getLineEndOffset(editor, line, true); if (CaretData.getLastColumn(editor.getCaretModel().getPrimaryCaret()) >= MotionGroup.LAST_COLUMN) { caret.setSelection(caret.getSelectionStart(), lineEndOffset); } if (!EditorHelper.isLineEmpty(editor, line, false)) { caret.moveToOffset(caret.getSelectionEnd() - 1); } } editor.getCaretModel().getPrimaryCaret().moveToOffset(end); VimPlugin.getMark().setVisualSelectionMarks(editor, new TextRange(start, end)); }
CaretData.setVisualStart(caret, caret.getSelectionStart()); updateSelection(editor, caret, caret.getSelectionEnd()); MotionGroup.moveCaret(editor, caret, CaretData.getVisualEnd(caret), true);
/** * Add markers with offsets for caret and selection */ private void addCaretInfo(@NotNull Caret caret, @NotNull List<Pair<Integer, String>> macroses) { macroses.add(Pair.create(caret.getOffset(), "<caret>")); if (caret.hasSelection()) { macroses.add(Pair.create(caret.getSelectionStart(), "<selection>")); macroses.add(Pair.create(caret.getSelectionEnd(), "</selection>")); } }