1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-07-31 03:59:07 +02:00

Convert all commands to VimCommandAction

This commit is contained in:
Alex Plate 2019-06-26 18:51:55 +03:00
parent f61134fd69
commit ced51e37b4
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
48 changed files with 2017 additions and 730 deletions

View File

@ -20,7 +20,6 @@ package com.maddyhome.idea.vim;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.maddyhome.idea.vim.action.VimCommandActionBase;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
@ -37,8 +36,6 @@ class RegisterActions {
*/
static void registerActions() {
registerVimCommandActions();
registerNormalModeActions();
registerSystemMappings();
}
@ -61,11 +58,11 @@ class RegisterActions {
parser.registerAction(MappingMode.NV, "ExpandRegion", Command.Type.OTHER_READONLY, new Shortcut("zo"));
parser.registerAction(MappingMode.NV, "ExpandRegionRecursively", Command.Type.OTHER_READONLY, new Shortcut("zO"));
parser.registerAction(MappingMode.I, "EditorBackSpace", Command.Type.INSERT,
parser.registerAction(MappingMode.I, "EditorBackSpace", Command.Type.INSERT, EnumSet.noneOf(CommandFlags.class),
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0))});
parser.registerAction(MappingMode.I, "EditorDelete", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_SAVE_STROKE),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)));
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0))});
parser.registerAction(MappingMode.I, "EditorDown", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_CLEAR_STROKES),
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0))});
@ -76,6 +73,8 @@ class RegisterActions {
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0))});
parser.registerAction(MappingMode.N, "QuickJavaDoc", Command.Type.OTHER_READONLY, new Shortcut('K'));
// Digraph shortcuts are handled directly by KeyHandler#handleKey, so they don't have an action. But we still need to
// register the shortcuts or the editor will swallow them. Technically, the shortcuts will be registered as part of
// other commands, but it's best to be explicit
@ -84,126 +83,4 @@ class RegisterActions {
parser.registerShortcutWithoutAction(new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK)));
parser.registerShortcutWithoutAction(new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)));
}
private static void registerNormalModeActions() {
final KeyGroup parser = VimPlugin.getKey();
// Insert/Replace/Change Actions
parser.registerAction(MappingMode.N, "VimChangeCaseLowerMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut("gu"), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeCaseToggleCharacter", Command.Type.CHANGE,
new Shortcut('~'));
parser.registerAction(MappingMode.N, "VimChangeCaseToggleMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut("g~"), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeCaseUpperMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut("gU"), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeCharacter", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_ALLOW_DIGRAPH),
new Shortcut('r'), Argument.Type.DIGRAPH);
parser
.registerAction(MappingMode.N, "VimChangeCharacters", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('s'));
parser
.registerAction(MappingMode.N, "VimChangeEndOfLine", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('C'));
parser.registerAction(MappingMode.N, "VimChangeLine", Command.Type.CHANGE,
EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_ALLOW_MID_COUNT, CommandFlags.FLAG_MULTIKEY_UNDO), new Shortcut[]{
new Shortcut("cc"),
new Shortcut('S')
});
parser.registerAction(MappingMode.N, "VimChangeNumberInc", Command.Type.CHANGE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.N, "VimChangeNumberDec", Command.Type.CHANGE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.N, "VimChangeMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND, CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('c'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeReplace", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('R'));
parser.registerAction(MappingMode.N, "VimDeleteCharacter", Command.Type.DELETE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)));
parser.registerAction(MappingMode.N, "VimDeleteCharacterLeft", Command.Type.DELETE,
new Shortcut('X'));
parser.registerAction(MappingMode.N, "VimDeleteCharacterRight", Command.Type.DELETE,
new Shortcut('x'));
parser.registerAction(MappingMode.N, "VimDeleteEndOfLine", Command.Type.DELETE,
new Shortcut('D'));
parser.registerAction(MappingMode.N, "VimDeleteJoinLines", Command.Type.DELETE,
new Shortcut("gJ"));
parser.registerAction(MappingMode.N, "VimDeleteJoinLinesSpaces", Command.Type.DELETE,
new Shortcut('J'));
parser.registerAction(MappingMode.N, "VimDeleteLine", Command.Type.DELETE, EnumSet.of(CommandFlags.FLAG_ALLOW_MID_COUNT),
new Shortcut("dd"));
parser.registerAction(MappingMode.N, "VimDeleteMotion", Command.Type.DELETE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut('d'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimFilterCountLines", Command.Type.CHANGE,
new Shortcut("!!"));
parser.registerAction(MappingMode.N, "VimFilterMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut('!'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimInsertAfterCursor", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('a'));
parser.registerAction(MappingMode.N, "VimInsertAfterLineEnd", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('A'));
parser.registerAction(MappingMode.N, "VimInsertAtPreviousInsert", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut("gi"));
parser.registerAction(MappingMode.N, "VimInsertBeforeFirstNonBlank", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('I'));
parser.registerAction(MappingMode.N, "VimInsertLineStart", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut("gI"));
parser.registerAction(MappingMode.N, "VimInsertNewLineAbove", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('O'));
parser.registerAction(MappingMode.N, "VimInsertNewLineBelow", Command.Type.INSERT, EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO),
new Shortcut('o'));
// Misc Actions
parser.registerAction(MappingMode.N, "VimLastSearchReplace", Command.Type.OTHER_WRITABLE,
new Shortcut('&'));
parser.registerAction(MappingMode.N, "VimLastGlobalSearchReplace", Command.Type.OTHER_WRITABLE,
new Shortcut("g&"));
parser.registerAction(MappingMode.N, "VimRepeatChange", Command.Type.OTHER_WRITABLE,
new Shortcut('.'));
parser.registerAction(MappingMode.N, "VimRepeatExCommand", Command.Type.OTHER_WRITABLE,
new Shortcut("@:"));
parser.registerAction(MappingMode.N, "QuickJavaDoc", Command.Type.OTHER_READONLY,
new Shortcut('K'));
parser.registerAction(MappingMode.N, "VimRedo", Command.Type.OTHER_SELF_SYNCHRONIZED,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.N, "VimUndo", Command.Type.OTHER_SELF_SYNCHRONIZED, new Shortcut[]{
new Shortcut('u'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UNDO, 0))
});
// File Actions
parser.registerAction(MappingMode.N, "VimFileSaveClose", Command.Type.OTHER_WRITABLE, new Shortcut[]{
new Shortcut("ZQ"),
new Shortcut("ZZ")
});
parser.registerAction(MappingMode.N, "VimFilePrevious", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_6, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_CIRCUMFLEX, KeyEvent.CTRL_MASK))
});
// Shift Actions
parser.registerAction(MappingMode.N, "VimAutoIndentLines", Command.Type.CHANGE,
new Shortcut("=="));
parser.registerAction(MappingMode.N, "VimAutoIndentMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut('='), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimShiftLeftMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut('<'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimShiftRightMotion", Command.Type.CHANGE, EnumSet.of(CommandFlags.FLAG_OP_PEND),
new Shortcut('>'), Argument.Type.MOTION);
// Jump Actions
parser.registerAction(MappingMode.N, "VimFileGetAscii", Command.Type.OTHER_READONLY,
new Shortcut("ga"));
parser.registerAction(MappingMode.N, "VimFileGetHex", Command.Type.OTHER_READONLY,
new Shortcut("g8"));
parser.registerAction(MappingMode.N, "VimFileGetFileInfo", Command.Type.OTHER_READONLY,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)));
// Macro Actions
parser.registerAction(MappingMode.N, "VimPlaybackLastRegister", Command.Type.OTHER_WRITABLE,
new Shortcut("@@"));
parser.registerAction(MappingMode.N, "VimPlaybackRegister", Command.Type.OTHER_WRITABLE,
new Shortcut('@'), Argument.Type.CHARACTER);
// TODO - support for :map macros
}
}

