mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-17 16:31:45 +02:00
Compare commits
53 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e3f57fd647 | ||
![]() |
e074105bde | ||
![]() |
7a8bdfc4fc | ||
![]() |
d765eb74ef | ||
![]() |
ac654d70fa | ||
![]() |
ecd0e771a5 | ||
![]() |
6eb15ecb96 | ||
![]() |
fbb23714a7 | ||
![]() |
b6e7533262 | ||
![]() |
2dba6f91bc | ||
![]() |
bb0fb6e787 | ||
![]() |
0e91f52cbc | ||
![]() |
ef67ecc898 | ||
![]() |
c81b668f82 | ||
![]() |
a8cc087a55 | ||
![]() |
02e349802c | ||
![]() |
2ddaa26b8f | ||
![]() |
c695e98787 | ||
![]() |
9e66424164 | ||
![]() |
4c5ccbd166 | ||
![]() |
f4ae8017ce | ||
![]() |
19ec6f3a10 | ||
![]() |
6248558217 | ||
![]() |
6afb83084c | ||
![]() |
85ebfc10b1 | ||
![]() |
800139eb85 | ||
![]() |
f4f04d5a08 | ||
![]() |
75138e20fd | ||
![]() |
9daf10cf22 | ||
![]() |
0d14a46d08 | ||
![]() |
0a079be25c | ||
![]() |
b0b89e7248 | ||
![]() |
4b6cd9a11f | ||
![]() |
46b53d682d | ||
![]() |
047183e89c | ||
![]() |
7d8b3acfde | ||
![]() |
6e8d3abb17 | ||
![]() |
c502c4a083 | ||
![]() |
87026bda3c | ||
![]() |
03bbc2e1f2 | ||
![]() |
0872a0c3b5 | ||
![]() |
7f4dea6846 | ||
![]() |
dc1b393679 | ||
![]() |
b26d68984f | ||
![]() |
a58203f0b2 | ||
![]() |
694bb9eefa | ||
![]() |
5429774744 | ||
![]() |
d4b202a7f4 | ||
![]() |
3a5b8dbf0f | ||
![]() |
228f0a3f31 | ||
![]() |
3d18c08fd4 | ||
![]() |
df4ac6d642 | ||
![]() |
e3abbf68dc |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/.idea/
|
||||
/idea/
|
||||
/out/
|
||||
/tmp/
|
50
CHANGES.txt
50
CHANGES.txt
@@ -1,6 +1,52 @@
|
||||
History of changes for IdeaVim for IntellIJ platform version @PLATFORM_VERSION@
|
||||
The Changelog
|
||||
=============
|
||||
|
||||
@VERSION@ from 0.8.4
|
||||
History of changes in IdeaVim for the IntelliJ platform.
|
||||
|
||||
|
||||
0.23.115, 2012-11-14
|
||||
--------------------
|
||||
|
||||
A bugfix release.
|
||||
|
||||
* VIM-318 Fixed executing editor commands for editors not bound to a project
|
||||
* VIM-321 Fixed IOOBE in delete empty range
|
||||
* VIM-112 Delete a single previous word with <C-W> in insert mode, not all inserted words
|
||||
|
||||
|
||||
0.23.111, 2012-11-12
|
||||
--------------------
|
||||
|
||||
A bugfix release.
|
||||
|
||||
* Register action for 'iW' selection
|
||||
* Vim compatible regexp substitutions for '\n' and '\r'
|
||||
* Index of supported commands covered with tests
|
||||
* VIM-276 T and F motions are exclusive, not inclusive
|
||||
* VIM-289 Fixed regexp substitute when the substitution contained newlines
|
||||
* VIM-185 Fixed NPE in KeyHandler.handleKey()
|
||||
* VIM-226 Added tests for the bug fixed together with VIM-146
|
||||
* VIM-146 Fixed handling of '$' in search and substitute commands
|
||||
* VIM-198 Fixed indexing bug in offset normalization
|
||||
* VIM-311 Test for single command sub-mode of insert mode
|
||||
* EA-33193 Fixed access to context data from different Swing events
|
||||
* Fixed command handling when motion expected, but another type of argument
|
||||
found
|
||||
|
||||
|
||||
0.23.93, 2012-03-21
|
||||
-------------------
|
||||
|
||||
A bugfix release. Vim.xml was fixed to use Command+C, Command+V on Mac OS.
|
||||
Unfortunately you need to update Vim.xml manually this time.
|
||||
|
||||
...
|
||||
|
||||
|
||||
Previous Releases
|
||||
-----------------
|
||||
|
||||
... from 0.8.4
|
||||
Bug Fixes
|
||||
- The Escape key is passed up to IDEA if not used by VIM first. This fix solves
|
||||
minor issues such as not being able to clear highlighted text using the
|
||||
|
@@ -1,3 +1,4 @@
|
||||
version-id:0.23
|
||||
platform-version:110.0
|
||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-11.zip
|
||||
build.number=x
|
||||
|
89
build.xml
89
build.xml
@@ -22,17 +22,20 @@
|
||||
<property name="idea" value="${basedir}/idea"/>
|
||||
<property name="src" value="${basedir}/src"/>
|
||||
<property name="resources" value="${basedir}/resources"/>
|
||||
<property name="test" value="${basedir}/test"/>
|
||||
<property name="keymap" value="${basedir}/keymap"/>
|
||||
<property name="idea.home" value="${idea}/unzip"/>
|
||||
|
||||
<property environment="env"/>
|
||||
<property name="tools.jar" value="${env.JAVA_HOME}/lib/tools.jar"/>
|
||||
<property name="version" value="${version-id}.${build.number}"/>
|
||||
<property name="filename" value="ideavim-${version}"/>
|
||||
|
||||
<!--Output-->
|
||||
<property name="out" value="${basedir}"/>
|
||||
<property name="out" value="${basedir}/out"/>
|
||||
<property name="classes" value="${out}/classes"/>
|
||||
<property name="build" value="${out}/build"/>
|
||||
<property name="dist" value="${out}/dist"/>
|
||||
<property name="test-reports" value="${out}/test-reports"/>
|
||||
|
||||
<!-- Define task -->
|
||||
<path id="ant-contrib">
|
||||
@@ -44,27 +47,31 @@
|
||||
<fileset dir="${idea.home}/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${java.home}/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<pathelement path="${classes}"/>
|
||||
</path>
|
||||
|
||||
<path id="test.classpath">
|
||||
<path refid="build.classpath"/>
|
||||
<pathelement path="${tools.jar}"/>
|
||||
</path>
|
||||
|
||||
<!-- Clean all the generated stuff -->
|
||||
<target name="clean" description="Removes all generated files">
|
||||
<delete dir="${build}"/>
|
||||
<delete dir="${classes}"/>
|
||||
<delete dir="${dist}"/>
|
||||
<delete dir="${out}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all the sources to the ${classes} folder -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- The task requires the following libraries from IntelliJ IDEA distribution: -->
|
||||
<!-- javac2.jar; jdom.jar; asm.jar; asm-commons.jar -->
|
||||
<taskdef name="javac2" classname="com.intellij.ant.Javac2">
|
||||
<classpath refid="build.classpath"/>
|
||||
</taskdef>
|
||||
<javac2 destdir="${classes}"
|
||||
debug="on"
|
||||
fork="true">
|
||||
<!-- The task requires the following libraries from IntelliJ IDEA distribution: -->
|
||||
<!-- javac2.jar; jdom.jar; asm.jar; asm-commons.jar -->
|
||||
<javac2 destdir="${classes}" debug="on" fork="true" includeantruntime="false">
|
||||
<classpath refid="build.classpath"/>
|
||||
<src path="${src}"/>
|
||||
<include name="com/maddyhome/idea/**"/>
|
||||
@@ -162,19 +169,19 @@
|
||||
|
||||
<target name="build" depends="unzip, clean, compile, jar, help" description="Compiles all source code and created plugin jar file"/>
|
||||
|
||||
<!-- Donwload IntelliJ IDEA distribution -->
|
||||
<target name="download" description="Downloads IntellIJ IDEA artifacts">
|
||||
<delete dir="${idea}"/>
|
||||
<!-- Download IntelliJ IDEA distribution -->
|
||||
<target name="download" description="Downloads IntelliJ IDEA artifacts">
|
||||
<mkdir dir="${idea}"/>
|
||||
<get src="${idea.download.url}" dest="${idea}"/>
|
||||
<get src="${idea.download.url}" dest="${idea}" skipexisting="true"/>
|
||||
</target>
|
||||
|
||||
<!-- Unpack idea-*.zip file for ideavim compilation -->
|
||||
<target name="unzip" depends="download" description="Unzip downloaded artifacts and set up idea.home">
|
||||
<delete dir="${idea}/unzip"/>
|
||||
<mkdir dir="${idea}/unzip"/>
|
||||
<basename property="idea.filename" file="${idea.download.url}"/>
|
||||
<unzip dest="${idea}/unzip">
|
||||
<fileset dir="${idea}" includes="idea*.zip"/>
|
||||
<fileset dir="${idea}" includes="${idea.filename}"/>
|
||||
</unzip>
|
||||
</target>
|
||||
|
||||
@@ -209,9 +216,59 @@
|
||||
<zip basedir="${build}" zipfile="${dist}/${filename}.zip" compress="true" includes="IdeaVim/**"/>
|
||||
</target>
|
||||
|
||||
<!-- Packs all the sources -->
|
||||
<!-- Packs all the sources -->
|
||||
<target name="dist-src" depends="clean" description="Creates the source tar file">
|
||||
<mkdir dir="${dist}"/>
|
||||
<tar basedir="." destfile="${dist}/${filename}-src.tar.gz" excludes=".git/**,.idea/**,idea/**,*.iws,*.iml" compression="gzip"/>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<taskdef name="javac2" classname="com.intellij.ant.Javac2">
|
||||
<classpath refid="build.classpath"/>
|
||||
</taskdef>
|
||||
<javac2 destdir="${classes}" debug="on" fork="true" includeantruntime="false">
|
||||
<classpath refid="build.classpath"/>
|
||||
<src path="${test}"/>
|
||||
<include name="org/jetbrains/plugins/ideavim/**"/>
|
||||
</javac2>
|
||||
</target>
|
||||
|
||||
<target name="prepare-tests" depends="compile-tests">
|
||||
<mkdir dir="${classes}/META-INF"/>
|
||||
<copy file="resources/META-INF/plugin.xml" todir="${classes}/META-INF">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${version}"/>
|
||||
<filter token="SINCE-VERSION" value="${platform-version}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<copy todir="${classes}">
|
||||
<fileset dir="${resources}"/>
|
||||
</copy>
|
||||
<mkdir dir="${out}/IdeaVim"/>
|
||||
<copy todir="${out}/IdeaVim">
|
||||
<fileset dir="${keymap}" includes="**"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="unzip, clean, prepare-tests">
|
||||
<mkdir dir="${test-reports}"/>
|
||||
<junit fork="true" logfailedtests="false" printsummary="true">
|
||||
<classpath refid="test.classpath"/>
|
||||
|
||||
<jvmarg value="-Xmx256M"/>
|
||||
<jvmarg value="-ea"/>
|
||||
<jvmarg value="-Djava.awt.headless=true"/>
|
||||
<jvmarg value="-Didea.plugins.path=${out}"/>
|
||||
<jvmarg value="-Didea.load.plugins.id=IdeaVIM"/>
|
||||
|
||||
<formatter type="plain"/>
|
||||
|
||||
<batchtest todir="${test-reports}">
|
||||
<fileset dir="${test}">
|
||||
<include name="**/*Test.java"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
</junit>
|
||||
</target>
|
||||
</project>
|
||||
|
114
index.txt
Normal file
114
index.txt
Normal file
@@ -0,0 +1,114 @@
|
||||
*index.txt*
|
||||
|
||||
|
||||
IDEAVIM REFERENCE MANUAL based on Vim Reference Manual
|
||||
|
||||
*index*
|
||||
This file contains a list of all commands for each mode, with a tag and a
|
||||
short description. The lists are sorted on ASCII value.
|
||||
|
||||
Tip: When looking for certain functionality, use a search command. E.g.,
|
||||
to look for deleting something, use: "/delete".
|
||||
|
||||
1. Insert mode |insert-index|
|
||||
2. Normal mode |normal-index|
|
||||
2.1. Text objects |objects|
|
||||
3. Visual mode |visual-index|
|
||||
5. EX commands |ex-cmd-index|
|
||||
|
||||
==============================================================================
|
||||
1. Insert mode *insert-index*
|
||||
|
||||
tag char action in Insert mode ~
|
||||
-----------------------------------------------------------------------
|
||||
|i_CTRL-K| CTRL-K {char1} {char2}
|
||||
enter digraph
|
||||
|i_CTRL-O| CTRL-O execute a single command and return to insert
|
||||
mode
|
||||
|i_CTRL-W| CTRL-W delete word before the cursor
|
||||
|
||||
==============================================================================
|
||||
2. Normal mode *normal-index*
|
||||
|
||||
CHAR any non-blank character
|
||||
WORD a sequence of non-blank characters
|
||||
N a number entered before the command
|
||||
{motion} a cursor movement command
|
||||
Nmove the text that is moved over with a {motion}
|
||||
SECTION a section that possibly starts with '}' instead of '{'
|
||||
|
||||
note: 1 = cursor movement command; 2 = can be undone/redone
|
||||
|
||||
tag char note action in Normal mode ~
|
||||
------------------------------------------------------------------------------
|
||||
|quote| "{a-zA-Z0-9.%#:-"} use register {a-zA-Z0-9.%#:-"} for next
|
||||
delete, yank or put (uppercase to append)
|
||||
({.%#:} only work with put)
|
||||
|/| /{pattern}<CR> 1 search forward for the Nth occurrence of
|
||||
{pattern}
|
||||
|count| 0 1 cursor to the first char of the line
|
||||
|count| 1 prepend to command to give a count
|
||||
|count| 2 "
|
||||
|count| 3 "
|
||||
|count| 4 "
|
||||
|count| 5 "
|
||||
|count| 6 "
|
||||
|count| 7 "
|
||||
|count| 8 "
|
||||
|count| 9 "
|
||||
|F| F{char} 1 cursor to the Nth occurrence of {char} to
|
||||
the left
|
||||
|P| ["x]P 2 put the text [from buffer x] before the
|
||||
cursor N times
|
||||
|T| T{char} 1 cursor till after Nth occurrence of {char}
|
||||
to the left
|
||||
|Y| ["x]Y yank N lines [into buffer x]; synonym for
|
||||
"yy"
|
||||
|c| ["x]c{motion} 2 delete Nmove text [into buffer x] and start
|
||||
insert
|
||||
|d| ["x]d{motion} 2 delete Nmove text [into buffer x]
|
||||
|f| f{char} 1 cursor to Nth occurrence of {char} to the
|
||||
right
|
||||
|i| i 2 insert text before the cursor N times
|
||||
|p| ["x]p 2 put the text [from register x] after the
|
||||
cursor N times
|
||||
|q| q{0-9a-zA-Z"} record typed characters into named register
|
||||
{0-9a-zA-Z"} (uppercase to append)
|
||||
|q| q (while recording) stops recording
|
||||
|t| t{char} 1 cursor till before Nth occurrence of {char}
|
||||
to the right
|
||||
|y| ["x]y{motion} yank Nmove text [into buffer x]
|
||||
|yy| ["x]yy yank N lines [into buffer x]
|
||||
|
||||
==============================================================================
|
||||
2.1 Text objects *objects*
|
||||
|
||||
These can be used after an operator or in Visual mode to select an object.
|
||||
|
||||
tag command action in op-pending and Visual mode ~
|
||||
------------------------------------------------------------------------------
|
||||
|v_iW| iW "inner WORD"
|
||||
|v_iw| iw "inner word"
|
||||
|
||||
==============================================================================
|
||||
3. Visual mode *visual-index*
|
||||
|
||||
Most commands in Visual mode are the same as in Normal mode. The ones listed
|
||||
here are those that are different.
|
||||
|
||||
tag command note action in Visual mode ~
|
||||
------------------------------------------------------------------------------
|
||||
|v_y| y yank the highlighted area
|
||||
|
||||
==============================================================================
|
||||
5. EX commands *ex-cmd-index*
|
||||
|
||||
This is a brief but complete listing of all the ":" commands, without
|
||||
mentioning any arguments. The optional part of the command name is inside [].
|
||||
The commands are sorted on the non-optional part of their name.
|
||||
|
||||
tag command action ~
|
||||
------------------------------------------------------------------------------
|
||||
|:display| :di[splay] display registers
|
||||
|:registers| :reg[isters] display the contents of registers
|
||||
|:substitute| :s[ubstitute] find and replace text
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
|
||||
@@ -39,6 +40,8 @@ import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import com.maddyhome.idea.vim.helper.RunnableHelper;
|
||||
import com.maddyhome.idea.vim.key.*;
|
||||
import com.maddyhome.idea.vim.option.Options;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -56,11 +59,11 @@ public class KeyHandler {
|
||||
*
|
||||
* @return A reference to the singleton
|
||||
*/
|
||||
@NotNull
|
||||
public static KeyHandler getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new KeyHandler();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -83,7 +86,7 @@ public class KeyHandler {
|
||||
/**
|
||||
* Gets the original key handler
|
||||
*
|
||||
* @return The orginal key handler
|
||||
* @return The original key handler
|
||||
*/
|
||||
public TypedActionHandler getOriginalHandler() {
|
||||
return origHandler;
|
||||
@@ -97,349 +100,397 @@ public class KeyHandler {
|
||||
* @param key The keystroke typed by the user
|
||||
* @param context The data context
|
||||
*/
|
||||
public void handleKey(Editor editor, KeyStroke key, DataContext context) {
|
||||
public void handleKey(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context) {
|
||||
VimPlugin.clearError();
|
||||
// All the editor actions should be performed with top level editor!!!
|
||||
// Be careful: all the EditorActionHandler implementation should correctly process InjectedEditors
|
||||
editor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||
logger.debug("handleKey " + key);
|
||||
CommandState editorState = CommandState.getInstance(editor);
|
||||
boolean isRecording = editorState.isRecording();
|
||||
final CommandState editorState = CommandState.getInstance(editor);
|
||||
final boolean isRecording = editorState.isRecording();
|
||||
boolean shouldRecord = true;
|
||||
for (int loop = 0; loop < 2; loop++) {
|
||||
// If this is a "regular" character keystroke, get the character
|
||||
char chKey = key.getKeyChar() == KeyEvent.CHAR_UNDEFINED ? 0 : key.getKeyChar();
|
||||
// If this is a "regular" character keystroke, get the character
|
||||
char chKey = key.getKeyChar() == KeyEvent.CHAR_UNDEFINED ? 0 : key.getKeyChar();
|
||||
|
||||
if ((editorState.getMode() == CommandState.MODE_COMMAND || mode == STATE_COMMAND) &&
|
||||
(key.getKeyCode() == KeyEvent.VK_ESCAPE ||
|
||||
(key.getKeyCode() == KeyEvent.VK_C && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0) ||
|
||||
(key.getKeyCode() == '[' && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0))) {
|
||||
if (mode != STATE_COMMAND && count == 0 && currentArg == Argument.NONE && currentCmd.size() == 0 &&
|
||||
CommandGroups.getInstance().getRegister().getCurrentRegister() == RegisterGroup.REGISTER_DEFAULT) {
|
||||
if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
KeyHandler.executeAction("VimEditorEscape", context);
|
||||
//getOriginalHandler().execute(editor, key.getKeyChar(), context);
|
||||
}
|
||||
VimPlugin.indicateError();
|
||||
}
|
||||
if (isEditorReset(key, editorState)) {
|
||||
handleEditorReset(editor, key, context);
|
||||
}
|
||||
// At this point the user must be typing in a command. Most commands can be preceded by a number. Let's
|
||||
// check if a number can be entered at this point, and if so, did the user send us a digit.
|
||||
else if (isCommandCount(editorState, chKey)) {
|
||||
// Update the count
|
||||
count = count * 10 + (chKey - '0');
|
||||
logger.debug("count now " + count);
|
||||
}
|
||||
// Pressing delete while entering a count "removes" the last digit entered
|
||||
else if (isDeleteCommandCount(key, editorState)) {
|
||||
// "Remove" the last digit sent to us
|
||||
count /= 10;
|
||||
logger.debug("count now " + count);
|
||||
}
|
||||
// If we got this far the user is entering a command or supplying an argument to an entered command.
|
||||
// First let's check to see if we are at the point of expecting a single character argument to a command.
|
||||
else if (currentArg == Argument.Type.CHARACTER) {
|
||||
handleCharArgument(key, chKey);
|
||||
}
|
||||
// If we are this far, then the user must be entering a command or a non-single-character argument
|
||||
// to an entered command. Let's figure out which it is
|
||||
else {
|
||||
// For debugging purposes we track the keys entered for this command
|
||||
keys.add(key);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("keys now " + keys);
|
||||
}
|
||||
|
||||
reset(editor);
|
||||
}
|
||||
// At this point the user must be typing in a command. Most commands can be preceeded by a number. Let's
|
||||
// check if a number can be entered at this point, and if so, did the user send us a digit.
|
||||
else if ((editorState.getMode() == CommandState.MODE_COMMAND ||
|
||||
editorState.getMode() == CommandState.MODE_VISUAL) &&
|
||||
mode == STATE_NEW_COMMAND && currentArg != Argument.CHARACTER && currentArg != Argument.DIGRAPH &&
|
||||
Character.isDigit(chKey) &&
|
||||
(count != 0 || chKey != '0')) {
|
||||
// Update the count
|
||||
count = count * 10 + (chKey - '0');
|
||||
logger.debug("count now " + count);
|
||||
}
|
||||
// Pressing delete while entering a count "removes" the last digit entered
|
||||
else if ((editorState.getMode() == CommandState.MODE_COMMAND ||
|
||||
editorState.getMode() == CommandState.MODE_VISUAL) &&
|
||||
mode == STATE_NEW_COMMAND && currentArg != Argument.CHARACTER && currentArg != Argument.DIGRAPH &&
|
||||
key.getKeyCode() == KeyEvent.VK_DELETE && count != 0) {
|
||||
// "Remove" the last digit sent to us
|
||||
count /= 10;
|
||||
logger.debug("count now " + count);
|
||||
}
|
||||
// If we got this far the user is entering a command or supplying an argument to an entered command.
|
||||
// First let's check to see if we are at the point of expecting a single character argument to a command.
|
||||
else if (currentArg == Argument.CHARACTER) {
|
||||
logger.debug("currentArg is Character");
|
||||
// We are expecting a character argument - is this a regular character the user typed?
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
// Ask the key/action tree if this is an appropriate key at this point in the command and if so,
|
||||
// return the node matching this keystroke
|
||||
final Node node = editorState.getCurrentNode().getChild(key);
|
||||
|
||||
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);
|
||||
mode = STATE_READY;
|
||||
}
|
||||
else {
|
||||
// Oops - this isn't a valid character argument
|
||||
mode = STATE_BAD_COMMAND;
|
||||
}
|
||||
if (handleDigraph(editor, key, context, node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is a branch node we have entered only part of a multi-key command
|
||||
if (node instanceof BranchNode) {
|
||||
handleBranchNode(editor, context, editorState, chKey, (BranchNode)node);
|
||||
}
|
||||
// If this is a command node the user has entered a valid key sequence of a known command
|
||||
else if (node instanceof CommandNode) {
|
||||
handleCommandNode(editor, context, (CommandNode)node);
|
||||
}
|
||||
// If this is an argument node then the last keystroke was not part of the current command but should
|
||||
// be the first keystroke of the argument of the current command
|
||||
else if (node instanceof ArgumentNode) {
|
||||
shouldRecord = handleArgumentNode(editor, key, context, editorState, shouldRecord, (ArgumentNode)node);
|
||||
}
|
||||
// If we are this far - sheesh, then the user must be entering a command or a non-single-character argument
|
||||
// to an entered command. Let's figure out which it is
|
||||
else {
|
||||
// For debugging purposes we track the keys entered for this command
|
||||
keys.add(key);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("keys now " + keys);
|
||||
logger.debug("checking for digraph");
|
||||
logger.debug("lastWasBS=" + lastWasBS);
|
||||
logger.debug("lastChar=" + lastChar);
|
||||
if (lastWasBS && lastChar != 0 && Options.getInstance().isSet("digraph")) {
|
||||
char dig = CommandGroups.getInstance().getDigraph().getDigraph(lastChar, key.getKeyChar());
|
||||
logger.debug("dig=" + dig);
|
||||
key = KeyStroke.getKeyStroke(dig);
|
||||
}
|
||||
|
||||
// Ask the key/action tree if this is an appropriate key at this point in the command and if so,
|
||||
// return the node matching this keystroke
|
||||
Node node = editorState.getCurrentNode().getChild(key);
|
||||
|
||||
if (digraph == null && !(node instanceof CommandNode) && DigraphSequence.isDigraphStart(key)) {
|
||||
digraph = new DigraphSequence();
|
||||
}
|
||||
if (digraph != null) {
|
||||
DigraphSequence.DigraphResult res = digraph.processKey(key, editor, context);
|
||||
switch (res.getResult()) {
|
||||
case DigraphSequence.DigraphResult.RES_OK:
|
||||
return;
|
||||
case DigraphSequence.DigraphResult.RES_BAD:
|
||||
digraph = null;
|
||||
return;
|
||||
case DigraphSequence.DigraphResult.RES_DONE:
|
||||
if (currentArg == Argument.DIGRAPH) {
|
||||
currentArg = Argument.CHARACTER;
|
||||
}
|
||||
key = res.getStroke();
|
||||
digraph = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.debug("digraph done");
|
||||
}
|
||||
|
||||
// If this is a branch node we have entered only part of a multikey command
|
||||
if (node instanceof BranchNode) {
|
||||
logger.debug("branch node");
|
||||
BranchNode bnode = (BranchNode)node;
|
||||
// Flag that we aren't allowing any more count digits (unless it's OK)
|
||||
if ((bnode.getFlags() & Command.FLAG_ALLOW_MID_COUNT) == 0) {
|
||||
mode = STATE_COMMAND;
|
||||
}
|
||||
editorState.setCurrentNode(bnode);
|
||||
|
||||
ArgumentNode arg = (ArgumentNode)((BranchNode)editorState.getCurrentNode()).getArgumentNode();
|
||||
if (arg != null) {
|
||||
if (editorState.isRecording() && (arg.getFlags() & Command.FLAG_NO_ARG_RECORDING) != 0) {
|
||||
handleKey(editor, KeyStroke.getKeyStroke(' '), context);
|
||||
}
|
||||
|
||||
if (arg.getArgType() == Argument.EX_STRING) {
|
||||
CommandGroups.getInstance().getProcess().startSearchCommand(editor, context, count, chKey);
|
||||
mode = STATE_NEW_COMMAND;
|
||||
currentArg = Argument.EX_STRING;
|
||||
editorState.pushState(CommandState.MODE_EX_ENTRY, 0, KeyParser.MAPPING_CMD_LINE);
|
||||
}
|
||||
// If we are in insert/replace mode send this key in for processing
|
||||
if (editorState.getMode() == CommandState.Mode.INSERT ||
|
||||
editorState.getMode() == CommandState.Mode.REPLACE) {
|
||||
if (!CommandGroups.getInstance().getChange().processKey(editor, context, key)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
// If this is a command node the user has entered a valid key sequence of a known command
|
||||
else if (node instanceof CommandNode) {
|
||||
logger.debug("command node");
|
||||
// If all does well we are ready to process this command
|
||||
mode = STATE_READY;
|
||||
CommandNode cmdNode = (CommandNode)node;
|
||||
// Did we just get the completed sequence for a motion command argument?
|
||||
if (currentArg == Argument.MOTION) {
|
||||
// We have been expecting a motion argument - is this one?
|
||||
if (cmdNode.getCmdType() == Command.MOTION) {
|
||||
// Create the motion command and add it to the stack
|
||||
Command cmd = new Command(count, cmdNode.getActionId(), cmdNode.getAction(),
|
||||
cmdNode.getCmdType(), cmdNode.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
}
|
||||
else if (cmdNode.getCmdType() == Command.RESET) {
|
||||
currentCmd.clear();
|
||||
Command cmd = new Command(1, cmdNode.getActionId(), cmdNode.getAction(),
|
||||
cmdNode.getCmdType(), cmdNode.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
}
|
||||
else {
|
||||
// Oops - this wasn't a motion command. The user goofed and typed something else
|
||||
mode = STATE_BAD_COMMAND;
|
||||
}
|
||||
}
|
||||
else if (currentArg == Argument.EX_STRING && (cmdNode.getFlags() & Command.FLAG_COMPLETE_EX) != 0) {
|
||||
String text = CommandGroups.getInstance().getProcess().endSearchCommand(editor, context);
|
||||
Argument arg = new Argument(text);
|
||||
Command cmd = currentCmd.peek();
|
||||
cmd.setArgument(arg);
|
||||
CommandState.getInstance(editor).popState();
|
||||
}
|
||||
// The user entered a valid command that doesn't take any arguments
|
||||
else {
|
||||
// Create the command and add it to the stack
|
||||
Command cmd = new Command(count, cmdNode.getActionId(), cmdNode.getAction(),
|
||||
cmdNode.getCmdType(), cmdNode.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
|
||||
// This is a sanity check that the command has a valid action. This should only fail if the
|
||||
// programmer made a typo or forgot to add the action to the plugin.xml file
|
||||
if (cmd.getAction() == null) {
|
||||
logger.error("NULL action for keys '" + keys + "'");
|
||||
mode = STATE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If this is an argument node then the last keystroke was not part of the current command but should
|
||||
// be the first keystroke of the current command's argument
|
||||
else if (node instanceof ArgumentNode) {
|
||||
logger.debug("argument node");
|
||||
// Create a new command based on what the user has typed so far, excluding this keystroke.
|
||||
ArgumentNode arg = (ArgumentNode)node;
|
||||
Command cmd = new Command(count, arg.getActionId(), arg.getAction(), arg.getCmdType(), arg.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
// What type of argument does this command expect?
|
||||
switch (arg.getArgType()) {
|
||||
case Argument.DIGRAPH:
|
||||
//digraphState = 0;
|
||||
digraph = new DigraphSequence();
|
||||
// No break - fall through
|
||||
case Argument.CHARACTER:
|
||||
case Argument.MOTION:
|
||||
mode = STATE_NEW_COMMAND;
|
||||
currentArg = arg.getArgType();
|
||||
// Is the current command an operator? If so set the state to only accept "operator pending"
|
||||
// commands
|
||||
if ((arg.getFlags() & Command.FLAG_OP_PEND) != 0) {
|
||||
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_OP_PEND);
|
||||
editorState.pushState(editorState.getMode(), editorState.getSubMode(),
|
||||
KeyParser.MAPPING_OP_PEND);
|
||||
}
|
||||
break;
|
||||
case Argument.EX_STRING:
|
||||
/*
|
||||
mode = STATE_NEW_COMMAND;
|
||||
currentArg = arg.getArgType();
|
||||
editorState.pushState(CommandState.MODE_EX_ENTRY, 0, KeyParser.MAPPING_CMD_LINE);
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
// Oops - we aren't expecting any other type of argument
|
||||
mode = STATE_ERROR;
|
||||
}
|
||||
|
||||
// If the current keystroke is really the first character of an argument the user needs to enter,
|
||||
// recursively go back and handle this keystroke again with all the state properly updated to
|
||||
// handle the argument
|
||||
if (currentArg != Argument.NONE) {
|
||||
partialReset(editor);
|
||||
boolean saveRecording = isRecording;
|
||||
handleKey(editor, key, context);
|
||||
isRecording = saveRecording;
|
||||
shouldRecord = false; // Prevent this from getting recorded twice
|
||||
else if (editorState.getMappingMode() == KeyParser.MAPPING_CMD_LINE) {
|
||||
if (!CommandGroups.getInstance().getProcess().processExKey(editor, key, true)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
// If we get here then the user has entered an unrecognized series of keystrokes
|
||||
else {
|
||||
logger.debug("checking for digraph");
|
||||
logger.debug("lastWasBS=" + lastWasBS);
|
||||
logger.debug("lastChar=" + lastChar);
|
||||
if (lastWasBS && lastChar != 0 && Options.getInstance().isSet("digraph")) {
|
||||
char dig = CommandGroups.getInstance().getDigraph().getDigraph(lastChar, key.getKeyChar());
|
||||
logger.debug("dig=" + dig);
|
||||
key = KeyStroke.getKeyStroke(dig);
|
||||
}
|
||||
|
||||
// If we are in insert/replace mode send this key in for processing
|
||||
if (editorState.getMode() == CommandState.MODE_INSERT ||
|
||||
editorState.getMode() == CommandState.MODE_REPLACE) {
|
||||
if (!CommandGroups.getInstance().getChange().processKey(editor, context, key)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
else if (editorState.getMappingMode() == KeyParser.MAPPING_CMD_LINE) {
|
||||
if (!CommandGroups.getInstance().getProcess().processExKey(editor, context, key, true)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
// If we get here then the user has entered an unrecognized series of keystrokes
|
||||
else {
|
||||
mode = STATE_BAD_COMMAND;
|
||||
}
|
||||
|
||||
lastChar = key.getKeyChar();
|
||||
partialReset(editor);
|
||||
state = State.BAD_COMMAND;
|
||||
}
|
||||
|
||||
lastChar = key.getKeyChar();
|
||||
partialReset(editor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Do we have a fully entered command at this point? If so, lets execute it
|
||||
if (mode == STATE_READY) {
|
||||
DelegateCommandListener.getInstance().setRunnable(null);
|
||||
// Let's go through the command stack and merge it all into one command. At this time there should never
|
||||
// be more than two commands on the stack - one is the actual command and the other would be a motion
|
||||
// command argument needed by the first command
|
||||
Command cmd = currentCmd.pop();
|
||||
while (currentCmd.size() > 0) {
|
||||
Command top = currentCmd.pop();
|
||||
top.setArgument(new Argument(cmd));
|
||||
cmd = top;
|
||||
if (state == State.READY) {
|
||||
executeCommand(editor, key, context, editorState);
|
||||
}
|
||||
else if (state == State.BAD_COMMAND) {
|
||||
VimPlugin.indicateError();
|
||||
reset(editor);
|
||||
}
|
||||
// We had some sort of error so reset the handler and let the user know (beep)
|
||||
else if (state == State.ERROR) {
|
||||
VimPlugin.indicateError();
|
||||
fullReset(editor);
|
||||
}
|
||||
else if (isRecording && shouldRecord) {
|
||||
CommandGroups.getInstance().getRegister().addKeyStroke(key);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context) {
|
||||
if (state != State.COMMAND && count == 0 && currentArg == Argument.Type.NONE && currentCmd.size() == 0 &&
|
||||
CommandGroups.getInstance().getRegister().getCurrentRegister() == RegisterGroup.REGISTER_DEFAULT) {
|
||||
if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
KeyHandler.executeAction("VimEditorEscape", context);
|
||||
//getOriginalHandler().execute(editor, key.getKeyChar(), context);
|
||||
}
|
||||
VimPlugin.indicateError();
|
||||
}
|
||||
|
||||
reset(editor);
|
||||
}
|
||||
|
||||
private boolean isDeleteCommandCount(@NotNull KeyStroke key, @NotNull CommandState editorState) {
|
||||
return (editorState.getMode() == CommandState.Mode.COMMAND ||
|
||||
editorState.getMode() == CommandState.Mode.VISUAL) &&
|
||||
state == State.NEW_COMMAND && currentArg != Argument.Type.CHARACTER && currentArg !=
|
||||
Argument.Type.DIGRAPH &&
|
||||
key.getKeyCode() == KeyEvent.VK_DELETE && count != 0;
|
||||
}
|
||||
|
||||
private boolean isCommandCount(@NotNull CommandState editorState, char chKey) {
|
||||
return (editorState.getMode() == CommandState.Mode.COMMAND ||
|
||||
editorState.getMode() == CommandState.Mode.VISUAL) &&
|
||||
state == State.NEW_COMMAND && currentArg != Argument.Type.CHARACTER && currentArg !=
|
||||
Argument.Type.DIGRAPH &&
|
||||
Character.isDigit(chKey) &&
|
||||
(count != 0 || chKey != '0');
|
||||
}
|
||||
|
||||
private boolean isEditorReset(@NotNull KeyStroke key, @NotNull CommandState editorState) {
|
||||
return (editorState.getMode() == CommandState.Mode.COMMAND || state == State.COMMAND) &&
|
||||
(key.getKeyCode() == KeyEvent.VK_ESCAPE ||
|
||||
(key.getKeyCode() == KeyEvent.VK_C && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0) ||
|
||||
(key.getKeyCode() == '[' && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0));
|
||||
}
|
||||
|
||||
private void handleCharArgument(@NotNull KeyStroke key, char chKey) {
|
||||
logger.debug("currentArg is Character");
|
||||
// We are expecting a character argument - is this a regular character the user typed?
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleDigraph(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context, @Nullable Node node) {
|
||||
if (digraph == null && !(node instanceof CommandNode) && DigraphSequence.isDigraphStart(key)) {
|
||||
digraph = new DigraphSequence();
|
||||
}
|
||||
if (digraph != null) {
|
||||
DigraphSequence.DigraphResult res = digraph.processKey(key, editor, context);
|
||||
switch (res.getResult()) {
|
||||
case DigraphSequence.DigraphResult.RES_OK:
|
||||
return true;
|
||||
case DigraphSequence.DigraphResult.RES_BAD:
|
||||
digraph = null;
|
||||
return true;
|
||||
case DigraphSequence.DigraphResult.RES_DONE:
|
||||
if (currentArg == Argument.Type.DIGRAPH) {
|
||||
currentArg = Argument.Type.CHARACTER;
|
||||
}
|
||||
digraph = null;
|
||||
handleKey(editor, res.getStroke(), context);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("cmd=" + cmd);
|
||||
}
|
||||
// If we have a command and a motion command argument, both could possibly have their own counts. We
|
||||
// need to adjust the counts so the motion gets the product of both counts and the command's count gets
|
||||
// reset. Example 3c2w (change 2 words, three times) becomes c6w (change 6 words)
|
||||
Argument arg = cmd.getArgument();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("arg=" + arg);
|
||||
}
|
||||
if (arg != null && arg.getType() == Argument.MOTION) {
|
||||
Command mot = arg.getMotion();
|
||||
// If no count was entered for either command then nothing changes. If either had a count then
|
||||
// the motion gets the product of both.
|
||||
int cnt = cmd.getRawCount() == 0 && mot.getRawCount() == 0 ? 0 : cmd.getCount() * mot.getCount();
|
||||
cmd.setCount(0);
|
||||
mot.setCount(cnt);
|
||||
}
|
||||
logger.debug("digraph done");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we were in "operator pending" mode, reset back to normal mode.
|
||||
if (editorState.getMappingMode() == KeyParser.MAPPING_OP_PEND) {
|
||||
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_NORMAL);
|
||||
editorState.popState();
|
||||
}
|
||||
private void executeCommand(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
||||
@NotNull CommandState editorState) {
|
||||
DelegateCommandListener.getInstance().setRunnable(null);
|
||||
// Let's go through the command stack and merge it all into one command. At this time there should never
|
||||
// be more than two commands on the stack - one is the actual command and the other would be a motion
|
||||
// command argument needed by the first command
|
||||
Command cmd = currentCmd.pop();
|
||||
while (currentCmd.size() > 0) {
|
||||
Command top = currentCmd.pop();
|
||||
top.setArgument(new Argument(cmd));
|
||||
cmd = top;
|
||||
}
|
||||
|
||||
// Save off the command we are about to execute
|
||||
editorState.setCommand(cmd);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("cmd=" + cmd);
|
||||
}
|
||||
// If we have a command and a motion command argument, both could possibly have their own counts. We
|
||||
// need to adjust the counts so the motion gets the product of both counts and the count associated with
|
||||
// the command gets reset. Example 3c2w (change 2 words, three times) becomes c6w (change 6 words)
|
||||
Argument arg = cmd.getArgument();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("arg=" + arg);
|
||||
}
|
||||
if (arg != null && arg.getType() == Argument.Type.MOTION) {
|
||||
Command mot = arg.getMotion();
|
||||
// If no count was entered for either command then nothing changes. If either had a count then
|
||||
// the motion gets the product of both.
|
||||
int cnt = cmd.getRawCount() == 0 && mot.getRawCount() == 0 ? 0 : cmd.getCount() * mot.getCount();
|
||||
cmd.setCount(0);
|
||||
mot.setCount(cnt);
|
||||
}
|
||||
|
||||
lastWasBS = ((cmd.getFlags() & Command.FLAG_IS_BACKSPACE) != 0);
|
||||
logger.debug("lastWasBS=" + lastWasBS);
|
||||
// If we were in "operator pending" mode, reset back to normal mode.
|
||||
if (editorState.getMappingMode() == KeyParser.MAPPING_OP_PEND) {
|
||||
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_NORMAL);
|
||||
editorState.popState();
|
||||
}
|
||||
|
||||
Project project = editor.getProject();
|
||||
if (cmd.isReadType() || EditorHelper.canEdit(project, editor)) {
|
||||
// Save off the command we are about to execute
|
||||
editorState.setCommand(cmd);
|
||||
|
||||
lastWasBS = ((cmd.getFlags() & Command.FLAG_IS_BACKSPACE) != 0);
|
||||
logger.debug("lastWasBS=" + lastWasBS);
|
||||
|
||||
Project project = editor.getProject();
|
||||
if (cmd.getType().isRead() || project == null || EditorHelper.canEdit(project, editor)) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
Runnable action = new ActionRunner(editor, context, cmd, key);
|
||||
if (cmd.isWriteType()) {
|
||||
if (cmd.getType().isWrite()) {
|
||||
RunnableHelper.runWriteCommand(project, action, cmd.getActionId(), null);
|
||||
}
|
||||
else {
|
||||
RunnableHelper.runReadCommand(project, action, cmd.getActionId(), null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.info("write command on read-only file");
|
||||
VimPlugin.indicateError();
|
||||
reset(editor);
|
||||
}
|
||||
}
|
||||
else if (mode == STATE_BAD_COMMAND) {
|
||||
else {
|
||||
logger.info("write command on read-only file");
|
||||
VimPlugin.indicateError();
|
||||
reset(editor);
|
||||
}
|
||||
// We had some sort of error so reset the handler and let the user know (beep)
|
||||
else if (mode == STATE_ERROR) {
|
||||
VimPlugin.indicateError();
|
||||
fullReset(editor);
|
||||
}
|
||||
|
||||
private boolean handleArgumentNode(@NotNull Editor editor,
|
||||
@NotNull KeyStroke key,
|
||||
@NotNull DataContext context,
|
||||
@NotNull CommandState editorState,
|
||||
boolean shouldRecord,
|
||||
@NotNull ArgumentNode node) {
|
||||
logger.debug("argument node");
|
||||
// Create a new command based on what the user has typed so far, excluding this keystroke.
|
||||
Command cmd = new Command(count, node.getActionId(), node.getAction(), node.getCmdType(), node.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
// What type of argument does this command expect?
|
||||
switch (node.getArgType()) {
|
||||
case DIGRAPH:
|
||||
//digraphState = 0;
|
||||
digraph = new DigraphSequence();
|
||||
// No break - fall through
|
||||
case CHARACTER:
|
||||
case MOTION:
|
||||
state = State.NEW_COMMAND;
|
||||
currentArg = node.getArgType();
|
||||
// Is the current command an operator? If so set the state to only accept "operator pending"
|
||||
// commands
|
||||
if ((node.getFlags() & Command.FLAG_OP_PEND) != 0) {
|
||||
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_OP_PEND);
|
||||
editorState.pushState(editorState.getMode(), editorState.getSubMode(),
|
||||
KeyParser.MAPPING_OP_PEND);
|
||||
}
|
||||
break;
|
||||
case EX_STRING:
|
||||
break;
|
||||
default:
|
||||
// Oops - we aren't expecting any other type of argument
|
||||
state = State.ERROR;
|
||||
}
|
||||
else if (isRecording && shouldRecord) {
|
||||
CommandGroups.getInstance().getRegister().addKeyStroke(key);
|
||||
|
||||
// If the current keystroke is really the first character of an argument the user needs to enter,
|
||||
// recursively go back and handle this keystroke again with all the state properly updated to
|
||||
// handle the argument
|
||||
if (currentArg != Argument.Type.NONE) {
|
||||
partialReset(editor);
|
||||
handleKey(editor, key, context);
|
||||
shouldRecord = false; // Prevent this from getting recorded twice
|
||||
}
|
||||
return shouldRecord;
|
||||
}
|
||||
|
||||
private void handleCommandNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandNode node) {
|
||||
logger.debug("command node");
|
||||
// If all does well we are ready to process this command
|
||||
state = State.READY;
|
||||
// Did we just get the completed sequence for a motion command argument?
|
||||
if (currentArg == Argument.Type.MOTION) {
|
||||
// We have been expecting a motion argument - is this one?
|
||||
if (node.getCmdType() == Command.Type.MOTION) {
|
||||
// Create the motion command and add it to the stack
|
||||
Command cmd = new Command(count, node.getActionId(), node.getAction(),
|
||||
node.getCmdType(), node.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
}
|
||||
else if (node.getCmdType() == Command.Type.RESET) {
|
||||
currentCmd.clear();
|
||||
Command cmd = new Command(1, node.getActionId(), node.getAction(),
|
||||
node.getCmdType(), node.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
}
|
||||
else {
|
||||
// Oops - this wasn't a motion command. The user goofed and typed something else
|
||||
state = State.BAD_COMMAND;
|
||||
}
|
||||
}
|
||||
else if (currentArg == Argument.Type.EX_STRING && (node.getFlags() & Command.FLAG_COMPLETE_EX) != 0) {
|
||||
String text = CommandGroups.getInstance().getProcess().endSearchCommand(editor, context);
|
||||
Argument arg = new Argument(text);
|
||||
Command cmd = currentCmd.peek();
|
||||
cmd.setArgument(arg);
|
||||
CommandState.getInstance(editor).popState();
|
||||
}
|
||||
// The user entered a valid command that doesn't take any arguments
|
||||
else {
|
||||
// Create the command and add it to the stack
|
||||
Command cmd = new Command(count, node.getActionId(), node.getAction(),
|
||||
node.getCmdType(), node.getFlags());
|
||||
cmd.setKeys(keys);
|
||||
currentCmd.push(cmd);
|
||||
|
||||
// This is a sanity check that the command has a valid action. This should only fail if the
|
||||
// programmer made a typo or forgot to add the action to the plugin.xml file
|
||||
if (cmd.getAction() == null) {
|
||||
logger.error("NULL action for keys '" + keys + "'");
|
||||
state = State.ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBranchNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandState editorState, char key,
|
||||
@NotNull BranchNode node) {
|
||||
logger.debug("branch node");
|
||||
// Flag that we aren't allowing any more count digits (unless it's OK)
|
||||
if ((node.getFlags() & Command.FLAG_ALLOW_MID_COUNT) == 0) {
|
||||
state = State.COMMAND;
|
||||
}
|
||||
editorState.setCurrentNode(node);
|
||||
|
||||
ArgumentNode arg = (ArgumentNode)((BranchNode)editorState.getCurrentNode()).getArgumentNode();
|
||||
if (arg != null) {
|
||||
if (currentArg == Argument.Type.MOTION && arg.getCmdType() != Command.Type.MOTION) {
|
||||
editorState.popState();
|
||||
state = State.BAD_COMMAND;
|
||||
return;
|
||||
}
|
||||
if (editorState.isRecording() && (arg.getFlags() & Command.FLAG_NO_ARG_RECORDING) != 0) {
|
||||
handleKey(editor, KeyStroke.getKeyStroke(' '), context);
|
||||
}
|
||||
|
||||
if (arg.getArgType() == Argument.Type.EX_STRING) {
|
||||
CommandGroups.getInstance().getProcess().startSearchCommand(editor, context, count, key);
|
||||
state = State.NEW_COMMAND;
|
||||
currentArg = Argument.Type.EX_STRING;
|
||||
editorState.pushState(CommandState.Mode.EX_ENTRY, CommandState.SubMode.NONE, KeyParser.MAPPING_CMD_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,7 +543,7 @@ public class KeyHandler {
|
||||
*
|
||||
* @param editor The editor to reset.
|
||||
*/
|
||||
private void partialReset(Editor editor) {
|
||||
private void partialReset(@Nullable Editor editor) {
|
||||
count = 0;
|
||||
keys = new ArrayList<KeyStroke>();
|
||||
CommandState editorState = CommandState.getInstance(editor);
|
||||
@@ -505,11 +556,11 @@ public class KeyHandler {
|
||||
*
|
||||
* @param editor The editor to reset.
|
||||
*/
|
||||
public void reset(Editor editor) {
|
||||
public void reset(@Nullable Editor editor) {
|
||||
partialReset(editor);
|
||||
mode = STATE_NEW_COMMAND;
|
||||
state = State.NEW_COMMAND;
|
||||
currentCmd.clear();
|
||||
currentArg = Argument.NONE;
|
||||
currentArg = Argument.Type.NONE;
|
||||
digraph = null;
|
||||
logger.debug("reset");
|
||||
}
|
||||
@@ -520,7 +571,8 @@ public class KeyHandler {
|
||||
*
|
||||
* @param editor The editor to reset.
|
||||
*/
|
||||
public void fullReset(Editor editor) {
|
||||
public void fullReset(@Nullable Editor editor) {
|
||||
VimPlugin.clearError();
|
||||
CommandState.getInstance(editor).reset();
|
||||
reset(editor);
|
||||
lastChar = 0;
|
||||
@@ -545,8 +597,8 @@ public class KeyHandler {
|
||||
boolean wasRecording = editorState.isRecording();
|
||||
|
||||
executeAction(cmd.getAction(), context);
|
||||
if (editorState.getMode() == CommandState.MODE_INSERT ||
|
||||
editorState.getMode() == CommandState.MODE_REPLACE) {
|
||||
if (editorState.getMode() == CommandState.Mode.INSERT ||
|
||||
editorState.getMode() == CommandState.Mode.REPLACE) {
|
||||
CommandGroups.getInstance().getChange().processCommand(editor, context, cmd);
|
||||
}
|
||||
|
||||
@@ -554,7 +606,7 @@ public class KeyHandler {
|
||||
|
||||
// By default the "empty" register is used by all commands so we want to reset whatever the last register
|
||||
// selected by the user was to the empty register - unless we just executed the "select register" command.
|
||||
if (cmd.getType() != Command.SELECT_REGISTER) {
|
||||
if (cmd.getType() != Command.Type.SELECT_REGISTER) {
|
||||
CommandGroups.getInstance().getRegister().resetRegister();
|
||||
}
|
||||
|
||||
@@ -562,7 +614,7 @@ public class KeyHandler {
|
||||
// mode we were in. This handles commands in those modes that temporarily allow us to execute normal
|
||||
// mode commands. An exception is if this command should leave us in the temporary mode such as
|
||||
// "select register"
|
||||
if (editorState.getSubMode() == CommandState.SUBMODE_SINGLE_COMMAND &&
|
||||
if (editorState.getSubMode() == CommandState.SubMode.SINGLE_COMMAND &&
|
||||
(cmd.getFlags() & Command.FLAG_EXPECT_MORE) == 0) {
|
||||
editorState.popState();
|
||||
}
|
||||
@@ -580,23 +632,24 @@ public class KeyHandler {
|
||||
private KeyStroke key;
|
||||
}
|
||||
|
||||
private static enum State {
|
||||
NEW_COMMAND,
|
||||
COMMAND,
|
||||
READY,
|
||||
ERROR,
|
||||
BAD_COMMAND
|
||||
}
|
||||
|
||||
private int count;
|
||||
private List<KeyStroke> keys;
|
||||
private int mode;
|
||||
private State state;
|
||||
private Stack<Command> currentCmd = new Stack<Command>();
|
||||
private int currentArg;
|
||||
@NotNull private Argument.Type currentArg;
|
||||
private TypedActionHandler origHandler;
|
||||
private DigraphSequence digraph = null;
|
||||
private char lastChar;
|
||||
private boolean lastWasBS;
|
||||
|
||||
private static KeyHandler instance;
|
||||
|
||||
private static final int STATE_NEW_COMMAND = 1;
|
||||
private static final int STATE_COMMAND = 2;
|
||||
private static final int STATE_READY = 3;
|
||||
private static final int STATE_ERROR = 4;
|
||||
private static final int STATE_BAD_COMMAND = 5;
|
||||
|
||||
private static Logger logger = Logger.getInstance(KeyHandler.class.getName());
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.maddyhome.idea.vim;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
@@ -97,7 +98,9 @@ public class VimKeyMapUtil {
|
||||
}
|
||||
|
||||
// Prompt user to select the parent for the Vim keyboard
|
||||
configureVimParentKeymap(path, document, false);
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
configureVimParentKeymap(path, document, false);
|
||||
}
|
||||
|
||||
final KeymapImpl vimKeyMap = new KeymapImpl();
|
||||
final Keymap[] allKeymaps = manager.getAllKeymaps();
|
||||
|
@@ -90,6 +90,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
private boolean isBlockCursor = false;
|
||||
private boolean isAnimatedScrolling = false;
|
||||
private boolean isRefrainFromScrolling = false;
|
||||
private boolean error = false;
|
||||
|
||||
private String previousKeyMap = "";
|
||||
|
||||
@@ -199,7 +200,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
DocumentManager.getInstance().init();
|
||||
|
||||
EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
|
||||
public void editorCreated(EditorFactoryEvent event) {
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
isBlockCursor = editor.getSettings().isBlockCursor();
|
||||
isAnimatedScrolling = editor.getSettings().isAnimatedScrolling();
|
||||
@@ -218,7 +219,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}
|
||||
}
|
||||
|
||||
public void editorReleased(EditorFactoryEvent event) {
|
||||
public void editorReleased(@NotNull EditorFactoryEvent event) {
|
||||
EditorData.uninitializeEditor(event.getEditor());
|
||||
event.getEditor().getSettings().setAnimatedScrolling(isAnimatedScrolling);
|
||||
event.getEditor().getSettings().setRefrainFromScrolling(isRefrainFromScrolling);
|
||||
@@ -310,7 +311,10 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
* Inidicate to the user that an error has occurred. Just beep.
|
||||
*/
|
||||
public static void indicateError() {
|
||||
if (!Options.getInstance().isSet("visualbell")) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
getInstance().error = true;
|
||||
}
|
||||
else if (!Options.getInstance().isSet("visualbell")) {
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
}
|
||||
@@ -324,11 +328,13 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
Project[] projs = pm.getOpenProjects();
|
||||
for (Project proj : projs) {
|
||||
StatusBar bar = WindowManager.getInstance().getStatusBar(proj);
|
||||
if (msg == null || msg.length() == 0) {
|
||||
bar.setInfo("");
|
||||
}
|
||||
else {
|
||||
bar.setInfo("VIM - " + msg);
|
||||
if (bar != null) {
|
||||
if (msg == null || msg.length() == 0) {
|
||||
bar.setInfo("");
|
||||
}
|
||||
else {
|
||||
bar.setInfo("VIM - " + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,4 +390,14 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public static void clearError() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
getInstance().error = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -42,7 +44,7 @@ public class PassThruDelegateEditorAction extends AbstractDelegateEditorAction {
|
||||
this.origHandler = handler;
|
||||
}
|
||||
|
||||
public void execute(Editor editor, DataContext dataContext) {
|
||||
public void execute(@Nullable Editor editor, @NotNull DataContext dataContext) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("actionPerformed key=" + stroke);
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ public class RepeatChangeAction extends EditorAction {
|
||||
}
|
||||
Command save = state.getCommand();
|
||||
state.setCommand(cmd);
|
||||
state.pushState(CommandState.MODE_REPEAT, 0, KeyParser.MAPPING_NORMAL);
|
||||
state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, KeyParser.MAPPING_NORMAL);
|
||||
char reg = CommandGroups.getInstance().getRegister().getCurrentRegister();
|
||||
CommandGroups.getInstance().getRegister().selectRegister(state.getLastChangeRegister());
|
||||
try {
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -36,8 +37,8 @@ public class ChangeVisualAction extends EditorAction {
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd, TextRange range) {
|
||||
int mode = range.isMultiple() ? Command.FLAG_MOT_BLOCKWISE : Command.FLAG_MOT_INCLUSIVE;
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, mode);
|
||||
final SelectionType type = range.isMultiple() ? SelectionType.BLOCK_WISE : SelectionType.CHARACTER_WISE;
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -40,7 +41,7 @@ public class ChangeVisualLinesAction extends EditorAction {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, Command.FLAG_MOT_LINEWISE);
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -47,14 +48,13 @@ public class ChangeVisualLinesEndAction extends EditorAction {
|
||||
}
|
||||
|
||||
range = new TextRange(starts, ends);
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range,
|
||||
Command.FLAG_MOT_BLOCKWISE);
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.BLOCK_WISE);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, Command.FLAG_MOT_LINEWISE);
|
||||
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public class FilterMotionAction extends EditorAction {
|
||||
LogicalPosition start = editor.offsetToLogicalPosition(range.getStartOffset());
|
||||
LogicalPosition end = editor.offsetToLogicalPosition(range.getEndOffset());
|
||||
if (current.line != start.line) {
|
||||
MotionGroup.moveCaret(editor, context, range.getStartOffset());
|
||||
MotionGroup.moveCaret(editor, range.getStartOffset());
|
||||
}
|
||||
|
||||
int count;
|
||||
@@ -59,7 +59,7 @@ public class FilterMotionAction extends EditorAction {
|
||||
count = 1;
|
||||
}
|
||||
|
||||
Command command = new Command(count, null, null, 0, 0);
|
||||
Command command = new Command(count, null, null, Command.Type.UNDEFINED, 0);
|
||||
CommandGroups.getInstance().getProcess().startFilterCommand(editor, context, command);
|
||||
|
||||
return true;
|
||||
|
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -38,13 +39,14 @@ public class DeleteVisualAction extends EditorAction {
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd, TextRange range) {
|
||||
int mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == Command.FLAG_MOT_LINEWISE) {
|
||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == CommandState.SubMode.VISUAL_LINE) {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
}
|
||||
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range, mode, false);
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range,
|
||||
SelectionType.fromSubMode(mode), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -38,16 +39,16 @@ public class DeleteVisualLinesAction extends EditorAction {
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd, TextRange range) {
|
||||
int mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == Command.FLAG_MOT_BLOCKWISE) {
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range, mode, false);
|
||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range,
|
||||
SelectionType.fromSubMode(mode), false);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range,
|
||||
Command.FLAG_MOT_LINEWISE, false);
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range, SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -48,14 +49,14 @@ public class DeleteVisualLinesEndAction extends EditorAction {
|
||||
|
||||
range = new TextRange(starts, ends);
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range,
|
||||
Command.FLAG_MOT_BLOCKWISE, false);
|
||||
SelectionType.BLOCK_WISE, false);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range,
|
||||
Command.FLAG_MOT_LINEWISE, false);
|
||||
SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -37,8 +38,9 @@ public class YankVisualAction extends EditorAction {
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd, TextRange range) {
|
||||
final CommandState.SubMode subMode = CommandState.getInstance(editor).getSubMode();
|
||||
return CommandGroups.getInstance().getCopy().yankRange(editor, context, range,
|
||||
CommandState.getInstance(editor).getSubMode(), true);
|
||||
SelectionType.fromSubMode(subMode), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
@@ -38,16 +39,16 @@ public class YankVisualLinesAction extends EditorAction {
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd, TextRange range) {
|
||||
int mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == Command.FLAG_MOT_BLOCKWISE) {
|
||||
return CommandGroups.getInstance().getCopy().yankRange(editor, context, range, mode, true);
|
||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
||||
return CommandGroups.getInstance().getCopy().yankRange(editor, context, range, SelectionType.fromSubMode(mode),
|
||||
true);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
|
||||
return CommandGroups.getInstance().getCopy().yankRange(editor, context, range, Command.FLAG_MOT_LINEWISE,
|
||||
true);
|
||||
return CommandGroups.getInstance().getCopy().yankRange(editor, context, range, SelectionType.LINE_WISE, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class BackspaceAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getProcess().processExKey(editor, context,
|
||||
return CommandGroups.getInstance().getProcess().processExKey(editor,
|
||||
(KeyStroke)cmd.getKeys().get(0), false);
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class ProcessExKeyAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getProcess().processExKey(editor, context,
|
||||
return CommandGroups.getInstance().getProcess().processExKey(editor,
|
||||
(KeyStroke)cmd.getKeys().get(0), false);
|
||||
}
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public class MotionLastColumnAction extends MotionEditorAction {
|
||||
if (CommandState.inInsertMode(editor)) {
|
||||
allow = true;
|
||||
}
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.MODE_VISUAL) {
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
||||
BoundStringOption opt = (BoundStringOption)Options.getInstance().getOption("selection");
|
||||
if (!opt.getValue().equals("old")) {
|
||||
allow = true;
|
||||
|
@@ -45,7 +45,7 @@ public class MotionLastScreenColumnAction extends MotionEditorAction {
|
||||
if (CommandState.inInsertMode(editor)) {
|
||||
allow = true;
|
||||
}
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.MODE_VISUAL) {
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
||||
BoundStringOption opt = (BoundStringOption)Options.getInstance().getOption("selection");
|
||||
if (!opt.getValue().equals("old")) {
|
||||
allow = true;
|
||||
|
@@ -42,7 +42,7 @@ public class MotionRightAction extends MotionEditorAction {
|
||||
if (CommandState.inInsertMode(editor)) {
|
||||
allow = true;
|
||||
}
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.MODE_VISUAL) {
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
||||
BoundStringOption opt = (BoundStringOption)Options.getInstance().getOption("selection");
|
||||
if (!opt.getValue().equals("old")) {
|
||||
allow = true;
|
||||
|
@@ -35,7 +35,7 @@ public class MotionGotoMarkAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMark(editor, context, argument.getCharacter());
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMark(editor, argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionGotoMarkLineAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMarkLine(editor, context, argument.getCharacter());
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMarkLine(editor, argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionMarkAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMark().setMark(editor, context, cmd.getArgument().getCharacter());
|
||||
return CommandGroups.getInstance().getMark().setMark(editor, cmd.getArgument().getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerBigWordAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, context, count, false, true);
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, count, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerBlockAngleAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, false, '<');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, false, '<');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerBlockBraceAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, false, '{');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, false, '{');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerBlockBracketAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, false, '[');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, false, '[');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerBlockParenAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, false, '(');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, false, '(');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerParagraphAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getParagraphRange(editor, context, count, false);
|
||||
return CommandGroups.getInstance().getMotion().getParagraphRange(editor, count, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerSentenceAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getSentenceRange(editor, context, count, false);
|
||||
return CommandGroups.getInstance().getMotion().getSentenceRange(editor, count, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionInnerWordAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, context, count, false, false);
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, count, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterBigWordAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, context, count, true, true);
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, count, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterBlockAngleAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, true, '<');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, true, '<');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterBlockBraceAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, true, '{');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, true, '{');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterBlockBracketAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, true, '[');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, true, '[');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterBlockParenAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, context, count, true, '(');
|
||||
return CommandGroups.getInstance().getMotion().getBlockRange(editor, count, true, '(');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterParagraphAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getParagraphRange(editor, context, count, true);
|
||||
return CommandGroups.getInstance().getMotion().getParagraphRange(editor, count, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterSentenceAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getSentenceRange(editor, context, count, true);
|
||||
return CommandGroups.getInstance().getMotion().getSentenceRange(editor, count, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionOuterWordAction extends TextObjectAction {
|
||||
|
||||
private static class Handler extends TextObjectActionHandler {
|
||||
public TextRange getRange(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, context, count, true, false);
|
||||
return CommandGroups.getInstance().getMotion().getWordRange(editor, count, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionFirstScreenLineAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToFirstScreenLine(editor, context, count);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToFirstScreenLine(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionLastScreenLineAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToLastScreenLine(editor, context, count);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToLastScreenLine(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionLastScreenLineEndAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToLastScreenLineEnd(editor, context, count);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToLastScreenLineEnd(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionMiddleScreenLineAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMiddleScreenLine(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMiddleScreenLine(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollColumnLeftAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollColumn(editor, context, cmd.getCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollColumn(editor, cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollColumnRightAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollColumn(editor, context, -cmd.getCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollColumn(editor, -cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollFirstScreenColumnAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollColumnToFirstScreenColumn(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().scrollColumnToFirstScreenColumn(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollFirstScreenLineAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToFirstScreenLine(editor, context, cmd.getRawCount(), cmd.getCount(), false);
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToFirstScreenLine(editor, cmd.getRawCount(), cmd.getCount(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -41,10 +41,10 @@ public class MotionScrollFirstScreenLinePageStartAction extends EditorAction {
|
||||
if (raw == 0) {
|
||||
int lines = EditorHelper.getScreenHeight(editor);
|
||||
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, context, lines);
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, lines);
|
||||
}
|
||||
else {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToFirstScreenLine(editor, context, raw, cnt, true);
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToFirstScreenLine(editor, raw, cnt, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollFirstScreenLineStartAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToFirstScreenLine(editor, context, cmd.getRawCount(),
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToFirstScreenLine(editor, cmd.getRawCount(),
|
||||
cmd.getCount(), true);
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollHalfPageDownAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollHalfPage(editor, context, 1, cmd.getRawCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollHalfPage(editor, 1, cmd.getRawCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollHalfPageUpAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollHalfPage(editor, context, -1, cmd.getRawCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollHalfPage(editor, -1, cmd.getRawCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollLastScreenColumnAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollColumnToLastScreenColumn(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().scrollColumnToLastScreenColumn(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollLastScreenLineAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToLastScreenLine(editor, context, cmd.getRawCount(), cmd.getCount(), false);
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToLastScreenLine(editor, cmd.getRawCount(), cmd.getCount(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -41,10 +41,10 @@ public class MotionScrollLastScreenLinePageStartAction extends EditorAction {
|
||||
if (raw == 0) {
|
||||
int lines = EditorHelper.getScreenHeight(editor);
|
||||
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, context, -lines);
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, -lines);
|
||||
}
|
||||
else {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToLastScreenLine(editor, context, raw, cnt, true);
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToLastScreenLine(editor, raw, cnt, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollLastScreenLineStartAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToLastScreenLine(editor, context, cmd.getRawCount(),
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToLastScreenLine(editor, cmd.getRawCount(),
|
||||
cmd.getCount(), true);
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollLineDownAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, context, cmd.getCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollLineUpAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, context, -cmd.getCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollLine(editor, -cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class MotionScrollMiddleScreenLineAction extends EditorAction {
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion()
|
||||
.scrollLineToMiddleScreenLine(editor, context, cmd.getRawCount(), cmd.getCount(), false);
|
||||
.scrollLineToMiddleScreenLine(editor, cmd.getRawCount(), cmd.getCount(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollMiddleScreenLineStartAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToMiddleScreenLine(editor, context, cmd.getRawCount(),
|
||||
return CommandGroups.getInstance().getMotion().scrollLineToMiddleScreenLine(editor, cmd.getRawCount(),
|
||||
cmd.getCount(), true);
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollPageDownAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollFullPage(editor, context, cmd.getCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollFullPage(editor, cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionScrollPageUpAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().scrollFullPage(editor, context, -cmd.getCount());
|
||||
return CommandGroups.getInstance().getMotion().scrollFullPage(editor, -cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class GotoDeclarationAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor, context);
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor);
|
||||
KeyHandler.executeAction("GotoDeclaration", context);
|
||||
|
||||
return true;
|
||||
|
@@ -36,7 +36,7 @@ public class SearchAgainNextAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().searchNext(editor, context, count);
|
||||
return CommandGroups.getInstance().getSearch().searchNext(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class SearchAgainPreviousAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().searchPrevious(editor, context, count);
|
||||
return CommandGroups.getInstance().getSearch().searchPrevious(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class SearchEntryFwdAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().search(editor, context, argument.getString(),
|
||||
return CommandGroups.getInstance().getSearch().search(editor, argument.getString(),
|
||||
count, Command.FLAG_SEARCH_FWD, false);
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class SearchEntryRevAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().search(editor, context, argument.getString(),
|
||||
return CommandGroups.getInstance().getSearch().search(editor, argument.getString(),
|
||||
count, Command.FLAG_SEARCH_REV, false);
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class SearchWholeWordBackwardAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, context, count, true, -1);
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, count, true, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class SearchWholeWordForwardAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, context, count, true, 1);
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, count, true, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class SearchWordBackwardAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, context, count, false, -1);
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, count, false, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class SearchWordForwardAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, context, count, false, 1);
|
||||
return CommandGroups.getInstance().getSearch().searchWord(editor, count, false, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionGotoLineFirstAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretGotoLineFirst(editor, context, count - 1);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretGotoLineFirst(editor, count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionGotoLineLastAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretGotoLineLast(editor, context, rawCount, count - 1);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretGotoLineLast(editor, rawCount, count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -42,14 +42,14 @@ public class MotionGotoLineLastEndAction extends MotionEditorAction {
|
||||
if (CommandState.inInsertMode(editor)) {
|
||||
allow = true;
|
||||
}
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.MODE_VISUAL) {
|
||||
else if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
||||
BoundStringOption opt = (BoundStringOption)Options.getInstance().getOption("selection");
|
||||
if (!opt.getValue().equals("old")) {
|
||||
allow = true;
|
||||
}
|
||||
}
|
||||
|
||||
return CommandGroups.getInstance().getMotion().moveCaretGotoLineLastEnd(editor, context, rawCount, count - 1, allow);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretGotoLineLastEnd(editor, rawCount, count - 1, allow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,10 +37,10 @@ public class MotionPercentOrMatchAction extends MotionEditorAction {
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
if (rawCount == 0) {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMatchingPair(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToMatchingPair(editor);
|
||||
}
|
||||
else {
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToLinePercent(editor, context, count);
|
||||
return CommandGroups.getInstance().getMotion().moveCaretToLinePercent(editor, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ public class VisualExitModeAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(Editor editor, DataContext context) {
|
||||
CommandGroups.getInstance().getMotion().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
CommandGroups.getInstance().getMotion().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class VisualSelectPreviousAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().selectPreviousVisualMode(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().selectPreviousVisualMode(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class VisualSwapEndsAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().swapVisualEnds(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().swapVisualEnds(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class VisualSwapEndsBlockAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().swapVisualEndsBlock(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().swapVisualEndsBlock(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class VisualSwapSelectionsAction extends EditorAction {
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion().swapVisualSelections(editor, context);
|
||||
return CommandGroups.getInstance().getMotion().swapVisualSelections(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class VisualToggleBlockModeAction extends EditorAction {
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion()
|
||||
.toggleVisual(editor, context, cmd.getCount(), cmd.getRawCount(), Command.FLAG_MOT_BLOCKWISE);
|
||||
.toggleVisual(editor, cmd.getCount(), cmd.getRawCount(), CommandState.SubMode.VISUAL_BLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class VisualToggleCharacterModeAction extends EditorAction {
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion()
|
||||
.toggleVisual(editor, context, cmd.getCount(), cmd.getRawCount(), Command.FLAG_MOT_CHARACTERWISE);
|
||||
.toggleVisual(editor, cmd.getCount(), cmd.getRawCount(), CommandState.SubMode.VISUAL_CHARACTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class VisualToggleLineModeAction extends EditorAction {
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
protected boolean execute(Editor editor, DataContext context, Command cmd) {
|
||||
return CommandGroups.getInstance().getMotion()
|
||||
.toggleVisual(editor, context, cmd.getCount(), cmd.getRawCount(), Command.FLAG_MOT_LINEWISE);
|
||||
.toggleVisual(editor, cmd.getCount(), cmd.getRawCount(), CommandState.SubMode.VISUAL_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,34 +19,21 @@ package com.maddyhome.idea.vim.command;
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This represents a command argument.
|
||||
*/
|
||||
public class Argument {
|
||||
/**
|
||||
* This represents no argument
|
||||
*/
|
||||
public static final int NONE = 0;
|
||||
/**
|
||||
* This is for arguments of type motion command
|
||||
*/
|
||||
public static final int MOTION = 1;
|
||||
/**
|
||||
* This is for arguments of type character
|
||||
*/
|
||||
public static final int CHARACTER = 2;
|
||||
/**
|
||||
* This is for arguments of type string
|
||||
*/
|
||||
public static final int STRING = 3;
|
||||
/**
|
||||
* This is for arguments consisting of a digraph or a regular character
|
||||
*/
|
||||
public static final int DIGRAPH = 4;
|
||||
/**
|
||||
* This is for argumaents consisting of an ex string
|
||||
*/
|
||||
public static final int EX_STRING = 5;
|
||||
|
||||
public static enum Type {
|
||||
NONE,
|
||||
MOTION,
|
||||
CHARACTER,
|
||||
STRING,
|
||||
DIGRAPH,
|
||||
EX_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a character argument
|
||||
@@ -55,7 +42,7 @@ public class Argument {
|
||||
*/
|
||||
public Argument(char charArg) {
|
||||
this.charArg = charArg;
|
||||
type = CHARACTER;
|
||||
type = Type.CHARACTER;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +52,7 @@ public class Argument {
|
||||
*/
|
||||
public Argument(Command motionArg) {
|
||||
this.motionArg = motionArg;
|
||||
type = MOTION;
|
||||
type = Type.MOTION;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +62,7 @@ public class Argument {
|
||||
*/
|
||||
public Argument(String strArg) {
|
||||
this.strArg = strArg;
|
||||
type = STRING;
|
||||
type = Type.STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +70,8 @@ public class Argument {
|
||||
*
|
||||
* @return The argument type
|
||||
*/
|
||||
public int getType() {
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -135,12 +123,12 @@ public class Argument {
|
||||
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
res.append("Argument {");
|
||||
res.append("Argument [");
|
||||
res.append("charArg=").append(charArg);
|
||||
res.append(",motionArg=").append(motionArg);
|
||||
res.append(",strArg=").append(strArg);
|
||||
res.append(",type=").append(type);
|
||||
res.append("}");
|
||||
res.append(", motionArg=").append(motionArg);
|
||||
res.append(", strArg=").append(strArg);
|
||||
res.append(", type=").append(type);
|
||||
res.append("]");
|
||||
|
||||
return res.toString();
|
||||
}
|
||||
@@ -148,5 +136,5 @@ public class Argument {
|
||||
private char charArg = 0;
|
||||
private Command motionArg = null;
|
||||
private String strArg = null;
|
||||
private int type;
|
||||
@NotNull private Type type;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
@@ -107,72 +108,70 @@ public class Command {
|
||||
public static final int FLAG_COMPLETE_EX = 1 << 29;
|
||||
public static final int FLAG_TEXT_BLOCK = 1 << 30;
|
||||
|
||||
/**
|
||||
* Represents commands that actually move the cursor and can be arguments to operators
|
||||
*/
|
||||
public static final int MOTION = 1;
|
||||
/**
|
||||
* Represents commands that insert new text into the editor
|
||||
*/
|
||||
public static final int INSERT = 2;
|
||||
/**
|
||||
* Represents commands that remove text from the editor
|
||||
*/
|
||||
public static final int DELETE = 3;
|
||||
/**
|
||||
* Represents commands that change text in the editor
|
||||
*/
|
||||
public static final int CHANGE = 4;
|
||||
/**
|
||||
* Represents commands that copy text in the editor
|
||||
*/
|
||||
public static final int COPY = 5;
|
||||
/**
|
||||
* Represents commands that paste text into the editor
|
||||
*/
|
||||
public static final int PASTE = 6;
|
||||
public static final int RESET = 7;
|
||||
/**
|
||||
* Represents commands that select the register
|
||||
*/
|
||||
public static final int SELECT_REGISTER = 8;
|
||||
/**
|
||||
* Represents other types of commands
|
||||
*/
|
||||
public static final int OTHER_READONLY = 9;
|
||||
public static final int OTHER_WRITABLE = 10;
|
||||
public static final int OTHER_READ_WRITE = 11;
|
||||
public static final int COMPLETION = 12;
|
||||
public static enum Type {
|
||||
/**
|
||||
* Represents undefined commands.
|
||||
*/
|
||||
UNDEFINED,
|
||||
/**
|
||||
* Represents commands that actually move the cursor and can be arguments to operators.
|
||||
*/
|
||||
MOTION,
|
||||
/**
|
||||
* Represents commands that insert new text into the editor.
|
||||
*/
|
||||
INSERT,
|
||||
/**
|
||||
* Represents commands that remove text from the editor.
|
||||
*/
|
||||
DELETE,
|
||||
/**
|
||||
* Represents commands that change text in the editor.
|
||||
*/
|
||||
CHANGE,
|
||||
/**
|
||||
* Represents commands that copy text in the editor.
|
||||
*/
|
||||
COPY,
|
||||
PASTE,
|
||||
RESET,
|
||||
/**
|
||||
* Represents commands that select the register.
|
||||
*/
|
||||
SELECT_REGISTER,
|
||||
OTHER_READONLY,
|
||||
OTHER_WRITABLE,
|
||||
OTHER_READ_WRITE,
|
||||
COMPLETION;
|
||||
|
||||
public boolean isReadType() {
|
||||
boolean res = false;
|
||||
switch (type) {
|
||||
case MOTION:
|
||||
case COPY:
|
||||
case SELECT_REGISTER:
|
||||
case OTHER_READONLY:
|
||||
case OTHER_READ_WRITE:
|
||||
case COMPLETION:
|
||||
res = true;
|
||||
public boolean isRead() {
|
||||
switch (this) {
|
||||
case MOTION:
|
||||
case COPY:
|
||||
case SELECT_REGISTER:
|
||||
case OTHER_READONLY:
|
||||
case OTHER_READ_WRITE:
|
||||
case COMPLETION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean isWriteType() {
|
||||
boolean res = false;
|
||||
switch (type) {
|
||||
case INSERT:
|
||||
case DELETE:
|
||||
case CHANGE:
|
||||
case PASTE:
|
||||
case RESET:
|
||||
case OTHER_WRITABLE:
|
||||
case OTHER_READ_WRITE:
|
||||
res = true;
|
||||
public boolean isWrite() {
|
||||
switch (this) {
|
||||
case INSERT:
|
||||
case DELETE:
|
||||
case CHANGE:
|
||||
case PASTE:
|
||||
case RESET:
|
||||
case OTHER_WRITABLE:
|
||||
case OTHER_READ_WRITE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +182,7 @@ public class Command {
|
||||
* @param type The type of the command
|
||||
* @param flags Any custom flags specific to this command
|
||||
*/
|
||||
public Command(int count, String actionId, AnAction action, int type, int flags) {
|
||||
public Command(int count, String actionId, AnAction action, @NotNull Type type, int flags) {
|
||||
this(count, actionId, action, type, flags, null);
|
||||
}
|
||||
|
||||
@@ -196,7 +195,7 @@ public class Command {
|
||||
* @param flags Any custom flags specific to this command
|
||||
* @param arg The argument to this command
|
||||
*/
|
||||
public Command(int count, String actionId, AnAction action, int type, int flags, Argument arg) {
|
||||
public Command(int count, String actionId, AnAction action, @NotNull Type type, int flags, Argument arg) {
|
||||
this.count = count;
|
||||
this.actionId = actionId;
|
||||
this.action = action;
|
||||
@@ -246,7 +245,8 @@ public class Command {
|
||||
*
|
||||
* @return The command type
|
||||
*/
|
||||
public int getType() {
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -322,15 +322,15 @@ public class Command {
|
||||
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
res.append("Command {");
|
||||
res.append("Command[");
|
||||
res.append("count=").append(count);
|
||||
res.append(",actionId=").append(actionId);
|
||||
res.append(",action=").append(action);
|
||||
res.append(",type=").append(type);
|
||||
res.append(",flags=").append(flags);
|
||||
res.append(",argument=").append(argument);
|
||||
res.append(",keys=").append(keys);
|
||||
res.append("}");
|
||||
res.append(", actionId=").append(actionId);
|
||||
res.append(", action=").append(action);
|
||||
res.append(", type=").append(type);
|
||||
res.append(", flags=").append(flags);
|
||||
res.append(", argument=").append(argument);
|
||||
res.append(", keys=").append(keys);
|
||||
res.append("]");
|
||||
|
||||
return res.toString();
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public class Command {
|
||||
private int count;
|
||||
private String actionId;
|
||||
private AnAction action;
|
||||
private int type;
|
||||
@NotNull private Type type;
|
||||
private int flags;
|
||||
private Argument argument;
|
||||
private List<KeyStroke> keys;
|
||||
|
@@ -28,6 +28,8 @@ import com.maddyhome.idea.vim.helper.EditorData;
|
||||
import com.maddyhome.idea.vim.key.KeyParser;
|
||||
import com.maddyhome.idea.vim.key.ParentNode;
|
||||
import com.maddyhome.idea.vim.option.Options;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -35,32 +37,23 @@ import java.util.Stack;
|
||||
* This singleton maintains various state information about commands being run
|
||||
*/
|
||||
public class CommandState {
|
||||
/**
|
||||
* Indicates a runtime state of being in command mode
|
||||
*/
|
||||
public static final int MODE_COMMAND = 1;
|
||||
/**
|
||||
* Indicates a runtime state of being in insert mode
|
||||
*/
|
||||
public static final int MODE_INSERT = 2;
|
||||
/**
|
||||
* Indicates a runtime state of being in replace mode
|
||||
*/
|
||||
public static final int MODE_REPLACE = 3;
|
||||
/**
|
||||
* Indicates a runtime state of being in repeat mode
|
||||
*/
|
||||
public static final int MODE_REPEAT = 4;
|
||||
/**
|
||||
* Indicates a runtime state of being in visual mode
|
||||
*/
|
||||
public static final int MODE_VISUAL = 5;
|
||||
/**
|
||||
* Indicates a runtime state of entering an Ex command
|
||||
*/
|
||||
public static final int MODE_EX_ENTRY = 6;
|
||||
|
||||
public static final int SUBMODE_SINGLE_COMMAND = 1;
|
||||
public static enum Mode {
|
||||
COMMAND,
|
||||
INSERT,
|
||||
REPLACE,
|
||||
REPEAT,
|
||||
VISUAL,
|
||||
EX_ENTRY;
|
||||
}
|
||||
|
||||
public static enum SubMode {
|
||||
NONE,
|
||||
SINGLE_COMMAND,
|
||||
VISUAL_CHARACTER,
|
||||
VISUAL_LINE,
|
||||
VISUAL_BLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command state singleton
|
||||
@@ -68,7 +61,8 @@ public class CommandState {
|
||||
* @param editor
|
||||
* @return The singleton instance
|
||||
*/
|
||||
public static CommandState getInstance(Editor editor) {
|
||||
@NotNull
|
||||
public static CommandState getInstance(@Nullable Editor editor) {
|
||||
if (editor == null) {
|
||||
return new CommandState();
|
||||
}
|
||||
@@ -83,8 +77,8 @@ public class CommandState {
|
||||
}
|
||||
|
||||
public static boolean inInsertMode(Editor editor) {
|
||||
final int mode = getInstance(editor).getMode();
|
||||
return mode == MODE_INSERT || mode == MODE_REPLACE;
|
||||
final Mode mode = getInstance(editor).getMode();
|
||||
return mode == Mode.INSERT || mode == Mode.REPLACE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +108,7 @@ public class CommandState {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void pushState(int mode, int submode, int mapping) {
|
||||
public void pushState(@NotNull Mode mode, @NotNull SubMode submode, int mapping) {
|
||||
logger.debug("pushState");
|
||||
modes.push(new State(mode, submode, mapping));
|
||||
updateStatus();
|
||||
@@ -137,19 +131,21 @@ public class CommandState {
|
||||
*
|
||||
* @return The current runtime mode
|
||||
*/
|
||||
public int getMode() {
|
||||
final int mode = currentState().getMode();
|
||||
@NotNull
|
||||
public Mode getMode() {
|
||||
final Mode mode = currentState().getMode();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getMode=" + mode);
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
public int getSubMode() {
|
||||
@NotNull
|
||||
public SubMode getSubMode() {
|
||||
return currentState().getSubmode();
|
||||
}
|
||||
|
||||
public void setSubMode(int submode) {
|
||||
public void setSubMode(@NotNull SubMode submode) {
|
||||
currentState().setSubmode(submode);
|
||||
updateStatus();
|
||||
}
|
||||
@@ -184,30 +180,30 @@ public class CommandState {
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
switch (state.getMode()) {
|
||||
case MODE_COMMAND:
|
||||
if (state.getSubmode() == SUBMODE_SINGLE_COMMAND) {
|
||||
case COMMAND:
|
||||
if (state.getSubmode() == SubMode.SINGLE_COMMAND) {
|
||||
msg.append('(').append(getStatusString(pos - 1).toLowerCase()).append(')');
|
||||
}
|
||||
break;
|
||||
case MODE_INSERT:
|
||||
case INSERT:
|
||||
msg.append("INSERT");
|
||||
break;
|
||||
case MODE_REPLACE:
|
||||
case REPLACE:
|
||||
msg.append("REPLACE");
|
||||
break;
|
||||
case MODE_VISUAL:
|
||||
case VISUAL:
|
||||
if (pos > 0) {
|
||||
State tmp = modes.get(pos - 1);
|
||||
if (tmp.getMode() == MODE_COMMAND && tmp.getSubmode() == SUBMODE_SINGLE_COMMAND) {
|
||||
if (tmp.getMode() == Mode.COMMAND && tmp.getSubmode() == SubMode.SINGLE_COMMAND) {
|
||||
msg.append(getStatusString(pos - 1));
|
||||
msg.append(" - ");
|
||||
}
|
||||
}
|
||||
switch (state.getSubmode()) {
|
||||
case Command.FLAG_MOT_LINEWISE:
|
||||
case VISUAL_LINE:
|
||||
msg.append("VISUAL LINE");
|
||||
break;
|
||||
case Command.FLAG_MOT_BLOCKWISE:
|
||||
case VISUAL_BLOCK:
|
||||
msg.append("VISUAL BLOCK");
|
||||
break;
|
||||
default:
|
||||
@@ -224,13 +220,13 @@ public class CommandState {
|
||||
* mode.
|
||||
*/
|
||||
public void toggleInsertOverwrite() {
|
||||
int oldmode = getMode();
|
||||
int newmode = oldmode;
|
||||
if (oldmode == MODE_INSERT) {
|
||||
newmode = MODE_REPLACE;
|
||||
Mode oldmode = getMode();
|
||||
Mode newmode = oldmode;
|
||||
if (oldmode == Mode.INSERT) {
|
||||
newmode = Mode.REPLACE;
|
||||
}
|
||||
else if (oldmode == MODE_REPLACE) {
|
||||
newmode = MODE_INSERT;
|
||||
else if (oldmode == Mode.REPLACE) {
|
||||
newmode = Mode.INSERT;
|
||||
}
|
||||
|
||||
if (oldmode != newmode) {
|
||||
@@ -332,25 +328,27 @@ public class CommandState {
|
||||
* Signleton, no public object creation
|
||||
*/
|
||||
private CommandState() {
|
||||
modes.push(new State(MODE_COMMAND, 0, KeyParser.MAPPING_NORMAL));
|
||||
modes.push(new State(Mode.COMMAND, SubMode.NONE, KeyParser.MAPPING_NORMAL));
|
||||
}
|
||||
|
||||
private class State {
|
||||
public State(int mode, int submode, int mapping) {
|
||||
public State(@NotNull Mode mode, @NotNull SubMode submode, int mapping) {
|
||||
this.mode = mode;
|
||||
this.submode = submode;
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
@NotNull
|
||||
public Mode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public int getSubmode() {
|
||||
@NotNull
|
||||
public SubMode getSubmode() {
|
||||
return submode;
|
||||
}
|
||||
|
||||
public void setSubmode(int submode) {
|
||||
public void setSubmode(@NotNull SubMode submode) {
|
||||
this.submode = submode;
|
||||
}
|
||||
|
||||
@@ -371,13 +369,13 @@ public class CommandState {
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
private int mode;
|
||||
private int submode;
|
||||
@NotNull private Mode mode;
|
||||
@NotNull private SubMode submode;
|
||||
private int mapping;
|
||||
}
|
||||
|
||||
private Stack<State> modes = new Stack<State>();
|
||||
private State defaultState = new State(MODE_COMMAND, 0, KeyParser.MAPPING_NORMAL);
|
||||
private State defaultState = new State(Mode.COMMAND, SubMode.NONE, KeyParser.MAPPING_NORMAL);
|
||||
private Command command;
|
||||
private int flags;
|
||||
private boolean isRecording = false;
|
||||
|
61
src/com/maddyhome/idea/vim/command/SelectionType.java
Normal file
61
src/com/maddyhome/idea/vim/command/SelectionType.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.maddyhome.idea.vim.command;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public enum SelectionType {
|
||||
// Integer values for registers serialization in RegisterGroup.readData()
|
||||
LINE_WISE(1 << 1),
|
||||
CHARACTER_WISE(1 << 2),
|
||||
BLOCK_WISE(1 << 3);
|
||||
|
||||
SelectionType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SelectionType fromValue(int value) {
|
||||
for (SelectionType type : SelectionType.values()) {
|
||||
if (type.getValue() == value) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SelectionType fromSubMode(@NotNull CommandState.SubMode subMode) {
|
||||
switch (subMode) {
|
||||
case VISUAL_LINE:
|
||||
return LINE_WISE;
|
||||
case VISUAL_CHARACTER:
|
||||
return CHARACTER_WISE;
|
||||
case VISUAL_BLOCK:
|
||||
return BLOCK_WISE;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SelectionType fromCommandFlags(int flags) {
|
||||
if ((flags & Command.FLAG_MOT_LINEWISE) != 0) {
|
||||
return SelectionType.LINE_WISE;
|
||||
}
|
||||
else if ((flags & Command.FLAG_MOT_BLOCKWISE) != 0) {
|
||||
return SelectionType.BLOCK_WISE;
|
||||
}
|
||||
else {
|
||||
return SelectionType.CHARACTER_WISE;
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,8 +19,10 @@ package com.maddyhome.idea.vim.command;
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VisualChange {
|
||||
public VisualChange(int lines, int columns, int type) {
|
||||
public VisualChange(int lines, int columns, @NotNull SelectionType type) {
|
||||
this.lines = lines;
|
||||
this.columns = columns;
|
||||
this.type = type;
|
||||
@@ -34,7 +36,8 @@ public class VisualChange {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
@NotNull
|
||||
public SelectionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -51,5 +54,5 @@ public class VisualChange {
|
||||
|
||||
int lines;
|
||||
int columns;
|
||||
int type;
|
||||
@NotNull SelectionType type;
|
||||
}
|
||||
|
@@ -19,8 +19,10 @@ package com.maddyhome.idea.vim.command;
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VisualRange {
|
||||
public VisualRange(int start, int end, int type, int offset) {
|
||||
public VisualRange(int start, int end, @NotNull CommandState.SubMode type, int offset) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.type = type;
|
||||
@@ -35,7 +37,8 @@ public class VisualRange {
|
||||
return end;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
@NotNull
|
||||
public CommandState.SubMode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -57,6 +60,6 @@ public class VisualRange {
|
||||
|
||||
int start;
|
||||
int end;
|
||||
int type;
|
||||
@NotNull CommandState.SubMode type;
|
||||
int offset;
|
||||
}
|
||||
|
@@ -19,7 +19,9 @@ package com.maddyhome.idea.vim.common;
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.helper.StringHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Comparator;
|
||||
@@ -33,17 +35,17 @@ public class Register {
|
||||
* Create a register of the specified type for the given text
|
||||
*
|
||||
* @param name The character
|
||||
* @param type The register type (linewise or characterwise)
|
||||
* @param type The register type
|
||||
* @param text The text to store
|
||||
*/
|
||||
public Register(char name, int type, String text) {
|
||||
public Register(char name, @NotNull SelectionType type, String text) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.text = text;
|
||||
this.keys = null;
|
||||
}
|
||||
|
||||
public Register(char name, int type, List<KeyStroke> keys) {
|
||||
public Register(char name, @NotNull SelectionType type, List<KeyStroke> keys) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.text = null;
|
||||
@@ -68,7 +70,8 @@ public class Register {
|
||||
*
|
||||
* @return The register type
|
||||
*/
|
||||
public int getType() {
|
||||
@NotNull
|
||||
public SelectionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -151,7 +154,7 @@ public class Register {
|
||||
}
|
||||
|
||||
private char name;
|
||||
private int type;
|
||||
@NotNull private SelectionType type;
|
||||
private String text;
|
||||
private List<KeyStroke> keys;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.Register;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.ex.handler.*;
|
||||
@@ -192,8 +192,8 @@ public class CommandParser {
|
||||
// Run the command
|
||||
boolean ok = handler.process(editor, context, new ExCommand(res.getRanges(), command, res.getArgument()), count);
|
||||
if (ok && (handler.getArgFlags() & CommandHandler.DONT_SAVE_LAST) == 0) {
|
||||
CommandGroups.getInstance().getRegister().storeTextInternal(editor, context, new TextRange(-1, -1), cmd,
|
||||
Command.FLAG_MOT_CHARACTERWISE, ':', false, false);
|
||||
CommandGroups.getInstance().getRegister().storeTextInternal(editor, new TextRange(-1, -1), cmd,
|
||||
SelectionType.CHARACTER_WISE, ':', false, false);
|
||||
}
|
||||
|
||||
if (ok && (handler.getArgFlags() & CommandHandler.KEEP_FOCUS) != 0) {
|
||||
|
@@ -204,8 +204,8 @@ public class Ranges {
|
||||
startLine = endLine;
|
||||
endLine = range.getLine(editor, context, lastZero);
|
||||
if (range.isMove()) {
|
||||
MotionGroup.moveCaret(editor, context,
|
||||
CommandGroups.getInstance().getMotion().moveCaretToLine(editor, context, endLine));
|
||||
MotionGroup.moveCaret(editor,
|
||||
CommandGroups.getInstance().getMotion().moveCaretToLine(editor, endLine));
|
||||
}
|
||||
// Did that last range represent the start of the file?
|
||||
lastZero = (endLine < 0);
|
||||
|
@@ -69,7 +69,7 @@ public class CmdFilterHandler extends CommandHandler {
|
||||
}
|
||||
|
||||
try {
|
||||
return CommandGroups.getInstance().getProcess().executeFilter(editor, context, range, command);
|
||||
return CommandGroups.getInstance().getProcess().executeFilter(editor, range, command);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ExException(e.getMessage());
|
||||
|
@@ -21,7 +21,8 @@ package com.maddyhome.idea.vim.ex.handler;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.ex.*;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
@@ -46,8 +47,8 @@ public class CopyTextHandler extends CommandHandler {
|
||||
int offset = CommandGroups.getInstance().getMotion().moveCaretToLineStart(editor, line + 1);
|
||||
|
||||
String text = EditorHelper.getText(editor, range.getStartOffset(), range.getEndOffset());
|
||||
CommandGroups.getInstance().getCopy().putText(editor, context, offset, text, Command.FLAG_MOT_LINEWISE, 1, true,
|
||||
false, 0);
|
||||
CommandGroups.getInstance().getCopy().putText(editor, context, offset, text, SelectionType.LINE_WISE, 1, true,
|
||||
false, CommandState.SubMode.NONE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ package com.maddyhome.idea.vim.ex.handler;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.ex.CommandHandler;
|
||||
import com.maddyhome.idea.vim.ex.ExCommand;
|
||||
@@ -50,6 +50,6 @@ public class DeleteLinesHandler extends CommandHandler {
|
||||
|
||||
TextRange range = cmd.getTextRange(editor, context, true);
|
||||
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range, Command.FLAG_MOT_LINEWISE, false);
|
||||
return CommandGroups.getInstance().getChange().deleteRange(editor, context, range, SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ public class EditFileHandler extends CommandHandler {
|
||||
String arg = cmd.getArgument();
|
||||
if (arg != null) {
|
||||
if (arg.equals("#")) {
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor, context);
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor);
|
||||
CommandGroups.getInstance().getFile().selectPreviousTab(context);
|
||||
|
||||
return true;
|
||||
@@ -51,7 +51,7 @@ public class EditFileHandler extends CommandHandler {
|
||||
else if (arg.length() > 0) {
|
||||
boolean res = CommandGroups.getInstance().getFile().openFile(arg, context);
|
||||
if (res) {
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor, context);
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@@ -42,7 +42,7 @@ public class FindClassHandler extends CommandHandler {
|
||||
if (arg != null && arg.length() > 0) {
|
||||
boolean res = CommandGroups.getInstance().getFile().openFile(arg + ".java", context);
|
||||
if (res) {
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor, context);
|
||||
CommandGroups.getInstance().getMark().saveJumpLocation(editor);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user