@Override public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { if (editor.isOneLineMode()) { return false; } return VimPlugin.getChange().insertCharacterAroundCursor(editor, caret, -1); } }
@Override protected boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) { return !editor.isOneLineMode() && VimPlugin.getChange().deleteJoinRange(editor, caret, range, true); } });
@Override protected boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) { return !editor.isOneLineMode() && VimPlugin.getChange().deleteJoinRange(editor, caret, range, false); } });
@Override protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) { if (editor.isOneLineMode()) return false; return VimPlugin.getChange().blockInsert(editor, context, range, false); } });
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) { if (editor.isOneLineMode()) return false; return VimPlugin.getChange().blockInsert(editor, context, range, true); } });
@Override public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { if (editor.isOneLineMode()) { return false; } return VimPlugin.getChange().deleteJoinLines(editor, caret, count, true); } }
@Override public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { if (editor.isOneLineMode()) { return false; } return VimPlugin.getChange().deleteJoinLines(editor, caret, count, false); } }
@Override public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { if (editor.isOneLineMode()) { return false; } return VimPlugin.getChange().insertCharacterAroundCursor(editor, caret, 1); } }
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { if (editor.isOneLineMode()) { return false; } VimPlugin.getChange().insertNewLineBelow(editor, context); return true; } }
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) { if (editor.isOneLineMode()) { return false; } VimPlugin.getChange().insertNewLineAbove(editor, context); return true; } }
public void startSearchCommand(@NotNull Editor editor, DataContext context, int count, char leader) { if (editor.isOneLineMode()) // Don't allow searching in one line editors { return; } String initText = ""; String label = "" + leader; ExEntryPanel panel = ExEntryPanel.getInstance(); panel.activate(editor, context, label, initText, count); }
/** * This performs the actual insert of the paste * * @param editor The editor to paste into * @param context The data context * @param startOffset The location within the file to paste the text * @param text The text to paste * @param type The type of paste * @param count The number of times to paste the text * @param indent True if pasted lines should be autoindented, false if not * @param cursorAfter If true move cursor to just after pasted text * @param mode The type of highlight prior to the put. * @param caret The caret to insert to */ public void putText(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, @NotNull String text, @NotNull SelectionType type, @NotNull CommandState.SubMode mode, int startOffset, int count, boolean indent, boolean cursorAfter) { if (mode == CommandState.SubMode.VISUAL_LINE && editor.isOneLineMode()) return; if (indent && type != SelectionType.LINE_WISE && mode != CommandState.SubMode.VISUAL_LINE) indent = false; if (type == SelectionType.LINE_WISE && text.length() > 0 && text.charAt(text.length() - 1) != '\n') { text = text + '\n'; } final int endOffset = putTextInternal(editor, caret, context, text, type, mode, startOffset, count, indent, cursorAfter); VimPlugin.getMark().setChangeMarks(editor, new TextRange(startOffset, endOffset)); }
public void startExCommand(@NotNull Editor editor, DataContext context, @NotNull Command cmd) { if (editor.isOneLineMode()) // Don't allow ex commands in one line editors { return; } String initText = getRange(editor, cmd); CommandState.getInstance(editor).pushState(CommandState.Mode.EX_ENTRY, CommandState.SubMode.NONE, MappingMode.CMD_LINE); ExEntryPanel panel = ExEntryPanel.getInstance(); panel.activate(editor, context, ":", initText, 1); }
/** * Inserts a new line below the caret position * * @param editor The editor to insert into * @param caret The caret to insert after * @param col The column to indent to */ private void insertNewLineBelow(@NotNull Editor editor, @NotNull Caret caret, int col) { if (editor.isOneLineMode()) return; MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret)); EditorData.setChangeSwitchMode(editor, CommandState.Mode.INSERT); insertText(editor, caret, "\n" + StringUtil.repeat(" ", col)); }
/** * Begin insert after the current line by creating a new blank line below the current line * for all carets * * @param editor The editor to insert into * @param context The data context */ public void insertNewLineBelow(@NotNull final Editor editor, @NotNull final DataContext context) { if (editor.isOneLineMode()) return; for (Caret caret : editor.getCaretModel().getAllCarets()) { MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret)); } initInsert(editor, context, CommandState.Mode.INSERT); runEnterAction(editor, context); }
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException { if (editor.isOneLineMode()) return false;
/** * Pastes text from the last register into the editor. * * @param editor The editor to paste into * @param context The data context * @param count The number of times to perform the paste * @return true if able to paste, false if not */ public boolean putText(@NotNull Editor editor, @NotNull DataContext context, int count, boolean indent, boolean cursorAfter, boolean beforeCursor) { final Register register = VimPlugin.getRegister().getLastRegister(); if (register == null) return false; final SelectionType selectionType = register.getType(); if (selectionType == SelectionType.LINE_WISE && editor.isOneLineMode()) return false; final String text = register.getText(); final List<Caret> carets = EditorHelper.getOrderedCaretsList(editor, beforeCursor ? CaretOrder.INCREASING_OFFSET : CaretOrder.DECREASING_OFFSET); for (Caret caret : carets) { final int startOffset = getStartOffset(editor, caret, selectionType, beforeCursor); if (text == null) { VimPlugin.getMark().setMark(editor, MarkGroup.MARK_CHANGE_POS, startOffset); VimPlugin.getMark().setChangeMarks(editor, new TextRange(startOffset, startOffset)); continue; } putText(editor, caret, context, text, selectionType, CommandState.SubMode.NONE, startOffset, count, indent, cursorAfter); } return true; }
if (register == null) return false; final SelectionType type = register.getType(); if (type == SelectionType.LINE_WISE && editor.isOneLineMode()) return false;
/** * Inserts a new line above the caret position * * @param editor The editor to insert into * @param caret The caret to insert above * @param col The column to indent to */ private void insertNewLineAbove(@NotNull Editor editor, @NotNull Caret caret, int col) { if (editor.isOneLineMode()) return; if (caret.getVisualPosition().line == 0) { MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineStart(editor, caret)); CaretData.setWasInFirstLine(caret, true); } else { MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretVertical(editor, caret, -1)); MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret)); } EditorData.setChangeSwitchMode(editor, CommandState.Mode.INSERT); insertText(editor, caret, "\n" + StringUtil.repeat(" ", col)); if (CaretData.wasInFirstLine(caret)) { MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretVertical(editor, caret, -1)); CaretData.setWasInFirstLine(caret, false); } }
/** * Begin insert before the current line by creating a new blank line above the current line * for all carets * * @param editor The editor to insert into */ public void insertNewLineAbove(@NotNull final Editor editor, @NotNull DataContext context) { if (editor.isOneLineMode()) return; for (Caret caret : editor.getCaretModel().getAllCarets()) { if (caret.getVisualPosition().line == 0) { MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineStart(editor, caret)); CaretData.setWasInFirstLine(caret, true); } else { MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretVertical(editor, caret, -1)); MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret)); } } initInsert(editor, context, CommandState.Mode.INSERT); runEnterAction(editor, context); for (Caret caret : editor.getCaretModel().getAllCarets()) { if (CaretData.wasInFirstLine(caret)) { CaretData.setWasInFirstLine(caret, false); MotionGroup.moveCaret(editor, caret, VimPlugin.getMotion().moveCaretVertical(editor, caret, -1)); } } }