View File

@ -20,22 +20,45 @@ package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.helper.UndoRedoHelper;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class RedoAction extends EditorAction {
public RedoAction() {
super(new Handler());
public class RedoAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return UndoRedoHelper.redo(context);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("<C-R>");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_SELF_SYNCHRONIZED;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return UndoRedoHelper.redo(context);
}
};
}
}

View File

@ -20,9 +20,9 @@ package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandState;
@ -30,56 +30,78 @@ import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class RepeatChangeAction extends EditorAction {
public RepeatChangeAction() {
super(new Handler());
public class RepeatChangeAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
CommandState state = CommandState.getInstance(editor);
Command cmd = state.getLastChangeCommand();
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet(".");
}
if (cmd != null) {
if (command.getRawCount() > 0) {
cmd.setCount(command.getCount());
Argument arg = cmd.getArgument();
if (arg != null) {
Command mot = arg.getMotion();
if (mot != null) {
mot.setCount(0);
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
CommandState state = CommandState.getInstance(editor);
Command cmd = state.getLastChangeCommand();
if (cmd != null) {
if (command.getRawCount() > 0) {
cmd.setCount(command.getCount());
Argument arg = cmd.getArgument();
if (arg != null) {
Command mot = arg.getMotion();
if (mot != null) {
mot.setCount(0);
}
}
}
}
Command save = state.getCommand();
int lastFTCmd = VimPlugin.getMotion().getLastFTCmd();
char lastFTChar = VimPlugin.getMotion().getLastFTChar();
Command save = state.getCommand();
int lastFTCmd = VimPlugin.getMotion().getLastFTCmd();
char lastFTChar = VimPlugin.getMotion().getLastFTChar();
state.setCommand(cmd);
state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, MappingMode.NORMAL);
char reg = VimPlugin.getRegister().getCurrentRegister();
VimPlugin.getRegister().selectRegister(state.getLastChangeRegister());
try {
KeyHandler.executeAction(cmd.getAction(), context);
}
catch (Exception e) {
// oops
}
state.popState();
if (save != null) {
state.setCommand(save);
}
VimPlugin.getMotion().setLastFTCmd(lastFTCmd, lastFTChar);
state.saveLastChangeCommand(cmd);
VimPlugin.getRegister().selectRegister(reg);
state.setCommand(cmd);
state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, MappingMode.NORMAL);
char reg = VimPlugin.getRegister().getCurrentRegister();
VimPlugin.getRegister().selectRegister(state.getLastChangeRegister());
try {
KeyHandler.executeAction(cmd.getAction(), context);
}
catch (Exception e) {
// oops
}
state.popState();
if (save != null) {
state.setCommand(save);
}
VimPlugin.getMotion().setLastFTCmd(lastFTCmd, lastFTChar);
state.saveLastChangeCommand(cmd);
VimPlugin.getRegister().selectRegister(reg);
return true;
return true;
}
else {
return false;
}
}
else {
return false;
}
}
};
}
}

