mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-17 16:31:45 +02:00
Compare commits
234 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 | ||
![]() |
e9e5c77cd3 | ||
![]() |
4d4bcbb365 | ||
![]() |
bd5a2976fd | ||
![]() |
cc6488ee2d | ||
![]() |
52068198a5 | ||
![]() |
5cdcd9d4d4 | ||
![]() |
fbeaa35d10 | ||
![]() |
1ac4bb38be | ||
![]() |
69c2a096ab | ||
![]() |
3dccf1b215 | ||
![]() |
035cb02362 | ||
![]() |
43d33a4502 | ||
![]() |
2b6e8dc566 | ||
![]() |
6388cc0639 | ||
![]() |
00bd6d2e3a | ||
![]() |
1f842b6d31 | ||
![]() |
954d7bd14c | ||
![]() |
d358893579 | ||
![]() |
3cb40cb09d | ||
![]() |
a4a8faedbb | ||
![]() |
c32fa2b53f | ||
![]() |
1d0b1791c4 | ||
![]() |
7251c8976d | ||
![]() |
684531aaae | ||
![]() |
4a1504f9e0 | ||
![]() |
ee1a6bbbd9 | ||
![]() |
52c86d8c27 | ||
![]() |
07e59536f3 | ||
![]() |
63f31b9b01 | ||
![]() |
4b6bf1bb9f | ||
![]() |
f03c202b46 | ||
![]() |
eb8a4a0e6a | ||
![]() |
c04b04f701 | ||
![]() |
2a0833e3b5 | ||
![]() |
6acc89331d | ||
![]() |
35afd9b92f | ||
![]() |
c16d83ceab | ||
![]() |
a7820f4fd0 | ||
![]() |
12dd338914 | ||
![]() |
720d552a21 | ||
![]() |
a0477f499b | ||
![]() |
20a4639995 | ||
![]() |
3d7a0e7917 | ||
![]() |
c9c1295001 | ||
![]() |
c93daf78f6 | ||
![]() |
c77812d2a8 | ||
![]() |
c7107b7ad7 | ||
![]() |
a9a28b259f | ||
![]() |
5f1a1d0aa0 | ||
![]() |
2f5dd3f2b1 | ||
![]() |
779909bdeb | ||
![]() |
e76bee2afa | ||
![]() |
bb9d551dad | ||
![]() |
db6399f1c5 | ||
![]() |
32ee6be7f9 | ||
![]() |
33a5dd9e1c | ||
![]() |
0c59182eb8 | ||
![]() |
391e14a05b | ||
![]() |
c3259faf42 | ||
![]() |
f588e473a1 | ||
![]() |
a076b4d71c | ||
![]() |
4540c75498 | ||
![]() |
239199462f | ||
![]() |
b703a7eabb | ||
![]() |
3cafe72f8f | ||
![]() |
48375c37de | ||
![]() |
f9ceb506d7 | ||
![]() |
a7a054f4e4 | ||
![]() |
f8781353a2 | ||
![]() |
b0760222f0 | ||
![]() |
66bcacc2c4 | ||
![]() |
5868f8a2a5 | ||
![]() |
8e54e24e03 | ||
![]() |
f511e6ea34 | ||
![]() |
6c9608a9ee | ||
![]() |
4a0f95f0f0 | ||
![]() |
e3e7bcffa0 | ||
![]() |
9340208c2c | ||
![]() |
a658b8d8bd | ||
![]() |
0b9946eaf9 | ||
![]() |
6ea255f125 | ||
![]() |
0225975e20 | ||
![]() |
af406c7d14 | ||
![]() |
a146e2c303 | ||
![]() |
f285051a9a | ||
![]() |
936f7e5d7c | ||
![]() |
463c8defa4 | ||
![]() |
19f0399f28 | ||
![]() |
05436427ee | ||
![]() |
2f6d4c9ff2 | ||
![]() |
64790c531e | ||
![]() |
9c209d2fb2 | ||
![]() |
8420ca355b | ||
![]() |
0aebcbd71e | ||
![]() |
13528667c8 | ||
![]() |
3b3fa3a455 | ||
![]() |
13d3d4e990 | ||
![]() |
b69d475e15 | ||
![]() |
b6f840aacb | ||
![]() |
ea454d3c07 | ||
![]() |
fb72d5d782 | ||
![]() |
d4b8c09b02 | ||
![]() |
254339037b | ||
![]() |
800e3a3012 | ||
![]() |
44a5021786 | ||
![]() |
db80629cbb | ||
![]() |
1c3a1c132b | ||
![]() |
751831f3b7 | ||
![]() |
d226d58e38 | ||
![]() |
230364ac87 | ||
![]() |
9df61bba7e | ||
![]() |
9ee1910a01 | ||
![]() |
46e10e1599 | ||
![]() |
ed29f7c1db | ||
![]() |
60f4c7b02e | ||
![]() |
5616723fa4 | ||
![]() |
724698df08 | ||
![]() |
9bdb99d948 | ||
![]() |
efc340a37a | ||
![]() |
58548a39d3 | ||
![]() |
638a205b6c | ||
![]() |
3031dbc600 | ||
![]() |
36dcb53e14 | ||
![]() |
1a94f4f12f | ||
![]() |
d87a241e34 | ||
![]() |
ddd28c9a44 | ||
![]() |
9637edf30e | ||
![]() |
b0a5e6d375 | ||
![]() |
6bec99b631 | ||
![]() |
a95b65067d | ||
![]() |
ac5c176deb | ||
![]() |
5d385eb26d | ||
![]() |
611620555f | ||
![]() |
d44412c712 | ||
![]() |
761719fffd | ||
![]() |
3015a4a8a2 | ||
![]() |
e8f579bf74 | ||
![]() |
f8da48f61d | ||
![]() |
5b21015f5b | ||
![]() |
326d62d815 | ||
![]() |
f5f6c92e59 | ||
![]() |
b56654c217 | ||
![]() |
f5e8572a73 | ||
![]() |
95a395ed70 | ||
![]() |
c08c122ea6 | ||
![]() |
95460df473 | ||
![]() |
ab489faa56 | ||
![]() |
48e49fe92d | ||
![]() |
441a296bde | ||
![]() |
7359ed74ad | ||
![]() |
dd56ec6b4c | ||
![]() |
2d271008f3 | ||
![]() |
d06340ac3c | ||
![]() |
f9a67c5180 | ||
![]() |
b4cce0980a | ||
![]() |
4a7557c5ba | ||
![]() |
4e84f056aa | ||
![]() |
68f938d476 | ||
![]() |
6a7135d2bc | ||
![]() |
58ab3ab1bb | ||
![]() |
78beef71ce | ||
![]() |
b05892e97d | ||
![]() |
f71e24d17e | ||
![]() |
3968e7741f |
@@ -22,6 +22,8 @@ Contributors:
|
||||
* [poxu](mailto:poxvuibr@gmail.com)
|
||||
* [Alexander Zolotov](mailto:alexander.zolotov@jetbrains.com)
|
||||
* [John Lindquist](mailto:johnlindquist@gmail.com)
|
||||
* [Ira Klotzko](mailto:iklotzko@ltech.com)
|
||||
* [Alex Selesse](mailto:alex@selesse.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.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
|
||||
----------------
|
||||
|
||||
Added support for `:map` key mapping commands. New keyboard shortcuts handler
|
||||
that doesn't require a separate keymap for Vim emulation. Added support for
|
||||
`:source` and `:sort` commands.
|
||||
|
||||
Features:
|
||||
|
||||
* VIM-288 Support for `:map` key mapping commands
|
||||
* VIM-543 Allow granular enable/disable of Vim shortcut keys
|
||||
* VIM-643 Support for `:source` command
|
||||
* VIM-439 Support for `:sort` command
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* VIM-528 Search and replace with grouping no longer works
|
||||
* VIM-281 Don't disable global reformat code action for Vim emulation
|
||||
|
||||
|
||||
0.32, 2013-11-15
|
||||
----------------
|
||||
|
||||
|
113
README.md
113
README.md
@@ -1,6 +1,20 @@
|
||||
IdeaVim
|
||||
=======
|
||||
|
||||
<div>
|
||||
<a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt299&guest=1">
|
||||
<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:bt299)/statusIcon"/>
|
||||
</a>
|
||||
<span>Build<span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt453&guest=1">
|
||||
<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:bt453)/statusIcon"/>
|
||||
</a>
|
||||
<span>Tests</span>
|
||||
</div>
|
||||
|
||||
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.
|
||||
@@ -10,7 +24,7 @@ Resources:
|
||||
* [Plugin homepage](http://plugins.jetbrains.com/plugin/164)
|
||||
* [Changelog](https://github.com/JetBrains/ideavim/blob/master/CHANGES.md)
|
||||
* [Bug tracker](http://youtrack.jetbrains.com/issues/VIM)
|
||||
* [Continuous integration builds](http://teamcity.jetbrains.com/project.html?projectId=IdeaVim)
|
||||
* [Continuous integration builds](http://teamcity.jetbrains.com/project.html?projectId=IdeaVim&guest=1)
|
||||
* [@IdeaVim](http://twitter.com/ideavim) in Twitter
|
||||
|
||||
|
||||
@@ -25,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
|
||||
---------------------------------
|
||||
@@ -41,6 +59,7 @@ Supported:
|
||||
* Some Ex commands
|
||||
* Some [:set options](https://github.com/JetBrains/ideavim/blob/master/doc/set-commands.md)
|
||||
* Full Vim regexps for search and search/replace
|
||||
* Key mappings
|
||||
* Macros
|
||||
* Digraphs
|
||||
* Command line and search history
|
||||
@@ -48,13 +67,30 @@ Supported:
|
||||
|
||||
Not supported (yet):
|
||||
|
||||
* Key mappings
|
||||
* Window commands
|
||||
* Jump lists
|
||||
* Various less used commands
|
||||
|
||||
Please see the file [index.txt](https://github.com/JetBrains/ideavim/blob/master/index.txt)
|
||||
for a list of commands covered with tests.
|
||||
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
|
||||
@@ -66,6 +102,8 @@ The IdeaVim plugin uses the undo/redo functionality of the IntelliJ platform,
|
||||
so the behaviour of the `u` and `<C-R>` commands may differ from the original
|
||||
Vim. Vim compatibility of undo/redo may be improved in the future releases.
|
||||
|
||||
See also [unresolved undo issues](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+u).
|
||||
|
||||
### Escape
|
||||
|
||||
Using `<Esc>` in dialog windows remains problematic. For most dialog windows
|
||||
@@ -73,58 +111,25 @@ the Vim emulator is put into the insert mode without the possibility to switch t
|
||||
the normal mode. In some dialog windows the normal mode is on by default. The
|
||||
usage of the Vim emulator in dialog windows is an area for improvements.
|
||||
|
||||
### Menu Changes
|
||||
|
||||
In order to emulate the keystrokes used by Vim, several of the default hotkeys
|
||||
used by the IDE had to be changed. Below is a list of IDE menus, their default
|
||||
keyboard shortcuts, and their new VIM keystrokes.
|
||||
|
||||
File
|
||||
Save All Ctrl-S :w
|
||||
|
||||
Edit
|
||||
Undo Ctrl-Z u
|
||||
Redo Ctrl-Shift-Z Ctrl-R
|
||||
Cut Ctrl-X "+x
|
||||
Copy Ctrl-C "+y
|
||||
Paste Ctrl-V "+P
|
||||
Select All Ctrl-A ggVG
|
||||
|
||||
Search
|
||||
Find Ctrl-F /
|
||||
Replace Ctrl-R :s
|
||||
Find Next F3 n
|
||||
Find Previous Shift-F3 N
|
||||
|
||||
View
|
||||
Quick JavaDoc Ctrl-Q K
|
||||
Parameter Info Ctrl-P Ctrl-Shift-P
|
||||
Swap Panels Ctrl-U <None>
|
||||
Recent Files... Ctrl-E <None>
|
||||
Type Hierarchy Ctrl-H Ctrl-Alt-Shift-H
|
||||
|
||||
Goto
|
||||
Class... Ctrl-N Alt-Shift-N
|
||||
Line... Ctrl-G G
|
||||
Declaration Ctrl-B gd
|
||||
Super Method Ctrl-U Ctrl-Shift-U
|
||||
|
||||
Code
|
||||
Override Methods... Ctrl-O Ctrl-Shift-O
|
||||
Implement Methods... Ctrl-I Ctrl-Shift-I
|
||||
Complete Code (Only in Insert mode)
|
||||
Basic Ctrl-Space Ctrl-Space or Ctrl-N or Ctrl-P
|
||||
Smart Type Ctrl-Shift-Space Ctrl-Shift-Space
|
||||
Class Name Ctrl-Alt-Space Ctrl-Alt-Space
|
||||
Insert Live Template Ctrl-J Ctrl-]
|
||||
|
||||
Tools
|
||||
Version Control
|
||||
Check In Project Ctrl-K <None>
|
||||
See also [unresolved escape issues](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+i_Esc).
|
||||
|
||||
|
||||
Development
|
||||
-----------
|
||||
Contributing
|
||||
------------
|
||||
|
||||
### Where to Start
|
||||
|
||||
In order to contribute to IdeaVim you should have some understanding of Java.
|
||||
|
||||
See also these docs on the IntelliJ API:
|
||||
|
||||
* [IntelliJ architectural overview](http://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Architectural+Overview)
|
||||
* [IntelliJ plugin development resources](http://confluence.jetbrains.com/display/IDEADEV/PluginDevelopment)
|
||||
|
||||
You can start by picking relatively simple tasks that are tagged with
|
||||
[#patch_welcome](http://youtrack.jetbrains.com/issues/VIM?q=%23patch_welcome)
|
||||
in the issue tracker.
|
||||
|
||||
|
||||
### Development Environment
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
version-id:0.32
|
||||
version-id:0.35
|
||||
platform-version:120.0
|
||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-12.1.zip
|
||||
build.number=x
|
||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-13.zip
|
||||
build.number=dev
|
||||
|
@@ -23,7 +23,6 @@
|
||||
<property name="src" value="${basedir}/src"/>
|
||||
<property name="resources" value="${basedir}/resources"/>
|
||||
<property name="test" value="${basedir}/test"/>
|
||||
<property name="keymap" value="${basedir}/resources/Vim.xml"/>
|
||||
<property name="idea.home" value="${idea}/unzip"/>
|
||||
<property environment="env"/>
|
||||
<property name="tools.jar" value="${env.JAVA_HOME}/lib/tools.jar"/>
|
||||
@@ -80,6 +79,7 @@
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${version}"/>
|
||||
<filter token="SINCE-VERSION" value="${platform-version}"/>
|
||||
<filter token="BUILD-NUMBER" value="${build.number}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<copy todir="${classes}">
|
||||
@@ -117,13 +117,12 @@
|
||||
<delete dir="${build}/IdeaVim"/>
|
||||
<mkdir dir="${build}/IdeaVim"/>
|
||||
<copy file="${basedir}/LICENSE.txt" tofile="${build}/IdeaVim/LICENSE"/>
|
||||
<copy file="${keymap}" todir="${build}/IdeaVim"/>
|
||||
<copy todir="${build}/IdeaVim/lib">
|
||||
<fileset dir="${build}" includes="*.jar"/>
|
||||
</copy>
|
||||
<copy file="${basedir}/README.md" tofile="${build}/IdeaVim/README"/>
|
||||
<copy file="${basedir}/CHANGES.md" tofile="${build}/IdeaVim/CHANGES"/>
|
||||
<zip basedir="${build}" zipfile="${dist}/${filename}.zip" compress="true" includes="IdeaVim/**"/>
|
||||
<zip basedir="${build}" zipfile="${dist}/${filename}-${build.number}.zip" compress="true" includes="IdeaVim/**"/>
|
||||
</target>
|
||||
|
||||
<!-- Packs all the sources -->
|
||||
@@ -156,7 +155,6 @@
|
||||
<fileset dir="${resources}"/>
|
||||
</copy>
|
||||
<mkdir dir="${out}/IdeaVim"/>
|
||||
<copy file="${keymap}" todir="${build}/IdeaVim"/>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="unzip, clean, prepare-tests">
|
||||
|
@@ -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
|
||||
@@ -18,6 +18,7 @@ The following `:set` commands can appear in `~/.vimrc` or set manually in the co
|
||||
'sidescroll' 'ss' minimum number of columns to scroll horizontal
|
||||
'sidescrolloff' 'siso' min. nr. of columns to left and right of cursor
|
||||
'smartcase' 'scs' no ignore case when pattern has uppercase
|
||||
'timeoutlen' 'tm' time that is waited for a mapped key sequence
|
||||
'undolevels' 'ul' maximum number of changes that can be undone
|
||||
'visualbell' 'vb' use visual bell instead of beeping
|
||||
'wrapscan' 'ws' searches wrap around the end of the file
|
||||
|
@@ -3,6 +3,23 @@
|
||||
<id>IdeaVIM</id>
|
||||
<change-notes>
|
||||
<![CDATA[
|
||||
<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>
|
||||
<li>New keyboard shortcuts handler that doesn't require a separate keymap for Vim emulation</li>
|
||||
<li>Support for <code>:source</code> command</li>
|
||||
<li>Support for <code>:sort</code> command</li>
|
||||
<li>Various bug fixes</li>
|
||||
</ul>
|
||||
<p>0.32:</p>
|
||||
<ul>
|
||||
<li>Fixed API compatibility with IntelliJ platform builds 132.1052+</li>
|
||||
@@ -17,21 +34,12 @@
|
||||
<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>0.28:</p>
|
||||
<ul>
|
||||
<li>Fixed reconfigure Vim keymap for user-defined base keymaps</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>Supported functionality:</p>
|
||||
<ul>
|
||||
@@ -45,6 +53,8 @@
|
||||
<li>Some Ex commands</li>
|
||||
<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>
|
||||
@@ -53,7 +63,7 @@
|
||||
]]>
|
||||
</description>
|
||||
<version>@VERSION@</version>
|
||||
<vendor logo="/icons/vim16x16.png">JetBrains</vendor>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<idea-version since-build="@SINCE-VERSION@"/>
|
||||
|
||||
@@ -69,16 +79,14 @@
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
|
||||
<applicationConfigurable instance="com.maddyhome.idea.vim.ui.VimEmulationConfigurable"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action id="VimPluginToggle" class="com.maddyhome.idea.vim.VimPluginToggleAction" text="Vim Emulator" description="Toggle the Vim Plugin On/Off">
|
||||
<action id="VimPluginToggle" class="com.maddyhome.idea.vim.action.VimPluginToggleAction" text="Vim Emulator" description="Toggle the Vim Plugin On/Off">
|
||||
<keyboard-shortcut first-keystroke="control alt V" keymap="$default"/>
|
||||
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="VimReconfigureKeymap" class="com.maddyhome.idea.vim.VimReconfigureKeymapAction" text="Reconfigure Vim Keymap" description="Reconfigure Vim keymap">
|
||||
<add-to-group group-id="ToolsMenu" relative-to-action="after VimPluginToggle"/>
|
||||
</action>
|
||||
|
||||
<!-- Motions -->
|
||||
<action id="VimMotionPreviousTab" class="com.maddyhome.idea.vim.action.motion.tabs.MotionPreviousTabAction" text="Move to Previous Tab"/>
|
||||
@@ -181,7 +189,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"/>
|
||||
@@ -209,7 +216,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 -->
|
||||
@@ -224,7 +231,6 @@
|
||||
<action id="VimInsertDeletePreviousWord" class="com.maddyhome.idea.vim.action.change.insert.InsertDeletePreviousWordAction" text="Delete Previous Word"/>
|
||||
<action id="VimInsertEnter" class="com.maddyhome.idea.vim.action.change.insert.InsertEnterAction" text="Enter"/>
|
||||
<action id="VimInsertExitMode" class="com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction" text="Exit Insert Mode"/>
|
||||
<action id="VimInsertHelp" class="com.maddyhome.idea.vim.action.change.insert.InsertHelpAction" text="Help"/>
|
||||
<action id="VimInsertLineStart" class="com.maddyhome.idea.vim.action.change.insert.InsertLineStartAction" text="Insert at Line Start"/>
|
||||
<action id="VimInsertNewLineAbove" class="com.maddyhome.idea.vim.action.change.insert.InsertNewLineAboveAction" text="Insert New Line Above"/>
|
||||
<action id="VimInsertNewLineBelow" class="com.maddyhome.idea.vim.action.change.insert.InsertNewLineBelowAction" text="Insert New Line Below"/>
|
||||
@@ -274,14 +280,8 @@
|
||||
<action id="VimFilterMotion" class="com.maddyhome.idea.vim.action.change.change.FilterMotionAction" text="Filter Lines"/>
|
||||
<action id="VimFilterCountLines" class="com.maddyhome.idea.vim.action.change.change.FilterCountLinesAction" text="Filter Lines"/>
|
||||
<action id="VimFilterVisualLines" class="com.maddyhome.idea.vim.action.change.change.FilterVisualLinesAction" text="Filter Visual Lines"/>
|
||||
<action id="VimAutoIndentVisual" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Auto Indent Selection"/>
|
||||
<action id="VimReformatVisual" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Reformat Selection"/>
|
||||
<action id="VimCommentByBlockComment" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Block Comment"/>
|
||||
<action id="VimCommentByLineComment" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Line Comment"/>
|
||||
<action id="VimSurroundWith" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Surround With"/>
|
||||
<action id="VimSurroundWithLiveTemplate" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Surround With Live Template"/>
|
||||
<action id="VimMoveStatementDown" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Move Statement Down"/>
|
||||
<action id="VimMoveStatementUp" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Move Statement Up"/>
|
||||
<action id="VimAutoIndentVisual" class="com.maddyhome.idea.vim.action.change.change.AutoIndentLinesVisualAction" text="Auto Indent Selection"/>
|
||||
<action id="VimReformatVisual" class="com.maddyhome.idea.vim.action.change.change.ReformatCodeVisualAction" text="Reformat Selection"/>
|
||||
|
||||
<!-- Shift -->
|
||||
<action id="VimAutoIndentLines" class="com.maddyhome.idea.vim.action.change.shift.AutoIndentLinesAction" text="Auto Indent Lines"/>
|
||||
@@ -348,30 +348,7 @@
|
||||
<action id="VimRedo" class="com.maddyhome.idea.vim.action.change.RedoAction" text="Redo"/>
|
||||
<action id="VimUndo" class="com.maddyhome.idea.vim.action.change.UndoAction" text="Undo"/>
|
||||
|
||||
<action id="VimClassNameCompletion" class="com.maddyhome.idea.vim.action.OriginalDelegateAction" text="Class Name Completion"/>
|
||||
<action id="VimCodeCompletion" class="com.maddyhome.idea.vim.action.OriginalDelegateAction" text="Code Completion"/>
|
||||
<action id="VimSmartTypeCompletion" class="com.maddyhome.idea.vim.action.OriginalDelegateAction" text="Smart Type Completion"/>
|
||||
<action id="VimWordCompletion" class="com.maddyhome.idea.vim.action.OriginalDelegateAction" text="Word Completion"/>
|
||||
<action id="VimInsertLiveTemplate" class="com.maddyhome.idea.vim.action.OriginalDelegateAction" text="Insert Live Template"/>
|
||||
|
||||
<!-- Keys -->
|
||||
<action id="VimKeyHandler" class="com.maddyhome.idea.vim.action.key.KeyAction" text="Keys"/>
|
||||
<action id="VimDummyHandler" class="com.maddyhome.idea.vim.action.key.DummyAction" text="Keys"/>
|
||||
<action id="VimNotImplementedHandler" class="com.maddyhome.idea.vim.action.key.NotImplementedAction" text="Reserved For Future Use"/>
|
||||
<action id="VimEditorBackSpace" class="com.maddyhome.idea.vim.action.key.BackSpaceAction" text="Backspace"/>
|
||||
<action id="VimEditorDelete" class="com.maddyhome.idea.vim.action.key.DeleteAction" text="Delete"/>
|
||||
<action id="VimEditorDown" class="com.maddyhome.idea.vim.action.key.DownAction" text="Down"/>
|
||||
<action id="VimEditorEnter" class="com.maddyhome.idea.vim.action.key.EnterAction" text="Enter"/>
|
||||
<action id="VimEditorEscape" class="com.maddyhome.idea.vim.action.key.EscapeAction" text="Escape"/>
|
||||
<action id="VimEditorLeft" class="com.maddyhome.idea.vim.action.key.LeftAction" text="Left"/>
|
||||
<action id="VimEditorLineEnd" class="com.maddyhome.idea.vim.action.key.LineEndAction" text="LineEnd"/>
|
||||
<action id="VimEditorLineStart" class="com.maddyhome.idea.vim.action.key.LineStartAction" text="LineStart"/>
|
||||
<action id="VimEditorPageDown" class="com.maddyhome.idea.vim.action.key.PageDownAction" text="PageDown"/>
|
||||
<action id="VimEditorPageUp" class="com.maddyhome.idea.vim.action.key.PageUpAction" text="PageUp"/>
|
||||
<action id="VimEditorRight" class="com.maddyhome.idea.vim.action.key.RightAction" text="Right"/>
|
||||
<action id="VimEditorTab" class="com.maddyhome.idea.vim.action.key.TabAction" text="Tab"/>
|
||||
<action id="VimEditorToggleInsertState" class="com.maddyhome.idea.vim.action.key.ToggleInsertStateAction" text="Insert/Overwrite"/>
|
||||
<action id="VimEditorUp" class="com.maddyhome.idea.vim.action.key.UpAction" text="Up"/>
|
||||
<action id="VimDigraphEntry" class="com.maddyhome.idea.vim.action.key.KeyAction" text="Digraph Entry"/>
|
||||
<action id="VimShortcutKeyAction" class="com.maddyhome.idea.vim.action.VimShortcutKeyAction" text="Vim Shortcuts"/>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
|
@@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<keymap version="1" name="Vim" disable-mnemonics="false" parent="$default">
|
||||
<action id="VimKeyHandler">
|
||||
<keyboard-shortcut first-keystroke="control 2" />
|
||||
<keyboard-shortcut first-keystroke="control A" />
|
||||
<keyboard-shortcut first-keystroke="control alt SPACE" />
|
||||
<keyboard-shortcut first-keystroke="control B" />
|
||||
<keyboard-shortcut first-keystroke="control BACK_SLASH" />
|
||||
<keyboard-shortcut first-keystroke="control C" />
|
||||
<keyboard-shortcut first-keystroke="control CLOSE_BRACKET" />
|
||||
<keyboard-shortcut first-keystroke="control D" />
|
||||
<keyboard-shortcut first-keystroke="control E" />
|
||||
<keyboard-shortcut first-keystroke="control END" />
|
||||
<keyboard-shortcut first-keystroke="control F" />
|
||||
<keyboard-shortcut first-keystroke="control G" />
|
||||
<keyboard-shortcut first-keystroke="control H" />
|
||||
<keyboard-shortcut first-keystroke="control HOME" />
|
||||
<keyboard-shortcut first-keystroke="control I" />
|
||||
<keyboard-shortcut first-keystroke="control J" />
|
||||
<keyboard-shortcut first-keystroke="control K" />
|
||||
<keyboard-shortcut first-keystroke="control L" />
|
||||
<keyboard-shortcut first-keystroke="control LEFT" />
|
||||
<keyboard-shortcut first-keystroke="control M" />
|
||||
<keyboard-shortcut first-keystroke="control O" />
|
||||
<keyboard-shortcut first-keystroke="control OPEN_BRACKET" />
|
||||
<keyboard-shortcut first-keystroke="control P" />
|
||||
<keyboard-shortcut first-keystroke="control PAGE_DOWN" />
|
||||
<keyboard-shortcut first-keystroke="control PAGE_UP" />
|
||||
<keyboard-shortcut first-keystroke="control Q" />
|
||||
<keyboard-shortcut first-keystroke="control R" />
|
||||
<keyboard-shortcut first-keystroke="control RIGHT" />
|
||||
<keyboard-shortcut first-keystroke="control S" />
|
||||
<keyboard-shortcut first-keystroke="control SPACE" />
|
||||
<keyboard-shortcut first-keystroke="control T" />
|
||||
<keyboard-shortcut first-keystroke="control U" />
|
||||
<keyboard-shortcut first-keystroke="control V" />
|
||||
<keyboard-shortcut first-keystroke="control W" />
|
||||
<keyboard-shortcut first-keystroke="control X" />
|
||||
<keyboard-shortcut first-keystroke="control Y" />
|
||||
<keyboard-shortcut first-keystroke="control Z" />
|
||||
<keyboard-shortcut first-keystroke="KP_DOWN" />
|
||||
<keyboard-shortcut first-keystroke="KP_LEFT" />
|
||||
<keyboard-shortcut first-keystroke="KP_RIGHT" />
|
||||
<keyboard-shortcut first-keystroke="KP_UP" />
|
||||
<keyboard-shortcut first-keystroke="shift control 2" />
|
||||
<keyboard-shortcut first-keystroke="shift control SPACE" />
|
||||
<keyboard-shortcut first-keystroke="shift DOWN" />
|
||||
<keyboard-shortcut first-keystroke="shift LEFT" />
|
||||
<keyboard-shortcut first-keystroke="shift RIGHT" />
|
||||
<keyboard-shortcut first-keystroke="shift UP" />
|
||||
</action>
|
||||
</keymap>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 866 B |
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();
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -31,18 +32,17 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.group.RegisterGroup;
|
||||
import com.maddyhome.idea.vim.helper.DelegateCommandListener;
|
||||
import com.maddyhome.idea.vim.helper.DigraphSequence;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import com.maddyhome.idea.vim.helper.RunnableHelper;
|
||||
import com.maddyhome.idea.vim.helper.*;
|
||||
import com.maddyhome.idea.vim.key.*;
|
||||
import com.maddyhome.idea.vim.option.Options;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -100,11 +100,21 @@ public class KeyHandler {
|
||||
* @param context The data context
|
||||
*/
|
||||
public void handleKey(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context) {
|
||||
handleKey(editor, key, context, true);
|
||||
}
|
||||
|
||||
public void handleKey(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
||||
boolean allowKeyMappings) {
|
||||
VimPlugin.clearError();
|
||||
// All the editor actions should be performed with top level editor!!!
|
||||
// Be careful: all the EditorActionHandler implementation should correctly process InjectedEditors
|
||||
editor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||
final CommandState editorState = CommandState.getInstance(editor);
|
||||
|
||||
if (allowKeyMappings && handleKeyMapping(editor, key, context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean isRecording = editorState.isRecording();
|
||||
boolean shouldRecord = true;
|
||||
// If this is a "regular" character keystroke, get the character
|
||||
@@ -154,22 +164,22 @@ 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")) {
|
||||
char dig = CommandGroups.getInstance().getDigraph().getDigraph(lastChar, key.getKeyChar());
|
||||
char dig = VimPlugin.getDigraph().getDigraph(lastChar, key.getKeyChar());
|
||||
key = KeyStroke.getKeyStroke(dig);
|
||||
}
|
||||
|
||||
// If we are in insert/replace mode send this key in for processing
|
||||
if (editorState.getMode() == CommandState.Mode.INSERT || editorState.getMode() == CommandState.Mode.REPLACE) {
|
||||
if (!CommandGroups.getInstance().getChange().processKey(editor, context, key)) {
|
||||
if (!VimPlugin.getChange().processKey(editor, context, key)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
else if (editorState.getMappingMode() == KeyParser.MAPPING_CMD_LINE) {
|
||||
if (!CommandGroups.getInstance().getProcess().processExKey(editor, key, true)) {
|
||||
else if (editorState.getMappingMode() == MappingMode.CMD_LINE) {
|
||||
if (!VimPlugin.getProcess().processExKey(editor, key)) {
|
||||
shouldRecord = false;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +198,7 @@ public class KeyHandler {
|
||||
executeCommand(editor, key, context, editorState);
|
||||
}
|
||||
else if (state == State.BAD_COMMAND) {
|
||||
if (editorState.getMappingMode() == KeyParser.MAPPING_OP_PEND) {
|
||||
if (editorState.getMappingMode() == MappingMode.OP_PENDING) {
|
||||
editorState.popState();
|
||||
}
|
||||
else {
|
||||
@@ -202,18 +212,93 @@ public class KeyHandler {
|
||||
fullReset(editor);
|
||||
}
|
||||
else if (isRecording && shouldRecord) {
|
||||
CommandGroups.getInstance().getRegister().recordKeyStroke(key);
|
||||
VimPlugin.getRegister().recordKeyStroke(key);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleKeyMapping(@NotNull final Editor editor, @NotNull KeyStroke key,
|
||||
@NotNull final DataContext context) {
|
||||
final CommandState commandState = CommandState.getInstance(editor);
|
||||
commandState.stopMappingTimer();
|
||||
|
||||
final List<KeyStroke> mappingKeys = commandState.getMappingKeys();
|
||||
final List<KeyStroke> fromKeys = new ArrayList<KeyStroke>(mappingKeys);
|
||||
fromKeys.add(key);
|
||||
|
||||
final MappingMode mappingMode = commandState.getMappingMode();
|
||||
if (MappingMode.NVO.contains(mappingMode) && (state != State.NEW_COMMAND || currentArg != Argument.Type.NONE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final KeyMapping mapping = VimPlugin.getKey().getKeyMapping(mappingMode);
|
||||
final MappingInfo mappingInfo = mapping.get(fromKeys);
|
||||
|
||||
if (mapping.isPrefix(fromKeys)) {
|
||||
mappingKeys.add(key);
|
||||
commandState.startMappingTimer(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
mappingKeys.clear();
|
||||
for (KeyStroke keyStroke : fromKeys) {
|
||||
handleKey(editor, keyStroke, new EditorDataContext(editor), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (mappingInfo != null) {
|
||||
mappingKeys.clear();
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
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()) {
|
||||
final boolean recursive = mappingInfo.isRecursive() && !(first && fromIsPrefix);
|
||||
handleKey(editor, keyStroke, new EditorDataContext(editor), recursive);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (application.isUnitTestMode()) {
|
||||
handleMappedKeys.run();
|
||||
}
|
||||
else {
|
||||
application.invokeLater(handleMappedKeys);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
final List<KeyStroke> unhandledKeys = new ArrayList<KeyStroke>(mappingKeys);
|
||||
mappingKeys.clear();
|
||||
for (KeyStroke keyStroke : unhandledKeys) {
|
||||
handleKey(editor, keyStroke, context, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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 &&
|
||||
CommandGroups.getInstance().getRegister().getCurrentRegister() == RegisterGroup.REGISTER_DEFAULT) {
|
||||
VimPlugin.getRegister().getCurrentRegister() == RegisterGroup.REGISTER_DEFAULT) {
|
||||
if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
CommandProcessor.getInstance().executeCommand(editor.getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
KeyHandler.executeAction("VimEditorEscape", context);
|
||||
KeyHandler.executeAction("EditorEscape", context);
|
||||
}
|
||||
}, "", null);
|
||||
}
|
||||
@@ -301,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
|
||||
@@ -328,8 +412,7 @@ public class KeyHandler {
|
||||
}
|
||||
|
||||
// If we were in "operator pending" mode, reset back to normal mode.
|
||||
if (editorState.getMappingMode() == KeyParser.MAPPING_OP_PEND) {
|
||||
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_NORMAL);
|
||||
if (editorState.getMappingMode() == MappingMode.OP_PENDING) {
|
||||
editorState.popState();
|
||||
}
|
||||
|
||||
@@ -359,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);
|
||||
@@ -378,8 +460,7 @@ public class KeyHandler {
|
||||
// Is the current command an operator? If so set the state to only accept "operator pending"
|
||||
// commands
|
||||
if ((node.getFlags() & Command.FLAG_OP_PEND) != 0) {
|
||||
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_OP_PEND);
|
||||
editorState.pushState(editorState.getMode(), editorState.getSubMode(), KeyParser.MAPPING_OP_PEND);
|
||||
editorState.pushState(editorState.getMode(), editorState.getSubMode(), MappingMode.OP_PENDING);
|
||||
}
|
||||
break;
|
||||
case EX_STRING:
|
||||
@@ -395,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) {
|
||||
@@ -424,7 +505,7 @@ public class KeyHandler {
|
||||
}
|
||||
}
|
||||
else if (currentArg == Argument.Type.EX_STRING && (node.getFlags() & Command.FLAG_COMPLETE_EX) != 0) {
|
||||
String text = CommandGroups.getInstance().getProcess().endSearchCommand(editor, context);
|
||||
String text = VimPlugin.getProcess().endSearchCommand(editor, context);
|
||||
Argument arg = new Argument(text);
|
||||
Command cmd = currentCmd.peek();
|
||||
cmd.setArgument(arg);
|
||||
@@ -465,10 +546,10 @@ public class KeyHandler {
|
||||
}
|
||||
|
||||
if (arg.getArgType() == Argument.Type.EX_STRING) {
|
||||
CommandGroups.getInstance().getProcess().startSearchCommand(editor, context, count, key);
|
||||
VimPlugin.getProcess().startSearchCommand(editor, context, count, key);
|
||||
state = State.NEW_COMMAND;
|
||||
currentArg = Argument.Type.EX_STRING;
|
||||
editorState.pushState(CommandState.Mode.EX_ENTRY, CommandState.SubMode.NONE, KeyParser.MAPPING_CMD_LINE);
|
||||
editorState.pushState(CommandState.Mode.EX_ENTRY, CommandState.SubMode.NONE, MappingMode.CMD_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -515,7 +596,9 @@ public class KeyHandler {
|
||||
count = 0;
|
||||
keys = new ArrayList<KeyStroke>();
|
||||
CommandState editorState = CommandState.getInstance(editor);
|
||||
editorState.setCurrentNode(KeyParser.getInstance().getKeyRoot(editorState.getMappingMode()));
|
||||
editorState.stopMappingTimer();
|
||||
editorState.getMappingKeys().clear();
|
||||
editorState.setCurrentNode(VimPlugin.getKey().getKeyRoot(editorState.getMappingMode()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,8 +626,7 @@ public class KeyHandler {
|
||||
reset(editor);
|
||||
lastChar = 0;
|
||||
lastWasBS = false;
|
||||
CommandGroups.getInstance().getRegister().resetRegister();
|
||||
DelegateCommandListener.getInstance().setRunnable(null);
|
||||
VimPlugin.getRegister().resetRegister();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,7 +646,7 @@ public class KeyHandler {
|
||||
|
||||
executeAction(cmd.getAction(), context);
|
||||
if (editorState.getMode() == CommandState.Mode.INSERT || editorState.getMode() == CommandState.Mode.REPLACE) {
|
||||
CommandGroups.getInstance().getChange().processCommand(editor, cmd);
|
||||
VimPlugin.getChange().processCommand(editor, cmd);
|
||||
}
|
||||
|
||||
// Now that the command has been executed let's clean up a few things.
|
||||
@@ -572,7 +654,7 @@ public class KeyHandler {
|
||||
// By default the "empty" register is used by all commands so we want to reset whatever the last register
|
||||
// selected by the user was to the empty register - unless we just executed the "select register" command.
|
||||
if (cmd.getType() != Command.Type.SELECT_REGISTER) {
|
||||
CommandGroups.getInstance().getRegister().resetRegister();
|
||||
VimPlugin.getRegister().resetRegister();
|
||||
}
|
||||
|
||||
// If, at this point, we are not in insert, replace, or visual modes, we need to restore the previous
|
||||
@@ -587,14 +669,14 @@ public class KeyHandler {
|
||||
KeyHandler.getInstance().reset(editor);
|
||||
|
||||
if (wasRecording && editorState.isRecording()) {
|
||||
CommandGroups.getInstance().getRegister().recordKeyStroke(key);
|
||||
VimPlugin.getRegister().recordKeyStroke(key);
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -608,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;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,240 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.Resources;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.impl.stores.StorageUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.impl.KeymapImpl;
|
||||
import com.intellij.openapi.keymap.impl.KeymapManagerImpl;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.maddyhome.idea.vim.ui.VimKeymapDialog;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.io.ByteStreams.toByteArray;
|
||||
|
||||
/**
|
||||
* @author oleg
|
||||
*/
|
||||
public class VimKeyMapUtil {
|
||||
private static final Joiner PATH_JOINER = Joiner.on(File.separatorChar);
|
||||
public static final String VIM_KEYMAP_NAME = "Vim";
|
||||
|
||||
private static final String VIM_XML = "Vim.xml";
|
||||
private static final String KEYMAPS_PATH = PATH_JOINER.join(PathManager.getConfigPath(), "keymaps");
|
||||
private static final String INSTALLED_VIM_KEYMAP_PATH = PATH_JOINER.join(KEYMAPS_PATH, VIM_XML);
|
||||
|
||||
private static Logger LOG = Logger.getInstance(VimKeyMapUtil.class);
|
||||
|
||||
public static boolean isVimKeymapInstalled() {
|
||||
return KeymapManager.getInstance().getKeymap(VIM_KEYMAP_NAME) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if keymap was installed or was successfully installed
|
||||
*/
|
||||
public static boolean installKeyBoardBindings() {
|
||||
LOG.debug("Check for keyboard bindings");
|
||||
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
|
||||
if (localFileSystem.refreshAndFindFileByPath(KEYMAPS_PATH) == null) {
|
||||
reportError("Failed to install vim keymap. Empty keymaps folder");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG.debug("No vim keyboard installed found. Installing");
|
||||
try {
|
||||
final byte[] bytes = toByteArray(retrieveSourceKeymapStream());
|
||||
Files.write(bytes, new File(INSTALLED_VIM_KEYMAP_PATH));
|
||||
final Document document = StorageUtil.loadDocument(bytes);
|
||||
if (document != null && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
// Prompt user to select the parent for the Vim keyboard
|
||||
if (!configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH, document, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
installKeymap(document);
|
||||
} catch (IOException e) {
|
||||
reportError("Source keymap not found", e);
|
||||
return false;
|
||||
} catch (InvalidDataException e) {
|
||||
reportError("Failed to install vim keymap. Vim.xml file is corrupted", e);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
reportError("Failed to install vim keymap.\n", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void installKeymap(@Nullable Document document) throws InvalidDataException {
|
||||
if (document == null) {
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
final KeymapImpl vimKeyMap = new KeymapImpl();
|
||||
final KeymapManagerImpl keymapManager = (KeymapManagerImpl) KeymapManager.getInstance();
|
||||
final Keymap[] allKeymaps = keymapManager.getAllKeymaps();
|
||||
vimKeyMap.readExternal(document.getRootElement(), allKeymaps);
|
||||
keymapManager.addKeymap(vimKeyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes parent keymap for the Vim
|
||||
*
|
||||
* @return true if document was changed successfully
|
||||
*/
|
||||
private static boolean configureVimParentKeymap(final String path, @NotNull final Document document,
|
||||
final boolean showNotification)
|
||||
throws IOException, InvalidDataException {
|
||||
final Element rootElement = document.getRootElement();
|
||||
final String parentKeymapName = rootElement.getAttributeValue("parent");
|
||||
final VimKeymapDialog vimKeymapDialog = new VimKeymapDialog(parentKeymapName);
|
||||
vimKeymapDialog.show();
|
||||
if (vimKeymapDialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
|
||||
return false;
|
||||
}
|
||||
rootElement.removeAttribute("parent");
|
||||
final Keymap parentKeymap = vimKeymapDialog.getSelectedKeymap();
|
||||
final String keymapName = parentKeymap.getName();
|
||||
VimKeymapConflictResolveUtil.resolveConflicts(rootElement, parentKeymap);
|
||||
// We cannot set a user-defined modifiable keymap as the parent of our Vim keymap so we have to copy its shortcuts
|
||||
if (parentKeymap.canModify()) {
|
||||
final KeymapImpl vimKeyMap = new KeymapImpl();
|
||||
final KeymapManager keymapManager = KeymapManager.getInstance();
|
||||
final KeymapManagerImpl keymapManagerImpl = (KeymapManagerImpl)keymapManager;
|
||||
final Keymap[] allKeymaps = keymapManagerImpl.getAllKeymaps();
|
||||
vimKeyMap.readExternal(rootElement, allKeymaps);
|
||||
final HashSet<String> ownActions = new HashSet<String>(Arrays.asList(vimKeyMap.getOwnActionIds()));
|
||||
final KeymapImpl parentKeymapImpl = (KeymapImpl)parentKeymap;
|
||||
for (String parentAction : parentKeymapImpl.getOwnActionIds()) {
|
||||
if (!ownActions.contains(parentAction)) {
|
||||
final List<Shortcut> shortcuts = Arrays.asList(parentKeymap.getShortcuts(parentAction));
|
||||
rootElement.addContent(VimKeymapConflictResolveUtil.createActionElement(parentAction, shortcuts));
|
||||
}
|
||||
}
|
||||
final Keymap grandParentKeymap = parentKeymap.getParent();
|
||||
rootElement.setAttribute("parent", grandParentKeymap.getName());
|
||||
}
|
||||
else {
|
||||
rootElement.setAttribute("parent", keymapName);
|
||||
}
|
||||
VimPlugin.getInstance().setPreviousKeyMap(keymapName);
|
||||
// Save modified keymap to the file
|
||||
JDOMUtil.writeDocument(document, path, "\n");
|
||||
if (showNotification) {
|
||||
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||
"Successfully configured vim keymap to be based on " +
|
||||
parentKeymap.getPresentableName(),
|
||||
NotificationType.INFORMATION));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isVimKeymapUsed() {
|
||||
return KeymapManager.getInstance().getActiveKeymap().getName().equals(VIM_KEYMAP_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if keymap was switched successfully, false otherwise
|
||||
*/
|
||||
public static boolean switchKeymapBindings(final boolean enableVimKeymap) {
|
||||
LOG.debug("Enabling keymap");
|
||||
|
||||
// In case if Vim keymap is already in use or we don't need it, we have nothing to do
|
||||
if (isVimKeymapUsed() == enableVimKeymap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final KeymapManagerImpl manager = (KeymapManagerImpl) KeymapManager.getInstance();
|
||||
// Get keymap to enable
|
||||
final String keymapName2Enable = enableVimKeymap ? VIM_KEYMAP_NAME : VimPlugin.getInstance().getPreviousKeyMap();
|
||||
if (keymapName2Enable.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (keymapName2Enable.equals(manager.getActiveKeymap().getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG.debug("Enabling keymap:" + keymapName2Enable);
|
||||
final Keymap keymap = manager.getKeymap(keymapName2Enable);
|
||||
if (keymap == null) {
|
||||
reportError("Failed to enable keymap: " + keymapName2Enable);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save previous keymap to enable after VIM emulation is turned off
|
||||
if (enableVimKeymap) {
|
||||
VimPlugin.getInstance().setPreviousKeyMap(manager.getActiveKeymap().getName());
|
||||
}
|
||||
|
||||
manager.setActiveKeymap(keymap);
|
||||
|
||||
final String keyMapPresentableName = keymap.getPresentableName();
|
||||
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||
keyMapPresentableName + " keymap was successfully enabled", NotificationType.INFORMATION));
|
||||
LOG.debug(keyMapPresentableName + " keymap was successfully enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static InputStream retrieveSourceKeymapStream() throws IOException {
|
||||
String keymapPath = PATH_JOINER.join(PathManager.getPluginsPath(), VimPlugin.IDEAVIM_NOTIFICATION_TITLE, VIM_XML);
|
||||
try {
|
||||
return new FileInputStream(keymapPath);
|
||||
} catch (FileNotFoundException e) {
|
||||
if (ApplicationManager.getApplication().isInternal()) {
|
||||
LOG.debug("Development mode on. Trying to retrieve source keymap from resources");
|
||||
return Resources.getResource(VimKeyMapUtil.class, "/" + VIM_XML).openStream();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static void reportError(final String message) {
|
||||
reportError(message, null);
|
||||
}
|
||||
|
||||
private static void reportError(final String message, @Nullable final Exception e) {
|
||||
LOG.error(message, e);
|
||||
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||
message + String.valueOf(e), NotificationType.ERROR));
|
||||
}
|
||||
}
|
@@ -1,242 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.actionSystem.MouseShortcut;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.impl.KeymapImpl;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
|
||||
import static com.google.common.collect.Lists.newLinkedList;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
|
||||
/**
|
||||
* User: zolotov
|
||||
* Date: 1/8/13
|
||||
*/
|
||||
public class VimKeymapConflictResolveUtil {
|
||||
private static final String SHIFT = "shift";
|
||||
private static final String CONTROL = "control";
|
||||
private static final String META = "meta";
|
||||
private static final String ALT = "alt";
|
||||
private static final String ALT_GRAPH = "altGraph";
|
||||
private static final String DOUBLE_CLICK = "doubleClick";
|
||||
|
||||
private static final String VIM_KEY_HANDLER_ACTION_ID = "VimKeyHandler";
|
||||
private static final String ACTION_TAG = "action";
|
||||
private static final String KEYBOARD_SHORTCUT_TAG = "keyboard-shortcut";
|
||||
private static final String MOUSE_SHORTCUT_TAG = "mouse-shortcut";
|
||||
private static final String ID_ATTRIBUTE = "id";
|
||||
private static final String FIRST_KEYSTROKE_ATTRIBUTE = "first-keystroke";
|
||||
private static final String KEYSTROKE_ATTRIBUTE = "keystroke";
|
||||
private static final String SECOND_KEYSTROKE_ATTRIBUTE = "second-keystroke";
|
||||
|
||||
private static final List<Integer> ALTERNATIVE_MODIFIERS = ImmutableList.of(
|
||||
InputEvent.ALT_DOWN_MASK,
|
||||
InputEvent.CTRL_DOWN_MASK,
|
||||
InputEvent.SHIFT_DOWN_MASK,
|
||||
InputEvent.META_DOWN_MASK,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK,
|
||||
InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK,
|
||||
InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
|
||||
|
||||
public static void resolveConflicts(Element targetKeymapRoot, Keymap parentKeymap) {
|
||||
final Collection<String> vimHandlingShortcuts = getVimHandlingShortcuts(targetKeymapRoot);
|
||||
final Map<String, List<Shortcut>> shortcutsToOverride = retrieveShortcutsToOverride(vimHandlingShortcuts, parentKeymap);
|
||||
overrideShortcuts(targetKeymapRoot, shortcutsToOverride);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetKeymapRoot root element of Vim keymap
|
||||
* @return all shortcuts in string representation that should be handled by Vim plugin
|
||||
*/
|
||||
private static Collection<String> getVimHandlingShortcuts(Element targetKeymapRoot) {
|
||||
Element vimKeyHandlerAction = retrieveActionElement(targetKeymapRoot);
|
||||
if (vimKeyHandlerAction != null) {
|
||||
Collection<String> result = newLinkedList();
|
||||
for (Object childAction : vimKeyHandlerAction.getChildren()) {
|
||||
if (childAction instanceof Element) {
|
||||
Element shortcut = (Element)childAction;
|
||||
result.add(shortcut.getAttributeValue(FIRST_KEYSTROKE_ATTRIBUTE));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetKeymapRoot root element of Vim keymap
|
||||
* @return Retrieve VimKeyHandler action element
|
||||
*/
|
||||
@Nullable
|
||||
private static Element retrieveActionElement(Element targetKeymapRoot) {
|
||||
Element vimKeyHandlerAction = null;
|
||||
for (Object child : targetKeymapRoot.getChildren(ACTION_TAG)) {
|
||||
if (child instanceof Element) {
|
||||
Element action = (Element)child;
|
||||
if (VIM_KEY_HANDLER_ACTION_ID.equals(action.getAttributeValue(ID_ATTRIBUTE))) {
|
||||
vimKeyHandlerAction = action;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vimKeyHandlerAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vimHandlingShortcuts collection of shortcuts that should be handled by Vim plugin
|
||||
* @param parentKeymap selected parent keymap for vim keymap
|
||||
* @return mapping of action names to its shortcuts that we should save in Vim-keymap
|
||||
* (or empty list of shortcuts if action just should be disabled)
|
||||
*/
|
||||
private static Map<String, List<Shortcut>> retrieveShortcutsToOverride(Collection<String> vimHandlingShortcuts, Keymap parentKeymap) {
|
||||
Map<String, List<Shortcut>> result = newHashMap();
|
||||
for (String shortcut : vimHandlingShortcuts) {
|
||||
final Map<String, ArrayList<KeyboardShortcut>> conflicts = parentKeymap.getConflicts("", KeyboardShortcut.fromString(shortcut));
|
||||
for (Map.Entry<String, ArrayList<KeyboardShortcut>> conflict : conflicts.entrySet()) {
|
||||
String actionName = conflict.getKey();
|
||||
final ArrayList<KeyboardShortcut> conflictedShortcuts = conflict.getValue();
|
||||
if (result.containsKey(actionName)) {
|
||||
// found another conflict for already overridden action
|
||||
List<Shortcut> overridesShortcuts = result.get(actionName);
|
||||
for (KeyboardShortcut conflictedShortcut : conflictedShortcuts) {
|
||||
overridesShortcuts.remove(conflictedShortcut);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// let's override action with all non-conflict shortcuts
|
||||
List<Shortcut> overriddenShortcuts = newLinkedList();
|
||||
for (Shortcut actionShortcut : parentKeymap.getShortcuts(actionName)) {
|
||||
if (!(actionShortcut instanceof KeyboardShortcut) || !conflictedShortcuts.contains(actionShortcut)) {
|
||||
overriddenShortcuts.add(actionShortcut);
|
||||
}
|
||||
}
|
||||
if (overriddenShortcuts.isEmpty()) {
|
||||
for (Integer modifier : ALTERNATIVE_MODIFIERS) {
|
||||
if (!SystemInfo.isMac && (modifier & InputEvent.META_DOWN_MASK) != 0) {
|
||||
continue;
|
||||
}
|
||||
final KeyStroke originalStroke = KeyStroke.getKeyStroke(shortcut);
|
||||
final int modifiers = originalStroke.getModifiers() | modifier;
|
||||
//noinspection MagicConstant
|
||||
final KeyStroke stroke = KeyStroke.getKeyStroke(originalStroke.getKeyCode(), modifiers);
|
||||
final KeyboardShortcut alternativeShortcut = new KeyboardShortcut(stroke, null);
|
||||
if (parentKeymap.getConflicts("", alternativeShortcut).isEmpty()) {
|
||||
overriddenShortcuts.add(alternativeShortcut);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
result.put(actionName, overriddenShortcuts);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill vim keymap with overridden actions.
|
||||
* Only keyboard and mouse shortcuts will be overridden.
|
||||
*
|
||||
* @param targetKeymapRoot root element of Vim keymap
|
||||
* @param shortcutsToOverride overriding mapping: actions -> shortcuts_should_be_saved
|
||||
*/
|
||||
|
||||
private static void overrideShortcuts(Element targetKeymapRoot, Map<String, List<Shortcut>> shortcutsToOverride) {
|
||||
for (Map.Entry<String, List<Shortcut>> action : shortcutsToOverride.entrySet()) {
|
||||
targetKeymapRoot.addContent(createActionElement(action.getKey(), action.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public static Element createActionElement(String actionName, List<Shortcut> shortcuts) {
|
||||
final Element overridesAction = new Element(ACTION_TAG);
|
||||
overridesAction.setAttribute(ID_ATTRIBUTE, actionName);
|
||||
for (Shortcut shortcut : shortcuts) {
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
|
||||
final String firstShortcutString = KeymapImpl.getKeyShortcutString(keyboardShortcut.getFirstKeyStroke());
|
||||
final Element shortcutElement = createShortcutElement(KEYBOARD_SHORTCUT_TAG, FIRST_KEYSTROKE_ATTRIBUTE,
|
||||
firstShortcutString);
|
||||
overridesAction.addContent(shortcutElement);
|
||||
final KeyStroke secondKeyStroke = keyboardShortcut.getSecondKeyStroke();
|
||||
if (secondKeyStroke != null) {
|
||||
final String secondShortcutString = KeymapImpl.getKeyShortcutString(secondKeyStroke);
|
||||
shortcutElement.setAttribute(SECOND_KEYSTROKE_ATTRIBUTE, secondShortcutString);
|
||||
}
|
||||
}
|
||||
else if (shortcut instanceof MouseShortcut) {
|
||||
overridesAction.addContent(createShortcutElement(MOUSE_SHORTCUT_TAG, KEYSTROKE_ATTRIBUTE, getMouseShortcutString((MouseShortcut)shortcut)));
|
||||
}
|
||||
}
|
||||
return overridesAction;
|
||||
}
|
||||
|
||||
private static Element createShortcutElement(String elementName, String shortcutAttributeName, String shortcut) {
|
||||
final Element shortcutElement = new Element(elementName);
|
||||
shortcutElement.setAttribute(shortcutAttributeName, shortcut);
|
||||
return shortcutElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create string representation of mouse shortcut
|
||||
* KeymapImpl has implementation for mouse shortcut marshaling, but it is private :-(
|
||||
*
|
||||
* @param shortcut mouse shortcut
|
||||
* @return string representation of mouse shortcut
|
||||
*/
|
||||
private static String getMouseShortcutString(MouseShortcut shortcut) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int modifiers = shortcut.getModifiers();
|
||||
if ((MouseEvent.SHIFT_DOWN_MASK & modifiers) > 0) {
|
||||
builder.append(SHIFT).append(' ');
|
||||
}
|
||||
if ((MouseEvent.CTRL_DOWN_MASK & modifiers) > 0) {
|
||||
builder.append(CONTROL).append(' ');
|
||||
}
|
||||
if ((MouseEvent.META_DOWN_MASK & modifiers) > 0) {
|
||||
builder.append(META).append(' ');
|
||||
}
|
||||
if ((MouseEvent.ALT_DOWN_MASK & modifiers) > 0) {
|
||||
builder.append(ALT).append(' ');
|
||||
}
|
||||
if ((MouseEvent.ALT_GRAPH_DOWN_MASK & modifiers) > 0) {
|
||||
builder.append(ALT_GRAPH).append(' ');
|
||||
}
|
||||
builder.append("button").append(shortcut.getButton()).append(' ');
|
||||
if (shortcut.getClickCount() > 1) {
|
||||
builder.append(DOUBLE_CLICK);
|
||||
}
|
||||
return builder.toString().trim();
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -17,15 +17,11 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.notification.*;
|
||||
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;
|
||||
@@ -38,7 +34,11 @@ import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||
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.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.impl.DefaultKeymap;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
@@ -48,15 +48,22 @@ import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
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;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This plugin attempts to emulate the key binding and general functionality of Vim and gVim. See the supplied
|
||||
@@ -70,25 +77,21 @@ import java.awt.*;
|
||||
*/
|
||||
@State(
|
||||
name = "VimSettings",
|
||||
storages = {
|
||||
@Storage(
|
||||
storages = {@Storage(
|
||||
id = "main",
|
||||
file = "$APP_CONFIG$/vim_settings.xml"
|
||||
)}
|
||||
)
|
||||
public class VimPlugin implements ApplicationComponent, PersistentStateComponent<Element>
|
||||
{
|
||||
|
||||
file = "$APP_CONFIG$/vim_settings.xml")})
|
||||
public class VimPlugin implements ApplicationComponent, PersistentStateComponent<Element> {
|
||||
private static final String IDEAVIM_COMPONENT_NAME = "VimPlugin";
|
||||
private static final String IDEAVIM_PLUGIN_ID = "IdeaVIM";
|
||||
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 = 2;
|
||||
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;
|
||||
@@ -100,206 +103,110 @@ 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;
|
||||
|
||||
@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;
|
||||
|
||||
/**
|
||||
* Creates the Vim Plugin
|
||||
*/
|
||||
public VimPlugin(final Application app) {
|
||||
myApp = app;
|
||||
|
||||
motion = new MotionGroup();
|
||||
change = new ChangeGroup();
|
||||
copy = new CopyGroup();
|
||||
mark = new MarkGroup();
|
||||
register = new RegisterGroup();
|
||||
file = new FileGroup();
|
||||
search = new SearchGroup();
|
||||
process = new ProcessGroup();
|
||||
macro = new MacroGroup();
|
||||
digraph = new DigraphGroup();
|
||||
history = new HistoryGroup();
|
||||
key = new KeyGroup();
|
||||
|
||||
LOG.debug("VimPlugin ctr");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VimPlugin getInstance() {
|
||||
return (VimPlugin)ApplicationManager.getApplication().getComponent(IDEAVIM_COMPONENT_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplies the name of the plugin
|
||||
*
|
||||
* @return The plugin name
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return IDEAVIM_COMPONENT_NAME;
|
||||
}
|
||||
|
||||
public String getPreviousKeyMap() {
|
||||
return previousKeyMap;
|
||||
}
|
||||
|
||||
public void setPreviousKeyMap(final String keymap) {
|
||||
previousKeyMap = keymap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the Vim Plugin. This plugs the vim key handler into the editor action manager.
|
||||
*/
|
||||
@Override
|
||||
public void initComponent() {
|
||||
LOG.debug("initComponent");
|
||||
|
||||
Notifications.Bus.register(IDEAVIM_STICKY_NOTIFICATION_ID, NotificationDisplayType.STICKY_BALLOON);
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
updateState();
|
||||
checkAndInstallKeymap();
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
// Add some listeners so we can handle special events
|
||||
setupListeners();
|
||||
final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
|
||||
EventFacade.getInstance().setupTypedActionHandler(new VimTypedActionHandler(typedAction.getHandler()));
|
||||
|
||||
// Register vim actions in command mode
|
||||
RegisterActions.registerActions();
|
||||
|
||||
// Add some listeners so we can handle special events
|
||||
setupListeners();
|
||||
|
||||
// Register ex handlers
|
||||
CommandParser.getInstance().registerHandlers();
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
|
||||
if (ideaVimRc != null) {
|
||||
VimScriptParser.executeFile(ideaVimRc);
|
||||
}
|
||||
}
|
||||
|
||||
LOG.debug("done");
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
boolean requiresRestart = false;
|
||||
if (previousStateVersion < 1 && SystemInfo.isMac && VimKeyMapUtil.isVimKeymapInstalled()) {
|
||||
if (Messages.showYesNoDialog("Vim keymap generator has been updated to create keymaps more compatible " +
|
||||
"with base keymaps.\n\nDo you want to reconfigure your Vim keymap?\n\n" +
|
||||
"Warning: Any custom shortcuts will be lost!\n\n" +
|
||||
"(You can do it later using Tools | Reconfigure Vim Keymap).",
|
||||
IDEAVIM_NOTIFICATION_TITLE,
|
||||
Messages.getQuestionIcon()) == Messages.YES) {
|
||||
KeyHandler.executeAction("VimReconfigureKeymap", SimpleDataContext.getProjectContext(null));
|
||||
}
|
||||
}
|
||||
if (previousStateVersion < 2 && SystemInfo.isMac) {
|
||||
final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
|
||||
final Boolean enabled = keyRepeat.isEnabled();
|
||||
if (enabled == null || !enabled) {
|
||||
if (Messages.showYesNoDialog("Do you want to enable repeating keys in Mac OS X on press and hold " +
|
||||
"(requires restart)?\n\n" +
|
||||
"(You can do it manually by running 'defaults write -g " +
|
||||
"ApplePressAndHoldEnabled 0' in the console).",
|
||||
IDEAVIM_NOTIFICATION_TITLE,
|
||||
Messages.getQuestionIcon()) == Messages.YES) {
|
||||
keyRepeat.setEnabled(true);
|
||||
requiresRestart = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requiresRestart) {
|
||||
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
app.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkAndInstallKeymap() {
|
||||
// Ensure that Vim keymap is installed and install if not.
|
||||
// Moreover we can use installed keymap as indicator of the first time installed plugin
|
||||
if (VimPlugin.isEnabled()) {
|
||||
boolean vimKeyMapInstalled = VimKeyMapUtil.isVimKeymapInstalled();
|
||||
// In case if keymap wasn't installed, we assume that this is the first launch after installation
|
||||
if (!vimKeyMapInstalled) {
|
||||
vimKeyMapInstalled = VimKeyMapUtil.installKeyBoardBindings();
|
||||
if (!vimKeyMapInstalled) {
|
||||
if (Messages.showYesNoDialog("It is crucial to use Vim keymap for IdeaVim plugin correct work, " +
|
||||
"however it was not installed correctly.\nDo you want " +
|
||||
ApplicationManagerEx.getApplicationEx().getName() +
|
||||
" to disable Vim emulation?", IDEAVIM_NOTIFICATION_TITLE, Messages.getQuestionIcon()) == Messages.YES) {
|
||||
VimPlugin.getInstance().turnOffPlugin();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
// Enable proper keymap bindings
|
||||
VimKeyMapUtil.switchKeymapBindings(true);
|
||||
}
|
||||
// In this case we should warn if user doesn't use vim keymap
|
||||
else {
|
||||
if (!VimKeyMapUtil.isVimKeymapUsed()) {
|
||||
Notifications.Bus.notify(new Notification(IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE,
|
||||
"Vim keymap is not active, IdeaVim plugin may work incorrectly",
|
||||
NotificationType.WARNING));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This sets up some listeners so we can handle various events that occur
|
||||
*/
|
||||
private void setupListeners() {
|
||||
DocumentManager.getInstance().addDocumentListener(new MarkGroup.MarkUpdater());
|
||||
DocumentManager.getInstance().addDocumentListener(new SearchGroup.DocumentSearchListener());
|
||||
DocumentManager.getInstance().init();
|
||||
|
||||
EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
isBlockCursor = editor.getSettings().isBlockCursor();
|
||||
isAnimatedScrolling = editor.getSettings().isAnimatedScrolling();
|
||||
isRefrainFromScrolling = editor.getSettings().isRefrainFromScrolling();
|
||||
EditorData.initializeEditor(editor);
|
||||
DocumentManager.getInstance().addListeners(editor.getDocument());
|
||||
|
||||
if (VimPlugin.isEnabled()) {
|
||||
// Turn on insert mode if editor doesn't have any file
|
||||
if (!EditorData.isFileEditor(editor) && editor.getDocument().isWritable() &&
|
||||
!CommandState.inInsertMode(editor)) {
|
||||
KeyHandler.getInstance().handleKey(editor, KeyStroke.getKeyStroke('i'), new EditorDataContext(editor));
|
||||
}
|
||||
editor.getSettings().setBlockCursor(!CommandState.inInsertMode(editor));
|
||||
editor.getSettings().setAnimatedScrolling(ANIMATED_SCROLLING_VIM_VALUE);
|
||||
editor.getSettings().setRefrainFromScrolling(REFRAIN_FROM_SCROLLING_VIM_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
public void editorReleased(@NotNull EditorFactoryEvent event) {
|
||||
EditorData.uninitializeEditor(event.getEditor());
|
||||
event.getEditor().getSettings().setAnimatedScrolling(isAnimatedScrolling);
|
||||
event.getEditor().getSettings().setRefrainFromScrolling(isRefrainFromScrolling);
|
||||
DocumentManager.getInstance().removeListeners(event.getEditor().getDocument());
|
||||
}
|
||||
}, 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() {
|
||||
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());
|
||||
}
|
||||
|
||||
public void projectClosed(final Project project) {
|
||||
}
|
||||
});
|
||||
|
||||
CommandProcessor.getInstance().addCommandListener(DelegateCommandListener.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* This shuts down the Vim plugin. All we need to do is reinstall the original key handler
|
||||
*/
|
||||
@Override
|
||||
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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
LOG.debug("Saving state");
|
||||
|
||||
final Element element = new Element("ideavim");
|
||||
// Save whether the plugin is enabled or not
|
||||
final Element state = new Element("state");
|
||||
state.setAttribute("version", Integer.toString(STATE_VERSION));
|
||||
state.setAttribute("enabled", Boolean.toString(enabled));
|
||||
element.addContent(state);
|
||||
|
||||
mark.saveData(element);
|
||||
register.saveData(element);
|
||||
search.saveData(element);
|
||||
history.saveData(element);
|
||||
key.saveData(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull final Element element) {
|
||||
LOG.debug("Loading state");
|
||||
@@ -316,30 +223,78 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
previousKeyMap = state.getAttributeValue("keymap");
|
||||
}
|
||||
|
||||
CommandGroups.getInstance().readData(element);
|
||||
mark.readData(element);
|
||||
register.readData(element);
|
||||
search.readData(element);
|
||||
history.readData(element);
|
||||
key.readData(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
LOG.debug("Saving state");
|
||||
|
||||
final Element element = new Element("ideavim");
|
||||
// Save whether the plugin is enabled or not
|
||||
final Element state = new Element("state");
|
||||
state.setAttribute("version", Integer.toString(STATE_VERSION));
|
||||
state.setAttribute("enabled", Boolean.toString(enabled));
|
||||
state.setAttribute("keymap", previousKeyMap);
|
||||
element.addContent(state);
|
||||
|
||||
CommandGroups.getInstance().saveData(element);
|
||||
return 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 PluginId getPluginId() {
|
||||
return PluginId.getId(IDEAVIM_PLUGIN_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the user has enabled or disabled the plugin
|
||||
*
|
||||
* @return true if the Vim plugin is enabled, false if not
|
||||
*/
|
||||
public static boolean isEnabled() {
|
||||
return getInstance().enabled;
|
||||
}
|
||||
@@ -354,8 +309,10 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
if (enabled) {
|
||||
getInstance().turnOnPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
VimKeyMapUtil.switchKeymapBindings(enabled);
|
||||
public static boolean isError() {
|
||||
return getInstance().error;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,6 +327,12 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearError() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
getInstance().error = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showMode(String msg) {
|
||||
showMessage(msg);
|
||||
}
|
||||
@@ -390,22 +353,144 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
}
|
||||
}
|
||||
|
||||
public void turnOnPlugin() {
|
||||
@NotNull
|
||||
private static VimPlugin getInstance() {
|
||||
return (VimPlugin)ApplicationManager.getApplication().getComponent(IDEAVIM_COMPONENT_NAME);
|
||||
}
|
||||
|
||||
private void turnOnPlugin() {
|
||||
KeyHandler.getInstance().fullReset(null);
|
||||
setCursors(BLOCK_CURSOR_VIM_VALUE);
|
||||
setAnimatedScrolling(ANIMATED_SCROLLING_VIM_VALUE);
|
||||
setRefrainFromScrolling(REFRAIN_FROM_SCROLLING_VIM_VALUE);
|
||||
|
||||
CommandGroups.getInstance().getMotion().turnOn();
|
||||
getMotion().turnOn();
|
||||
}
|
||||
|
||||
public void turnOffPlugin() {
|
||||
private void turnOffPlugin() {
|
||||
KeyHandler.getInstance().fullReset(null);
|
||||
setCursors(isBlockCursor);
|
||||
setAnimatedScrolling(isAnimatedScrolling);
|
||||
setRefrainFromScrolling(isRefrainFromScrolling);
|
||||
|
||||
CommandGroups.getInstance().getMotion().turnOff();
|
||||
getMotion().turnOff();
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
boolean requiresRestart = false;
|
||||
if (previousStateVersion < 2 && SystemInfo.isMac) {
|
||||
final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
|
||||
final Boolean enabled = keyRepeat.isEnabled();
|
||||
if (enabled == null || !enabled) {
|
||||
if (Messages.showYesNoDialog("Do you want to enable repeating keys in Mac OS X on press and hold " +
|
||||
"(requires restart)?\n\n" +
|
||||
"(You can do it manually by running 'defaults write -g " +
|
||||
"ApplePressAndHoldEnabled 0' in the console).", IDEAVIM_NOTIFICATION_TITLE,
|
||||
Messages.getQuestionIcon()
|
||||
) == Messages.YES) {
|
||||
keyRepeat.setEnabled(true);
|
||||
requiresRestart = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previousStateVersion > 0 && previousStateVersion < 3) {
|
||||
final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
|
||||
Keymap keymap = null;
|
||||
if (previousKeyMap != null) {
|
||||
keymap = manager.getKeymap(previousKeyMap);
|
||||
}
|
||||
if (keymap == null) {
|
||||
keymap = manager.getKeymap(DefaultKeymap.getInstance().getDefaultKeymapName());
|
||||
}
|
||||
assert keymap != null : "Default keymap not found";
|
||||
new Notification(
|
||||
VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID,
|
||||
VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||
String.format("IdeaVim plugin doesn't use the special \"Vim\" keymap any longer. " +
|
||||
"Switching to \"%s\" keymap.<br/><br/>" +
|
||||
"Now it is possible to set up:<br/>" +
|
||||
"<ul>" +
|
||||
"<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()),
|
||||
NotificationType.INFORMATION,
|
||||
new NotificationListener.Adapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
|
||||
ShowSettingsUtil.getInstance().editConfigurable((Project)null, new VimEmulationConfigurable());
|
||||
}
|
||||
}).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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
|
||||
eventFacade.addEditorFactoryListener(new EditorFactoryAdapter() {
|
||||
@Override
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
isBlockCursor = editor.getSettings().isBlockCursor();
|
||||
isAnimatedScrolling = editor.getSettings().isAnimatedScrolling();
|
||||
isRefrainFromScrolling = editor.getSettings().isRefrainFromScrolling();
|
||||
EditorData.initializeEditor(editor);
|
||||
DocumentManager.getInstance().addListeners(editor.getDocument());
|
||||
key.registerRequiredShortcutKeys(editor);
|
||||
|
||||
if (VimPlugin.isEnabled()) {
|
||||
// Turn on insert mode if editor doesn't have any file
|
||||
if (!EditorData.isFileEditor(editor) && editor.getDocument().isWritable() &&
|
||||
!CommandState.inInsertMode(editor)) {
|
||||
KeyHandler.getInstance().handleKey(editor, KeyStroke.getKeyStroke('i'), new EditorDataContext(editor));
|
||||
}
|
||||
editor.getSettings().setBlockCursor(!CommandState.inInsertMode(editor));
|
||||
editor.getSettings().setAnimatedScrolling(ANIMATED_SCROLLING_VIM_VALUE);
|
||||
editor.getSettings().setRefrainFromScrolling(REFRAIN_FROM_SCROLLING_VIM_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editorReleased(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
EditorData.uninitializeEditor(editor);
|
||||
key.unregisterShortcutKeys(editor);
|
||||
editor.getSettings().setAnimatedScrolling(isAnimatedScrolling);
|
||||
editor.getSettings().setRefrainFromScrolling(isRefrainFromScrolling);
|
||||
DocumentManager.getInstance().removeListeners(editor.getDocument());
|
||||
}
|
||||
}, myApp);
|
||||
|
||||
eventFacade.addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@Override
|
||||
public void projectOpened(@NotNull final Project project) {
|
||||
eventFacade.addFileEditorManagerListener(project, new MotionGroup.MotionEditorChange());
|
||||
eventFacade.addFileEditorManagerListener(project, new FileGroup.SelectionCheck());
|
||||
eventFacade.addFileEditorManagerListener(project, new SearchGroup.EditorSelectionCheck());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setCursors(boolean isBlock) {
|
||||
@@ -430,14 +515,4 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
editor.getSettings().setRefrainFromScrolling(isOn);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public static void clearError() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
getInstance().error = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.maddyhome.idea.vim;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupEx;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -29,51 +29,25 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* This handler accepts all regular keystrokes and passes them on to the Vim Key handler
|
||||
* Accepts all regular keystrokes and passes them on to the Vim key handler.
|
||||
*
|
||||
* IDE shortcut keys used by Vim commands are handled by {@link com.maddyhome.idea.vim.action.VimShortcutKeyAction}.
|
||||
*/
|
||||
public class VimTypedActionHandler implements TypedActionHandler {
|
||||
/**
|
||||
* Creates an instance of the key handler
|
||||
*
|
||||
* @param origHandler The original key handler
|
||||
*/
|
||||
private static final Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
|
||||
|
||||
private final TypedActionHandler origHandler;
|
||||
@NotNull private final KeyHandler handler;
|
||||
|
||||
public VimTypedActionHandler(TypedActionHandler origHandler) {
|
||||
this.origHandler = origHandler;
|
||||
handler = KeyHandler.getInstance();
|
||||
handler.setOriginalHandler(origHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the original key handler
|
||||
*
|
||||
* @return The original key handler
|
||||
*/
|
||||
public TypedActionHandler getOriginalTypedHandler() {
|
||||
return origHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* All characters typed into an editor will get sent to this handler. Only letters, numbers, and punctuation
|
||||
* are sent here. Keys like Tab, Enter, Home, Backspace, etc. and all Control-Letter etc. argType keys are not
|
||||
* sent by Idea to this handler.
|
||||
*
|
||||
* @param editor The editor the character was typed into
|
||||
* @param charTyped The character that was typed
|
||||
* @param context The data context
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext context) {
|
||||
// If the plugin is disabled we simply resend the character to the original handler
|
||||
if (!VimPlugin.isEnabled()) {
|
||||
origHandler.execute(editor, charTyped, context);
|
||||
return;
|
||||
}
|
||||
// In case if keystrokes go to lookup, we use original handler
|
||||
final LookupEx lookup = LookupManager.getActiveLookup(editor);
|
||||
if (lookup != null && lookup.isFocused()) {
|
||||
origHandler.execute(editor, charTyped, context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEnabled(editor)) {
|
||||
// Run key handler outside of the key typed command for creating our own undoable commands
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -87,9 +61,16 @@ public class VimTypedActionHandler implements TypedActionHandler {
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
origHandler.execute(editor, charTyped, context);
|
||||
}
|
||||
}
|
||||
|
||||
private TypedActionHandler origHandler;
|
||||
private KeyHandler handler;
|
||||
|
||||
private static Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
|
||||
private boolean isEnabled(@NotNull Editor editor) {
|
||||
if (VimPlugin.isEnabled()) {
|
||||
final Lookup lookup = LookupManager.getActiveLookup(editor);
|
||||
return lookup == null || !lookup.isFocused();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractDelegateAction extends AnAction implements DelegateAction {
|
||||
protected AbstractDelegateAction() {
|
||||
}
|
||||
|
||||
protected AbstractDelegateAction(@NotNull AnAction origAction) {
|
||||
setOrigAction(origAction);
|
||||
}
|
||||
|
||||
public void setOrigAction(@NotNull AnAction origAction) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("origAction=" + origAction);
|
||||
}
|
||||
this.origAction = origAction;
|
||||
copyFrom(origAction);
|
||||
}
|
||||
|
||||
public AnAction getOrigAction() {
|
||||
return origAction;
|
||||
}
|
||||
|
||||
private AnAction origAction;
|
||||
|
||||
private static Logger logger = Logger.getInstance(AbstractDelegateAction.class.getName());
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractDelegateEditorAction extends EditorAction implements DelegateAction {
|
||||
protected AbstractDelegateEditorAction(EditorActionHandler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
protected AbstractDelegateEditorAction(EditorActionHandler handler, @NotNull EditorAction origAction) {
|
||||
this(handler);
|
||||
setOrigAction(origAction);
|
||||
}
|
||||
|
||||
public void setOrigAction(@NotNull AnAction origAction) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("origAction=" + origAction);
|
||||
}
|
||||
this.origAction = origAction;
|
||||
copyFrom(origAction);
|
||||
}
|
||||
|
||||
public AnAction getOrigAction() {
|
||||
return origAction;
|
||||
}
|
||||
|
||||
private AnAction origAction;
|
||||
|
||||
private static Logger logger = Logger.getInstance(AbstractDelegateEditorAction.class.getName());
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
|
||||
public interface DelegateAction {
|
||||
void setOrigAction(AnAction origAction);
|
||||
|
||||
AnAction getOrigAction();
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,9 @@ package com.maddyhome.idea.vim.action;
|
||||
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.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -34,9 +34,9 @@ public class ExEntryAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
CommandGroups.getInstance().getProcess().startExCommand(editor, context, cmd);
|
||||
VimPlugin.getProcess().startExCommand(editor, context, cmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OriginalDelegateAction extends AbstractDelegateAction {
|
||||
public void actionPerformed(@NotNull AnActionEvent event) {
|
||||
Editor editor = event.getData(PlatformDataKeys.EDITOR);
|
||||
if (editor != null) {
|
||||
getOrigAction().actionPerformed(event);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class PassThruDelegateAction extends AbstractDelegateAction {
|
||||
public PassThruDelegateAction(KeyStroke stroke) {
|
||||
this.stroke = stroke;
|
||||
}
|
||||
|
||||
public void actionPerformed(@NotNull AnActionEvent event) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("actionPerformed key=" + stroke);
|
||||
}
|
||||
final Editor editor = event.getData(PlatformDataKeys.EDITOR); // API change - don't merge
|
||||
if (editor == null || !VimPlugin.isEnabled()) {
|
||||
getOrigAction().actionPerformed(event);
|
||||
}
|
||||
else if (event.getInputEvent() instanceof KeyEvent) {
|
||||
KeyStroke key = KeyStroke.getKeyStrokeForEvent((KeyEvent)event.getInputEvent());
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("event = KeyEvent: " + key);
|
||||
}
|
||||
KeyHandler.getInstance().handleKey(editor, key, event.getDataContext());
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("event is a " + event.getInputEvent().getClass().getName());
|
||||
}
|
||||
KeyHandler.getInstance().handleKey(editor, stroke, event.getDataContext());
|
||||
}
|
||||
}
|
||||
|
||||
private KeyStroke stroke;
|
||||
|
||||
private static Logger logger = Logger.getInstance(PassThruDelegateAction.class.getName());
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class PassThruDelegateEditorAction extends AbstractDelegateEditorAction {
|
||||
public PassThruDelegateEditorAction(KeyStroke stroke, EditorActionHandler origHandler) {
|
||||
super(new MyHandler(stroke, origHandler));
|
||||
}
|
||||
|
||||
private static Logger logger = Logger.getInstance(PassThruDelegateEditorAction.class.getName());
|
||||
|
||||
private static class MyHandler extends EditorActionHandler {
|
||||
public MyHandler(KeyStroke stroke, EditorActionHandler handler) {
|
||||
this.stroke = stroke;
|
||||
this.origHandler = handler;
|
||||
}
|
||||
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext dataContext) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("actionPerformed key=" + stroke);
|
||||
}
|
||||
if (!VimPlugin.isEnabled()) {
|
||||
origHandler.execute(editor, dataContext);
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("event = KeyEvent: " + stroke);
|
||||
}
|
||||
KeyHandler.getInstance().handleKey(InjectedLanguageUtil.getTopLevelEditor(editor), stroke, dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
private KeyStroke stroke;
|
||||
private EditorActionHandler origHandler;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -18,14 +18,23 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.handler.ResetModeHandler;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ResetModeAction extends EditorAction {
|
||||
public ResetModeAction() {
|
||||
super(new ResetModeHandler());
|
||||
super(new EditorActionHandler() {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
KeyHandler.getInstance().fullReset(InjectedLanguageUtil.getTopLevelEditor(editor));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
80
src/com/maddyhome/idea/vim/action/VimCommandAction.java
Normal file
80
src/com/maddyhome/idea/vim/action/VimCommandAction.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Action that represents a Vim command.
|
||||
*
|
||||
* Actions should be registered in resources/META-INF/plugin.xml and in package-info.java
|
||||
* inside {@link com.maddyhome.idea.vim.action}.
|
||||
*
|
||||
* @author vlan
|
||||
*/
|
||||
public abstract class VimCommandAction extends EditorAction {
|
||||
protected VimCommandAction(EditorActionHandler defaultHandler) {
|
||||
super(defaultHandler);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract Set<MappingMode> getMappingModes();
|
||||
|
||||
@NotNull
|
||||
public abstract Set<List<KeyStroke>> getKeyStrokesSet();
|
||||
|
||||
@NotNull
|
||||
public abstract Command.Type getType();
|
||||
|
||||
@NotNull
|
||||
public Argument.Type getArgumentType() {
|
||||
return Argument.Type.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns various binary flags for the command.
|
||||
*
|
||||
* These legacy flags will be refactored in future releases.
|
||||
*
|
||||
* @see {@link Command}.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -16,11 +16,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim;
|
||||
package com.maddyhome.idea.vim.action;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
|
||||
/**
|
||||
* This class is used to handle the Vim Plugin enabled/disabled toggle. This is most likely used as a menu option
|
215
src/com/maddyhome/idea/vim/action/VimShortcutKeyAction.java
Normal file
215
src/com/maddyhome/idea/vim/action/VimShortcutKeyAction.java
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.helper.EditorData;
|
||||
import com.maddyhome.idea.vim.key.ShortcutOwner;
|
||||
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.awt.event.KeyEvent.*;
|
||||
|
||||
/**
|
||||
* Handles Vim keys that are treated as action shortcuts by the IDE.
|
||||
*
|
||||
* 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 {
|
||||
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))
|
||||
.addAll(getKeyStrokes(VK_BACK_SPACE, 0, CTRL_MASK))
|
||||
.addAll(getKeyStrokes(VK_INSERT, 0))
|
||||
.addAll(getKeyStrokes(VK_DELETE, 0, CTRL_MASK))
|
||||
.addAll(getKeyStrokes(VK_UP, 0, CTRL_MASK, SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_DOWN, 0, CTRL_MASK, SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_LEFT, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.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, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.addAll(getKeyStrokes(VK_PAGE_DOWN, 0, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||
.build();
|
||||
|
||||
@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);
|
||||
if (editor != null && keyStroke != null) {
|
||||
final ShortcutOwner owner = VimPlugin.getKey().getSavedShortcutConflicts().get(keyStroke);
|
||||
if (owner == ShortcutOwner.UNDEFINED) {
|
||||
notifyAboutShortcutConflict(keyStroke);
|
||||
}
|
||||
// Should we use InjectedLanguageUtil.getTopLevelEditor(editor) here, as we did in former EditorKeyHandler?
|
||||
KeyHandler.getInstance().handleKey(editor, keyStroke, e.getDataContext());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
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(
|
||||
"Using the <b>%s</b> shortcut for Vim emulation.<br/>" +
|
||||
"You can redefine it as an <a href='#ide'>IDE shortcut</a> or " +
|
||||
"configure its handler in <a href='#settings'>Vim Emulation</a> settings.",
|
||||
KeymapUtil.getShortcutText(new KeyboardShortcut(keyStroke, null)));
|
||||
final NotificationListener listener = new NotificationListener.Adapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
|
||||
final String description = e.getDescription();
|
||||
if ("#ide".equals(description)) {
|
||||
VimPlugin.getKey().getSavedShortcutConflicts().put(keyStroke, ShortcutOwner.IDE);
|
||||
notification.expire();
|
||||
}
|
||||
else if ("#settings".equals(description)) {
|
||||
ShowSettingsUtil.getInstance().editConfigurable((Project)null, new VimEmulationConfigurable());
|
||||
}
|
||||
}
|
||||
};
|
||||
final Notification notification = new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID,
|
||||
VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||
message,
|
||||
NotificationType.INFORMATION,
|
||||
listener);
|
||||
notification.notify(null);
|
||||
}
|
||||
|
||||
private boolean isEnabled(@NotNull AnActionEvent e) {
|
||||
if (VimPlugin.isEnabled()) {
|
||||
final Editor editor = getEditor(e);
|
||||
final KeyStroke keyStroke = getKeyStroke(e);
|
||||
if (editor != null && keyStroke != null) {
|
||||
final int keyCode = keyStroke.getKeyCode();
|
||||
if (LookupManager.getActiveLookup(editor) != null) {
|
||||
return isExitInsertMode(keyStroke);
|
||||
}
|
||||
if (CommandState.inInsertMode(editor)) {
|
||||
// XXX: <Enter> and <Tab> won't be recorded in macros
|
||||
if (keyCode == VK_ENTER || keyCode == VK_TAB) {
|
||||
return false;
|
||||
}
|
||||
// Debug watch, Python console, etc.
|
||||
if (NON_FILE_EDITOR_KEYS.contains(keyStroke) && !EditorData.isFileEditor(editor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (VIM_ONLY_EDITOR_KEYS.contains(keyStroke)) {
|
||||
return true;
|
||||
}
|
||||
final Map<KeyStroke, ShortcutOwner> savedShortcutConflicts = VimPlugin.getKey().getSavedShortcutConflicts();
|
||||
final ShortcutOwner owner = savedShortcutConflicts.get(keyStroke);
|
||||
if (owner == ShortcutOwner.VIM) {
|
||||
return true;
|
||||
}
|
||||
else if (owner == ShortcutOwner.IDE) {
|
||||
return !isShortcutConflict(keyStroke);
|
||||
}
|
||||
else {
|
||||
if (isShortcutConflict(keyStroke)) {
|
||||
savedShortcutConflicts.put(keyStroke, ShortcutOwner.UNDEFINED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isExitInsertMode(@NotNull KeyStroke keyStroke) {
|
||||
for (List<KeyStroke> keys : InsertExitModeAction.getInstance().getKeyStrokesSet()) {
|
||||
// XXX: Currently we cannot handle <C-\><C-N> because of the importance of <C-N> for the IDE on Linux
|
||||
if (keys.size() == 1 && keyStroke.equals(keys.get(0))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isShortcutConflict(@NotNull KeyStroke keyStroke) {
|
||||
return !VimPlugin.getKey().getKeymapConflicts(keyStroke).isEmpty();
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
return keyStrokes;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private KeyStroke getKeyStroke(@NotNull AnActionEvent e) {
|
||||
final InputEvent inputEvent = e.getInputEvent();
|
||||
if (inputEvent instanceof KeyEvent) {
|
||||
final KeyEvent keyEvent = (KeyEvent)inputEvent;
|
||||
return KeyStroke.getKeyStrokeForEvent(keyEvent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Editor getEditor(@NotNull AnActionEvent e) {
|
||||
return e.getData(PlatformDataKeys.EDITOR);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -22,7 +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.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import com.maddyhome.idea.vim.helper.UndoRedoHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class RedoAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return UndoRedoHelper.redo(context);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -22,12 +22,12 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.key.KeyParser;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ public class RepeatChangeAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
|
||||
CommandState state = CommandState.getInstance(editor);
|
||||
Command cmd = state.getLastChangeCommand();
|
||||
@@ -54,9 +54,9 @@ public class RepeatChangeAction extends EditorAction {
|
||||
}
|
||||
Command save = state.getCommand();
|
||||
state.setCommand(cmd);
|
||||
state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, KeyParser.MAPPING_NORMAL);
|
||||
char reg = CommandGroups.getInstance().getRegister().getCurrentRegister();
|
||||
CommandGroups.getInstance().getRegister().selectRegister(state.getLastChangeRegister());
|
||||
state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, MappingMode.NORMAL);
|
||||
char reg = VimPlugin.getRegister().getCurrentRegister();
|
||||
VimPlugin.getRegister().selectRegister(state.getLastChangeRegister());
|
||||
try {
|
||||
KeyHandler.executeAction(cmd.getAction(), context);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class RepeatChangeAction extends EditorAction {
|
||||
state.setCommand(save);
|
||||
}
|
||||
state.saveLastChangeCommand(cmd);
|
||||
CommandGroups.getInstance().getRegister().selectRegister(reg);
|
||||
VimPlugin.getRegister().selectRegister(reg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.ex.CommandParser;
|
||||
import com.maddyhome.idea.vim.ex.ExException;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ public class RepeatExCommandAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
|
||||
int count = command.getCount();
|
||||
try {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -22,7 +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.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import com.maddyhome.idea.vim.helper.UndoRedoHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class UndoAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return UndoRedoHelper.undo(context);
|
||||
}
|
||||
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.change.change;
|
||||
|
||||
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.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 VimCommandAction {
|
||||
public AutoIndentLinesVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
@NotNull Command cmd,
|
||||
@NotNull TextRange range) {
|
||||
VimPlugin.getChange().autoIndentLines(context);
|
||||
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 | Command.FLAG_FORCE_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,11 +21,12 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -35,9 +36,10 @@ public class ChangeCaseLowerMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeCaseMotion(editor, context, count, rawCount,
|
||||
CharacterHelper.CASE_LOWER, argument);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return argument != null &&
|
||||
VimPlugin.getChange().changeCaseMotion(editor, context, count, rawCount, CharacterHelper.CASE_LOWER,
|
||||
argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeCaseToggleCharacterAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeCaseToggleCharacter(editor, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeCaseToggleCharacter(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,11 +21,12 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -35,8 +36,8 @@ public class ChangeCaseToggleMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeCaseMotion(editor, context, count, rawCount,
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return argument != null && VimPlugin.getChange().changeCaseMotion(editor, context, count, rawCount,
|
||||
CharacterHelper.CASE_TOGGLE, argument);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().getChange().changeCaseRange(editor, range, CharacterHelper.CASE_TOGGLE);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,11 +21,12 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -35,8 +36,8 @@ public class ChangeCaseUpperMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeCaseMotion(editor, context, count, rawCount,
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return argument != null && VimPlugin.getChange().changeCaseMotion(editor, context, count, rawCount,
|
||||
CharacterHelper.CASE_UPPER, argument);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().getChange().changeCaseRange(editor, range, CharacterHelper.CASE_UPPER);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeCharacterAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeCharacter(editor, count, argument.getCharacter());
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return argument != null && VimPlugin.getChange().changeCharacter(editor, count, argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeCharactersAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeCharacters(editor, context, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeCharacters(editor, context, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeEndOfLineAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeEndOfLine(editor, context, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeEndOfLine(editor, context, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,12 +21,13 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.ex.LineRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -36,9 +37,9 @@ public class ChangeLastGlobalSearchReplaceAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
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 CommandGroups.getInstance().getSearch().searchAndReplace(editor, context, range, "s", "//~/&");
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, range, "s", "//~/&");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,11 +21,12 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.ex.LineRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -35,10 +36,10 @@ public class ChangeLastSearchReplaceAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
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 CommandGroups.getInstance().getSearch().searchAndReplace(editor, context, range, "s", "//~/");
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, range, "s", "//~/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeLineAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeLine(editor, context, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeLine(editor, context, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeMotion(editor, context, count, rawCount, argument);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return argument != null && VimPlugin.getChange().changeMotion(editor, context, count, rawCount, argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeNumberDecAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeNumber(editor, -count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeNumber(editor, -count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeNumberIncAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeNumber(editor, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeNumber(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ChangeReplaceAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().changeReplace(editor, context);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().changeReplace(editor, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().getChange().changeRange(editor, context, range, type);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
||||
return VimPlugin.getChange().changeRange(editor, context, lineRange, 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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,9 @@ 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.command.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -33,9 +33,9 @@ public class FilterCountLinesAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
CommandGroups.getInstance().getProcess().startFilterCommand(editor, context, cmd);
|
||||
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -22,11 +22,12 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.group.MotionGroup;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -36,10 +37,13 @@ public class FilterMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
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;
|
||||
}
|
||||
@@ -60,7 +64,7 @@ public class FilterMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
Command command = new Command(count, null, null, Command.Type.UNDEFINED, 0);
|
||||
CommandGroups.getInstance().getProcess().startFilterCommand(editor, context, command);
|
||||
VimPlugin.getProcess().startFilterCommand(editor, context, command);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
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 FilterVisualLinesAction extends EditorAction {
|
||||
public class FilterVisualLinesAction extends VimCommandAction {
|
||||
public FilterVisualLinesAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
super(new EditorActionHandlerBase() {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
CommandGroups.getInstance().getProcess().startFilterCommand(editor, context, cmd);
|
||||
CommandGroups.getInstance().getMotion().resetVisual(editor, true);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.change.change;
|
||||
|
||||
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.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 VimCommandAction {
|
||||
public ReformatCodeVisualAction() {
|
||||
super(new VisualOperatorActionHandler() {
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class DeleteCharacterAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().deleteCharacter(editor, 1, false);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().deleteCharacter(editor, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class DeleteCharacterLeftAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().deleteCharacter(editor, -count, false);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().deleteCharacter(editor, -count, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class DeleteCharacterRightAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().deleteCharacter(editor, count, false);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().deleteCharacter(editor, count, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class DeleteEndOfLineAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().deleteEndOfLine(editor, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().deleteEndOfLine(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,12 +35,12 @@ public class DeleteJoinLinesAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CommandGroups.getInstance().getChange().deleteJoinLines(editor, count, false);
|
||||
return VimPlugin.getChange().deleteJoinLines(editor, count, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,12 +35,12 @@ public class DeleteJoinLinesSpacesAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CommandGroups.getInstance().getChange().deleteJoinLines(editor, count, true);
|
||||
return VimPlugin.getChange().deleteJoinLines(editor, count, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class DeleteLineAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().deleteLine(editor, count);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getChange().deleteLine(editor, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class DeleteMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
return CommandGroups.getInstance().getChange().deleteMotion(editor, context, count, rawCount, argument, false);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return argument != null && VimPlugin.getChange().deleteMotion(editor, context, count, rawCount, argument, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class InsertAfterCursorAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().insertAfterCursor(editor, context);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertAfterCursor(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class InsertAfterLineEndAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().insertAfterLineEnd(editor, context);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertAfterLineEnd(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class InsertAtPreviousInsertAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().insertAtPreviousInsert(editor, context);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertAtPreviousInsert(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -20,24 +20,50 @@ package com.maddyhome.idea.vim.action.change.insert;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class InsertBeforeCursorAction extends EditorAction {
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class InsertBeforeCursorAction extends VimCommandAction {
|
||||
public InsertBeforeCursorAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().insertBeforeCursor(editor, context);
|
||||
|
||||
super(new ChangeEditorActionHandler() {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
|
||||
@Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertBeforeCursor(editor, context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("i", "<Insert>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.INSERT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return Command.FLAG_MULTIKEY_UNDO;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class InsertBeforeFirstNonBlankAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().insertBeforeFirstNonBlank(editor, context);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertBeforeFirstNonBlank(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,9 @@ 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.command.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -33,13 +33,13 @@ public class InsertCharacterAboveCursorAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CommandGroups.getInstance().getChange().insertCharacterAroundCursor(editor, context, -1);
|
||||
return VimPlugin.getChange().insertCharacterAroundCursor(editor, context, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,9 @@ 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.command.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -33,13 +33,13 @@ public class InsertCharacterBelowCursorAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CommandGroups.getInstance().getChange().insertCharacterAroundCursor(editor, context, 1);
|
||||
return VimPlugin.getChange().insertCharacterAroundCursor(editor, context, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,9 @@ 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.command.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -33,9 +33,9 @@ public class InsertDeleteInsertedTextAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return CommandGroups.getInstance().getChange().insertDeleteInsertedText(editor);
|
||||
return VimPlugin.getChange().insertDeleteInsertedText(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,9 @@ 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.command.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -33,9 +33,9 @@ public class InsertDeletePreviousWordAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return CommandGroups.getInstance().getChange().insertDeletePreviousWord(editor);
|
||||
return VimPlugin.getChange().insertDeletePreviousWord(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -23,7 +23,7 @@ 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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class InsertEnterAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().processEnter(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
VimPlugin.getChange().processEnter(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -18,24 +18,53 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action.change.insert;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
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.group.CommandGroups;
|
||||
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 InsertExitModeAction extends EditorAction {
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class InsertExitModeAction extends VimCommandAction {
|
||||
private static final String ACTION_ID = "VimInsertExitMode";
|
||||
|
||||
public InsertExitModeAction() {
|
||||
super(new Handler());
|
||||
super(new EditorActionHandlerBase() {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getChange().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.I;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("<C-[>", "<C-C>", "<Esc>", "<C-\\><C-N>");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.INSERT;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VimCommandAction getInstance() {
|
||||
return (VimCommandAction)ActionManager.getInstance().getAction(ACTION_ID);
|
||||
}
|
||||
}
|
||||
|
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 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.change.insert;
|
||||
|
||||
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.group.CommandGroups;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class InsertHelpAction extends EditorAction {
|
||||
public InsertHelpAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().insertHelp(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -23,7 +23,7 @@ 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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class InsertInsertAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().processInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
VimPlugin.getChange().processInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class InsertLineStartAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().insertLineStart(editor, context);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertLineStart(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,12 +35,12 @@ public class InsertNewLineAboveAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandGroups.getInstance().getChange().insertNewLineAbove(editor, context);
|
||||
VimPlugin.getChange().insertNewLineAbove(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,12 +35,12 @@ public class InsertNewLineBelowAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandGroups.getInstance().getChange().insertNewLineBelow(editor, context);
|
||||
VimPlugin.getChange().insertNewLineBelow(editor, context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -23,7 +23,7 @@ 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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class InsertPreviousInsertAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().insertPreviousInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context, false);
|
||||
VimPlugin.getChange().insertPreviousInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -23,7 +23,7 @@ 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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class InsertPreviousInsertExitAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().insertPreviousInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context, true);
|
||||
VimPlugin.getChange().insertPreviousInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,9 +21,10 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -33,9 +34,10 @@ public class InsertRegisterAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends AbstractEditorActionHandler {
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
return CommandGroups.getInstance().getChange().insertRegister(editor, context, cmd.getArgument().getCharacter());
|
||||
final Argument argument = cmd.getArgument();
|
||||
return argument != null && VimPlugin.getChange().insertRegister(editor, context, argument.getCharacter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -23,7 +23,7 @@ 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.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class InsertSingleCommandAction extends EditorAction {
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||
CommandGroups.getInstance().getChange().processSingleCommand(InjectedLanguageUtil.getTopLevelEditor(editor));
|
||||
VimPlugin.getChange().processSingleCommand(InjectedLanguageUtil.getTopLevelEditor(editor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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 CommandGroups.getInstance().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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,9 +35,8 @@ public class AutoIndentLinesAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().autoIndentLines(context);
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().autoIndentLines(context);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ShiftLeftLinesAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().indentLines(editor, context, count, -1);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().indentLines(editor, context, count, -1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,10 +35,14 @@ public class ShiftLeftMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
CommandGroups.getInstance().getChange().indentMotion(editor, context, count, rawCount, argument, -1);
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (argument != null) {
|
||||
VimPlugin.getChange().indentMotion(editor, context, count, rawCount, argument, -1);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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) {
|
||||
CommandGroups.getInstance().getChange().indentRange(editor, context, range, cmd.getCount(), -1);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class ShiftRightLinesAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
CommandGroups.getInstance().getChange().indentLines(editor, context, count, 1);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
VimPlugin.getChange().indentLines(editor, context, count, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,10 +35,14 @@ public class ShiftRightMotionAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||
CommandGroups.getInstance().getChange().indentMotion(editor, context, count, rawCount, argument, 1);
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (argument != null) {
|
||||
VimPlugin.getChange().indentMotion(editor, context, count, rawCount, argument, 1);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -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.group.CommandGroups;
|
||||
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) {
|
||||
CommandGroups.getInstance().getChange().indentRange(editor, context, range, cmd.getCount(), 1);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2013 The IdeaVim authors
|
||||
* 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
|
||||
@@ -21,10 +21,11 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.group.CommandGroups;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -34,8 +35,8 @@ public class PutTextAfterCursorAction extends EditorAction {
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) {
|
||||
return CommandGroups.getInstance().getCopy().putTextAfterCursor(editor, context, count, true, false);
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
return VimPlugin.getCopy().putTextAfterCursor(editor, context, count, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user