Search in sources :

Example 6 with Command

use of com.maddyhome.idea.vim.command.Command in project ideavim by JetBrains.

the class KeyHandler method handleCharArgument.

private void handleCharArgument(@NotNull KeyStroke key, char chKey) {
    // Some special keys can be handled as character arguments - let's check for them here.
    if (chKey == 0) {
        switch(key.getKeyCode()) {
            case KeyEvent.VK_TAB:
                chKey = '\t';
                break;
            case KeyEvent.VK_ENTER:
                chKey = '\n';
                break;
        }
    }
    if (chKey != 0) {
        // Create the character argument, add it to the current command, and signal we are ready to process
        // the command
        Argument arg = new Argument(chKey);
        Command cmd = currentCmd.peek();
        cmd.setArgument(arg);
        state = State.READY;
    } else {
        // Oops - this isn't a valid character argument
        state = State.BAD_COMMAND;
    }
}
Also used : Argument(com.maddyhome.idea.vim.command.Argument) Command(com.maddyhome.idea.vim.command.Command)

Example 7 with Command

use of com.maddyhome.idea.vim.command.Command in project ideavim by JetBrains.

the class CopyGroup method yankMotion.

/**
   * This yanks the text moved over by the motion command argument.
   *
   * @param editor   The editor to yank from
   * @param context  The data context
   * @param count    The number of times to yank
   * @param rawCount The actual count entered by the user
   * @param argument The motion command argument
   * @return true if able to yank the text, false if not
   */
public boolean yankMotion(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
    TextRange range = MotionGroup.getMotionRange(editor, context, count, rawCount, argument, true);
    final Command motion = argument.getMotion();
    return motion != null && yankRange(editor, range, SelectionType.fromCommandFlags(motion.getFlags()), true);
}
Also used : Command(com.maddyhome.idea.vim.command.Command) TextRange(com.maddyhome.idea.vim.common.TextRange)

Aggregations

Command (com.maddyhome.idea.vim.command.Command)7 Argument (com.maddyhome.idea.vim.command.Argument)3 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)1 Project (com.intellij.openapi.project.Project)1 CommandState (com.maddyhome.idea.vim.command.CommandState)1 Mark (com.maddyhome.idea.vim.common.Mark)1 TextRange (com.maddyhome.idea.vim.common.TextRange)1