View File

@ -20,29 +20,52 @@ package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.ex.CommandParser;
import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class RepeatExCommandAction extends EditorAction {
public RepeatExCommandAction() {
super(new Handler());
public class RepeatExCommandAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
int count = command.getCount();
try {
return CommandParser.getInstance().processLastCommand(editor, context, count);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("@:");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
int count = command.getCount();
try {
return CommandParser.getInstance().processLastCommand(editor, context, count);
}
catch (ExException e) {
return false;
}
}
catch (ExException e) {
return false;
}
}
};
}
}

View File

@ -20,22 +20,45 @@ package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.helper.UndoRedoHelper;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class UndoAction extends EditorAction {
public UndoAction() {
super(new Handler());
public class UndoAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return UndoRedoHelper.undo(context);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("u", "<Undo>");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_SELF_SYNCHRONIZED;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return UndoRedoHelper.undo(context);
}
};
}
}

View File

@ -21,27 +21,70 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeCaseLowerMotionAction extends EditorAction {
public ChangeCaseLowerMotionAction() {
super(new Handler());
public class ChangeCaseLowerMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange()
.changeCaseMotion(editor, caret, context, count, rawCount, CharacterHelper.CASE_LOWER, argument);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("gu");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange()
.changeCaseMotion(editor, caret, context, count, rawCount, CharacterHelper.CASE_LOWER, argument);
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class ChangeCaseToggleCharacterAction extends EditorAction {
public ChangeCaseToggleCharacterAction() {
super(new Handler());
public class ChangeCaseToggleCharacterAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().changeCaseToggleCharacter(editor, caret, count);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("~");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().changeCaseToggleCharacter(editor, caret, count);
}
};
}
}

View File

@ -21,27 +21,70 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeCaseToggleMotionAction extends EditorAction {
public ChangeCaseToggleMotionAction() {
super(new Handler());
public class ChangeCaseToggleMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange()
.changeCaseMotion(editor, caret, context, count, rawCount, CharacterHelper.CASE_TOGGLE, argument);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("g~");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange()
.changeCaseMotion(editor, caret, context, count, rawCount, CharacterHelper.CASE_TOGGLE, argument);
}
};
}
}

View File

@ -21,27 +21,70 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeCaseUpperMotionAction extends EditorAction {
public ChangeCaseUpperMotionAction() {
super(new Handler());
public class ChangeCaseUpperMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange()
.changeCaseMotion(editor, caret, context, count, rawCount, CharacterHelper.CASE_UPPER, argument);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("gU");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange()
.changeCaseMotion(editor, caret, context, count, rawCount, CharacterHelper.CASE_UPPER, argument);
}
};
}
}

View File

@ -21,24 +21,67 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeCharacterAction extends EditorAction {
public ChangeCharacterAction() {
super(new Handler());
public class ChangeCharacterAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return argument != null && VimPlugin.getChange().changeCharacter(editor, caret, count, argument.getCharacter());
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("r");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.DIGRAPH;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_ALLOW_DIGRAPH);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return argument != null && VimPlugin.getChange().changeCharacter(editor, caret, count, argument.getCharacter());
}
};
}
}

View File

@ -21,24 +21,61 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeCharactersAction extends EditorAction {
public ChangeCharactersAction() {
super(new Handler());
public class ChangeCharactersAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().changeCharacters(editor, caret, count);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("s");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().changeCharacters(editor, caret, count);
}
};
}
}

View File

@ -21,24 +21,61 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeEndOfLineAction extends EditorAction {
public ChangeEndOfLineAction() {
super(new Handler());
public class ChangeEndOfLineAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().changeEndOfLine(editor, caret, count);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("C");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().changeEndOfLine(editor, caret, count);
}
};
}
}

