mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-17 16:31:45 +02:00
Compare commits
94 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
969ca0119a | ||
![]() |
6a1c792cda | ||
![]() |
c0ba39ab40 | ||
![]() |
3e0e08c5e1 | ||
![]() |
3d64373c22 | ||
![]() |
2557688657 | ||
![]() |
fcc564df25 | ||
![]() |
4ecbb93d01 | ||
![]() |
9bdc9b3634 | ||
![]() |
f46c3b0aa9 | ||
![]() |
095fdf07c5 | ||
![]() |
648e988b64 | ||
![]() |
b1add735d6 | ||
![]() |
3f5882118e | ||
![]() |
4e83f56696 | ||
![]() |
ab250f1d9c | ||
![]() |
4672dece51 | ||
![]() |
a632de9214 | ||
![]() |
e8ebba8b3d | ||
![]() |
5cf8181474 | ||
![]() |
a717e4785d | ||
![]() |
16ce16c632 | ||
![]() |
8d7bf2661a | ||
![]() |
9e1b026a88 | ||
![]() |
3750417323 | ||
![]() |
d7bfb1ff10 | ||
![]() |
1797771527 | ||
![]() |
e564eb5878 | ||
![]() |
9cd620af58 | ||
![]() |
1414ef8a4f | ||
![]() |
110623f6ef | ||
![]() |
0887c72486 | ||
![]() |
a516fd880e | ||
![]() |
50e15112d6 | ||
![]() |
8b6f99385a | ||
![]() |
2d1b40f00c | ||
![]() |
2fc2f30055 | ||
![]() |
2094a19723 | ||
![]() |
5b1416424d | ||
![]() |
8b9e737c05 | ||
![]() |
cc0f4acec6 | ||
![]() |
30884162a0 | ||
![]() |
f1e7a8c444 | ||
![]() |
3271939c87 | ||
![]() |
c9cb487cbc | ||
![]() |
56f6b69adf | ||
![]() |
77dcee1269 | ||
![]() |
c9068ee4d1 | ||
![]() |
e7addf7fa8 | ||
![]() |
7cc0a8db92 | ||
![]() |
bccb62a84f | ||
![]() |
d47570664b | ||
![]() |
a7137558cc | ||
![]() |
0251c5a33d | ||
![]() |
365722ef7e | ||
![]() |
77e0c30e57 | ||
![]() |
8a0cad765a | ||
![]() |
272378b800 | ||
![]() |
a34d17ff95 | ||
![]() |
82c782e9f0 | ||
![]() |
b7b46d2fee | ||
![]() |
8916f0f314 | ||
![]() |
8d727ef508 | ||
![]() |
fd0be10492 | ||
![]() |
a810f95101 | ||
![]() |
8857545cf0 | ||
![]() |
2300c0005f | ||
![]() |
827b91286f | ||
![]() |
4d8e35655d | ||
![]() |
f7e6ae9f3c | ||
![]() |
67679843b4 | ||
![]() |
b67b072be2 | ||
![]() |
d6896e4e76 | ||
![]() |
f86c24a695 | ||
![]() |
b200c842b4 | ||
![]() |
c8df52a86c | ||
![]() |
b17a592c95 | ||
![]() |
f71d6c7fab | ||
![]() |
30cfae91c0 | ||
![]() |
5332128852 | ||
![]() |
b593d90dff | ||
![]() |
02fac3b931 | ||
![]() |
446ffc3602 | ||
![]() |
44c1a2e139 | ||
![]() |
f6cb04c7ef | ||
![]() |
276755ae9d | ||
![]() |
6ee0b821cc | ||
![]() |
72dc121fcd | ||
![]() |
786c4dc817 | ||
![]() |
c7cfbaed0a | ||
![]() |
4351d5c366 | ||
![]() |
ff3795798f | ||
![]() |
45281adfd9 | ||
![]() |
0d813afc67 |
@@ -24,6 +24,9 @@ Contributors:
|
||||
* [John Lindquist](mailto:johnlindquist@gmail.com)
|
||||
* [Ira Klotzko](mailto:iklotzko@ltech.com)
|
||||
* [Alex Selesse](mailto:alex@selesse.com)
|
||||
* [Dathan Bennett](mailto:dbennett@palantir.com)
|
||||
* [salaam](mailto:kphayen@gmail.com)
|
||||
* [Alexey Shmalko](mailto:rasen.dubi@gmail.com)
|
||||
|
||||
If you are a contributor and your name is not listed here, feel free to
|
||||
contact the maintainer.
|
||||
|
57
CHANGES.md
57
CHANGES.md
@@ -4,6 +4,63 @@ The Changelog
|
||||
History of changes in IdeaVim for the IntelliJ platform.
|
||||
|
||||
|
||||
0.36, 2014-10-14
|
||||
----------------
|
||||
|
||||
Added support for common window splitting and navigation commands. Various bug
|
||||
fixes.
|
||||
|
||||
Features:
|
||||
|
||||
* VIM-171 Window `<C-W>` commands: split, close, next/previous windows,
|
||||
left/right/up/down windows
|
||||
* VIM-265 Window `:split` and `:vsplit` commands
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* VIM-632 Restored visual block mode that was broken due to multiple carets support
|
||||
* VIM-770 Close the current tab on `:quit` instead of all tabs with the current
|
||||
file
|
||||
* VIM-569 Fixed `<C-W>` when the caret is at the end of a line
|
||||
|
||||
|
||||
0.35, 2014-05-15
|
||||
----------------
|
||||
|
||||
The `~/.vimrc` initialization file is no longer read by default, use
|
||||
`~/.ideavimrc` instead.
|
||||
|
||||
Features:
|
||||
|
||||
* VIM-690 Read initialization commands only from `~/.ideavimrc`
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* VIM-676 Handle control characters in `.ideavimrc` as pressed, not typed
|
||||
keystrokes
|
||||
* VIM-679 Parse characters less than U+0020 as `<C-$CHAR>`
|
||||
* VIM-683 Allow `<C-PageUp>`/`<C-PagDown>` to be used outside of Vim emulation
|
||||
* VIM-646 Don't update the visual selection if a command moves the caret and exits
|
||||
the visual mode
|
||||
* VIM-213 Use `'<` and `'>` marks for saving and restoring the last visual
|
||||
selection
|
||||
|
||||
|
||||
0.34, 2014-04-29
|
||||
----------------
|
||||
|
||||
A bugfix release.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* VIM-674 Don't handle `<Tab>` in Insert mode in Vim emulation
|
||||
* VIM-672 Ignore mappings that contain `<Plug>` and `<SID>`
|
||||
* VIM-670 First character of a recursive mapping shouldn't be mapped again
|
||||
* VIM-666 Support `<Bar>` in Vim key notation
|
||||
* VIM-666 Ignore characters after `|` in `:map` commands
|
||||
* VIM-667 Ignore potentially nested lines of .vimrc based on leading whitespace
|
||||
|
||||
|
||||
0.33, 2014-04-28
|
||||
----------------
|
||||
|
||||
|
26
README.md
26
README.md
@@ -17,7 +17,7 @@ IdeaVim
|
||||
|
||||
IdeaVim is a Vim emulation plug-in for IDEs based on the IntelliJ platform.
|
||||
IdeaVim can be used with IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm,
|
||||
AppCode and Android Studio.
|
||||
AppCode, CLion and Android Studio.
|
||||
|
||||
Resources:
|
||||
|
||||
@@ -39,6 +39,10 @@ If you wish to disable the plugin, select the "Tools | Vim Emulator" menu so
|
||||
it is unchecked. At this point IDE will work with it's regular keyboard
|
||||
shortcuts.
|
||||
|
||||
Keyboard shortcut conflicts between the Vim emulation and the IDE can be
|
||||
resolved via "File | Settings | Vim Emulation", "File | Settings | Keymap"
|
||||
and key mapping commands in your ~/.ideavimrc file.
|
||||
|
||||
|
||||
Summary of Supported Vim Features
|
||||
---------------------------------
|
||||
@@ -59,21 +63,35 @@ Supported:
|
||||
* Macros
|
||||
* Digraphs
|
||||
* Command line and search history
|
||||
* Window commands
|
||||
* Vim web help
|
||||
|
||||
Not supported (yet):
|
||||
|
||||
* Window commands
|
||||
* Jump lists
|
||||
* Various less used commands
|
||||
|
||||
See also:
|
||||
|
||||
* [List of recently added commands](https://github.com/JetBrains/ideavim/blob/master/src/com/maddyhome/idea/vim/package-info.java)
|
||||
* [List of commands covered with tests](https://github.com/JetBrains/ideavim/blob/master/index.txt)
|
||||
* [Top features and bugs](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+sort+by%3A+votes)
|
||||
|
||||
|
||||
Files
|
||||
-----
|
||||
|
||||
* ~/.ideavimrc
|
||||
* Your IdeaVim-specific Vim initialization commands
|
||||
|
||||
You can read your ~/.vimrc file from ~/.ideavimrc using this command:
|
||||
|
||||
source ~/.vimrc
|
||||
|
||||
Note, that IdeaVim currently parses ~/.ideavimrc file via simple pattern matching,
|
||||
see [VIM-669](http://youtrack.jetbrains.com/issue/VIM-669) for proper parsing
|
||||
of VimL files.
|
||||
|
||||
|
||||
Changes to the IDE
|
||||
------------------
|
||||
|
||||
@@ -116,7 +134,7 @@ in the issue tracker.
|
||||
|
||||
1. Fork IdeaVim on GitHub and clone the repository on your local machine.
|
||||
|
||||
2. Open the project in IntelliJ IDEA 12+ (Community or Ultimate) using "File |
|
||||
2. Open the project in IntelliJ IDEA 13.1+ (Community or Ultimate) using "File |
|
||||
Open... | /path/to/ideavim".
|
||||
|
||||
3. Set up a JDK if you haven't got it yet. Use "File | Project Structure | SDKs
|
||||
|
@@ -1,4 +1,4 @@
|
||||
version-id:0.33
|
||||
platform-version:120.0
|
||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-13.zip
|
||||
version-id:0.36
|
||||
platform-version:135.0
|
||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-13.1.zip
|
||||
build.number=dev
|
||||
|
@@ -1,7 +1,7 @@
|
||||
List of Supported Set Commands
|
||||
==============================
|
||||
|
||||
The following `:set` commands can appear in `~/.vimrc` or set manually in the command mode:
|
||||
The following `:set` commands can appear in `~/.ideavimrc` or set manually in the command mode:
|
||||
|
||||
'digraph' 'dg' enable the entering of digraphs in Insert mode
|
||||
'gdefault' 'gd' the ":substitute" flag 'g' is default on
|
||||
|
@@ -3,6 +3,22 @@
|
||||
<id>IdeaVIM</id>
|
||||
<change-notes>
|
||||
<![CDATA[
|
||||
<p>0.36:</p>
|
||||
<ul>
|
||||
<li>Window commands from the <code><C-W></code> family</li>
|
||||
<li>Support for <code>:split</code>/<code>:vsplit</code> commands</li>
|
||||
<li>Fixed visual block selection mode</li>
|
||||
<li>Various bug fixes</li>
|
||||
</ul>
|
||||
<p>0.35:</p>
|
||||
<ul>
|
||||
<li><code>~/.vimrc</code> is no longer read by default, use <code>~/.ideavimrc</code> instead</li>
|
||||
<li>Various bug fixes</li>
|
||||
</ul>
|
||||
<p>0.34:</p>
|
||||
<ul>
|
||||
<li>Various bug fixes</li>
|
||||
</ul>
|
||||
<p>0.33:</p>
|
||||
<ul>
|
||||
<li>Support for <code>:map</code> key mapping commands</li>
|
||||
@@ -25,23 +41,17 @@
|
||||
<li>Fixed long-standing issues with merged undo/redo commands and <code><Esc></code> during completion</li>
|
||||
<li>Various bug fixes</li>
|
||||
</ul>
|
||||
<p>0.29:</p>
|
||||
<ul>
|
||||
<li>Fixed repeat buffer limits</li>
|
||||
<li>Enable normal <code><Enter></code> handling for one-line editors</li>
|
||||
<li>Don't move cursor while scrolling</li>
|
||||
</ul>
|
||||
<p>See also the complete <a href="https://github.com/JetBrains/ideavim/blob/master/CHANGES.md">changelog</a>.</p>
|
||||
]]>
|
||||
</change-notes>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<p>Build @VERSION@-@BUILD-NUMBER@</p>
|
||||
<p>Vim emulation plug-in for IDEs based on the IntelliJ platform. IdeaVim can be used with IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm, AppCode and Android Studio.</p>
|
||||
<p>Vim emulation plug-in for IDEs based on the IntelliJ platform. IdeaVim can be used with IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm, AppCode, CLion and Android Studio.</p>
|
||||
<p>Supported functionality:</p>
|
||||
<ul>
|
||||
<li>Motion keys</li>
|
||||
<li>Deletion/Changing</li>
|
||||
<li>Deletion/changing</li>
|
||||
<li>Insert mode commands</li>
|
||||
<li>Marks</li>
|
||||
<li>Registers</li>
|
||||
@@ -51,9 +61,11 @@
|
||||
<li>Some :set options</li>
|
||||
<li>Full Vim regexps for search and search/replace</li>
|
||||
<li>Key mappings</li>
|
||||
<li>Configuration via ~/.ideavimrc</li>
|
||||
<li>Macros</li>
|
||||
<li>Digraphs</li>
|
||||
<li>Command line and search history</li>
|
||||
<li>Window commands</li>
|
||||
<li>Vim web help</li>
|
||||
</ul>
|
||||
]]>
|
||||
@@ -185,7 +197,6 @@
|
||||
<!-- Screen -->
|
||||
<action id="VimMotionFirstScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionFirstScreenLineAction" text="First Screen Line"/>
|
||||
<action id="VimMotionLastScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionLastScreenLineAction" text="Last Screen Line"/>
|
||||
<action id="VimMotionLastScreenLineEnd" class="com.maddyhome.idea.vim.action.motion.screen.MotionLastScreenLineEndAction" text="Last Screen Line End"/>
|
||||
<action id="VimMotionMiddleScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionMiddleScreenLineAction" text="Middle Screen Line"/>
|
||||
<!-- Scroll -->
|
||||
<action id="VimMotionScrollFirstScreenLinePageStart" class="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollFirstScreenLinePageStartAction" text="Scroll Line to Top"/>
|
||||
@@ -213,7 +224,7 @@
|
||||
<action id="VimVisualToggleBlockMode" class="com.maddyhome.idea.vim.action.motion.visual.VisualToggleBlockModeAction" text="Toggle Block Selection"/>
|
||||
<action id="VimVisualSwapEnds" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapEndsAction" text="Swap Visual Selection Ends"/>
|
||||
<action id="VimVisualSwapEndsBlock" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapEndsBlockAction" text="Swap Visual Selection Ends"/>
|
||||
<action id="VimVisualSelectPrevious" class="com.maddyhome.idea.vim.action.motion.visual.VisualSelectPreviousAction" text="Swap Visual Selection Ends"/>
|
||||
<action id="VimVisualSelectPrevious" class="com.maddyhome.idea.vim.action.motion.visual.VisualSelectPreviousAction" text="Visual Select Previous"/>
|
||||
<action id="VimVisualSwapSelections" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapSelectionsAction" text="Swap Visual Selection Ends"/>
|
||||
|
||||
<!-- Insert -->
|
||||
@@ -313,6 +324,18 @@
|
||||
<action id="VimFileGetFileInfo" class="com.maddyhome.idea.vim.action.file.FileGetFileInfoAction" text="Get File Info"/>
|
||||
<action id="VimFileGetLocationInfo" class="com.maddyhome.idea.vim.action.file.FileGetLocationInfoAction" text="Get Location Info"/>
|
||||
|
||||
<!-- Window -->
|
||||
<action id="VimWindowSplitVertical" class="com.maddyhome.idea.vim.action.window.VerticalSplitAction" text="Split window vertically"/>
|
||||
<action id="VimWindowSplitHorizontal" class="com.maddyhome.idea.vim.action.window.HorizontalSplitAction" text="Split window horizontally"/>
|
||||
<action id="VimWindowClose" class="com.maddyhome.idea.vim.action.window.CloseWindowAction" text="Close current window"/>
|
||||
<action id="VimWindowOnly" class="com.maddyhome.idea.vim.action.window.WindowOnlyAction" text="Close all windows except current"/>
|
||||
<action id="VimWindowNext" class="com.maddyhome.idea.vim.action.window.WindowNextAction" text="Select next window"/>
|
||||
<action id="VimWindowPrev" class="com.maddyhome.idea.vim.action.window.WindowPrevAction" text="Select previous window"/>
|
||||
<action id="VimWindowLeft" class="com.maddyhome.idea.vim.action.window.WindowLeftAction" text="Go to left window"/>
|
||||
<action id="VimWindowRight" class="com.maddyhome.idea.vim.action.window.WindowRightAction" text="Go to right window"/>
|
||||
<action id="VimWindowUp" class="com.maddyhome.idea.vim.action.window.WindowUpAction" text="Go to window up"/>
|
||||
<action id="VimWindowDown" class="com.maddyhome.idea.vim.action.window.WindowDownAction" text="Go to window down"/>
|
||||
|
||||
<!-- Search -->
|
||||
<action id="VimSearchFwdEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryFwdAction" text="Search Forward"/>
|
||||
<action id="VimSearchRevEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryRevAction" text="Search Backward"/>
|
||||
|
109
src/com/maddyhome/idea/vim/EventFacade.java
Normal file
109
src/com/maddyhome/idea/vim/EventFacade.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.maddyhome.idea.vim;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.ShortcutSet;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||
import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerListener;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class EventFacade {
|
||||
@NotNull private static final EventFacade ourInstance = new EventFacade();
|
||||
|
||||
@Nullable private TypedActionHandler myOriginalTypedActionHandler;
|
||||
|
||||
private EventFacade() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static EventFacade getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
public void addProjectManagerListener(@NotNull ProjectManagerListener listener) {
|
||||
ProjectManager.getInstance().addProjectManagerListener(listener);
|
||||
}
|
||||
|
||||
public void setupTypedActionHandler(@NotNull TypedActionHandler handler) {
|
||||
final TypedAction typedAction = getTypedAction();
|
||||
myOriginalTypedActionHandler = typedAction.getHandler();
|
||||
typedAction.setupHandler(handler);
|
||||
}
|
||||
|
||||
public void restoreTypedActionHandler() {
|
||||
if (myOriginalTypedActionHandler != null) {
|
||||
getTypedAction().setupHandler(myOriginalTypedActionHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerCustomShortcutSet(@NotNull AnAction action, @NotNull ShortcutSet shortcutSet,
|
||||
@Nullable JComponent component) {
|
||||
action.registerCustomShortcutSet(shortcutSet, component);
|
||||
}
|
||||
|
||||
public void unregisterCustomShortcutSet(@NotNull AnAction action, @Nullable JComponent component) {
|
||||
action.unregisterCustomShortcutSet(component);
|
||||
}
|
||||
|
||||
public void addFileEditorManagerListener(@NotNull Project project, @NotNull FileEditorManagerListener listener) {
|
||||
final MessageBusConnection connection = project.getMessageBus().connect();
|
||||
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
|
||||
}
|
||||
|
||||
public void addDocumentListener(@NotNull Document document, @NotNull DocumentListener listener) {
|
||||
document.addDocumentListener(listener);
|
||||
}
|
||||
|
||||
public void removeDocumentListener(@NotNull Document document, @NotNull DocumentListener listener) {
|
||||
document.removeDocumentListener(listener);
|
||||
}
|
||||
|
||||
public void addEditorFactoryListener(@NotNull EditorFactoryListener listener, @NotNull Disposable parentDisposable) {
|
||||
EditorFactory.getInstance().addEditorFactoryListener(listener, parentDisposable);
|
||||
}
|
||||
|
||||
public void addEditorMouseListener(@NotNull Editor editor, @NotNull EditorMouseListener listener) {
|
||||
editor.addEditorMouseListener(listener);
|
||||
}
|
||||
|
||||
public void removeEditorMouseListener(@NotNull Editor editor, @NotNull EditorMouseListener listener) {
|
||||
editor.removeEditorMouseListener(listener);
|
||||
}
|
||||
|
||||
public void addEditorMouseMotionListener(@NotNull Editor editor, @NotNull EditorMouseMotionListener listener) {
|
||||
editor.addEditorMouseMotionListener(listener);
|
||||
}
|
||||
|
||||
public void removeEditorMouseMotionListener(@NotNull Editor editor, @NotNull EditorMouseMotionListener listener) {
|
||||
editor.removeEditorMouseMotionListener(listener);
|
||||
}
|
||||
|
||||
public void addEditorSelectionListener(@NotNull Editor editor, @NotNull SelectionListener listener) {
|
||||
editor.getSelectionModel().addSelectionListener(listener);
|
||||
}
|
||||
|
||||
public void removeEditorSelectionListener(@NotNull Editor editor, @NotNull SelectionListener listener) {
|
||||
editor.getSelectionModel().removeSelectionListener(listener);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TypedAction getTypedAction() {
|
||||
return EditorActionManager.getInstance().getTypedAction();
|
||||
}
|
||||
}
|
@@ -164,7 +164,7 @@ public class KeyHandler {
|
||||
// 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, true, (ArgumentNode)node);
|
||||
shouldRecord = handleArgumentNode(editor, key, context, editorState, (ArgumentNode)node);
|
||||
}
|
||||
else {
|
||||
if (lastWasBS && lastChar != 0 && Options.getInstance().isSet("digraph")) {
|
||||
@@ -179,7 +179,7 @@ public class KeyHandler {
|
||||
}
|
||||
}
|
||||
else if (editorState.getMappingMode() == MappingMode.CMD_LINE) {
|
||||
if (!VimPlugin.getProcess().processExKey(editor, key, true)) {
|
||||
if (!VimPlugin.getProcess().processExKey(editor, key)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
@@ -252,8 +252,12 @@ public class KeyHandler {
|
||||
final Runnable handleMappedKeys = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final boolean fromIsPrefix = isPrefix(mappingInfo.getFromKeys(), mappingInfo.getToKeys());
|
||||
boolean first = true;
|
||||
for (KeyStroke keyStroke : mappingInfo.getToKeys()) {
|
||||
handleKey(editor, keyStroke, new EditorDataContext(editor), mappingInfo.isRecursive());
|
||||
final boolean recursive = mappingInfo.isRecursive() && !(first && fromIsPrefix);
|
||||
handleKey(editor, keyStroke, new EditorDataContext(editor), recursive);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -275,6 +279,18 @@ public class KeyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> boolean isPrefix(@NotNull List<T> list1, @NotNull List<T> list2) {
|
||||
if (list1.size() > list2.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < list1.size(); i++) {
|
||||
if (!list1.get(i).equals(list2.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull final DataContext context) {
|
||||
if (state != State.COMMAND && count == 0 && currentArg == Argument.Type.NONE && currentCmd.size() == 0 &&
|
||||
VimPlugin.getRegister().getCurrentRegister() == RegisterGroup.REGISTER_DEFAULT) {
|
||||
@@ -370,7 +386,6 @@ public class KeyHandler {
|
||||
|
||||
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
|
||||
@@ -427,8 +442,7 @@ public class KeyHandler {
|
||||
}
|
||||
|
||||
private boolean handleArgumentNode(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
||||
@NotNull CommandState editorState, boolean shouldRecord,
|
||||
@NotNull ArgumentNode node) {
|
||||
@NotNull CommandState editorState, @NotNull ArgumentNode 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);
|
||||
@@ -462,9 +476,9 @@ public class KeyHandler {
|
||||
if (currentArg != Argument.Type.NONE) {
|
||||
partialReset(editor);
|
||||
handleKey(editor, key, context);
|
||||
shouldRecord = false; // Prevent this from getting recorded twice
|
||||
return false;
|
||||
}
|
||||
return shouldRecord;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleCommandNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandNode node) {
|
||||
@@ -613,7 +627,6 @@ public class KeyHandler {
|
||||
lastChar = 0;
|
||||
lastWasBS = false;
|
||||
VimPlugin.getRegister().resetRegister();
|
||||
DelegateCommandListener.getInstance().setRunnable(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -660,10 +673,10 @@ public class KeyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private Editor editor;
|
||||
private DataContext context;
|
||||
private Command cmd;
|
||||
private KeyStroke key;
|
||||
private final Editor editor;
|
||||
private final DataContext context;
|
||||
private final Command cmd;
|
||||
private final KeyStroke key;
|
||||
}
|
||||
|
||||
private static enum State {
|
||||
@@ -677,7 +690,7 @@ public class KeyHandler {
|
||||
private int count;
|
||||
private List<KeyStroke> keys;
|
||||
private State state;
|
||||
@NotNull private Stack<Command> currentCmd = new Stack<Command>();
|
||||
@NotNull private final Stack<Command> currentCmd = new Stack<Command>();
|
||||
@NotNull private Argument.Type currentArg;
|
||||
private TypedActionHandler origHandler;
|
||||
@Nullable private DigraphSequence digraph = null;
|
||||
|
@@ -37,7 +37,6 @@ public class RegisterActions {
|
||||
registerVimCommandActions();
|
||||
|
||||
registerInsertModeActions();
|
||||
registerVisualModeActions();
|
||||
registerNormalModeActions();
|
||||
registerNVOModesActions();
|
||||
registerCommandLineActions();
|
||||
@@ -251,8 +250,7 @@ public class RegisterActions {
|
||||
parser
|
||||
.registerAction(MappingMode.NVO, "VimMotionFirstScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||
new Shortcut[]{
|
||||
new Shortcut('H'),
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, KeyEvent.CTRL_MASK))
|
||||
new Shortcut('H')
|
||||
});
|
||||
parser
|
||||
.registerAction(MappingMode.NVO, "VimMotionGotoLineFirst", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||
@@ -283,9 +281,6 @@ public class RegisterActions {
|
||||
parser
|
||||
.registerAction(MappingMode.NVO, "VimMotionLastScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||
new Shortcut('L'));
|
||||
parser.registerAction(MappingMode.NVO, "VimMotionLastScreenLineEnd", Command.Type.MOTION,
|
||||
Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, KeyEvent.CTRL_MASK)));
|
||||
parser.registerAction(MappingMode.NVO, "VimMotionLeft", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
|
||||
new Shortcut('h'),
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0))
|
||||
@@ -605,8 +600,6 @@ public class RegisterActions {
|
||||
new Shortcut('&'));
|
||||
parser.registerAction(MappingMode.N, "VimLastGlobalSearchReplace", Command.Type.OTHER_WRITABLE,
|
||||
new Shortcut("g&"));
|
||||
parser.registerAction(MappingMode.N, "VimVisualSelectPrevious", Command.Type.OTHER_READONLY,
|
||||
new Shortcut("gv"));
|
||||
parser.registerAction(MappingMode.N, "VimRepeatChange", Command.Type.OTHER_WRITABLE,
|
||||
new Shortcut('.'));
|
||||
parser.registerAction(MappingMode.N, "VimRepeatExCommand", Command.Type.OTHER_WRITABLE,
|
||||
@@ -664,9 +657,6 @@ public class RegisterActions {
|
||||
parser.registerAction(MappingMode.N, "VimFileGetFileInfo", Command.Type.OTHER_READONLY,
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)));
|
||||
|
||||
// Window Actions
|
||||
// TODO - CTRL-W commands: +, -, =, S, s, _, b, c, n, o, q, s, t, <up>, <down>
|
||||
|
||||
// Macro Actions
|
||||
parser.registerAction(MappingMode.N, "VimPlaybackLastRegister", Command.Type.OTHER_WRITABLE,
|
||||
new Shortcut("@@"));
|
||||
@@ -675,93 +665,6 @@ public class RegisterActions {
|
||||
// TODO - support for :map macros
|
||||
}
|
||||
|
||||
private static void registerVisualModeActions() {
|
||||
final KeyGroup parser = VimPlugin.getKey();
|
||||
parser.registerAction(MappingMode.V, "VimAutoIndentVisual", Command.Type.CHANGE,
|
||||
Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE,
|
||||
new Shortcut('='));
|
||||
parser.registerAction(MappingMode.V, "VimReformatVisual", Command.Type.CHANGE,
|
||||
Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE,
|
||||
new Shortcut("gq"));
|
||||
parser.registerAction(MappingMode.V, "VimChangeCaseLowerVisual", Command.Type.CHANGE,
|
||||
new Shortcut('u'));
|
||||
parser.registerAction(MappingMode.V, "VimChangeCaseToggleVisual", Command.Type.CHANGE,
|
||||
new Shortcut('~'));
|
||||
parser.registerAction(MappingMode.V, "VimChangeCaseUpperVisual", Command.Type.CHANGE,
|
||||
new Shortcut('U'));
|
||||
parser.registerAction(MappingMode.V, "VimChangeVisual", Command.Type.CHANGE, Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
|
||||
new Shortcut('c'),
|
||||
new Shortcut('s')
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimChangeVisualCharacter", Command.Type.CHANGE, Command.FLAG_ALLOW_DIGRAPH,
|
||||
new Shortcut('r'), Argument.Type.DIGRAPH);
|
||||
parser.registerAction(MappingMode.V, "VimChangeVisualLines", Command.Type.CHANGE,
|
||||
Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
|
||||
new Shortcut('R'),
|
||||
new Shortcut('S')
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimChangeVisualLinesEnd", Command.Type.CHANGE,
|
||||
Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
|
||||
new Shortcut('C')
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimCopyYankVisual", Command.Type.COPY,
|
||||
new Shortcut('y'));
|
||||
parser.registerAction(MappingMode.V, "VimCopyYankVisualLines", Command.Type.COPY, Command.FLAG_MOT_LINEWISE,
|
||||
new Shortcut('Y'));
|
||||
parser.registerAction(MappingMode.V, "VimDeleteJoinVisualLines", Command.Type.DELETE,
|
||||
new Shortcut("gJ"));
|
||||
parser.registerAction(MappingMode.V, "VimDeleteJoinVisualLinesSpaces", Command.Type.DELETE,
|
||||
new Shortcut('J'));
|
||||
parser.registerAction(MappingMode.V, "VimDeleteVisual", Command.Type.DELETE, new Shortcut[]{
|
||||
new Shortcut('d'),
|
||||
new Shortcut('x'),
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0))
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimDeleteVisualLinesEnd", Command.Type.DELETE, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
|
||||
new Shortcut('D')
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimDeleteVisualLines", Command.Type.DELETE, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
|
||||
new Shortcut('X')
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimFilterVisualLines", Command.Type.CHANGE, Command.FLAG_MOT_LINEWISE,
|
||||
new Shortcut('!'));
|
||||
parser.registerAction(MappingMode.V, "VimShiftLeftVisual", Command.Type.CHANGE,
|
||||
new Shortcut('<'));
|
||||
parser.registerAction(MappingMode.V, "VimShiftRightVisual", Command.Type.CHANGE,
|
||||
new Shortcut('>'));
|
||||
parser.registerAction(MappingMode.V, "VimVisualExitMode", Command.Type.OTHER_READONLY, new Shortcut[]{
|
||||
new Shortcut(KeyStroke.getKeyStroke('[', KeyEvent.CTRL_MASK)),
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)),
|
||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)),
|
||||
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, KeyEvent.CTRL_MASK),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)})
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimVisualPutText", Command.Type.PASTE, new Shortcut[]{
|
||||
new Shortcut('P'),
|
||||
new Shortcut('p')
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimVisualPutTextMoveCursor", Command.Type.PASTE, new Shortcut[]{
|
||||
new Shortcut("gp"),
|
||||
new Shortcut("gP")
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimVisualPutTextNoIndent", Command.Type.PASTE, new Shortcut[]{
|
||||
new Shortcut("[p"),
|
||||
new Shortcut("]p"),
|
||||
new Shortcut("[P"),
|
||||
new Shortcut("]P")
|
||||
});
|
||||
parser.registerAction(MappingMode.V, "VimVisualBlockInsert", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
|
||||
new Shortcut('I'));
|
||||
parser.registerAction(MappingMode.V, "VimVisualBlockAppend", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
|
||||
new Shortcut('A'));
|
||||
parser.registerAction(MappingMode.V, "VimVisualSwapEnds", Command.Type.OTHER_READONLY,
|
||||
new Shortcut('o'));
|
||||
parser.registerAction(MappingMode.V, "VimVisualSwapEndsBlock", Command.Type.OTHER_READONLY,
|
||||
new Shortcut('O'));
|
||||
parser.registerAction(MappingMode.V, "VimVisualSwapSelections", Command.Type.OTHER_READONLY,
|
||||
new Shortcut("gv"));
|
||||
}
|
||||
|
||||
private static void registerInsertModeActions() {
|
||||
final KeyGroup parser = VimPlugin.getKey();
|
||||
// Other insert actions
|
||||
|
@@ -22,7 +22,6 @@ import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
@@ -36,7 +35,6 @@ import com.intellij.openapi.editor.event.EditorFactoryAdapter;
|
||||
import com.intellij.openapi.editor.event.EditorFactoryEvent;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.impl.DefaultKeymap;
|
||||
@@ -52,7 +50,10 @@ import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.ex.CommandParser;
|
||||
import com.maddyhome.idea.vim.ex.VimScriptParser;
|
||||
import com.maddyhome.idea.vim.group.*;
|
||||
import com.maddyhome.idea.vim.helper.*;
|
||||
import com.maddyhome.idea.vim.helper.DocumentManager;
|
||||
import com.maddyhome.idea.vim.helper.EditorData;
|
||||
import com.maddyhome.idea.vim.helper.EditorDataContext;
|
||||
import com.maddyhome.idea.vim.helper.MacKeyRepeat;
|
||||
import com.maddyhome.idea.vim.option.Options;
|
||||
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
|
||||
import org.jdom.Element;
|
||||
@@ -85,13 +86,12 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
public static final String IDEAVIM_NOTIFICATION_ID = "ideavim";
|
||||
public static final String IDEAVIM_STICKY_NOTIFICATION_ID = "ideavim-sticky";
|
||||
public static final String IDEAVIM_NOTIFICATION_TITLE = "IdeaVim";
|
||||
public static final int STATE_VERSION = 3;
|
||||
public static final int STATE_VERSION = 4;
|
||||
|
||||
private static final boolean BLOCK_CURSOR_VIM_VALUE = true;
|
||||
private static final boolean ANIMATED_SCROLLING_VIM_VALUE = false;
|
||||
private static final boolean REFRAIN_FROM_SCROLLING_VIM_VALUE = true;
|
||||
|
||||
private VimTypedActionHandler vimHandler;
|
||||
private boolean isBlockCursor = false;
|
||||
private boolean isAnimatedScrolling = false;
|
||||
private boolean isRefrainFromScrolling = false;
|
||||
@@ -103,22 +103,23 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
// It is enabled by default to avoid any special configuration after plugin installation
|
||||
private boolean enabled = true;
|
||||
|
||||
private static Logger LOG = Logger.getInstance(VimPlugin.class);
|
||||
private static final Logger LOG = Logger.getInstance(VimPlugin.class);
|
||||
|
||||
private final Application myApp;
|
||||
|
||||
private MotionGroup motion;
|
||||
private ChangeGroup change;
|
||||
private CopyGroup copy;
|
||||
private MarkGroup mark;
|
||||
private RegisterGroup register;
|
||||
private FileGroup file;
|
||||
private SearchGroup search;
|
||||
private ProcessGroup process;
|
||||
private MacroGroup macro;
|
||||
private DigraphGroup digraph;
|
||||
private HistoryGroup history;
|
||||
private KeyGroup key;
|
||||
@NotNull private final MotionGroup motion;
|
||||
@NotNull private final ChangeGroup change;
|
||||
@NotNull private final CopyGroup copy;
|
||||
@NotNull private final MarkGroup mark;
|
||||
@NotNull private final RegisterGroup register;
|
||||
@NotNull private final FileGroup file;
|
||||
@NotNull private final SearchGroup search;
|
||||
@NotNull private final ProcessGroup process;
|
||||
@NotNull private final MacroGroup macro;
|
||||
@NotNull private final DigraphGroup digraph;
|
||||
@NotNull private final HistoryGroup history;
|
||||
@NotNull private final KeyGroup key;
|
||||
@NotNull private WindowGroup window;
|
||||
|
||||
public VimPlugin(final Application app) {
|
||||
myApp = app;
|
||||
@@ -135,6 +136,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
digraph = new DigraphGroup();
|
||||
history = new HistoryGroup();
|
||||
key = new KeyGroup();
|
||||
window = new WindowGroup();
|
||||
|
||||
LOG.debug("VimPlugin ctr");
|
||||
}
|
||||
@@ -157,12 +159,8 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}
|
||||
});
|
||||
|
||||
EditorActionManager manager = EditorActionManager.getInstance();
|
||||
TypedAction action = manager.getTypedAction();
|
||||
|
||||
// Replace the default key handler with the Vim key handler
|
||||
vimHandler = new VimTypedActionHandler(action.getHandler());
|
||||
action.setupHandler(vimHandler);
|
||||
final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
|
||||
EventFacade.getInstance().setupTypedActionHandler(new VimTypedActionHandler(typedAction.getHandler()));
|
||||
|
||||
// Register vim actions in command mode
|
||||
RegisterActions.registerActions();
|
||||
@@ -174,9 +172,9 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
CommandParser.getInstance().registerHandlers();
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final File vimrc = VimScriptParser.findVimrc();
|
||||
if (vimrc != null) {
|
||||
VimScriptParser.executeFile(vimrc);
|
||||
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
|
||||
if (ideaVimRc != null) {
|
||||
VimScriptParser.executeFile(ideaVimRc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,9 +185,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
public void disposeComponent() {
|
||||
LOG.debug("disposeComponent");
|
||||
turnOffPlugin();
|
||||
EditorActionManager manager = EditorActionManager.getInstance();
|
||||
TypedAction action = manager.getTypedAction();
|
||||
action.setupHandler(vimHandler.getOriginalTypedHandler());
|
||||
EventFacade.getInstance().restoreTypedActionHandler();
|
||||
LOG.debug("done");
|
||||
}
|
||||
|
||||
@@ -236,54 +232,72 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
key.readData(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static MotionGroup getMotion() {
|
||||
return getInstance().motion;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ChangeGroup getChange() {
|
||||
return getInstance().change;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CopyGroup getCopy() {
|
||||
return getInstance().copy;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static MarkGroup getMark() {
|
||||
return getInstance().mark;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static RegisterGroup getRegister() {
|
||||
return getInstance().register;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FileGroup getFile() {
|
||||
return getInstance().file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SearchGroup getSearch() {
|
||||
return getInstance().search;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ProcessGroup getProcess() {
|
||||
return getInstance().process;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static MacroGroup getMacro() {
|
||||
return getInstance().macro;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static DigraphGroup getDigraph() {
|
||||
return getInstance().digraph;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HistoryGroup getHistory() {
|
||||
return getInstance().history;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KeyGroup getKey() {
|
||||
return getInstance().key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static WindowGroup getWindow() {
|
||||
return getInstance().window;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PluginId getPluginId() {
|
||||
return PluginId.getId(IDEAVIM_PLUGIN_ID);
|
||||
}
|
||||
@@ -387,7 +401,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previousStateVersion < 3) {
|
||||
if (previousStateVersion > 0 && previousStateVersion < 3) {
|
||||
final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
|
||||
Keymap keymap = null;
|
||||
if (previousKeyMap != null) {
|
||||
@@ -404,7 +418,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
"Switching to \"%s\" keymap.<br/><br/>" +
|
||||
"Now it is possible to set up:<br/>" +
|
||||
"<ul>" +
|
||||
"<li>Vim keys in your .vimrc file using key mapping commands</li>" +
|
||||
"<li>Vim keys in your ~/.ideavimrc file using key mapping commands</li>" +
|
||||
"<li>IDE action shortcuts in \"File | Settings | Keymap\"</li>" +
|
||||
"<li>Vim or IDE handlers for conflicting shortcuts in <a href='#settings'>Vim Emulation</a> settings</li>" +
|
||||
"</ul>", keymap.getPresentableName()),
|
||||
@@ -417,6 +431,15 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}).notify(null);
|
||||
manager.setActiveKeymap(keymap);
|
||||
}
|
||||
if (previousStateVersion > 0 && previousStateVersion < 4) {
|
||||
new Notification(
|
||||
VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID,
|
||||
VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||
"The ~/.vimrc file is no longer read by default, use ~/.ideavimrc instead. You can read it from your " +
|
||||
"~/.ideavimrc using this command:<br/><br/>" +
|
||||
"<code>source ~/.vimrc</code>",
|
||||
NotificationType.INFORMATION).notify(null);
|
||||
}
|
||||
if (requiresRestart) {
|
||||
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
app.restart();
|
||||
@@ -428,11 +451,12 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
* This sets up some listeners so we can handle various events that occur
|
||||
*/
|
||||
private void setupListeners() {
|
||||
final EventFacade eventFacade = EventFacade.getInstance();
|
||||
|
||||
DocumentManager.getInstance().addDocumentListener(new MarkGroup.MarkUpdater());
|
||||
DocumentManager.getInstance().addDocumentListener(new SearchGroup.DocumentSearchListener());
|
||||
DocumentManager.getInstance().init();
|
||||
|
||||
EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
|
||||
eventFacade.addEditorFactoryListener(new EditorFactoryAdapter() {
|
||||
@Override
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
@@ -466,25 +490,14 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}
|
||||
}, myApp);
|
||||
|
||||
// Since the Vim plugin custom actions aren't available to the call to <code>initComponent()</code>
|
||||
// we need to force the generation of the key map when the first project is opened.
|
||||
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
eventFacade.addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@Override
|
||||
public void projectOpened(@NotNull final Project project) {
|
||||
project.getMessageBus().connect()
|
||||
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MotionGroup.MotionEditorChange());
|
||||
project.getMessageBus().connect()
|
||||
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileGroup.SelectionCheck());
|
||||
project.getMessageBus().connect()
|
||||
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new SearchGroup.EditorSelectionCheck());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed(final Project project) {
|
||||
eventFacade.addFileEditorManagerListener(project, new MotionGroup.MotionEditorChange());
|
||||
eventFacade.addFileEditorManagerListener(project, new FileGroup.SelectionCheck());
|
||||
eventFacade.addFileEditorManagerListener(project, new SearchGroup.EditorSelectionCheck());
|
||||
}
|
||||
});
|
||||
|
||||
CommandProcessor.getInstance().addCommandListener(DelegateCommandListener.getInstance());
|
||||
}
|
||||
|
||||
private void setCursors(boolean isBlock) {
|
||||
|
@@ -34,10 +34,10 @@ import javax.swing.*;
|
||||
* IDE shortcut keys used by Vim commands are handled by {@link com.maddyhome.idea.vim.action.VimShortcutKeyAction}.
|
||||
*/
|
||||
public class VimTypedActionHandler implements TypedActionHandler {
|
||||
private static Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
|
||||
private static final Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
|
||||
|
||||
private TypedActionHandler origHandler;
|
||||
private KeyHandler handler;
|
||||
private final TypedActionHandler origHandler;
|
||||
@NotNull private final KeyHandler handler;
|
||||
|
||||
public VimTypedActionHandler(TypedActionHandler origHandler) {
|
||||
this.origHandler = origHandler;
|
||||
@@ -66,10 +66,6 @@ public class VimTypedActionHandler implements TypedActionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public TypedActionHandler getOriginalTypedHandler() {
|
||||
return origHandler;
|
||||
}
|
||||
|
||||
private boolean isEnabled(@NotNull Editor editor) {
|
||||
if (VimPlugin.isEnabled()) {
|
||||
final Lookup lookup = LookupManager.getActiveLookup(editor);
|
||||
|
@@ -18,11 +18,13 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.helper.StringHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -66,4 +68,13 @@ public abstract class VimCommandAction extends EditorAction {
|
||||
public int getFlags() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Set<List<KeyStroke>> parseKeysSet(@NotNull String... keyStrings) {
|
||||
final ImmutableSet.Builder<List<KeyStroke>> builder = ImmutableSet.builder();
|
||||
for (String keyString : keyStrings) {
|
||||
builder.add(StringHelper.parseKeys(keyString));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
@@ -23,10 +23,7 @@ import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
@@ -59,7 +56,9 @@ import static java.awt.event.KeyEvent.*;
|
||||
* These keys are not passed to {@link com.maddyhome.idea.vim.VimTypedActionHandler} and should be handled by actions.
|
||||
*/
|
||||
public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
||||
@NotNull public static Set<KeyStroke> VIM_ONLY_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
||||
private static final String ACTION_ID = "VimShortcutKeyAction";
|
||||
|
||||
@NotNull public static final Set<KeyStroke> VIM_ONLY_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
||||
.addAll(getKeyStrokes(VK_ENTER, 0))
|
||||
.addAll(getKeyStrokes(VK_ESCAPE, 0))
|
||||
.addAll(getKeyStrokes(VK_TAB, 0))
|
||||
@@ -72,17 +71,18 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
||||
.addAll(getKeyStrokes(VK_RIGHT, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_HOME, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_END, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_PAGE_UP, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_PAGE_DOWN, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_PAGE_UP, 0, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_PAGE_DOWN, 0, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.build();
|
||||
|
||||
@NotNull private static Set<KeyStroke> NON_FILE_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
||||
@NotNull private static final Set<KeyStroke> NON_FILE_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
||||
.addAll(getKeyStrokes(VK_ESCAPE, 0))
|
||||
.addAll(getKeyStrokes(VK_TAB, 0))
|
||||
.addAll(getKeyStrokes(VK_UP, 0))
|
||||
.addAll(getKeyStrokes(VK_DOWN, 0))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
final Editor editor = getEditor(e);
|
||||
final KeyStroke keyStroke = getKeyStroke(e);
|
||||
@@ -101,6 +101,11 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
||||
e.getPresentation().setEnabled(isEnabled(e));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnAction getInstance() {
|
||||
return ActionManager.getInstance().getAction(ACTION_ID);
|
||||
}
|
||||
|
||||
private void notifyAboutShortcutConflict(@NotNull final KeyStroke keyStroke) {
|
||||
VimPlugin.getKey().getSavedShortcutConflicts().put(keyStroke, ShortcutOwner.VIM);
|
||||
final String message = String.format(
|
||||
@@ -139,7 +144,8 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
||||
return isExitInsertMode(keyStroke);
|
||||
}
|
||||
if (CommandState.inInsertMode(editor)) {
|
||||
if (keyCode == VK_ENTER) {
|
||||
// XXX: <Enter> and <Tab> won't be recorded in macros
|
||||
if (keyCode == VK_ENTER || keyCode == VK_TAB) {
|
||||
return false;
|
||||
}
|
||||
// Debug watch, Python console, etc.
|
||||
@@ -183,7 +189,8 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
||||
return !VimPlugin.getKey().getKeymapConflicts(keyStroke).isEmpty();
|
||||
}
|
||||
|
||||
private static List<KeyStroke> getKeyStrokes(int keyCode, int... modifiers) {
|
||||
@NotNull
|
||||
private static List<KeyStroke> getKeyStrokes(int keyCode, @NotNull int... modifiers) {
|
||||
final List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>();
|
||||
for (int modifier : modifiers) {
|
||||
keyStrokes.add(KeyStroke.getKeyStroke(keyCode, modifier));
|
||||
|
@@ -20,17 +20,22 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class AutoIndentLinesVisualAction extends EditorAction {
|
||||
public class AutoIndentLinesVisualAction extends VimCommandAction {
|
||||
public AutoIndentLinesVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
@Override
|
||||
@@ -43,4 +48,27 @@ public class AutoIndentLinesVisualAction extends EditorAction {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("=");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,28 +20,54 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeCaseLowerVisualAction extends EditorAction {
|
||||
public ChangeCaseLowerVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeCaseLowerVisualAction extends VimCommandAction {
|
||||
public ChangeCaseLowerVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
return VimPlugin.getChange().changeCaseRange(InjectedLanguageUtil.getTopLevelEditor(editor),
|
||||
range, CharacterHelper.CASE_LOWER);
|
||||
}
|
||||
final Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||
return VimPlugin.getChange().changeCaseRange(topLevelEditor, range, CharacterHelper.CASE_LOWER);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("u");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeCaseToggleVisualAction extends EditorAction {
|
||||
public ChangeCaseToggleVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeCaseToggleVisualAction extends VimCommandAction {
|
||||
public ChangeCaseToggleVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_TOGGLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("~");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeCaseUpperVisualAction extends EditorAction {
|
||||
public ChangeCaseUpperVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeCaseUpperVisualAction extends VimCommandAction {
|
||||
public ChangeCaseUpperVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_UPPER);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("U");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ public class ChangeLastGlobalSearchReplaceAction extends EditorAction {
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
LineRange range = new LineRange(0, EditorHelper.getLineCount(editor) - 1);
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, context, range, "s", "//~/&");
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, range, "s", "//~/&");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ public class ChangeLastSearchReplaceAction extends EditorAction {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
int line = editor.getCaretModel().getLogicalPosition().line;
|
||||
LineRange range = new LineRange(line, line);
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, context, range, "s", "//~/");
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, range, "s", "//~/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,26 +20,53 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeVisualAction extends EditorAction {
|
||||
public ChangeVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeVisualAction extends VimCommandAction {
|
||||
public ChangeVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
final SelectionType type = range.isMultiple() ? SelectionType.BLOCK_WISE : SelectionType.CHARACTER_WISE;
|
||||
return VimPlugin.getChange().changeRange(editor, context, range, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("c", "s");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,24 +20,59 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeVisualCharacterAction extends EditorAction {
|
||||
public class ChangeVisualCharacterAction extends VimCommandAction {
|
||||
public ChangeVisualCharacterAction() {
|
||||
super(new Handler());
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
final Argument argument = cmd.getArgument();
|
||||
return argument != null && VimPlugin.getChange().changeCharacterRange(editor, range, argument.getCharacter());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
||||
return VimPlugin.getChange().changeCharacterRange(editor, range,
|
||||
cmd.getArgument().getCharacter());
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("r");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Argument.Type getArgumentType() {
|
||||
return Argument.Type.DIGRAPH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_ALLOW_DIGRAPH | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,29 +20,55 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeVisualLinesAction extends EditorAction {
|
||||
public ChangeVisualLinesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeVisualLinesAction extends VimCommandAction {
|
||||
public ChangeVisualLinesAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
return VimPlugin.getChange().changeRange(editor, context, lineRange, SelectionType.LINE_WISE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("R", "S");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,43 +20,68 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeVisualLinesEndAction extends EditorAction {
|
||||
public ChangeVisualLinesEndAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ChangeVisualLinesEndAction extends VimCommandAction {
|
||||
public ChangeVisualLinesEndAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
if (range.isMultiple()) {
|
||||
int[] starts = range.getStartOffsets();
|
||||
int[] ends = range.getEndOffsets();
|
||||
final int[] starts = range.getStartOffsets();
|
||||
final int[] ends = range.getEndOffsets();
|
||||
for (int i = 0; i < starts.length; i++) {
|
||||
if (ends[i] > starts[i]) {
|
||||
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
range = new TextRange(starts, ends);
|
||||
return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.BLOCK_WISE);
|
||||
final TextRange blockRange = new TextRange(starts, ends);
|
||||
return VimPlugin.getChange().changeRange(editor, context, blockRange, SelectionType.BLOCK_WISE);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
return VimPlugin.getChange().changeRange(editor, context, lineRange, SelectionType.LINE_WISE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("C");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.MotionGroup;
|
||||
@@ -38,8 +39,11 @@ public class FilterMotionAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
TextRange range = MotionGroup.getMotionRange(editor, context, cmd.getCount(), cmd.getRawCount(),
|
||||
cmd.getArgument(), false, false);
|
||||
final Argument argument = cmd.getArgument();
|
||||
if (argument == null) {
|
||||
return false;
|
||||
}
|
||||
TextRange range = MotionGroup.getMotionRange(editor, context, cmd.getCount(), cmd.getRawCount(), argument, false);
|
||||
if (range == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -20,25 +20,51 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class FilterVisualLinesAction extends EditorAction {
|
||||
public FilterVisualLinesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class FilterVisualLinesAction extends VimCommandAction {
|
||||
public FilterVisualLinesAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
|
||||
VimPlugin.getMotion().resetVisual(editor, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("!");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE;
|
||||
}
|
||||
}
|
||||
|
@@ -20,27 +20,53 @@ package com.maddyhome.idea.vim.action.change.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ReformatCodeVisualAction extends EditorAction {
|
||||
public class ReformatCodeVisualAction extends VimCommandAction {
|
||||
public ReformatCodeVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
@NotNull Command cmd,
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
VimPlugin.getChange().reformatCode(context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("gq");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.delete;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DeleteJoinVisualLinesAction extends EditorAction {
|
||||
public DeleteJoinVisualLinesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class DeleteJoinVisualLinesAction extends VimCommandAction {
|
||||
public DeleteJoinVisualLinesAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
return !editor.isOneLineMode() && VimPlugin.getChange().deleteJoinRange(editor, range, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().deleteJoinRange(editor, range, false);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("gJ");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.delete;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DeleteJoinVisualLinesSpacesAction extends EditorAction {
|
||||
public DeleteJoinVisualLinesSpacesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class DeleteJoinVisualLinesSpacesAction extends VimCommandAction {
|
||||
public DeleteJoinVisualLinesSpacesAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
return !editor.isOneLineMode() && VimPlugin.getChange().deleteJoinRange(editor, range, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().deleteJoinRange(editor, range, true);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("J");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,34 +20,62 @@ package com.maddyhome.idea.vim.action.change.delete;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DeleteVisualAction extends EditorAction {
|
||||
public DeleteVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class DeleteVisualAction extends VimCommandAction {
|
||||
public DeleteVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
final CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == CommandState.SubMode.VISUAL_LINE) {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
return VimPlugin.getChange().deleteRange(editor, lineRange, SelectionType.fromSubMode(mode), false);
|
||||
}
|
||||
else {
|
||||
return VimPlugin.getChange().deleteRange(editor, range, SelectionType.fromSubMode(mode), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().deleteRange(editor, range,
|
||||
SelectionType.fromSubMode(mode), false);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("d", "x", "<Del>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,37 +20,62 @@ package com.maddyhome.idea.vim.action.change.delete;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DeleteVisualLinesAction extends EditorAction {
|
||||
public DeleteVisualLinesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class DeleteVisualLinesAction extends VimCommandAction {
|
||||
public DeleteVisualLinesAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
final CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
||||
return VimPlugin.getChange().deleteRange(editor, range,
|
||||
SelectionType.fromSubMode(mode), false);
|
||||
return VimPlugin.getChange().deleteRange(editor, range, SelectionType.fromSubMode(mode), false);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
return VimPlugin.getChange().deleteRange(editor, lineRange, SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().deleteRange(editor, range, SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("X");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,45 +20,68 @@ package com.maddyhome.idea.vim.action.change.delete;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DeleteVisualLinesEndAction extends EditorAction {
|
||||
public DeleteVisualLinesEndAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class DeleteVisualLinesEndAction extends VimCommandAction {
|
||||
public DeleteVisualLinesEndAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
if (range.isMultiple()) {
|
||||
int[] starts = range.getStartOffsets();
|
||||
int[] ends = range.getEndOffsets();
|
||||
final int[] starts = range.getStartOffsets();
|
||||
final int[] ends = range.getEndOffsets();
|
||||
for (int i = 0; i < starts.length; i++) {
|
||||
if (ends[i] > starts[i]) {
|
||||
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
range = new TextRange(starts, ends);
|
||||
return VimPlugin.getChange().deleteRange(editor, range,
|
||||
SelectionType.BLOCK_WISE, false);
|
||||
final TextRange blockRange = new TextRange(starts, ends);
|
||||
return VimPlugin.getChange().deleteRange(editor, blockRange, SelectionType.BLOCK_WISE, false);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
return VimPlugin.getChange().deleteRange(editor, lineRange, SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().deleteRange(editor, range,
|
||||
SelectionType.LINE_WISE, false);
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("D");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -33,8 +33,6 @@ import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
|
||||
|
||||
public class InsertBeforeCursorAction extends VimCommandAction {
|
||||
public InsertBeforeCursorAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
|
@@ -33,8 +33,6 @@ import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
|
||||
|
||||
public class InsertExitModeAction extends VimCommandAction {
|
||||
private static final String ACTION_ID = "VimInsertExitMode";
|
||||
|
||||
|
@@ -22,6 +22,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.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,7 +36,8 @@ public class InsertRegisterAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getChange().insertRegister(editor, context, cmd.getArgument().getCharacter());
|
||||
final Argument argument = cmd.getArgument();
|
||||
return argument != null && VimPlugin.getChange().insertRegister(editor, context, argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.insert;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class VisualBlockAppendAction extends EditorAction {
|
||||
public VisualBlockAppendAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualBlockAppendAction extends VimCommandAction {
|
||||
public VisualBlockAppendAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
return !editor.isOneLineMode() && VimPlugin.getChange().blockInsert(editor, context, range, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().blockInsert(editor, context, range, true);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("A");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.INSERT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.insert;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class VisualBlockInsertAction extends EditorAction {
|
||||
public VisualBlockInsertAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualBlockInsertAction extends VimCommandAction {
|
||||
public VisualBlockInsertAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
return !editor.isOneLineMode() && VimPlugin.getChange().blockInsert(editor, context, range, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getChange().blockInsert(editor, context, range, false);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("I");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.INSERT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.shift;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ShiftLeftVisualAction extends EditorAction {
|
||||
public class ShiftLeftVisualAction extends VimCommandAction {
|
||||
public ShiftLeftVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), -1);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.shift;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class ShiftRightVisualAction extends EditorAction {
|
||||
public class ShiftRightVisualAction extends VimCommandAction {
|
||||
public ShiftRightVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet(">");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,23 +20,51 @@ package com.maddyhome.idea.vim.action.copy;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PutVisualTextAction extends EditorAction {
|
||||
public PutVisualTextAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class PutVisualTextAction extends VimCommandAction {
|
||||
public PutVisualTextAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), true, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("p", "P");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.PASTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,23 +20,51 @@ package com.maddyhome.idea.vim.action.copy;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PutVisualTextMoveCursorAction extends EditorAction {
|
||||
public PutVisualTextMoveCursorAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class PutVisualTextMoveCursorAction extends VimCommandAction {
|
||||
public PutVisualTextMoveCursorAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("gp", "gP");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.PASTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,23 +20,51 @@ package com.maddyhome.idea.vim.action.copy;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PutVisualTextNoIndentAction extends EditorAction {
|
||||
public PutVisualTextNoIndentAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class PutVisualTextNoIndentAction extends VimCommandAction {
|
||||
public PutVisualTextNoIndentAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("[p", "]p", "[P", "]P");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.PASTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,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.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -37,7 +38,8 @@ public class SelectRegisterAction extends EditorAction {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getRegister().selectRegister(cmd.getArgument().getCharacter());
|
||||
final Argument argument = cmd.getArgument();
|
||||
return argument != null && VimPlugin.getRegister().selectRegister(argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,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.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,7 +36,9 @@ public class YankMotionAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getCopy().yankMotion(editor, context, cmd.getCount(), cmd.getRawCount(), cmd.getArgument());
|
||||
final Argument argument = cmd.getArgument();
|
||||
return argument != null && VimPlugin.getCopy().yankMotion(editor, context, cmd.getCount(), cmd.getRawCount(),
|
||||
argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,28 +20,54 @@ package com.maddyhome.idea.vim.action.copy;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class YankVisualAction extends EditorAction {
|
||||
public YankVisualAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class YankVisualAction extends VimCommandAction {
|
||||
public YankVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
final CommandState.SubMode subMode = CommandState.getInstance(editor).getSubMode();
|
||||
return VimPlugin.getCopy().yankRange(editor, range,
|
||||
SelectionType.fromSubMode(subMode), true);
|
||||
}
|
||||
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.fromSubMode(subMode), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("y");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.COPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -20,37 +20,62 @@ package com.maddyhome.idea.vim.action.copy;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class YankVisualLinesAction extends EditorAction {
|
||||
public YankVisualLinesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends VisualOperatorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class YankVisualLinesAction extends VimCommandAction {
|
||||
public YankVisualLinesAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
final CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
||||
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.fromSubMode(mode),
|
||||
true);
|
||||
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.fromSubMode(mode), true);
|
||||
}
|
||||
else {
|
||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||
return VimPlugin.getCopy().yankRange(editor, lineRange, SelectionType.LINE_WISE, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.LINE_WISE, true);
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("Y");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.COPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MOT_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,6 @@ import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BackspaceAction extends EditorAction {
|
||||
@@ -37,8 +35,7 @@ public class BackspaceAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getProcess().processExKey(editor,
|
||||
(KeyStroke)cmd.getKeys().get(0), false);
|
||||
return VimPlugin.getProcess().processExKey(editor, cmd.getKeys().get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,6 @@ import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessExKeyAction extends EditorAction {
|
||||
@@ -37,8 +35,7 @@ public class ProcessExKeyAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getProcess().processExKey(editor,
|
||||
(KeyStroke)cmd.getKeys().get(0), false);
|
||||
return VimPlugin.getProcess().processExKey(editor, cmd.getKeys().get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
@@ -36,9 +37,8 @@ public class PlaybackLastRegisterAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getMacro().playbackLastRegister(editor, context,
|
||||
PlatformDataKeys.PROJECT.getData(context),
|
||||
cmd.getCount()); // API change - don't merge
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
return VimPlugin.getMacro().playbackLastRegister(editor, context, project, cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,10 +38,13 @@ public class PlaybackRegisterAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
char reg = cmd.getArgument().getCharacter();
|
||||
return VimPlugin.getMacro().playbackRegister(editor, context,
|
||||
PlatformDataKeys.PROJECT.getData(context), reg,
|
||||
cmd.getCount()); // API change - don't merge
|
||||
final Argument argument = cmd.getArgument();
|
||||
if (argument == null) {
|
||||
return false;
|
||||
}
|
||||
final char reg = argument.getCharacter();
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
return VimPlugin.getMacro().playbackRegister(editor, context, project, reg, cmd.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,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.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
@@ -37,7 +38,11 @@ public class ToggleRecordingAction extends EditorAction {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (!CommandState.getInstance(editor).isRecording()) {
|
||||
char reg = cmd.getArgument().getCharacter();
|
||||
final Argument argument = cmd.getArgument();
|
||||
if (argument == null) {
|
||||
return false;
|
||||
}
|
||||
char reg = argument.getCharacter();
|
||||
return VimPlugin.getRegister().startRecording(editor, reg);
|
||||
}
|
||||
else {
|
||||
|
@@ -36,5 +36,5 @@ public abstract class MotionEditorAction extends EditorAction {
|
||||
return handler.getOffset(editor, context, count, rawCount, argument);
|
||||
}
|
||||
|
||||
private MotionEditorActionHandler handler;
|
||||
private final MotionEditorActionHandler handler;
|
||||
}
|
||||
|
@@ -39,5 +39,5 @@ public abstract class TextObjectAction extends EditorAction {
|
||||
return handler.getRange(editor, context, count, rawCount, argument);
|
||||
}
|
||||
|
||||
private TextObjectActionHandler handler;
|
||||
private final TextObjectActionHandler handler;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionJumpNextAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return VimPlugin.getMotion().moveCaretToJump(editor, context, count);
|
||||
return VimPlugin.getMotion().moveCaretToJump(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionJumpPreviousAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return VimPlugin.getMotion().moveCaretToJump(editor, context, -count);
|
||||
return VimPlugin.getMotion().moveCaretToJump(editor, -count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,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.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,7 +36,8 @@ public class MotionMarkAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getMark().setMark(editor, cmd.getArgument().getCharacter());
|
||||
final Argument argument = cmd.getArgument();
|
||||
return argument != null && VimPlugin.getMark().setMark(editor, argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,8 +37,11 @@ public class SearchEntryFwdAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return VimPlugin.getSearch().search(editor, argument.getString(),
|
||||
count, Command.FLAG_SEARCH_FWD, false);
|
||||
final String command = argument.getString();
|
||||
if (command == null) {
|
||||
return -1;
|
||||
}
|
||||
return VimPlugin.getSearch().search(editor, command, count, Command.FLAG_SEARCH_FWD, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,8 +37,11 @@ public class SearchEntryRevAction extends MotionEditorAction {
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return VimPlugin.getSearch().search(editor, argument.getString(),
|
||||
count, Command.FLAG_SEARCH_REV, false);
|
||||
final String command = argument.getString();
|
||||
if (command == null) {
|
||||
return -1;
|
||||
}
|
||||
return VimPlugin.getSearch().search(editor, command, count, Command.FLAG_SEARCH_REV, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionNextTabAction extends MotionEditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
||||
public int getOffset(@NotNull final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
||||
return VimPlugin.getMotion().moveCaretGotoNextTab(editor, context);
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class MotionPreviousTabAction extends MotionEditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends MotionEditorActionHandler {
|
||||
public int getOffset(final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
||||
public int getOffset(@NotNull final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
||||
return VimPlugin.getMotion().moveCaretGotoPreviousTab(editor, context);
|
||||
}
|
||||
}
|
||||
|
@@ -20,24 +20,46 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VisualExitModeAction extends EditorAction {
|
||||
public VisualExitModeAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualExitModeAction extends VimCommandAction {
|
||||
public VisualExitModeAction() {
|
||||
super(new EditorActionHandler() {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
VimPlugin.getMotion().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<Esc>", "<C-[>", "<C-C>", "<C-\\><C-N>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,24 +20,44 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VisualSelectPreviousAction extends EditorAction {
|
||||
public VisualSelectPreviousAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualSelectPreviousAction extends VimCommandAction {
|
||||
public VisualSelectPreviousAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getMotion().selectPreviousVisualMode(editor);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("gv");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
||||
|
@@ -20,24 +20,45 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VisualSwapEndsAction extends EditorAction {
|
||||
public VisualSwapEndsAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualSwapEndsAction extends VimCommandAction {
|
||||
public VisualSwapEndsAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getMotion().swapVisualEnds(editor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("o");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,24 +20,45 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VisualSwapEndsBlockAction extends EditorAction {
|
||||
public VisualSwapEndsBlockAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualSwapEndsBlockAction extends VimCommandAction {
|
||||
public VisualSwapEndsBlockAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getMotion().swapVisualEndsBlock(editor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("O");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,24 +20,45 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VisualSwapSelectionsAction extends EditorAction {
|
||||
public VisualSwapSelectionsAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VisualSwapSelectionsAction extends VimCommandAction {
|
||||
public VisualSwapSelectionsAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return VimPlugin.getMotion().swapVisualSelections(editor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.V;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("gv");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,8 +32,6 @@ import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
|
||||
|
||||
public class VisualToggleCharacterModeAction extends VimCommandAction {
|
||||
public VisualToggleCharacterModeAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author rasendubi
|
||||
*/
|
||||
public class CloseWindowAction extends VimCommandAction {
|
||||
public CloseWindowAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().closeCurrentWindow(context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>c");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author rasendubi
|
||||
*/
|
||||
public class HorizontalSplitAction extends VimCommandAction {
|
||||
public HorizontalSplitAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().splitWindowHorizontal(context, "");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>s", "<C-W>S", "<C-W><C-S>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author rasendubi
|
||||
*/
|
||||
public class VerticalSplitAction extends VimCommandAction {
|
||||
public VerticalSplitAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().splitWindowVertical(context, "");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>v", "<C-W><C-V>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class WindowDownAction extends VimCommandAction {
|
||||
public WindowDownAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount(), true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>j");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class WindowLeftAction extends VimCommandAction {
|
||||
public WindowLeftAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount() * -1, false);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>h");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author rasendubi
|
||||
*/
|
||||
public class WindowNextAction extends VimCommandAction {
|
||||
public WindowNextAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (cmd.getRawCount() == 0) {
|
||||
VimPlugin.getWindow().selectNextWindow(context);
|
||||
} else {
|
||||
VimPlugin.getWindow().selectWindow(context, cmd.getCount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>w", "<C-W><C-W>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author rasendubi
|
||||
*/
|
||||
public class WindowOnlyAction extends VimCommandAction {
|
||||
public WindowOnlyAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().closeAllExceptCurrent(context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>o", "<C-W><C-O>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class WindowPrevAction extends VimCommandAction {
|
||||
public WindowPrevAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (cmd.getRawCount() == 0) {
|
||||
VimPlugin.getWindow().selectPreviousWindow(context);
|
||||
} else {
|
||||
VimPlugin.getWindow().selectWindow(context, cmd.getCount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>W");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class WindowRightAction extends VimCommandAction {
|
||||
public WindowRightAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount(), false);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>l");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
65
src/com/maddyhome/idea/vim/action/window/WindowUpAction.java
Normal file
65
src/com/maddyhome/idea/vim/action/window/WindowUpAction.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class WindowUpAction extends VimCommandAction {
|
||||
public WindowUpAction() {
|
||||
super(new EditorActionHandlerBase() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount() * -1, true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-W>k");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.OTHER_READONLY;
|
||||
}
|
||||
}
|
@@ -32,7 +32,7 @@ public class Argument {
|
||||
CHARACTER,
|
||||
STRING,
|
||||
DIGRAPH,
|
||||
EX_STRING;
|
||||
EX_STRING
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ public class Argument {
|
||||
*
|
||||
* @param motionArg The motion command
|
||||
*/
|
||||
public Argument(Command motionArg) {
|
||||
public Argument(@Nullable Command motionArg) {
|
||||
this.motionArg = motionArg;
|
||||
type = Type.MOTION;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class Argument {
|
||||
*
|
||||
* @param strArg The string
|
||||
*/
|
||||
public Argument(String strArg) {
|
||||
public Argument(@Nullable String strArg) {
|
||||
this.strArg = strArg;
|
||||
type = Type.STRING;
|
||||
}
|
||||
@@ -126,19 +126,21 @@ public class Argument {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
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("]");
|
||||
|
||||
return res.toString();
|
||||
return "Argument [" +
|
||||
"charArg=" +
|
||||
charArg +
|
||||
", motionArg=" +
|
||||
motionArg +
|
||||
", strArg=" +
|
||||
strArg +
|
||||
", type=" +
|
||||
type +
|
||||
"]";
|
||||
}
|
||||
|
||||
private char charArg = 0;
|
||||
@Nullable private Command motionArg = null;
|
||||
@Nullable private String strArg = null;
|
||||
@NotNull private Type type;
|
||||
@NotNull private final Type type;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
@@ -80,10 +81,13 @@ public class Command {
|
||||
public static final int FLAG_SEARCH_FWD = 1 << 16;
|
||||
public static final int FLAG_SEARCH_REV = 1 << 17;
|
||||
|
||||
public static final int FLAG_KEEP_VISUAL = 1 << 20;
|
||||
/**
|
||||
* Command exits the visual mode, so caret movement shouldn't update visual selection
|
||||
*/
|
||||
public static final int FLAG_EXIT_VISUAL = 1 << 20;
|
||||
public static final int FLAG_FORCE_VISUAL = 1 << 21;
|
||||
public static final int FLAG_FORCE_LINEWISE = 1 << 22;
|
||||
public static final int FLAG_DELEGATE = 1 << 23;
|
||||
|
||||
/**
|
||||
* Special flag used for any mappings involving operators
|
||||
*/
|
||||
@@ -182,24 +186,11 @@ public class Command {
|
||||
* @param flags Any custom flags specific to this command
|
||||
*/
|
||||
public Command(int count, String actionId, AnAction action, @NotNull Type type, int flags) {
|
||||
this(count, actionId, action, type, flags, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a command that requires an argument
|
||||
*
|
||||
* @param count The number entered prior to the command (zero if no specific number)
|
||||
* @param action The action to be executed when the command is run
|
||||
* @param type The type of the 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, @NotNull Type type, int flags, Argument arg) {
|
||||
this.count = count;
|
||||
this.action = action;
|
||||
this.type = type;
|
||||
this.flags = flags;
|
||||
this.argument = arg;
|
||||
this.argument = null;
|
||||
|
||||
if (action instanceof EditorAction) {
|
||||
EditorAction eaction = (EditorAction)action;
|
||||
@@ -289,6 +280,7 @@ public class Command {
|
||||
*
|
||||
* @return The command's argument, null if there isn't one
|
||||
*/
|
||||
@Nullable
|
||||
public Argument getArgument() {
|
||||
return argument;
|
||||
}
|
||||
@@ -298,7 +290,7 @@ public class Command {
|
||||
*
|
||||
* @param argument The new argument, can be null to clear the argument
|
||||
*/
|
||||
public void setArgument(Argument argument) {
|
||||
public void setArgument(@Nullable Argument argument) {
|
||||
this.argument = argument;
|
||||
}
|
||||
|
||||
@@ -312,23 +304,27 @@ public class Command {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
res.append("Command[");
|
||||
res.append("count=").append(count);
|
||||
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();
|
||||
return "Command[" +
|
||||
"count=" +
|
||||
count +
|
||||
", action=" +
|
||||
action +
|
||||
", type=" +
|
||||
type +
|
||||
", flags=" +
|
||||
flags +
|
||||
", argument=" +
|
||||
argument +
|
||||
", keys=" +
|
||||
keys +
|
||||
"]";
|
||||
}
|
||||
|
||||
private int count;
|
||||
private AnAction action;
|
||||
@NotNull private Type type;
|
||||
@NotNull private final Type type;
|
||||
private int flags;
|
||||
private Argument argument;
|
||||
@Nullable private Argument argument;
|
||||
private List<KeyStroke> keys;
|
||||
}
|
||||
|
@@ -40,8 +40,8 @@ public class CommandState {
|
||||
@Nullable private static Command ourLastChange = null;
|
||||
private static char ourLastRegister = RegisterGroup.REGISTER_DEFAULT;
|
||||
|
||||
@NotNull private Stack<State> myStates = new Stack<State>();
|
||||
@NotNull private State myDefaultState = new State(Mode.COMMAND, SubMode.NONE, MappingMode.NORMAL);
|
||||
@NotNull private final Stack<State> myStates = new Stack<State>();
|
||||
@NotNull private final State myDefaultState = new State(Mode.COMMAND, SubMode.NONE, MappingMode.NORMAL);
|
||||
@Nullable private Command myCommand;
|
||||
@NotNull private ParentNode myCurrentNode = VimPlugin.getKey().getKeyRoot(getMappingMode());
|
||||
@NotNull private final List<KeyStroke> myMappingKeys = new ArrayList<KeyStroke>();
|
||||
@@ -329,9 +329,9 @@ public class CommandState {
|
||||
}
|
||||
|
||||
private class State {
|
||||
@NotNull private Mode myMode;
|
||||
@NotNull private final Mode myMode;
|
||||
@NotNull private SubMode mySubMode;
|
||||
@NotNull private MappingMode myMappingMode;
|
||||
@NotNull private final MappingMode myMappingMode;
|
||||
|
||||
public State(@NotNull Mode mode, @NotNull SubMode subMode, @NotNull MappingMode mappingMode) {
|
||||
this.myMode = mode;
|
||||
|
@@ -62,6 +62,19 @@ public enum SelectionType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CommandState.SubMode toSubMode() {
|
||||
switch (this) {
|
||||
case LINE_WISE:
|
||||
return CommandState.SubMode.VISUAL_LINE;
|
||||
case CHARACTER_WISE:
|
||||
return CommandState.SubMode.VISUAL_CHARACTER;
|
||||
case BLOCK_WISE:
|
||||
return CommandState.SubMode.VISUAL_BLOCK;
|
||||
default:
|
||||
return CommandState.SubMode.VISUAL_CHARACTER;
|
||||
}
|
||||
}
|
||||
|
||||
public static SelectionType fromCommandFlags(int flags) {
|
||||
if ((flags & Command.FLAG_MOT_LINEWISE) != 0) {
|
||||
return SelectionType.LINE_WISE;
|
||||
|
@@ -42,17 +42,11 @@ public class VisualChange {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
res.append("VisualChange[");
|
||||
res.append("lines=").append(lines);
|
||||
res.append(", columns=").append(columns);
|
||||
res.append(", type=").append(type);
|
||||
res.append("]");
|
||||
|
||||
return res.toString();
|
||||
return "VisualChange[" + "lines=" + lines + ", columns=" + columns + ", type=" + type + "]";
|
||||
}
|
||||
|
||||
int lines;
|
||||
int columns;
|
||||
@NotNull SelectionType type;
|
||||
final int lines;
|
||||
final int columns;
|
||||
@NotNull final SelectionType type;
|
||||
}
|
||||
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.command;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VisualRange {
|
||||
public VisualRange(int start, int end, @NotNull CommandState.SubMode type, int offset) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.type = type;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CommandState.SubMode getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
res.append("VisualRange[");
|
||||
res.append("start=").append(start);
|
||||
res.append(", end=").append(end);
|
||||
res.append(", type=").append(type);
|
||||
res.append(", offset=").append(offset);
|
||||
res.append("]");
|
||||
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
int start;
|
||||
int end;
|
||||
@NotNull CommandState.SubMode type;
|
||||
int offset;
|
||||
}
|
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class FileLocation {
|
||||
protected FileLocation(int lline, int col, String filename) {
|
||||
protected FileLocation(int lline, int col, @Nullable String filename) {
|
||||
this.line = lline;
|
||||
this.col = col;
|
||||
this.filename = filename;
|
||||
@@ -90,13 +90,7 @@ public abstract class FileLocation {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append("FileLocation");
|
||||
sb.append("{col=").append(col);
|
||||
sb.append(", line=").append(line);
|
||||
sb.append(", filename='").append(filename).append('\'');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
return "FileLocation" + "{col=" + col + ", line=" + line + ", filename='" + filename + '\'' + '}';
|
||||
}
|
||||
|
||||
private int line;
|
||||
|
@@ -62,12 +62,7 @@ public class Mark extends FileLocation {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append("Mark{");
|
||||
sb.append(super.toString());
|
||||
sb.append(",key=").append(key);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
return "Mark{" + super.toString() + ",key=" + key + '}';
|
||||
}
|
||||
|
||||
public static class KeySorter<V> implements Comparator<V> {
|
||||
@@ -86,5 +81,5 @@ public class Mark extends FileLocation {
|
||||
}
|
||||
}
|
||||
|
||||
private char key;
|
||||
private final char key;
|
||||
}
|
||||
|
@@ -33,8 +33,8 @@ import java.util.List;
|
||||
*/
|
||||
public class Register {
|
||||
private char name;
|
||||
@NotNull private SelectionType type;
|
||||
@NotNull private List<KeyStroke> keys;
|
||||
@NotNull private final SelectionType type;
|
||||
@NotNull private final List<KeyStroke> keys;
|
||||
|
||||
public Register(char name, @NotNull SelectionType type, @NotNull String text) {
|
||||
this.name = name;
|
||||
|
@@ -100,7 +100,7 @@ public class TextRange {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("TextRange");
|
||||
sb.append("{starts=").append(starts == null ? "null" : "");
|
||||
for (int i = 0; starts != null && i < starts.length; ++i) {
|
||||
@@ -114,6 +114,6 @@ public class TextRange {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private int[] starts;
|
||||
private int[] ends;
|
||||
private final int[] starts;
|
||||
private final int[] ends;
|
||||
}
|
@@ -89,7 +89,7 @@ public abstract class CommandHandler {
|
||||
* @param argFlags Range and Arguments commands
|
||||
* @param optFlags Other command specific flags
|
||||
*/
|
||||
public CommandHandler(CommandName[] names, int argFlags, int optFlags) {
|
||||
public CommandHandler(@Nullable CommandName[] names, int argFlags, int optFlags) {
|
||||
this.names = names;
|
||||
this.argFlags = argFlags;
|
||||
this.optFlags = optFlags;
|
||||
@@ -261,7 +261,7 @@ public abstract class CommandHandler {
|
||||
*/
|
||||
public abstract boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException;
|
||||
|
||||
@Nullable protected CommandName[] names;
|
||||
protected int argFlags;
|
||||
protected int optFlags;
|
||||
@Nullable protected final CommandName[] names;
|
||||
protected final int argFlags;
|
||||
protected final int optFlags;
|
||||
}
|
||||
|
@@ -35,6 +35,6 @@ public class CommandName {
|
||||
return optional;
|
||||
}
|
||||
|
||||
private String required;
|
||||
private String optional;
|
||||
private final String required;
|
||||
private final String optional;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class CommandNode {
|
||||
command = null;
|
||||
}
|
||||
|
||||
public CommandNode(CommandHandler command) {
|
||||
public CommandNode(@Nullable CommandHandler command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@@ -57,5 +57,5 @@ public class CommandNode {
|
||||
}
|
||||
|
||||
@Nullable private CommandHandler command;
|
||||
@NotNull private HashMap<Character, CommandNode> nodes = new HashMap<Character, CommandNode>();
|
||||
@NotNull private final HashMap<Character, CommandNode> nodes = new HashMap<Character, CommandNode>();
|
||||
}
|
||||
|
@@ -32,6 +32,9 @@ import com.maddyhome.idea.vim.helper.Msg;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Maintains a tree of Ex commands based on the required and optional parts of the command names. Parses and
|
||||
* executes Ex commands entered by the user.
|
||||
@@ -41,6 +44,7 @@ public class CommandParser {
|
||||
public static final int RES_ERROR = 1;
|
||||
public static final int RES_READONLY = 1;
|
||||
public static final int RES_DONT_REOPEN = 4;
|
||||
public static final Pattern TRIM_WHITESPACE = Pattern.compile("[ \\t]*(.*)[ \\t\\n\\r]+", Pattern.DOTALL);
|
||||
|
||||
/**
|
||||
* There is only one parser.
|
||||
@@ -106,6 +110,7 @@ public class CommandParser {
|
||||
new ShiftRightHandler();
|
||||
new SourceHandler();
|
||||
new SortHandler();
|
||||
new SplitHandler();
|
||||
new SubstituteHandler();
|
||||
new UndoHandler();
|
||||
new WriteAllHandler();
|
||||
@@ -222,8 +227,8 @@ public class CommandParser {
|
||||
}
|
||||
int state = STATE_START;
|
||||
Ranges ranges = new Ranges(); // The list of ranges
|
||||
StringBuffer command = new StringBuffer(); // The command
|
||||
StringBuffer argument = new StringBuffer(); // The command's argument(s)
|
||||
StringBuilder command = new StringBuilder(); // The command
|
||||
StringBuilder argument = new StringBuilder(); // The command's argument(s)
|
||||
StringBuffer location = null; // The current range text
|
||||
int offsetSign = 1; // Sign of current range offset
|
||||
int offsetNumber = 0; // The value of the current range offset
|
||||
@@ -533,7 +538,12 @@ public class CommandParser {
|
||||
logger.debug("argument = " + argument);
|
||||
}
|
||||
|
||||
return new ExCommand(ranges, command.toString(), argument.toString().trim());
|
||||
String argumentString = argument.toString();
|
||||
final Matcher matcher = TRIM_WHITESPACE.matcher(argumentString);
|
||||
if (matcher.matches()) {
|
||||
argumentString = matcher.group(1);
|
||||
}
|
||||
return new ExCommand(ranges, command.toString(), argumentString);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -544,6 +554,9 @@ public class CommandParser {
|
||||
public void addHandler(@NotNull CommandHandler handler) {
|
||||
// Iterator through each command name alias
|
||||
CommandName[] names = handler.getNames();
|
||||
if (names == null) {
|
||||
return;
|
||||
}
|
||||
for (CommandName name : names) {
|
||||
CommandNode node = root;
|
||||
String text = name.getRequired();
|
||||
@@ -583,7 +596,7 @@ public class CommandParser {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull private CommandNode root = new CommandNode();
|
||||
@NotNull private final CommandNode root = new CommandNode();
|
||||
private boolean registered = false;
|
||||
|
||||
private static CommandParser ourInstance;
|
||||
@@ -610,5 +623,5 @@ public class CommandParser {
|
||||
private static final int STATE_RANGE_DONE = 51;
|
||||
private static final int STATE_ERROR = 99;
|
||||
|
||||
private static Logger logger = Logger.getInstance(CommandParser.class.getName());
|
||||
private static final Logger logger = Logger.getInstance(CommandParser.class.getName());
|
||||
}
|
||||
|
@@ -53,13 +53,8 @@ public class ExCommand {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LineRange getLineRange(@NotNull Editor editor, DataContext context, boolean checkCount) {
|
||||
int count = -1;
|
||||
if (checkCount) {
|
||||
count = getCountArgument();
|
||||
}
|
||||
|
||||
return ranges.getLineRange(editor, context, count);
|
||||
public LineRange getLineRange(@NotNull Editor editor, DataContext context) {
|
||||
return ranges.getLineRange(editor, context, -1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -100,8 +95,8 @@ public class ExCommand {
|
||||
return ranges;
|
||||
}
|
||||
|
||||
@NotNull private Ranges ranges;
|
||||
@NotNull private String command;
|
||||
@NotNull private final Ranges ranges;
|
||||
@NotNull private final String command;
|
||||
@NotNull private String argument;
|
||||
|
||||
private static Logger logger = Logger.getInstance(ExCommand.class.getName());
|
||||
|
@@ -41,6 +41,6 @@ public class LineRange {
|
||||
return endLine;
|
||||
}
|
||||
|
||||
private int startLine;
|
||||
private int endLine;
|
||||
private final int startLine;
|
||||
private final int endLine;
|
||||
}
|
||||
|
@@ -24,9 +24,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
*
|
||||
*/
|
||||
public class ParseResult {
|
||||
@NotNull private Ranges ranges;
|
||||
@NotNull private String command;
|
||||
@NotNull private String argument;
|
||||
@NotNull private final Ranges ranges;
|
||||
@NotNull private final String command;
|
||||
@NotNull private final String argument;
|
||||
|
||||
public ParseResult(@NotNull Ranges ranges, @NotNull String command, @NotNull String argument) {
|
||||
this.ranges = ranges;
|
||||
|
@@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -47,9 +48,7 @@ public class Ranges {
|
||||
* @param range The list of ranges to append to the current list
|
||||
*/
|
||||
public void addRange(@NotNull Range[] range) {
|
||||
for (Range aRange : range) {
|
||||
ranges.add(aRange);
|
||||
}
|
||||
Collections.addAll(ranges, range);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +183,10 @@ public class Ranges {
|
||||
@NotNull
|
||||
public static TextRange getFileTextRange(@NotNull Editor editor, DataContext context) {
|
||||
Ranges ranges = new Ranges();
|
||||
ranges.addRange(AbstractRange.createRange("%", 0, false));
|
||||
final Range[] range = AbstractRange.createRange("%", 0, false);
|
||||
if (range != null) {
|
||||
ranges.addRange(range);
|
||||
}
|
||||
|
||||
return ranges.getTextRange(editor, context, -1);
|
||||
}
|
||||
@@ -225,11 +227,8 @@ public class Ranges {
|
||||
|
||||
@NotNull
|
||||
public String toString() {
|
||||
StringBuffer res = new StringBuffer();
|
||||
res.append("Ranges[ranges=").append(ranges);
|
||||
res.append("]");
|
||||
|
||||
return res.toString();
|
||||
return "Ranges[ranges=" + ranges + "]";
|
||||
}
|
||||
|
||||
private int startLine = 0;
|
||||
@@ -237,5 +236,5 @@ public class Ranges {
|
||||
private int count = 0;
|
||||
private int defaultLine = -1;
|
||||
private boolean done = false;
|
||||
private List<Range> ranges;
|
||||
@NotNull private final List<Range> ranges;
|
||||
}
|
||||
|
@@ -25,18 +25,21 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class VimScriptParser {
|
||||
public static final String[] VIMRC_FILES = {".ideavimrc", "_ideavimrc", ".vimrc", "_vimrc"};
|
||||
public static final String[] VIMRC_FILES = {".ideavimrc", "_ideavimrc"};
|
||||
public static final int BUFSIZE = 4096;
|
||||
private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(" *(\r\n|\n)+ *");
|
||||
|
||||
private VimScriptParser() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File findVimrc() {
|
||||
public static File findIdeaVimRc() {
|
||||
final String homeDirName = System.getProperty("user.home");
|
||||
if (homeDirName != null) {
|
||||
for (String fileName : VIMRC_FILES) {
|
||||
@@ -50,16 +53,27 @@ public class VimScriptParser {
|
||||
}
|
||||
|
||||
public static void executeFile(@NotNull File file) {
|
||||
final String data;
|
||||
try {
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
try {
|
||||
line = line.trim();
|
||||
data = readFile(file);
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
return;
|
||||
}
|
||||
executeText(data);
|
||||
}
|
||||
|
||||
public static void executeText(@NotNull String text) {
|
||||
for (String line : EOL_SPLIT_PATTERN.split(text)) {
|
||||
// TODO: Build a proper parse tree for a VimL file instead of ignoring potentially nested lines (VIM-669)
|
||||
if (line.startsWith(" ") || line.startsWith("\t")) {
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(":")) {
|
||||
line = line.substring(1);
|
||||
}
|
||||
final CommandParser commandParser = CommandParser.getInstance();
|
||||
try {
|
||||
final ExCommand command = commandParser.parse(line);
|
||||
final CommandHandler commandHandler = commandParser.getCommandHandler(command);
|
||||
if (commandHandler instanceof VimScriptCommandHandler) {
|
||||
@@ -71,7 +85,16 @@ public class VimScriptParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String readFile(@NotNull File file) throws IOException {
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final char[] buffer = new char[BUFSIZE];
|
||||
int n;
|
||||
while ((n = reader.read(buffer)) > 0) {
|
||||
builder.append(buffer, 0, n);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
@@ -76,5 +76,5 @@ public class CmdFilterHandler extends CommandHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static Logger logger = Logger.getInstance(CmdFilterHandler.class.getName());
|
||||
private static final Logger logger = Logger.getInstance(CmdFilterHandler.class.getName());
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ public class DeleteLinesHandler extends CommandHandler {
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {
|
||||
StringBuffer arg = new StringBuffer(cmd.getArgument());
|
||||
StringBuilder arg = new StringBuilder(cmd.getArgument());
|
||||
char register = RegisterGroup.REGISTER_DEFAULT;
|
||||
if (arg.length() > 0 && (arg.charAt(0) < '0' || arg.charAt(0) > '9')) {
|
||||
register = arg.charAt(0);
|
||||
|
@@ -41,8 +41,8 @@ public class DigraphHandler extends CommandHandler {
|
||||
logger.debug("arg=" + arg);
|
||||
}
|
||||
|
||||
return VimPlugin.getDigraph().parseCommandLine(editor, cmd.getArgument(), true);
|
||||
return VimPlugin.getDigraph().parseCommandLine(editor, cmd.getArgument());
|
||||
}
|
||||
|
||||
private static Logger logger = Logger.getInstance(DigraphHandler.class.getName());
|
||||
private static final Logger logger = Logger.getInstance(DigraphHandler.class.getName());
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class DumpLineHandler extends CommandHandler {
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {
|
||||
LineRange range = cmd.getLineRange(editor, context, false);
|
||||
LineRange range = cmd.getLineRange(editor, context);
|
||||
|
||||
CharSequence chars = editor.getDocument().getCharsSequence();
|
||||
for (int l = range.getStartLine(); l <= range.getEndLine(); l++) {
|
||||
@@ -55,5 +55,5 @@ public class DumpLineHandler extends CommandHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Logger logger = Logger.getInstance(DumpLineHandler.class.getName());
|
||||
private static final Logger logger = Logger.getInstance(DumpLineHandler.class.getName());
|
||||
}
|
||||
|
@@ -42,7 +42,6 @@ public class EditFileHandler extends CommandHandler {
|
||||
public boolean execute(@NotNull final Editor editor, @NotNull final DataContext context,
|
||||
@NotNull ExCommand cmd) throws ExException {
|
||||
final String arg = cmd.getArgument();
|
||||
if (arg != null) {
|
||||
if (arg.equals("#")) {
|
||||
VimPlugin.getMark().saveJumpLocation(editor);
|
||||
VimPlugin.getFile().selectPreviousTab(context);
|
||||
@@ -55,7 +54,6 @@ public class EditFileHandler extends CommandHandler {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't open a choose file dialog under a write action
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
@@ -39,5 +39,5 @@ public class EmptyHandler extends CommandHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Logger logger = Logger.getInstance(EmptyHandler.class.getName());
|
||||
private static final Logger logger = Logger.getInstance(EmptyHandler.class.getName());
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user