private void restoreCursor(@NotNull Editor editor, @NotNull Caret caret, int startLine) { if (caret != editor.getCaretModel().getPrimaryCaret()) { editor.getCaretModel().addCaret( editor.offsetToVisualPosition(VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, startLine)), false); } }
@Override public int getOffset(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { Caret lastDownCaret = EditorData.getLastDownCaret(editor); EditorData.setLastDownCaret(editor, caret); if (CommandState.inVisualBlockMode(editor) && EditorData.shouldIgnoreNextMove(editor)) { EditorData.dontIgnoreNextMove(editor); if (lastDownCaret != caret) { return caret.getOffset(); } } if (CommandState.inVisualBlockMode(editor)) { int blockEndOffset = EditorData.getVisualBlockEnd(editor); int blockStartOffset = EditorData.getVisualBlockStart(editor); VisualPosition blockEndPosition = editor.offsetToVisualPosition(blockEndOffset); VisualPosition blockStartPosition = editor.offsetToVisualPosition(blockStartOffset); if (blockEndPosition.getLine() < blockStartPosition.getLine()) { EditorData.ignoreNextMove(editor); } } return VimPlugin.getMotion().moveCaretVertical(editor, caret, count); }
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException { LineRange range = cmd.getLineRange(editor, context); CharSequence chars = editor.getDocument().getCharsSequence(); for (int l = range.getStartLine(); l <= range.getEndLine(); l++) { int start = editor.getDocument().getLineStartOffset(l); int end = editor.getDocument().getLineEndOffset(l); if (logger.isDebugEnabled()) { logger.debug("Line " + l + ", start offset=" + start + ", end offset=" + end); for (int i = start; i <= end; i++) { logger.debug("Offset " + i + ", char=" + chars.charAt(i) + ", lp=" + editor.offsetToLogicalPosition(i) + ", vp=" + editor.offsetToVisualPosition(i)); } } } return true; }
@Override protected void textChanged(DocumentEvent e) { final Editor editor = entry.getEditor(); final boolean forwards = !label.getText().equals("?"); if (incHighlighter != null) { editor.getMarkupModel().removeHighlighter(incHighlighter); } final String pattern = entry.getText(); final TextRange range = SearchGroup.findNext(editor, pattern, editor.getCaretModel().getOffset(), true, forwards); if (range != null) { final TextAttributes color = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); incHighlighter = SearchGroup.highlightMatch(editor, range.getStartOffset(), range.getEndOffset()); incHighlighter.setErrorStripeMarkColor(color.getBackgroundColor()); incHighlighter.setErrorStripeTooltip(pattern); MotionGroup.scrollPositionIntoView(editor, editor.offsetToVisualPosition(range.getStartOffset()), true); } } };
final int eoff = EditorHelper.getLineEndOffset(editor, l, true); final int woff = VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, l); final int col = editor.offsetToVisualPosition(woff).column; final int limit = Math.max(0, col + dir * indentSize * count); if (col > 0 || soff != eoff) {
if (do_ask) { RangeHighlighter hl = highlightConfirm(editor, startoff, endoff); MotionGroup.scrollPositionIntoView(editor, editor.offsetToVisualPosition(startoff), true); MotionGroup.moveCaret(editor, caret, start); final ReplaceConfirmationChoice choice = confirmChoice(editor, match);