View File

@ -20,26 +20,56 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.ex.LineRange;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class ChangeLastGlobalSearchReplaceAction extends EditorAction {
public ChangeLastGlobalSearchReplaceAction() {
super(new Handler());
public class ChangeLastGlobalSearchReplaceAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
final LineRange range = new LineRange(0, EditorHelper.getLineCount(editor) - 1);
return VimPlugin.getSearch().searchAndReplace(editor, editor.getCaretModel().getPrimaryCaret(), range, "s", "//~/&");
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("g&");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
final LineRange range = new LineRange(0, EditorHelper.getLineCount(editor) - 1);
return VimPlugin.getSearch()
.searchAndReplace(editor, editor.getCaretModel().getPrimaryCaret(), range, "s", "//~/&");
}
};
}
}

View File

@ -21,33 +21,61 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.ex.LineRange;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class ChangeLastSearchReplaceAction extends EditorAction {
public ChangeLastSearchReplaceAction() {
super(new Handler());
public class ChangeLastSearchReplaceAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
@Nullable Argument argument) {
boolean result = true;
for (Caret caret : editor.getCaretModel().getAllCarets()) {
final int line = caret.getLogicalPosition().line;
if (!VimPlugin.getSearch().searchAndReplace(editor, caret, new LineRange(line, line), "s", "//~/")) {
result = false;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("&");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
boolean result = true;
for (Caret caret : editor.getCaretModel().getAllCarets()) {
final int line = caret.getLogicalPosition().line;
if (!VimPlugin.getSearch().searchAndReplace(editor, caret, new LineRange(line, line), "s", "//~/")) {
result = false;
}
}
return result;
}
return result;
}
};
}
}

View File

@ -21,17 +21,52 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeLineAction extends EditorAction {
public ChangeLineAction() {
super(new ChangeEditorActionHandler.ForEachCaret() {
public class ChangeLineAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("cc", "S");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_ALLOW_MID_COUNT, CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@ -41,6 +76,6 @@ public class ChangeLineAction extends EditorAction {
@Nullable Argument argument) {
return VimPlugin.getChange().changeLine(editor, caret, count, context);
}
});
};
}
}

View File

@ -21,24 +21,68 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeMotionAction extends EditorAction {
public ChangeMotionAction() {
super(new Handler());
public class ChangeMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return argument != null && VimPlugin.getChange().changeMotion(editor, caret, context, count, rawCount, argument);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("c");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND, CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange().changeMotion(editor, caret, context, count, rawCount, argument);
}
};
}
}

View File

@ -20,17 +20,52 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ChangeReplaceAction extends EditorAction {
public ChangeReplaceAction() {
super(new ChangeEditorActionHandler.SingleExecution() {
public class ChangeReplaceAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("R");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
@ -40,6 +75,6 @@ public class ChangeReplaceAction extends EditorAction {
VimPlugin.getChange().changeReplace(editor, context);
return true;
}
});
};
}
}

View File

@ -20,24 +20,47 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class FilterCountLinesAction extends EditorAction {
public FilterCountLinesAction() {
super(new Handler());
public class FilterCountLinesAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("!!");
}
return true;
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
return true;
}
};
}
}

View File

@ -21,57 +21,91 @@ package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.group.MotionGroup;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class FilterMotionAction extends EditorAction {
public FilterMotionAction() {
super(new Handler());
public class FilterMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
final Argument argument = cmd.getArgument();
if (argument == null) {
return false;
}
TextRange range = MotionGroup
.getMotionRange(editor, editor.getCaretModel().getPrimaryCaret(), context, cmd.getCount(), cmd.getRawCount(),
argument, false);
if (range == null) {
return false;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("!");
}
LogicalPosition current = editor.getCaretModel().getLogicalPosition();
LogicalPosition start = editor.offsetToLogicalPosition(range.getStartOffset());
LogicalPosition end = editor.offsetToLogicalPosition(range.getEndOffset());
if (current.line != start.line) {
MotionGroup.moveCaret(editor, editor.getCaretModel().getPrimaryCaret(), range.getStartOffset());
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
int count;
if (start.line < end.line) {
count = end.line - start.line + 1;
}
else {
count = 1;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
Command command = new Command(count, null, null, Command.Type.UNDEFINED, EnumSet.noneOf(CommandFlags.class));
VimPlugin.getProcess().startFilterCommand(editor, context, command);
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
return true;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
final Argument argument = cmd.getArgument();
if (argument == null) {
return false;
}
TextRange range = MotionGroup
.getMotionRange(editor, editor.getCaretModel().getPrimaryCaret(), context, cmd.getCount(), cmd.getRawCount(),
argument, false);
if (range == null) {
return false;
}
LogicalPosition current = editor.getCaretModel().getLogicalPosition();
LogicalPosition start = editor.offsetToLogicalPosition(range.getStartOffset());
LogicalPosition end = editor.offsetToLogicalPosition(range.getEndOffset());
if (current.line != start.line) {
MotionGroup.moveCaret(editor, editor.getCaretModel().getPrimaryCaret(), range.getStartOffset());
}
int count;
if (start.line < end.line) {
count = end.line - start.line + 1;
}
else {
count = 1;
}
Command command = new Command(count, null, null, Command.Type.UNDEFINED, EnumSet.noneOf(CommandFlags.class));
VimPlugin.getProcess().startFilterCommand(editor, context, command);
return true;
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.change.number;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class ChangeNumberDecAction extends EditorAction {
public ChangeNumberDecAction() {
super(new Handler());
public class ChangeNumberDecAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().changeNumber(editor, caret, -count);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("<C-X>");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().changeNumber(editor, caret, -count);
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.change.number;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class ChangeNumberIncAction extends EditorAction {
public ChangeNumberIncAction() {
super(new Handler());
public class ChangeNumberIncAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().changeNumber(editor, caret, count);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("<C-A>");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().changeNumber(editor, caret, count);
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class DeleteCharacterAction extends EditorAction {
public DeleteCharacterAction() {
super(new Handler());
public class DeleteCharacterAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().deleteCharacter(editor, caret, 1, false);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("<DEL>");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().deleteCharacter(editor, caret, 1, false);
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class DeleteCharacterLeftAction extends EditorAction {
public DeleteCharacterLeftAction() {
super(new Handler());
public class DeleteCharacterLeftAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().deleteCharacter(editor, caret, -count, false);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("X");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().deleteCharacter(editor, caret, -count, false);
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class DeleteCharacterRightAction extends EditorAction {
public DeleteCharacterRightAction() {
super(new Handler());
public class DeleteCharacterRightAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret{
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().deleteCharacter(editor, caret, count, false);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("x");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().deleteCharacter(editor, caret, count, false);
}
};
}
}

View File

@ -21,24 +21,53 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class DeleteEndOfLineAction extends EditorAction {
public DeleteEndOfLineAction() {
super(new Handler());
public class DeleteEndOfLineAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return VimPlugin.getChange().deleteEndOfLine(editor, caret, count);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("D");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return VimPlugin.getChange().deleteEndOfLine(editor, caret, count);
}
};
}
}

View File

@ -20,40 +20,65 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.util.Ref;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.option.OptionsManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class DeleteJoinLinesAction extends EditorAction {
public DeleteJoinLinesAction() {
super(new Handler());
public class DeleteJoinLinesAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
if (editor.isOneLineMode()) return false;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("gJ");
}
if (OptionsManager.INSTANCE.getSmartjoin().isSet()) {
return VimPlugin.getChange().joinViaIdeaByCount(editor, context, count);
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
if (editor.isOneLineMode()) return false;
if (OptionsManager.INSTANCE.getSmartjoin().isSet()) {
return VimPlugin.getChange().joinViaIdeaByCount(editor, context, count);
}
VimPlugin.getEditor().notifyAboutSmartJoin();
Ref<Boolean> res = Ref.create(true);
editor.getCaretModel().runForEachCaret(caret -> {
if (!VimPlugin.getChange().deleteJoinLines(editor, caret, count, false)) res.set(false);
}, true);
return res.get();
}
VimPlugin.getEditor().notifyAboutSmartJoin();
Ref<Boolean> res = Ref.create(true);
editor.getCaretModel().runForEachCaret(caret -> {
if (!VimPlugin.getChange().deleteJoinLines(editor, caret, count, false)) res.set(false);
}, true);
return res.get();
}
};
}
}

View File

@ -20,41 +20,66 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.util.Ref;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import com.maddyhome.idea.vim.option.OptionsManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class DeleteJoinLinesSpacesAction extends EditorAction {
public DeleteJoinLinesSpacesAction() {
super(new Handler());
public class DeleteJoinLinesSpacesAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
if (editor.isOneLineMode()) return false;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("J");
}
if (OptionsManager.INSTANCE.getSmartjoin().isSet()) {
return VimPlugin.getChange().joinViaIdeaByCount(editor, context, count);
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
if (editor.isOneLineMode()) return false;
if (OptionsManager.INSTANCE.getSmartjoin().isSet()) {
return VimPlugin.getChange().joinViaIdeaByCount(editor, context, count);
}
VimPlugin.getEditor().notifyAboutSmartJoin();
Ref<Boolean> res = Ref.create(true);
editor.getCaretModel().runForEachCaret(caret -> {
if (!VimPlugin.getChange().deleteJoinLines(editor, caret, count, true)) res.set(false);
}, true);
return res.get();
}
VimPlugin.getEditor().notifyAboutSmartJoin();
Ref<Boolean> res = Ref.create(true);
editor.getCaretModel().runForEachCaret(caret -> {
if (!VimPlugin.getChange().deleteJoinLines(editor, caret, count, true)) res.set(false);
}, true);
return res.get();
}
};
}
}

View File

@ -21,17 +21,56 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class DeleteLineAction extends EditorAction {
public class DeleteLineAction extends VimCommandAction {
public DeleteLineAction() {
super(new ChangeEditorActionHandler.ForEachCaret() {
super();
}
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("dd");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_ALLOW_MID_COUNT);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@ -41,6 +80,6 @@ public class DeleteLineAction extends EditorAction {
@Nullable Argument argument) {
return VimPlugin.getChange().deleteLine(editor, caret, count);
}
});
};
}
}

View File

@ -21,25 +21,68 @@ package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class DeleteMotionAction extends EditorAction {
public DeleteMotionAction() {
super(new Handler());
public class DeleteMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange().deleteMotion(editor, caret, context, count, rawCount, argument, false);
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("d");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.DELETE;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
return argument != null &&
VimPlugin.getChange().deleteMotion(editor, caret, context, count, rawCount, argument, false);
}
};
}
}

View File

@ -20,17 +20,52 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertAfterCursorAction extends EditorAction {
public InsertAfterCursorAction() {
super(new ChangeEditorActionHandler.SingleExecution() {
public class InsertAfterCursorAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("a");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
@ -40,6 +75,6 @@ public class InsertAfterCursorAction extends EditorAction {
VimPlugin.getChange().insertAfterCursor(editor, context);
return true;
}
});
};
}
}

View File

@ -20,17 +20,52 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertAfterLineEndAction extends EditorAction {
public InsertAfterLineEndAction() {
super(new ChangeEditorActionHandler.SingleExecution() {
public class InsertAfterLineEndAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("A");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
@ -40,6 +75,6 @@ public class InsertAfterLineEndAction extends EditorAction {
VimPlugin.getChange().insertAfterLineEnd(editor, context);
return true;
}
});
};
}
}

View File

@ -20,17 +20,52 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertAtPreviousInsertAction extends EditorAction {
public InsertAtPreviousInsertAction() {
super(new ChangeEditorActionHandler.SingleExecution() {
public class InsertAtPreviousInsertAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("gi");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
@ -40,6 +75,6 @@ public class InsertAtPreviousInsertAction extends EditorAction {
VimPlugin.getChange().insertAtPreviousInsert(editor, context);
return true;
}
});
};
}
}

View File

@ -20,17 +20,52 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertBeforeFirstNonBlankAction extends EditorAction {
public InsertBeforeFirstNonBlankAction() {
super(new ChangeEditorActionHandler.SingleExecution() {
public class InsertBeforeFirstNonBlankAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("I");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
@ -40,6 +75,6 @@ public class InsertBeforeFirstNonBlankAction extends EditorAction {
VimPlugin.getChange().insertBeforeFirstNonBlank(editor, context);
return true;
}
});
};
}
}

View File

@ -20,17 +20,52 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertLineStartAction extends EditorAction {
public InsertLineStartAction() {
super(new ChangeEditorActionHandler.SingleExecution() {
public class InsertLineStartAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("gI");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull DataContext context,
@ -40,6 +75,6 @@ public class InsertLineStartAction extends EditorAction {
VimPlugin.getChange().insertLineStart(editor, context);
return true;
}
});
};
}
}

View File

@ -20,29 +20,66 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertNewLineAboveAction extends EditorAction {
public InsertNewLineAboveAction() {
super(new Handler());
public class InsertNewLineAboveAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
if (editor.isOneLineMode()) {
return false;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("O");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
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;
}
VimPlugin.getChange().insertNewLineAbove(editor, context);
return true;
}
};
}
}

View File

@ -20,30 +20,66 @@ package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class InsertNewLineBelowAction extends EditorAction {
public InsertNewLineBelowAction() {
super(new Handler());
public class InsertNewLineBelowAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
@Nullable Argument argument) {
if (editor.isOneLineMode()) {
return false;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("o");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.INSERT;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_MULTIKEY_UNDO);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.SingleExecution() {
@Override
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;
}
VimPlugin.getChange().insertNewLineBelow(editor, context);
return true;
}
};
}
}

View File

@ -21,23 +21,54 @@ package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class AutoIndentLinesAction extends EditorAction {
protected AutoIndentLinesAction() {
super(new ChangeEditorActionHandler.ForEachCaret() {
public class AutoIndentLinesAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("==");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
VimPlugin.getChange().autoIndentLines(editor, caret, context, count);
return true;
}
});
};
}
}

View File

@ -21,19 +21,60 @@ package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
/**
* @author Aleksey Lagoshin
*/
public class AutoIndentMotionAction extends EditorAction {
protected AutoIndentMotionAction() {
super(new ChangeEditorActionHandler.ForEachCaret() {
public class AutoIndentMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("=");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
@ -44,6 +85,6 @@ public class AutoIndentMotionAction extends EditorAction {
VimPlugin.getChange().autoIndentMotion(editor, caret, context, count, rawCount, argument);
return true;
}
});
};
}
}

View File

@ -21,30 +21,73 @@ package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ShiftLeftMotionAction extends EditorAction {
public ShiftLeftMotionAction() {
super(new Handler());
public class ShiftLeftMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
if (argument != null) {
VimPlugin.getChange().indentMotion(editor, caret, context, count, rawCount, argument, -1);
return true;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("<");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
if (argument != null) {
VimPlugin.getChange().indentMotion(editor, caret, context, count, rawCount, argument, -1);
return true;
}
else {
return false;
}
}
else {
return false;
}
}
};
}
}

View File

@ -21,30 +21,73 @@ package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandFlags;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class ShiftRightMotionAction extends EditorAction {
public ShiftRightMotionAction() {
super(new Handler());
public class ShiftRightMotionAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
@Override
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
int rawCount, @Nullable Argument argument) {
if (argument != null) {
VimPlugin.getChange().indentMotion(editor, caret, context, count, rawCount, argument, 1);
return true;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet(">");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.CHANGE;
}
@NotNull
@Override
public Argument.Type getArgumentType() {
return Argument.Type.MOTION;
}
@NotNull
@Override
public EnumSet<CommandFlags> getFlags() {
return EnumSet.of(CommandFlags.FLAG_OP_PEND);
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new ChangeEditorActionHandler.ForEachCaret() {
@Override
public boolean execute(@NotNull Editor editor,
@NotNull Caret caret,
@NotNull DataContext context,
int count,
int rawCount,
@Nullable Argument argument) {
if (argument != null) {
VimPlugin.getChange().indentMotion(editor, caret, context, count, rawCount, argument, 1);
return true;
}
else {
return false;
}
}
else {
return false;
}
}
};
}
}

View File

@ -20,24 +20,47 @@ package com.maddyhome.idea.vim.action.file;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class FileGetAsciiAction extends EditorAction {
public FileGetAsciiAction() {
super(new Handler());
public class FileGetAsciiAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().displayAsciiInfo(editor);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("ga");
}
return true;
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_READONLY;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().displayAsciiInfo(editor);
return true;
}
};
}
}

View File

@ -20,24 +20,47 @@ package com.maddyhome.idea.vim.action.file;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class FileGetFileInfoAction extends EditorAction {
public FileGetFileInfoAction() {
super(new FileGetFileInfoAction.Handler());
public class FileGetFileInfoAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().displayFileInfo(editor, cmd.getRawCount() > 0);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("<C-G>");
}
return true;
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_READONLY;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().displayFileInfo(editor, cmd.getRawCount() > 0);
return true;
}
};
}
}

View File

@ -20,24 +20,46 @@ package com.maddyhome.idea.vim.action.file;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class FileGetHexAction extends EditorAction {
public FileGetHexAction() {
super(new Handler());
public class FileGetHexAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().displayHexInfo(editor);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("g8");
}
return true;
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_READONLY;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().displayHexInfo(editor);
return true;
}
};
}
}

View File

@ -20,24 +20,54 @@ package com.maddyhome.idea.vim.action.file;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class FilePreviousAction extends EditorAction {
public FilePreviousAction() {
super(new FilePreviousHandler());
public class FilePreviousAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class FilePreviousHandler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().selectPreviousTab(context);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
Set<List<KeyStroke>> keys = new HashSet<>();
keys
.add(Collections.singletonList(KeyStroke.getKeyStroke(KeyEvent.VK_6, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK)));
keys.add(Collections.singletonList(KeyStroke.getKeyStroke(KeyEvent.VK_CIRCUMFLEX, KeyEvent.CTRL_MASK)));
return keys;
}
return true;
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_READONLY;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().selectPreviousTab(context);
return true;
}
};
}
}

View File

@ -20,25 +20,48 @@ package com.maddyhome.idea.vim.action.file;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class FileSaveCloseAction extends EditorAction {
public FileSaveCloseAction() {
super(new Handler());
public class FileSaveCloseAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().saveFile(context);
VimPlugin.getFile().closeFile(editor, context);
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("ZQ", "ZZ");
}
return true;
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
VimPlugin.getFile().saveFile(context);
VimPlugin.getFile().closeFile(editor, context);
return true;
}
};
}
}

View File

@ -21,24 +21,47 @@ package com.maddyhome.idea.vim.action.macro;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.project.Project;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class PlaybackLastRegisterAction extends EditorAction {
public PlaybackLastRegisterAction() {
super(new Handler());
public class PlaybackLastRegisterAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
return VimPlugin.getMacro().playbackLastRegister(editor, context, project, cmd.getCount());
}
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("@@");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
return VimPlugin.getMacro().playbackLastRegister(editor, context, project, cmd.getCount());
}
};
}
}

View File

@ -21,30 +21,52 @@ package com.maddyhome.idea.vim.action.macro;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.project.Project;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.VimCommandAction;
import com.maddyhome.idea.vim.command.Argument;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.handler.VimActionHandler;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Set;
public class PlaybackRegisterAction extends EditorAction {
public PlaybackRegisterAction() {
super(new Handler());
public class PlaybackRegisterAction extends VimCommandAction {
@NotNull
@Override
public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
private static class Handler extends VimActionHandler.SingleExecution {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
final Argument argument = cmd.getArgument();
if (argument == null) {
return false;
@NotNull
@Override
public Set<List<KeyStroke>> getKeyStrokesSet() {
return parseKeysSet("@");
}
@NotNull
@Override
public Command.Type getType() {
return Command.Type.OTHER_WRITABLE;
}
@NotNull
@Override
protected VimActionHandler makeActionHandler() {
return new VimActionHandler.SingleExecution() {
@Override
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
final Argument argument = cmd.getArgument();
if (argument == null) {
return false;
}
final char reg = argument.getCharacter();
final Project project = PlatformDataKeys.PROJECT.getData(context);
return VimPlugin.getMacro().playbackRegister(editor, context, project, reg, cmd.getCount());
}
final char reg = argument.getCharacter();
final Project project = PlatformDataKeys.PROJECT.getData(context);
return VimPlugin.getMacro().playbackRegister(editor, context, project, reg, cmd.getCount());
}
};
}
}

View File

@ -269,85 +269,26 @@ public class KeyGroup {
public void registerCommandAction(@NotNull VimCommandActionBase commandAction, @NotNull String actionId) {
final List<Shortcut> shortcuts = new ArrayList<>();
for (List<KeyStroke> keyStrokes : commandAction.getKeyStrokesSet()) {
shortcuts.add(new Shortcut(keyStrokes.toArray(new KeyStroke[keyStrokes.size()])));
shortcuts.add(new Shortcut(keyStrokes.toArray(new KeyStroke[0])));
}
//noinspection deprecation
registerAction(commandAction.getMappingModes(), actionId, commandAction.getType(), commandAction.getFlags(),
shortcuts.toArray(new Shortcut[shortcuts.size()]), commandAction.getArgumentType());
shortcuts.toArray(new Shortcut[0]), commandAction.getArgumentType());
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, Shortcut shortcut) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, new Shortcut[]{shortcut});
registerAction(mappingModes, actName, cmdType, EnumSet.noneOf(CommandFlags.class), new Shortcut[]{shortcut});
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, EnumSet<CommandFlags> cmdFlags, Shortcut shortcut) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, cmdFlags, new Shortcut[]{shortcut});
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, Shortcut shortcut,
@NotNull Argument.Type argType) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, new Shortcut[]{shortcut}, argType);
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, EnumSet<CommandFlags> cmdFlags, Shortcut shortcut,
@NotNull Argument.Type argType) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, cmdFlags, new Shortcut[]{shortcut}, argType);
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, @NotNull Shortcut[] shortcuts) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, EnumSet.noneOf(CommandFlags.class), shortcuts);
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, @NotNull Shortcut[] shortcuts,
@NotNull Argument.Type argType) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, EnumSet.noneOf(CommandFlags.class), shortcuts, argType);
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, EnumSet<CommandFlags> cmdFlags, @NotNull Shortcut[] shortcuts) {
//noinspection deprecation
registerAction(mappingModes, actName, cmdType, cmdFlags, shortcuts, Argument.Type.NONE);
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
public void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, EnumSet<CommandFlags> cmdFlags, @NotNull Shortcut[] shortcuts,
@NotNull Argument.Type argType) {
private void registerAction(@NotNull Set<MappingMode> mappingModes,
@NotNull String actName,
@NotNull Command.Type cmdType,
EnumSet<CommandFlags> cmdFlags,
@NotNull Shortcut[] shortcuts,
@NotNull Argument.Type argType) {
for (Shortcut shortcut : shortcuts) {
final KeyStroke[] keys = registerRequiredShortcut(shortcut);
registerAction(mappingModes, actName, cmdType, cmdFlags, keys, argType);
@ -364,10 +305,6 @@ public class KeyGroup {
return keys;
}
/**
* @deprecated Inherit your action from {@link com.maddyhome.idea.vim.action.VimCommandAction} instead.
*/
@Deprecated
private void registerAction(@NotNull Set<MappingMode> mappingModes, @NotNull String actName, @NotNull Command.Type cmdType, EnumSet<CommandFlags> cmdFlags, @NotNull KeyStroke[] keys,
@NotNull Argument.Type argType) {
for (MappingMode mappingMode : mappingModes) {