1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-17 16:31:45 +02:00

Compare commits

...

238 Commits
0.27 ... 0.33

Author SHA1 Message Date
Andrey Vlasovskikh
e9e5c77cd3 VIM-661 Apply Operator pending and Visual mode mappings only at command start 2014-04-28 17:23:45 +04:00
Andrey Vlasovskikh
4d4bcbb365 Updated CHANGES 2014-04-28 16:05:02 +04:00
Andrey Vlasovskikh
bd5a2976fd Bumped version to 0.33 2014-04-28 16:02:34 +04:00
Andrey Vlasovskikh
cc6488ee2d Added a hyperlink for setting the IDE as a shortcut handler in case of conflicts 2014-04-28 15:57:57 +04:00
Andrey Vlasovskikh
52068198a5 VIM-665 Allow <C-C> in Insert mode when completion pop-up is active 2014-04-28 15:27:04 +04:00
Andrey Vlasovskikh
5cdcd9d4d4 Set up the vertical scroll bar on More panel in order to handle keys correctly 2014-04-25 18:06:43 +04:00
Andrey Vlasovskikh
fbeaa35d10 Use original Up/Down actions for non file-based editors 2014-04-25 17:18:08 +04:00
Andrey Vlasovskikh
1ac4bb38be Updated CHANGES 2014-04-25 16:45:27 +04:00
Andrey Vlasovskikh
69c2a096ab Updated CHANGES 2014-04-24 18:14:10 +04:00
Andrey Vlasovskikh
3dccf1b215 Nullity and immutability 2014-04-24 18:09:53 +04:00
Andrey Vlasovskikh
035cb02362 Local class name conventions 2014-04-24 18:03:46 +04:00
Andrey Vlasovskikh
43d33a4502 Immutable local variables where possible 2014-04-24 18:01:59 +04:00
Andrey Vlasovskikh
2b6e8dc566 Fixed nullity warnings 2014-04-24 17:47:59 +04:00
Andrey Vlasovskikh
6388cc0639 Added Alex Selesse to the list of contributors 2014-04-24 17:45:06 +04:00
Andrey Vlasovskikh
00bd6d2e3a Added |:sort| to index 2014-04-24 17:39:43 +04:00
Andrey Vlasovskikh
1f842b6d31 New IdeaVim API compatibility 2014-04-24 17:38:37 +04:00
Andrey Vlasovskikh
954d7bd14c Merge remote-tracking branch 'selesse/vim-439'
Conflicts:
	src/com/maddyhome/idea/vim/ex/CommandParser.java
2014-04-24 17:35:10 +04:00
Andrey Vlasovskikh
d358893579 Vim shortcuts handler is enabled for keys associated with IDE if there are no shortcut conflicts 2014-04-24 16:54:35 +04:00
Andrey Vlasovskikh
3cb40cb09d VIM-661 Apply Normal mode mappings only at command start 2014-04-23 20:44:06 +04:00
Andrey Vlasovskikh
a4a8faedbb Removed unused method 2014-04-22 19:47:48 +04:00
Andrey Vlasovskikh
c32fa2b53f VIM-648 Use default keymap if there is no previous keymap in config
Keymap upgrade message has been improved.
2014-04-22 19:40:07 +04:00
Andrey Vlasovskikh
1d0b1791c4 VIM-651 Parse <BS> as backspace 2014-04-22 17:59:49 +04:00
Andrey Vlasovskikh
7251c8976d Removed obsolete Vim help action for <F1> 2014-04-22 17:22:46 +04:00
Andrey Vlasovskikh
684531aaae VIM-665 Handle Shift-char as typed uppercase keystroke, not as pressed one 2014-04-22 17:16:09 +04:00
Andrey Vlasovskikh
4a1504f9e0 VIM-660 Handle <C-Space> as pressed keystroke, not typed one 2014-04-22 16:50:46 +04:00
Andrey Vlasovskikh
ee1a6bbbd9 Updated copyright headers 2014-04-08 00:43:51 +04:00
Andrey Vlasovskikh
52c86d8c27 VIM-645 Handle '<Space>' in key mappings as a typed key, not as a pressed shortcut 2014-04-08 00:25:14 +04:00
Andrey Vlasovskikh
07e59536f3 Updated link names 2014-04-07 20:15:50 +04:00
Andrey Vlasovskikh
63f31b9b01 Links to issues and docs, removed menu changes 2014-04-07 20:12:22 +04:00
Andrey Vlasovskikh
4b6bf1bb9f Markup for badges 2014-04-07 20:01:29 +04:00
Andrey Vlasovskikh
f03c202b46 TeamCity badges for builds and tests 2014-04-07 19:59:28 +04:00
Andrey Vlasovskikh
eb8a4a0e6a Use guest link for TeamCity builds 2014-04-07 19:53:07 +04:00
Andrey Vlasovskikh
c04b04f701 Mentioned key mappings support in README and CHANGES 2014-04-07 19:42:04 +04:00
Andrey Vlasovskikh
2a0833e3b5 Don't try to interpret '<script>' and '<expr>' key mappings 2014-04-06 03:52:39 +04:00
Andrey Vlasovskikh
6acc89331d Ignore special arguments of 'map' 2014-04-06 03:45:36 +04:00
Andrey Vlasovskikh
35afd9b92f Show all '<Enter>' equivalents as '<CR>' 2014-04-06 03:45:17 +04:00
Andrey Vlasovskikh
c16d83ceab Handle '<nop>' in mappings 2014-04-05 00:25:54 +04:00
Andrey Vlasovskikh
a7820f4fd0 More special keys of Vim '<>' notation 2014-04-05 00:15:11 +04:00
Andrey Vlasovskikh
12dd338914 Fixed parsing lowercase characters in keystrokes with modifiers 2014-04-04 23:51:58 +04:00
Andrey Vlasovskikh
720d552a21 Renamed VimrcParser and VimrcCommandHandler to VimScript* 2014-04-04 22:22:25 +04:00
Andrey Vlasovskikh
a0477f499b Added new ':source' command handler 2014-04-04 22:21:22 +04:00
Andrey Vlasovskikh
20a4639995 Show error messages after Ex exceptions where possible 2014-04-04 22:20:18 +04:00
Andrey Vlasovskikh
3d7a0e7917 Modify and re-register shortcut set required by Vim emulation after ':map' 2014-04-04 21:09:29 +04:00
Andrey Vlasovskikh
c9c1295001 Cleanup 2014-04-04 17:49:45 +04:00
Andrey Vlasovskikh
c93daf78f6 Unify ':map' and ':noremap' handlers 2014-04-04 17:35:59 +04:00
Andrey Vlasovskikh
c77812d2a8 Refactored MapHandler to be more declarative 2014-04-04 17:31:16 +04:00
Andrey Vlasovskikh
c7107b7ad7 Reuse MappingInfo for rows of key mapping table 2014-04-04 16:54:41 +04:00
Andrey Vlasovskikh
a9a28b259f Made MappingInfo comparable 2014-04-04 16:48:15 +04:00
Andrey Vlasovskikh
5f1a1d0aa0 Show non-recursive mapping status in the output of 'map' 2014-04-04 16:46:40 +04:00
Andrey Vlasovskikh
2f5dd3f2b1 'map!' is not supported yet 2014-04-04 16:36:06 +04:00
Andrey Vlasovskikh
779909bdeb Added support for 'noremap' commands 2014-04-04 16:35:11 +04:00
Andrey Vlasovskikh
e76bee2afa Add 'recursive' flag to key mapping info 2014-04-04 16:30:41 +04:00
Andrey Vlasovskikh
bb9d551dad Extracted logic from MapHandler to KeyGroup 2014-04-04 16:21:56 +04:00
Andrey Vlasovskikh
db6399f1c5 Added test for recursive key mapping 2014-04-04 15:39:20 +04:00
Andrey Vlasovskikh
32ee6be7f9 Fixed displaying 'map' NVO mapping code 2014-04-04 00:29:52 +04:00
Andrey Vlasovskikh
33a5dd9e1c Allow commands that start with ':' in .vimrc 2014-04-04 00:21:05 +04:00
Andrey Vlasovskikh
0c59182eb8 Show modes code for mappings 2014-04-04 00:15:57 +04:00
Andrey Vlasovskikh
391e14a05b Output sorted map results 2014-04-04 00:09:52 +04:00
Andrey Vlasovskikh
c3259faf42 Don't read .vimrc during unit testing 2014-04-03 23:45:31 +04:00
Andrey Vlasovskikh
f588e473a1 Use unit test friendly ExOutputModel instead of ExOutputPanel 2014-04-03 23:19:14 +04:00
Andrey Vlasovskikh
a076b4d71c Renamed MorePanel to ExOutputPanel 2014-04-03 22:58:45 +04:00
Andrey Vlasovskikh
4540c75498 Made MorePanel.activate() private 2014-04-03 22:52:42 +04:00
Andrey Vlasovskikh
239199462f Removed unnecessary MorePanel.isActive() check 2014-04-03 22:52:00 +04:00
Andrey Vlasovskikh
b703a7eabb Show MorePanel on every MorePanel.setText() instead of showing it explicitly after Ex commands 2014-04-03 22:49:54 +04:00
Andrey Vlasovskikh
3cafe72f8f Removed unused code 2014-04-03 22:29:57 +04:00
Andrey Vlasovskikh
48375c37de Removed unnecessary logging 2014-04-03 19:05:19 +04:00
Andrey Vlasovskikh
f9ceb506d7 Don't store editor's content component 2014-04-03 19:03:47 +04:00
Andrey Vlasovskikh
a7a054f4e4 Use EditorHelper.getScreenWidth() instead of MorePanel.getDisplayWidth() 2014-04-03 18:57:43 +04:00
Andrey Vlasovskikh
f8781353a2 Made MorePanel per-editor based 2014-04-03 17:41:22 +04:00
Andrey Vlasovskikh
b0760222f0 Cleanup 2014-04-03 17:12:09 +04:00
Andrey Vlasovskikh
66bcacc2c4 Show mappings in Ex output panel 2014-04-02 17:40:22 +04:00
Andrey Vlasovskikh
5868f8a2a5 Renamed pad() to rightJustify() 2014-04-02 13:41:06 +04:00
Andrey Vlasovskikh
8e54e24e03 Show not implemented message for show mappings command instead of an exception 2014-04-02 13:28:29 +04:00
Andrey Vlasovskikh
f511e6ea34 Set default editor font for Ex and More panels on every activation 2014-04-02 13:17:17 +04:00
Andrey Vlasovskikh
6c9608a9ee Prettier border for Ex entry panel 2014-04-02 13:07:20 +04:00
Andrey Vlasovskikh
4a0f95f0f0 Removed aliases 2014-04-02 12:55:01 +04:00
Andrey Vlasovskikh
e3e7bcffa0 Added more mapping commands for various modes 2014-04-02 12:54:15 +04:00
Andrey Vlasovskikh
9340208c2c Handle unknown special keys as simple key sequences 2014-04-02 02:12:08 +04:00
Andrey Vlasovskikh
a658b8d8bd Handle unfinished special keys as simple key sequences 2014-04-02 02:05:57 +04:00
Andrey Vlasovskikh
0b9946eaf9 Handle '\' at the end of the mapping as regular '\' 2014-04-02 01:55:35 +04:00
Andrey Vlasovskikh
6ea255f125 Reset key mappings for each test 2014-04-02 01:54:26 +04:00
Andrey Vlasovskikh
0225975e20 Backslash is an escape character only for '\' and '<' 2014-04-02 01:43:20 +04:00
Andrey Vlasovskikh
af406c7d14 Execute key mapping commands from .vimrc 2014-04-02 00:40:46 +04:00
Andrey Vlasovskikh
a146e2c303 Prevented sharing DataContext between Swing events 2014-04-02 00:40:02 +04:00
Andrey Vlasovskikh
f285051a9a Merge remote-tracking branch 'origin/map-commands' into map-commands 2014-04-02 00:29:20 +04:00
Andrey Vlasovskikh
936f7e5d7c Modularized .vimrc parsing a bit 2014-04-02 00:23:35 +04:00
Andrey Vlasovskikh
463c8defa4 Added 'timeoutlen' option 2014-04-01 17:15:50 +04:00
Andrey Vlasovskikh
19f0399f28 Added 'imap' to mapping commands table
It's now possible to try ':imap jj <Esc>' at runtime. Reading mappings
from .vimrc is not supported yet.
2014-04-01 00:42:43 +04:00
Andrey Vlasovskikh
05436427ee Very initial key mapping support 2014-04-01 00:20:13 +04:00
Andrey Vlasovskikh
2f6d4c9ff2 Spelling and naming conventions 2014-03-31 22:50:46 +04:00
Andrey Vlasovskikh
64790c531e Removed unused logging and debug info 2014-03-31 22:44:07 +04:00
Andrey Vlasovskikh
9c209d2fb2 Sorted methods and attributes 2014-03-31 22:42:25 +04:00
Andrey Vlasovskikh
8420ca355b Nullity annotations 2014-03-31 15:44:15 +04:00
Andrey Vlasovskikh
0aebcbd71e Nullity annotations for CommandHandler.execute() 2014-03-31 15:27:40 +04:00
Andrey Vlasovskikh
13528667c8 Moved command index to the root of the package 2014-03-31 14:27:02 +04:00
Andrey Vlasovskikh
3b3fa3a455 Split configureByText() and typeText() 2014-03-28 16:38:41 +04:00
Andrey Vlasovskikh
13d3d4e990 Unified running Ex commands in tests with the usual key handling 2014-03-28 16:30:06 +04:00
Andrey Vlasovskikh
b69d475e15 Removed legacy CDATA-based XML serializer 2014-03-26 18:48:08 +04:00
Andrey Vlasovskikh
b6f840aacb Use StringBuilder instead of StringBuffer 2014-03-26 18:45:56 +04:00
Andrey Vlasovskikh
ea454d3c07 Use parseKeys() instead of stringToKeys() in tests 2014-03-26 18:44:57 +04:00
Andrey Vlasovskikh
fb72d5d782 Parse <C-x> and some special keys 2014-03-26 18:44:33 +04:00
Andrey Vlasovskikh
d4b8c09b02 Fixed broken <Enter> in inplace editors, e.g. refactorings and live templates 2014-03-26 16:48:29 +04:00
Andrey Vlasovskikh
254339037b Merged KeyParser into KeyGroup 2014-03-26 14:36:04 +04:00
Andrey Vlasovskikh
800e3a3012 Moved shortcut conflicts state to new KeyGroup 2014-03-26 14:16:34 +04:00
Andrey Vlasovskikh
44a5021786 Updated changelist 2014-03-26 13:33:25 +04:00
Andrey Vlasovskikh
db80629cbb Add build number string to plugin description 2014-03-26 13:20:46 +04:00
Andrey Vlasovskikh
1c3a1c132b Don't include logo into plugin.xml 2014-03-26 13:17:10 +04:00
Andrey Vlasovskikh
751831f3b7 Include build number in archive name 2014-03-26 13:14:32 +04:00
Andrey Vlasovskikh
d226d58e38 Changed build number for developer builds to 'dev' 2014-03-26 13:14:11 +04:00
Andrey Vlasovskikh
230364ac87 Removed unused code 2014-03-26 01:49:01 +04:00
Andrey Vlasovskikh
9df61bba7e Mentioned the active keymap in the shortcut conflicts title 2014-03-26 01:43:48 +04:00
Andrey Vlasovskikh
9ee1910a01 Set up Vim handler by default and show notifications on the first use 2014-03-26 01:18:35 +04:00
Andrey Vlasovskikh
46e10e1599 Changed table column sizes 2014-03-26 01:17:52 +04:00
Andrey Vlasovskikh
ed29f7c1db Don't use sticky balloons 2014-03-26 00:57:38 +04:00
Andrey Vlasovskikh
60f4c7b02e Configurable shortcut conflicts in Vim Emulation settings 2014-03-25 22:58:36 +04:00
Andrey Vlasovskikh
5616723fa4 Read-only table of shortcut conflicts 2014-03-25 20:06:05 +04:00
Andrey Vlasovskikh
724698df08 Moved getKeymapConflicts() to KeyParser 2014-03-25 19:58:01 +04:00
Andrey Vlasovskikh
9bdb99d948 Initial Vim Emulation configurable with empty Shortcut Conflicts table 2014-03-25 18:16:37 +04:00
Andrey Vlasovskikh
efc340a37a Reordered methods 2014-03-23 19:52:00 +04:00
Andrey Vlasovskikh
58548a39d3 Removed obsolete TODO item 2014-03-23 19:49:31 +04:00
Andrey Vlasovskikh
638a205b6c Fixed loading of saved shortcut conflicts settings 2014-03-23 19:49:01 +04:00
Andrey Vlasovskikh
3031dbc600 Detect shortcut conflicts between Vim emulation and IDE keymap 2014-03-23 19:48:20 +04:00
Andrey Vlasovskikh
36dcb53e14 Cleanup 2014-03-23 15:35:16 +04:00
Andrey Vlasovskikh
1a94f4f12f Deprecated old action registration 2014-03-22 16:32:45 +04:00
Andrey Vlasovskikh
d87a241e34 Typo 2014-03-22 16:05:30 +04:00
Andrey Vlasovskikh
ddd28c9a44 Cleanup and minor refactorings 2014-03-22 15:49:50 +04:00
Andrey Vlasovskikh
9637edf30e Some docs 2014-03-22 15:44:24 +04:00
Andrey Vlasovskikh
b0a5e6d375 Don't reserve any shortcuts before implementing actual actions that use them 2014-03-22 15:33:33 +04:00
Andrey Vlasovskikh
6bec99b631 Moved and renamed KeyAction to VimShortcutKeyAction 2014-03-22 15:32:12 +04:00
Andrey Vlasovskikh
a95b65067d Switched from EditorActionHandler substitution to registering custom shortcut sets for Vim-enabled editors 2014-03-22 15:29:04 +04:00
Andrey Vlasovskikh
ac5c176deb Nullity annotations for ChangeEditorActionHandler 2014-03-20 23:30:46 +04:00
Andrey Vlasovskikh
5d385eb26d Added parseKeysSet() helper 2014-03-20 22:43:29 +04:00
Andrey Vlasovskikh
611620555f Initial version of shortcut conflicts settings 2014-03-20 19:38:38 +04:00
Andrey Vlasovskikh
d44412c712 Don't require a custom "Vim" keymap any longer
Keyboard shortcut conflicts aren't handled yet.
2014-03-20 18:18:43 +04:00
Andrey Vlasovskikh
761719fffd Made VisualToggleCharacterModeAction a VimCommandAction 2014-03-20 16:46:53 +04:00
Andrey Vlasovskikh
3015a4a8a2 Initial version of Vim notation typed characters parsing 2014-03-20 15:58:04 +04:00
Andrey Vlasovskikh
e8f579bf74 Added Vim actions index with Javadoc links 2014-03-20 14:39:42 +04:00
Andrey Vlasovskikh
f8da48f61d Added VimCommandAction base class for simplifying action registration 2014-03-20 14:17:14 +04:00
Andrey Vlasovskikh
5b21015f5b Inlined action handler 2014-03-20 13:27:34 +04:00
Andrey Vlasovskikh
326d62d815 Renamed Mapping to MappingMode 2014-03-20 13:24:03 +04:00
Andrey Vlasovskikh
f5f6c92e59 Removed unused class 2014-03-19 19:56:57 +04:00
Andrey Vlasovskikh
b56654c217 Removed unused actionId field 2014-03-19 19:37:02 +04:00
Andrey Vlasovskikh
f5e8572a73 Replaced mapping int codes with Mapping enum 2014-03-19 19:34:32 +04:00
Andrey Vlasovskikh
95a395ed70 Moved Vim operation groups accessors to VimPlugin
VimPlugin now acts as a facade to Vim operations.
2014-03-19 18:29:42 +04:00
Andrey Vlasovskikh
c08c122ea6 Reordered methods 2014-03-19 17:55:25 +04:00
Andrey Vlasovskikh
95460df473 Reformat 2014-03-19 17:37:29 +04:00
Andrey Vlasovskikh
ab489faa56 Some overrides and deprecations 2014-03-19 17:35:39 +04:00
Andrey Vlasovskikh
48e49fe92d Renamed AbstractEditorActionHandler to EditorActionHandlerBase 2014-03-19 16:46:48 +04:00
Andrey Vlasovskikh
441a296bde No abstract classes for no reason 2014-03-19 16:42:23 +04:00
Andrey Vlasovskikh
7359ed74ad Moved some actions to com.maddyhome.vim.action package 2014-03-19 16:35:22 +04:00
Andrey Vlasovskikh
dd56ec6b4c Removed unused MakeTags CLI utility 2014-03-19 16:33:44 +04:00
Andrey Vlasovskikh
2d271008f3 Flattened com.intellij.idea.vim.handler.* package 2014-03-19 16:32:38 +04:00
Andrey Vlasovskikh
d06340ac3c Inlined ResetModeHandler 2014-03-19 16:30:41 +04:00
Andrey Vlasovskikh
f9a67c5180 Removed unused classes 2014-03-19 16:29:35 +04:00
Andrey Vlasovskikh
b4cce0980a Removed practically unused ActionGroup and AbstractActionGroup interfaces 2014-03-19 16:26:12 +04:00
Andrey Vlasovskikh
4a7557c5ba Don't reset visual mode after some IntelliJ actions that operate on selections
These actions are: comment by block/line comment, surround with /
surround with template, move statement up/down.

The reason is simplification of action handling as a step towards
keymap-less IdeaVim configuration.
2014-03-19 14:55:08 +04:00
Andrey Vlasovskikh
4e84f056aa Renamed KeyParser.registerAction() to KeyParser.registerIdeaAction() 2014-03-17 16:17:38 +04:00
Andrey Vlasovskikh
68f938d476 Don't override completion and live templates actions
This requires reconfiguring the Vim keymap.
2014-03-17 14:06:02 +04:00
Alex Selesse
6a7135d2bc VIM-439: Implement :sort command.
- Supports "n", "i" and "!" arguments.
2014-02-06 08:43:55 -05:00
Andrey Vlasovskikh
58ab3ab1bb Added Ira Klotzko to the contributors list 2013-12-06 17:09:41 +04:00
ik
78beef71ce Merge remote-tracking branch 'upstream/master' 2013-12-04 13:41:41 -05:00
ik
b05892e97d VIM-528
Change annotations to reflect that pp (CharPointer) is Nullable
Create check that if pp (CharPointer) is Nullable, code that could result in an NPE (NullPointerException) is not executed
Update the added tests' comments to reflect that they are for VIM-528
2013-12-02 10:42:27 -05:00
ik
f71e24d17e VIM-528 and VIM-459
These 2 cases (duplicates) are fixed with this commit
Additionally, there are a couple of new test cases for search groups and substitutions.
2013-11-18 14:33:06 -05:00
Andrey Vlasovskikh
3968e7741f Added 'Where to start' for contributors 2013-11-18 20:42:41 +04:00
Andrey Vlasovskikh
aa75245d79 Note about Android Studio 2013-11-15 17:06:13 +04:00
Andrey Vlasovskikh
e8c97ba6bf Bumped version 2013-11-15 17:05:45 +04:00
Andrey Vlasovskikh
27bbae3ccd Minor changes to README 2013-11-15 16:59:00 +04:00
Andrey Vlasovskikh
305c03458a Note about Android Studio 2013-11-15 16:57:43 +04:00
Andrey Vlasovskikh
8143114a86 Revert "Fixed usages of deprecated platform API methods"
This reverts commit d3d63395b3.
2013-11-15 16:36:56 +04:00
Andrey Vlasovskikh
a39a56cd39 Dropped JComboBox generics 2013-11-15 16:16:36 +04:00
Andrey Vlasovskikh
c1c076830a Merge remote-tracking branch 'origin/master'
Conflicts:
	build.properties
2013-11-15 16:11:53 +04:00
Andrey Vlasovskikh
d3d63395b3 Fixed usages of deprecated platform API methods 2013-11-15 16:09:57 +04:00
Andrey Vlasovskikh
5a9a53d235 Use moved ListCellRendererWrapper for compatibility with IntelliJ builds
132.1052+
2013-11-15 16:03:17 +04:00
Andrey Vlasovskikh
b7e37aeb20 Release notes 2013-11-12 04:18:53 +04:00
Andrey Vlasovskikh
a86ef05d52 Revert "Remove editor selection after undo"
This reverts commit 13fc780287.
2013-11-12 04:14:05 +04:00
Andrey Vlasovskikh
1be2d9affc VIM-582 Fixed line comment and reformat commands with no visual selection 2013-11-12 04:12:20 +04:00
Andrey Vlasovskikh
43e9469546 Bumped version 2013-11-11 15:36:03 +04:00
Andrey Vlasovskikh
23bb0679dd New URL for the plugin page 2013-11-08 18:18:38 +04:00
Andrey Vlasovskikh
04c41414da More release notes 2013-11-08 18:17:11 +04:00
Andrey Vlasovskikh
3490d83ce6 Draft of release notes for 0.30 2013-11-08 18:11:15 +04:00
Andrey Vlasovskikh
13fc780287 Remove editor selection after undo 2013-11-08 17:56:58 +04:00
Andrey Vlasovskikh
f0c234a5de Nullability annotations for 'cmd' parameter of execute() methods 2013-11-08 17:44:19 +04:00
Andrey Vlasovskikh
7f8050e645 Removed unused argument 2013-11-08 17:31:48 +04:00
Andrey Vlasovskikh
e8b27724c9 Nullability annotations for execute() methods of action handlers 2013-11-08 17:07:13 +04:00
Andrey Vlasovskikh
327cd2c524 EA-43519 Fixed IOOBE: EditorImpl.offsetToLogicalLine 2013-11-08 15:52:22 +04:00
Andrey Vlasovskikh
1366e859be Removed a note about <Esc> in completion windows 2013-11-07 20:43:35 +04:00
Andrey Vlasovskikh
17b779b494 Launch Vim action handler for <Esc> in completion windows (VIM-193) 2013-11-07 20:33:59 +04:00
Andrey Vlasovskikh
7e30b7c7a7 Merge branch 'warning-removal' 2013-09-17 00:18:34 +04:00
Andrey Vlasovskikh
b1b8c49c43 Removed unnecessary generate actions override 2013-08-31 16:14:21 +04:00
Andrey Vlasovskikh
876c35c212 Removed old unused undo classes 2013-08-30 16:48:24 +04:00
Andrey Vlasovskikh
e758e3d457 Removed unused VimSettings 2013-08-30 16:45:42 +04:00
Andrey Vlasovskikh
91e7bfce1d Fixed setting command count 2013-08-30 16:39:56 +04:00
Andrey Vlasovskikh
2e6c53fb52 Typos 2013-08-30 16:04:34 +04:00
Andrey Vlasovskikh
510edeb9a6 Reformat code 2013-08-30 16:03:11 +04:00
Andrey Vlasovskikh
8566e7bf46 Fixed potential NPE 2013-08-30 15:57:38 +04:00
Andrey Vlasovskikh
7dfea2feb6 Removed unused parameter 2013-08-30 15:52:13 +04:00
Andrey Vlasovskikh
fcb9de1930 @Nullable 2013-08-30 15:51:51 +04:00
Andrey Vlasovskikh
2c7a3b877c Argument is always true 2013-08-30 15:47:37 +04:00
Andrey Vlasovskikh
e4ae7f8566 Removed unnecessary logger 2013-08-30 15:45:46 +04:00
Andrey Vlasovskikh
94f8544dfa Removed unnecessary Ascii class 2013-08-30 15:42:08 +04:00
Andrey Vlasovskikh
0159155e1c Removed unused ErrorHandler class 2013-08-30 15:41:21 +04:00
Andrey Vlasovskikh
b45e32dd3f Cleanup 2013-08-12 19:40:44 +04:00
Andrey Vlasovskikh
f3d66b3356 VIM-551 Argument of ':put' is optional 2013-08-12 19:39:59 +04:00
Andrey Vlasovskikh
f21190cb24 VIM-550 ':put' creates a new line 2013-08-12 19:38:33 +04:00
Andrey Vlasovskikh
9554eb0990 Extracted VimTestCase.typeText() 2013-08-12 18:40:51 +04:00
Andrey Vlasovskikh
9c04525df8 Extracted VimTestCase.runExCommand() 2013-08-12 18:26:52 +04:00
Andrey Vlasovskikh
26555c6ad6 VIM-425 Read config from .ideavimrc if available 2013-08-12 17:56:32 +04:00
Andrey Vlasovskikh
d6ee29dc91 Refactored Options.loadVimrc() 2013-08-12 17:54:26 +04:00
Andrey Vlasovskikh
e6dacd0b84 Cleanup 2013-08-12 17:38:11 +04:00
Andrey Vlasovskikh
acf75ad080 Cleanup 2013-08-12 17:01:38 +04:00
Andrey Vlasovskikh
92067b2577 VIM-440 Fixed ':e' open file dialog 2013-08-12 16:59:43 +04:00
Andrey Vlasovskikh
24f197ce99 Use SwingUtilities.invokeLater() for consistency 2013-08-12 16:52:33 +04:00
Andrey Vlasovskikh
39cc7db50b Typos 2013-08-09 00:47:05 +04:00
Andrey Vlasovskikh
510a6d12a7 Replace StringBuffer with concatenation 2013-08-09 00:44:25 +04:00
Andrey Vlasovskikh
cb8c1ea4b5 Fixed possible NPE 2013-08-09 00:43:27 +04:00
Andrey Vlasovskikh
3284102dde Specify size in toArray() 2013-08-09 00:40:50 +04:00
Andrey Vlasovskikh
4a5457ad49 Removed unused method 2013-08-09 00:40:21 +04:00
Andrey Vlasovskikh
39ed9265d7 Converted a RegisterActions class instance into a function 2013-08-09 00:30:52 +04:00
Andrey Vlasovskikh
2fc721f220 Typo 2013-08-09 00:19:20 +04:00
Andrey Vlasovskikh
28c658810f Split RegisterActions constructor into several methods 2013-08-09 00:18:08 +04:00
Andrey Vlasovskikh
2f2ecc252e Updated copyright years in sources 2013-08-09 00:06:38 +04:00
Andrey Vlasovskikh
9f2613c56a Moved RegisterActions to the root IdeaVim package
This class is an entry point to nearly all Vim actions, so it should be
easier to discover.
2013-08-08 23:47:00 +04:00
Andrey Vlasovskikh
a58929d4fb Added forgotten release date for 0.29 2013-08-08 21:12:41 +04:00
Andrey Vlasovskikh
fa13be1e15 Updated link to build server 2013-08-08 21:11:20 +04:00
Andrey Vlasovskikh
7a4d900b06 VIM-98 Invoke actions in separate commands for better Undo/Redo
Vim actions used to be invoked inside a key typing command and didn't
have their own commands. Now they've got separate commands with unique
group IDs in order to stop them from being merged into combined
Undo/Redo steps.

The Undo/Redo behaviour still differs from Vim: typing in a single
Insert mode session is split into several Undo chunks depending on
timing. An Undo step may require one more Undo step for moving the
cursor to its position before Undo.
2013-08-08 20:56:28 +04:00
Andrey Vlasovskikh
421ce832dd Updated changelog 2013-05-15 19:18:13 +04:00
Andrey Vlasovskikh
987781f826 VIM-121 Don't move cursor while scrolling 2013-05-15 18:57:46 +04:00
Andrey Vlasovskikh
d85a41ea98 VIM-91 Enable normal <Enter> handling for one-line editors 2013-05-15 17:15:04 +04:00
Andrey Vlasovskikh
42f86a3f73 VIM-482 Added repeat buffer limits 2013-05-15 16:46:09 +04:00
Andrey Vlasovskikh
0241b58777 Updated change notes 2013-04-06 22:29:58 +04:00
Andrey Vlasovskikh
97a2c73efe Updated changelog 2013-04-06 22:19:50 +04:00
Andrey Vlasovskikh
5f1e46ca82 Merge branch 'vim-479' 2013-04-06 21:59:50 +04:00
Andrey Vlasovskikh
805779144e Fixed copying second keystrokes in Reconfigure Vim keymap 2013-04-06 21:50:12 +04:00
Andrey Vlasovskikh
c65e21708c VIM-478 Fixed bug in reconfiguring Vim keymap based on user-defined keymaps 2013-04-06 21:21:22 +04:00
Andrey Vlasovskikh
08e546b677 Fixed NPE in VimKeyMapUtil.installKeyBoardBindings 2013-04-06 19:57:27 +04:00
Andrey Vlasovskikh
11cf8454ad VIM-479 Don't try to put read-only editors into insert mode 2013-04-06 19:53:57 +04:00
Andrey Vlasovskikh
c3494803dc Removed unused code 2013-04-06 18:39:56 +04:00
Andrey Vlasovskikh
c84496b942 Suggest reconfiguring keymap during update only for Macs 2013-04-06 18:12:15 +04:00
470 changed files with 10540 additions and 11799 deletions

View File

@@ -22,6 +22,8 @@ Contributors:
* [poxu](mailto:poxvuibr@gmail.com) * [poxu](mailto:poxvuibr@gmail.com)
* [Alexander Zolotov](mailto:alexander.zolotov@jetbrains.com) * [Alexander Zolotov](mailto:alexander.zolotov@jetbrains.com)
* [John Lindquist](mailto:johnlindquist@gmail.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 If you are a contributor and your name is not listed here, feel free to
contact the maintainer. contact the maintainer.

View File

@@ -4,6 +4,86 @@ The Changelog
History of changes in IdeaVim for the IntelliJ platform. History of changes in IdeaVim for the IntelliJ platform.
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
----------------
Fixed API compatibility with IntelliJ platform builds 132.1052+.
0.31, 2013-11-12
----------------
A bugfix release.
Bug fixes:
* VIM-582 Fixed line comment and reformat commands with no visual selection
0.30, 2013-11-11
----------------
Added support for a separate `.ideavimrc` config file. Fixed long-standing
issues with merged undo/redo commands and `<Esc>` during code completion.
Various bug fixes.
Features:
* VIM-425 Read config from .ideavimrc if available
Bug fixes:
* VIM-98 Invoke actions in separate commands for better undo/redo
* VIM-193 Launch Vim action handler for `<Esc>` in completion windows
* VIM-440 Fixed `:e` open file dialog
* VIM-550 `:put` creates a new line
* VIM-551 Argument of `:put` is optional
* Fixed several reported exceptions
0.29, 2013-05-15
----------------
A bugfix release.
Bug fixes:
* VIM-482 Fixed repeat buffer limits
* VIM-91 Enable normal `<Enter>` handling for one-line editors
* VIM-121 Don't move cursor while scrolling
0.28, 2013-04-06
----------------
A bugfix release.
Bug fixes:
* VIM-478 Fixed reconfigure Vim keymap for user-defined base keymaps
* VIM-479 Don't try to activate insert mode for diff view
0.27, 2013-04-03 0.27, 2013-04-03
---------------- ----------------

118
README.md
View File

@@ -1,16 +1,30 @@
IdeaVim 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 is a Vim emulation plug-in for IDEs based on the IntelliJ platform.
IdeaVim can be used with IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm IdeaVim can be used with IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm,
and AppCode. AppCode and Android Studio.
Resources: Resources:
* [Plugin homepage](http://plugins.intellij.net/plugin/?id=164) * [Plugin homepage](http://plugins.jetbrains.com/plugin/164)
* [Changelog](https://github.com/JetBrains/ideavim/blob/master/CHANGES.md) * [Changelog](https://github.com/JetBrains/ideavim/blob/master/CHANGES.md)
* [Bug tracker](http://youtrack.jetbrains.com/issues/VIM) * [Bug tracker](http://youtrack.jetbrains.com/issues/VIM)
* [Continuous integration builds](http://teamcity.jetbrains.com/project.html?projectId=project55) * [Continuous integration builds](http://teamcity.jetbrains.com/project.html?projectId=IdeaVim&guest=1)
* [@IdeaVim](http://twitter.com/ideavim) in Twitter * [@IdeaVim](http://twitter.com/ideavim) in Twitter
@@ -18,10 +32,10 @@ Installation
------------ ------------
Use the IDE's plugin manager to install the latest version of the plugin. Use the IDE's plugin manager to install the latest version of the plugin.
Start the IDE normally and enable the Vim emulation using "Tools | VIM Start the IDE normally and enable the Vim emulation using "Tools | Vim
Emulator" menu item. At this point you must use Vim keystrokes in all editors. Emulator" menu item. At this point you must use Vim keystrokes in all editors.
If you wish to disable the plugin, select the "Tools | VIM Emulator" menu so 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 it is unchecked. At this point IDE will work with it's regular keyboard
shortcuts. shortcuts.
@@ -32,7 +46,7 @@ Summary of Supported Vim Features
Supported: Supported:
* Motion keys * Motion keys
* Deletion/Changing * Deletion/changing
* Insert mode commands * Insert mode commands
* Marks * Marks
* Registers * Registers
@@ -41,6 +55,7 @@ Supported:
* Some Ex commands * Some Ex commands
* Some [:set options](https://github.com/JetBrains/ideavim/blob/master/doc/set-commands.md) * Some [:set options](https://github.com/JetBrains/ideavim/blob/master/doc/set-commands.md)
* Full Vim regexps for search and search/replace * Full Vim regexps for search and search/replace
* Key mappings
* Macros * Macros
* Digraphs * Digraphs
* Command line and search history * Command line and search history
@@ -48,13 +63,15 @@ Supported:
Not supported (yet): Not supported (yet):
* Key mappings
* Various less used commands
* Jump lists
* Window commands * Window commands
* Jump lists
* Various less used commands
Please see the file [index.txt](https://github.com/JetBrains/ideavim/blob/master/index.txt) See also:
for a list of commands covered with tests.
* [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)
Changes to the IDE Changes to the IDE
@@ -66,77 +83,40 @@ 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 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. Vim. Vim compatibility of undo/redo may be improved in the future releases.
### Escape See also [unresolved undo issues](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+u).
In the IDE, the `<Esc>` key is used during editing to cancel code completion ### Escape
windows, dialog windows, and parameter tooltips. While in the Vim insert mode,
`<Esc>` is used to return back to the normal mode. If you are typing in the
insert mode and a code completion window is popped up, pressing `<Esc>` cancel
the window without exiting the insert mode.
Using `<Esc>` in dialog windows remains problematic. For most dialog windows Using `<Esc>` in dialog windows remains problematic. For most dialog windows
the Vim emulator is put into the insert mode without the possibility to switch to the Vim emulator is put into the insert mode without the possibility to switch to
the normal mode. In some dialog windows the normal mode is on by default. The 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. usage of the Vim emulator in dialog windows is an area for improvements.
### Menu Changes See also [unresolved escape issues](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+i_Esc).
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>
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 ### Development Environment
1. Fork IdeaVim on GitHub and clone the repository on your local machine. 1. Fork IdeaVim on GitHub and clone the repository on your local machine.
2. Open the project in IntelliJ IDEA 11+ (Community or Ultimate) using "File | 2. Open the project in IntelliJ IDEA 12+ (Community or Ultimate) using "File |
Open... | /path/to/ideavim". Open... | /path/to/ideavim".
3. Set up a JDK if you haven't got it yet. Use "File | Project Structure | SDKs 3. Set up a JDK if you haven't got it yet. Use "File | Project Structure | SDKs

View File

@@ -1,4 +1,4 @@
version-id:0.27 version-id:0.33
platform-version:110.0 platform-version:120.0
idea.download.url=http://download.jetbrains.com/idea/ideaIU-12.0.zip idea.download.url=http://download.jetbrains.com/idea/ideaIU-13.zip
build.number=x build.number=dev

View File

@@ -23,7 +23,6 @@
<property name="src" value="${basedir}/src"/> <property name="src" value="${basedir}/src"/>
<property name="resources" value="${basedir}/resources"/> <property name="resources" value="${basedir}/resources"/>
<property name="test" value="${basedir}/test"/> <property name="test" value="${basedir}/test"/>
<property name="keymap" value="${basedir}/resources/Vim.xml"/>
<property name="idea.home" value="${idea}/unzip"/> <property name="idea.home" value="${idea}/unzip"/>
<property environment="env"/> <property environment="env"/>
<property name="tools.jar" value="${env.JAVA_HOME}/lib/tools.jar"/> <property name="tools.jar" value="${env.JAVA_HOME}/lib/tools.jar"/>
@@ -80,6 +79,7 @@
<filterset> <filterset>
<filter token="VERSION" value="${version}"/> <filter token="VERSION" value="${version}"/>
<filter token="SINCE-VERSION" value="${platform-version}"/> <filter token="SINCE-VERSION" value="${platform-version}"/>
<filter token="BUILD-NUMBER" value="${build.number}"/>
</filterset> </filterset>
</copy> </copy>
<copy todir="${classes}"> <copy todir="${classes}">
@@ -117,13 +117,12 @@
<delete dir="${build}/IdeaVim"/> <delete dir="${build}/IdeaVim"/>
<mkdir dir="${build}/IdeaVim"/> <mkdir dir="${build}/IdeaVim"/>
<copy file="${basedir}/LICENSE.txt" tofile="${build}/IdeaVim/LICENSE"/> <copy file="${basedir}/LICENSE.txt" tofile="${build}/IdeaVim/LICENSE"/>
<copy file="${keymap}" todir="${build}/IdeaVim"/>
<copy todir="${build}/IdeaVim/lib"> <copy todir="${build}/IdeaVim/lib">
<fileset dir="${build}" includes="*.jar"/> <fileset dir="${build}" includes="*.jar"/>
</copy> </copy>
<copy file="${basedir}/README.md" tofile="${build}/IdeaVim/README"/> <copy file="${basedir}/README.md" tofile="${build}/IdeaVim/README"/>
<copy file="${basedir}/CHANGES.md" tofile="${build}/IdeaVim/CHANGES"/> <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> </target>
<!-- Packs all the sources --> <!-- Packs all the sources -->
@@ -156,7 +155,6 @@
<fileset dir="${resources}"/> <fileset dir="${resources}"/>
</copy> </copy>
<mkdir dir="${out}/IdeaVim"/> <mkdir dir="${out}/IdeaVim"/>
<copy file="${keymap}" todir="${build}/IdeaVim"/>
</target> </target>
<target name="test" depends="unzip, clean, prepare-tests"> <target name="test" depends="unzip, clean, prepare-tests">

View File

@@ -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 'sidescroll' 'ss' minimum number of columns to scroll horizontal
'sidescrolloff' 'siso' min. nr. of columns to left and right of cursor 'sidescrolloff' 'siso' min. nr. of columns to left and right of cursor
'smartcase' 'scs' no ignore case when pattern has uppercase '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 'undolevels' 'ul' maximum number of changes that can be undone
'visualbell' 'vb' use visual bell instead of beeping 'visualbell' 'vb' use visual bell instead of beeping
'wrapscan' 'ws' searches wrap around the end of the file 'wrapscan' 'ws' searches wrap around the end of the file

View File

@@ -1,37 +1,43 @@
<idea-plugin url="http://plugins.intellij.net/plugin/?id=164"> <idea-plugin url="http://plugins.jetbrains.com/plugin/164">
<name>IdeaVim</name> <name>IdeaVim</name>
<id>IdeaVIM</id> <id>IdeaVIM</id>
<change-notes> <change-notes>
<![CDATA[ <![CDATA[
<p>0.27:</p> <p>0.33:</p>
<ul> <ul>
<li>Better Vim keymaps for Mac OS X</li> <li>Support for <code>:map</code> key mapping commands</li>
<li>Ask if the plugin should enable repeating keys in Mac OS X</li> <li>New keyboard shortcuts handler that doesn't require a separate keymap for Vim emulation</li>
<li>Fixed a long-standing bug with code completion and repeat last change command ('<code>.</code>')</li> <li>Support for <code>:source</code> command</li>
<li>Support for <code>:sort</code> command</li>
<li>Various bug fixes</li> <li>Various bug fixes</li>
</ul> </ul>
<p>0.26:</p> <p>0.32:</p>
<ul> <ul>
<li>Added support for paste in the command mode: from a register using <code>&lt;C-R&gt;</code>, from the clipboard using <code>&lt;S-Insert&gt;</code> or <code>&lt;M-V&gt;</code></li> <li>Fixed API compatibility with IntelliJ platform builds 132.1052+</li>
<li>Added support for the last change position mark (the dot <code>.</code> mark)</li>
<li>New shortcuts for Go to declaration <code>&lt;C-]&gt;</code> and Navigate back <code>&lt;C-T&gt;</code></li>
<li>Various bug fixes</li>
</ul> </ul>
<p>0.25:</p> <p>0.31:</p>
<ul> <ul>
<li>Various bug fixes</li> <li>Various bug fixes</li>
</ul> </ul>
<p>0.24:</p> <p>0.30:</p>
<ul> <ul>
<li>Added Vim string object selection motions (see help topics <code>v_i"</code>, <code>v_a"</code>)</li> <li>Support for a separate <code>.ideavimrc</code> config file</li>
<li>Fixed long-standing issues with merged undo/redo commands and <code>&lt;Esc&gt;</code> during completion</li>
<li>Various bug fixes</li> <li>Various bug fixes</li>
</ul> </ul>
<p>0.29:</p>
<ul>
<li>Fixed repeat buffer limits</li>
<li>Enable normal <code>&lt;Enter&gt;</code> handling for one-line editors</li>
<li>Don't move cursor while scrolling</li>
</ul>
<p>See also the complete <a href="https://github.com/JetBrains/ideavim/blob/master/CHANGES.md">changelog</a>.</p> <p>See also the complete <a href="https://github.com/JetBrains/ideavim/blob/master/CHANGES.md">changelog</a>.</p>
]]> ]]>
</change-notes> </change-notes>
<description> <description>
<![CDATA[ <![CDATA[
<p>Vim emulation plug-in for IDEs based on the IntelliJ platform. IdeaVim can be used with IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm and AppCode.</p> <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> <p>Supported functionality:</p>
<ul> <ul>
<li>Motion keys</li> <li>Motion keys</li>
@@ -44,6 +50,7 @@
<li>Some Ex commands</li> <li>Some Ex commands</li>
<li>Some :set options</li> <li>Some :set options</li>
<li>Full Vim regexps for search and search/replace</li> <li>Full Vim regexps for search and search/replace</li>
<li>Key mappings</li>
<li>Macros</li> <li>Macros</li>
<li>Digraphs</li> <li>Digraphs</li>
<li>Command line and search history</li> <li>Command line and search history</li>
@@ -52,7 +59,7 @@
]]> ]]>
</description> </description>
<version>@VERSION@</version> <version>@VERSION@</version>
<vendor logo="/icons/vim16x16.png">JetBrains</vendor> <vendor>JetBrains</vendor>
<idea-version since-build="@SINCE-VERSION@"/> <idea-version since-build="@SINCE-VERSION@"/>
@@ -68,16 +75,14 @@
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/> <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
<applicationConfigurable instance="com.maddyhome.idea.vim.ui.VimEmulationConfigurable"/>
</extensions> </extensions>
<actions> <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"/> <keyboard-shortcut first-keystroke="control alt V" keymap="$default"/>
<add-to-group group-id="ToolsMenu" anchor="last"/> <add-to-group group-id="ToolsMenu" anchor="last"/>
</action> </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 --> <!-- Motions -->
<action id="VimMotionPreviousTab" class="com.maddyhome.idea.vim.action.motion.tabs.MotionPreviousTabAction" text="Move to Previous Tab"/> <action id="VimMotionPreviousTab" class="com.maddyhome.idea.vim.action.motion.tabs.MotionPreviousTabAction" text="Move to Previous Tab"/>
@@ -223,7 +228,6 @@
<action id="VimInsertDeletePreviousWord" class="com.maddyhome.idea.vim.action.change.insert.InsertDeletePreviousWordAction" text="Delete Previous Word"/> <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="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="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="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="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"/> <action id="VimInsertNewLineBelow" class="com.maddyhome.idea.vim.action.change.insert.InsertNewLineBelowAction" text="Insert New Line Below"/>
@@ -273,14 +277,8 @@
<action id="VimFilterMotion" class="com.maddyhome.idea.vim.action.change.change.FilterMotionAction" text="Filter Lines"/> <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="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="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="VimAutoIndentVisual" class="com.maddyhome.idea.vim.action.change.change.AutoIndentLinesVisualAction" text="Auto Indent Selection"/>
<action id="VimReformatVisual" class="com.maddyhome.idea.vim.action.visual.VisualOperatorDelegateAction" text="Reformat Selection"/> <action id="VimReformatVisual" class="com.maddyhome.idea.vim.action.change.change.ReformatCodeVisualAction" 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"/>
<!-- Shift --> <!-- Shift -->
<action id="VimAutoIndentLines" class="com.maddyhome.idea.vim.action.change.shift.AutoIndentLinesAction" text="Auto Indent Lines"/> <action id="VimAutoIndentLines" class="com.maddyhome.idea.vim.action.change.shift.AutoIndentLinesAction" text="Auto Indent Lines"/>
@@ -346,36 +344,8 @@
<action id="VimResetMode" class="com.maddyhome.idea.vim.action.ResetModeAction" text="Reset Mode"/> <action id="VimResetMode" class="com.maddyhome.idea.vim.action.ResetModeAction" text="Reset Mode"/>
<action id="VimRedo" class="com.maddyhome.idea.vim.action.change.RedoAction" text="Redo"/> <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="VimUndo" class="com.maddyhome.idea.vim.action.change.UndoAction" text="Undo"/>
<action id="VimGenerateConstructor" class="com.maddyhome.idea.vim.action.TxActionWrapper" text="Generate Constructor"/>
<action id="VimGenerateGetter" class="com.maddyhome.idea.vim.action.TxActionWrapper" text="Generate Getter"/>
<action id="VimGenerateSetter" class="com.maddyhome.idea.vim.action.TxActionWrapper" text="Generate Setter"/>
<action id="VimGenerateGetterAndSetter" class="com.maddyhome.idea.vim.action.TxActionWrapper" text="Generate Getter and Setter"/>
<action id="VimGenerateEquals" class="com.maddyhome.idea.vim.action.TxActionWrapper" text="Generate Equals"/>
<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 --> <!-- Keys -->
<action id="VimKeyHandler" class="com.maddyhome.idea.vim.action.key.KeyAction" text="Keys"/> <action id="VimShortcutKeyAction" class="com.maddyhome.idea.vim.action.VimShortcutKeyAction" text="Vim Shortcuts"/>
<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"/>
</actions> </actions>
</idea-plugin> </idea-plugin>

View File

@@ -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

View File

@@ -1,30 +1,30 @@
package com.maddyhome.idea.vim;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2006 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim;
import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.TypedActionHandler; import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
@@ -32,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.Argument;
import com.maddyhome.idea.vim.command.Command; import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandState; 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.group.RegisterGroup;
import com.maddyhome.idea.vim.helper.DelegateCommandListener; import com.maddyhome.idea.vim.helper.*;
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.key.*; import com.maddyhome.idea.vim.key.*;
import com.maddyhome.idea.vim.option.Options; import com.maddyhome.idea.vim.option.Options;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -101,12 +100,21 @@ public class KeyHandler {
* @param context The data context * @param context The data context
*/ */
public void handleKey(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext 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(); VimPlugin.clearError();
// All the editor actions should be performed with top level editor!!! // All the editor actions should be performed with top level editor!!!
// Be careful: all the EditorActionHandler implementation should correctly process InjectedEditors // Be careful: all the EditorActionHandler implementation should correctly process InjectedEditors
editor = InjectedLanguageUtil.getTopLevelEditor(editor); editor = InjectedLanguageUtil.getTopLevelEditor(editor);
logger.debug("handleKey " + key);
final CommandState editorState = CommandState.getInstance(editor); final CommandState editorState = CommandState.getInstance(editor);
if (allowKeyMappings && handleKeyMapping(editor, key, context)) {
return;
}
final boolean isRecording = editorState.isRecording(); final boolean isRecording = editorState.isRecording();
boolean shouldRecord = true; boolean shouldRecord = true;
// If this is a "regular" character keystroke, get the character // If this is a "regular" character keystroke, get the character
@@ -120,13 +128,11 @@ public class KeyHandler {
else if (isCommandCount(editorState, chKey)) { else if (isCommandCount(editorState, chKey)) {
// Update the count // Update the count
count = count * 10 + (chKey - '0'); count = count * 10 + (chKey - '0');
logger.debug("count now " + count);
} }
// Pressing delete while entering a count "removes" the last digit entered // Pressing delete while entering a count "removes" the last digit entered
else if (isDeleteCommandCount(key, editorState)) { else if (isDeleteCommandCount(key, editorState)) {
// "Remove" the last digit sent to us // "Remove" the last digit sent to us
count /= 10; count /= 10;
logger.debug("count now " + count);
} }
// If we got this far the user is entering a command or supplying an argument to an entered command. // If we got this far the user is entering a command or supplying an argument to an entered command.
// First let's check to see if we are at the point of expecting a single character argument to a command. // First let's check to see if we are at the point of expecting a single character argument to a command.
@@ -138,9 +144,6 @@ public class KeyHandler {
else { else {
// For debugging purposes we track the keys entered for this command // For debugging purposes we track the keys entered for this command
keys.add(key); keys.add(key);
if (logger.isDebugEnabled()) {
logger.debug("keys now " + keys);
}
// Ask the key/action tree if this is an appropriate key at this point in the command and if so, // Ask the key/action tree if this is an appropriate key at this point in the command and if so,
// return the node matching this keystroke // return the node matching this keystroke
@@ -161,27 +164,22 @@ public class KeyHandler {
// If this is an argument node then the last keystroke was not part of the current command but should // 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 // be the first keystroke of the argument of the current command
else if (node instanceof ArgumentNode) { else if (node instanceof ArgumentNode) {
shouldRecord = handleArgumentNode(editor, key, context, editorState, shouldRecord, (ArgumentNode)node); shouldRecord = handleArgumentNode(editor, key, context, editorState, true, (ArgumentNode)node);
} }
else { else {
logger.debug("checking for digraph");
logger.debug("lastWasBS=" + lastWasBS);
logger.debug("lastChar=" + lastChar);
if (lastWasBS && lastChar != 0 && Options.getInstance().isSet("digraph")) { 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());
logger.debug("dig=" + dig);
key = KeyStroke.getKeyStroke(dig); key = KeyStroke.getKeyStroke(dig);
} }
// If we are in insert/replace mode send this key in for processing // If we are in insert/replace mode send this key in for processing
if (editorState.getMode() == CommandState.Mode.INSERT || if (editorState.getMode() == CommandState.Mode.INSERT || editorState.getMode() == CommandState.Mode.REPLACE) {
editorState.getMode() == CommandState.Mode.REPLACE) { if (!VimPlugin.getChange().processKey(editor, context, key)) {
if (!CommandGroups.getInstance().getChange().processKey(editor, context, key)) {
shouldRecord = false; shouldRecord = false;
} }
} }
else if (editorState.getMappingMode() == KeyParser.MAPPING_CMD_LINE) { else if (editorState.getMappingMode() == MappingMode.CMD_LINE) {
if (!CommandGroups.getInstance().getProcess().processExKey(editor, key, true)) { if (!VimPlugin.getProcess().processExKey(editor, key, true)) {
shouldRecord = false; shouldRecord = false;
} }
} }
@@ -200,7 +198,7 @@ public class KeyHandler {
executeCommand(editor, key, context, editorState); executeCommand(editor, key, context, editorState);
} }
else if (state == State.BAD_COMMAND) { else if (state == State.BAD_COMMAND) {
if (editorState.getMappingMode() == KeyParser.MAPPING_OP_PEND) { if (editorState.getMappingMode() == MappingMode.OP_PENDING) {
editorState.popState(); editorState.popState();
} }
else { else {
@@ -214,49 +212,106 @@ public class KeyHandler {
fullReset(editor); fullReset(editor);
} }
else if (isRecording && shouldRecord) { else if (isRecording && shouldRecord) {
CommandGroups.getInstance().getRegister().recordKeyStroke(key); VimPlugin.getRegister().recordKeyStroke(key);
} }
} }
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context) { 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() {
for (KeyStroke keyStroke : mappingInfo.getToKeys()) {
handleKey(editor, keyStroke, new EditorDataContext(editor), mappingInfo.isRecursive());
}
}
};
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 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 && 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) { if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
KeyHandler.executeAction("VimEditorEscape", context); CommandProcessor.getInstance().executeCommand(editor.getProject(), new Runnable() {
//getOriginalHandler().execute(editor, key.getKeyChar(), context); @Override
public void run() {
KeyHandler.executeAction("EditorEscape", context);
}
}, "", null);
} }
VimPlugin.indicateError(); VimPlugin.indicateError();
} }
reset(editor);
reset(editor); }
}
private boolean isDeleteCommandCount(@NotNull KeyStroke key, @NotNull CommandState editorState) { private boolean isDeleteCommandCount(@NotNull KeyStroke key, @NotNull CommandState editorState) {
return (editorState.getMode() == CommandState.Mode.COMMAND || return (editorState.getMode() == CommandState.Mode.COMMAND || editorState.getMode() == CommandState.Mode.VISUAL) &&
editorState.getMode() == CommandState.Mode.VISUAL) && state == State.NEW_COMMAND && currentArg != Argument.Type.CHARACTER && currentArg != Argument.Type.DIGRAPH &&
state == State.NEW_COMMAND && currentArg != Argument.Type.CHARACTER && currentArg != key.getKeyCode() == KeyEvent.VK_DELETE && count != 0;
Argument.Type.DIGRAPH &&
key.getKeyCode() == KeyEvent.VK_DELETE && count != 0;
} }
private boolean isCommandCount(@NotNull CommandState editorState, char chKey) { private boolean isCommandCount(@NotNull CommandState editorState, char chKey) {
return (editorState.getMode() == CommandState.Mode.COMMAND || return (editorState.getMode() == CommandState.Mode.COMMAND || editorState.getMode() == CommandState.Mode.VISUAL) &&
editorState.getMode() == CommandState.Mode.VISUAL) && state == State.NEW_COMMAND && currentArg != Argument.Type.CHARACTER && currentArg != Argument.Type.DIGRAPH &&
state == State.NEW_COMMAND && currentArg != Argument.Type.CHARACTER && currentArg != Character.isDigit(chKey) &&
Argument.Type.DIGRAPH && (count != 0 || chKey != '0');
Character.isDigit(chKey) &&
(count != 0 || chKey != '0');
} }
private boolean isEditorReset(@NotNull KeyStroke key, @NotNull CommandState editorState) { private boolean isEditorReset(@NotNull KeyStroke key, @NotNull CommandState editorState) {
return (editorState.getMode() == CommandState.Mode.COMMAND || state == State.COMMAND) && return (editorState.getMode() == CommandState.Mode.COMMAND || state == State.COMMAND) &&
(key.getKeyCode() == KeyEvent.VK_ESCAPE || (key.getKeyCode() == KeyEvent.VK_ESCAPE ||
(key.getKeyCode() == KeyEvent.VK_C && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0) || (key.getKeyCode() == KeyEvent.VK_C && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0) ||
(key.getKeyCode() == '[' && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0)); (key.getKeyCode() == '[' && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0));
} }
private void handleCharArgument(@NotNull KeyStroke key, char chKey) { private void handleCharArgument(@NotNull KeyStroke key, char chKey) {
logger.debug("currentArg is Character");
// We are expecting a character argument - is this a regular character the user typed? // We are expecting a character argument - is this a regular character the user typed?
// Some special keys can be handled as character arguments - let's check for them here. // Some special keys can be handled as character arguments - let's check for them here.
if (chKey == 0) { if (chKey == 0) {
@@ -284,12 +339,13 @@ public class KeyHandler {
} }
} }
private boolean handleDigraph(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context, @Nullable Node node) { private boolean handleDigraph(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
@Nullable Node node) {
if (digraph == null && !(node instanceof CommandNode) && DigraphSequence.isDigraphStart(key)) { if (digraph == null && !(node instanceof CommandNode) && DigraphSequence.isDigraphStart(key)) {
digraph = new DigraphSequence(); digraph = new DigraphSequence();
} }
if (digraph != null) { if (digraph != null) {
DigraphSequence.DigraphResult res = digraph.processKey(key, editor, context); DigraphSequence.DigraphResult res = digraph.processKey(key, editor);
switch (res.getResult()) { switch (res.getResult()) {
case DigraphSequence.DigraphResult.RES_OK: case DigraphSequence.DigraphResult.RES_OK:
return true; return true;
@@ -301,11 +357,13 @@ public class KeyHandler {
currentArg = Argument.Type.CHARACTER; currentArg = Argument.Type.CHARACTER;
} }
digraph = null; digraph = null;
handleKey(editor, res.getStroke(), context); final KeyStroke stroke = res.getStroke();
if (stroke == null) {
return false;
}
handleKey(editor, stroke, context);
return true; return true;
} }
logger.debug("digraph done");
} }
return false; return false;
} }
@@ -323,28 +381,23 @@ public class KeyHandler {
cmd = top; cmd = top;
} }
if (logger.isDebugEnabled()) {
logger.debug("cmd=" + cmd);
}
// If we have a command and a motion command argument, both could possibly have their own counts. We // If we have a command and a motion command argument, both could possibly have their own counts. We
// need to adjust the counts so the motion gets the product of both counts and the count associated with // need to adjust the counts so the motion gets the product of both counts and the count associated with
// the command gets reset. Example 3c2w (change 2 words, three times) becomes c6w (change 6 words) // the command gets reset. Example 3c2w (change 2 words, three times) becomes c6w (change 6 words)
Argument arg = cmd.getArgument(); final Argument arg = cmd.getArgument();
if (logger.isDebugEnabled()) {
logger.debug("arg=" + arg);
}
if (arg != null && arg.getType() == Argument.Type.MOTION) { if (arg != null && arg.getType() == Argument.Type.MOTION) {
Command mot = arg.getMotion(); final Command mot = arg.getMotion();
// If no count was entered for either command then nothing changes. If either had a count then // If no count was entered for either command then nothing changes. If either had a count then
// the motion gets the product of both. // the motion gets the product of both.
int cnt = cmd.getRawCount() == 0 && mot.getRawCount() == 0 ? 0 : cmd.getCount() * mot.getCount(); if (mot != null) {
int cnt = cmd.getRawCount() == 0 && mot.getRawCount() == 0 ? 0 : cmd.getCount() * mot.getCount();
mot.setCount(cnt);
}
cmd.setCount(0); cmd.setCount(0);
mot.setCount(cnt);
} }
// If we were in "operator pending" mode, reset back to normal mode. // If we were in "operator pending" mode, reset back to normal mode.
if (editorState.getMappingMode() == KeyParser.MAPPING_OP_PEND) { if (editorState.getMappingMode() == MappingMode.OP_PENDING) {
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_NORMAL);
editorState.popState(); editorState.popState();
} }
@@ -352,34 +405,30 @@ public class KeyHandler {
editorState.setCommand(cmd); editorState.setCommand(cmd);
lastWasBS = ((cmd.getFlags() & Command.FLAG_IS_BACKSPACE) != 0); lastWasBS = ((cmd.getFlags() & Command.FLAG_IS_BACKSPACE) != 0);
logger.debug("lastWasBS=" + lastWasBS);
Project project = editor.getProject(); Project project = editor.getProject();
if (cmd.getType().isRead() || project == null || EditorHelper.canEdit(project, editor)) { if (cmd.getType().isRead() || project == null || EditorHelper.canEdit(project, editor)) {
if (ApplicationManager.getApplication().isDispatchThread()) { if (ApplicationManager.getApplication().isDispatchThread()) {
Runnable action = new ActionRunner(editor, context, cmd, key); Runnable action = new ActionRunner(editor, context, cmd, key);
String name = cmd.getAction().getTemplatePresentation().getText();
name = name != null ? "Vim " + name : "";
if (cmd.getType().isWrite()) { if (cmd.getType().isWrite()) {
RunnableHelper.runWriteCommand(project, action, cmd.getActionId(), null); RunnableHelper.runWriteCommand(project, action, name, action);
} }
else { else {
RunnableHelper.runReadCommand(project, action, cmd.getActionId(), null); RunnableHelper.runReadCommand(project, action, name, action);
} }
} }
} }
else { else {
logger.info("write command on read-only file");
VimPlugin.indicateError(); VimPlugin.indicateError();
reset(editor); reset(editor);
} }
} }
private boolean handleArgumentNode(@NotNull Editor editor, private boolean handleArgumentNode(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
@NotNull KeyStroke key, @NotNull CommandState editorState, boolean shouldRecord,
@NotNull DataContext context,
@NotNull CommandState editorState,
boolean shouldRecord,
@NotNull ArgumentNode node) { @NotNull ArgumentNode node) {
logger.debug("argument node");
// Create a new command based on what the user has typed so far, excluding this keystroke. // 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()); Command cmd = new Command(count, node.getActionId(), node.getAction(), node.getCmdType(), node.getFlags());
cmd.setKeys(keys); cmd.setKeys(keys);
@@ -397,9 +446,7 @@ public class KeyHandler {
// Is the current command an operator? If so set the state to only accept "operator pending" // Is the current command an operator? If so set the state to only accept "operator pending"
// commands // commands
if ((node.getFlags() & Command.FLAG_OP_PEND) != 0) { if ((node.getFlags() & Command.FLAG_OP_PEND) != 0) {
//CommandState.getInstance().setMappingMode(KeyParser.MAPPING_OP_PEND); editorState.pushState(editorState.getMode(), editorState.getSubMode(), MappingMode.OP_PENDING);
editorState.pushState(editorState.getMode(), editorState.getSubMode(),
KeyParser.MAPPING_OP_PEND);
} }
break; break;
case EX_STRING: case EX_STRING:
@@ -421,7 +468,6 @@ public class KeyHandler {
} }
private void handleCommandNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandNode node) { private void handleCommandNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandNode node) {
logger.debug("command node");
// If all does well we are ready to process this command // If all does well we are ready to process this command
state = State.READY; state = State.READY;
// Did we just get the completed sequence for a motion command argument? // Did we just get the completed sequence for a motion command argument?
@@ -429,15 +475,13 @@ public class KeyHandler {
// We have been expecting a motion argument - is this one? // We have been expecting a motion argument - is this one?
if (node.getCmdType() == Command.Type.MOTION) { if (node.getCmdType() == Command.Type.MOTION) {
// Create the motion command and add it to the stack // Create the motion command and add it to the stack
Command cmd = new Command(count, node.getActionId(), node.getAction(), Command cmd = new Command(count, node.getActionId(), node.getAction(), node.getCmdType(), node.getFlags());
node.getCmdType(), node.getFlags());
cmd.setKeys(keys); cmd.setKeys(keys);
currentCmd.push(cmd); currentCmd.push(cmd);
} }
else if (node.getCmdType() == Command.Type.RESET) { else if (node.getCmdType() == Command.Type.RESET) {
currentCmd.clear(); currentCmd.clear();
Command cmd = new Command(1, node.getActionId(), node.getAction(), Command cmd = new Command(1, node.getActionId(), node.getAction(), node.getCmdType(), node.getFlags());
node.getCmdType(), node.getFlags());
cmd.setKeys(keys); cmd.setKeys(keys);
currentCmd.push(cmd); currentCmd.push(cmd);
} }
@@ -447,7 +491,7 @@ public class KeyHandler {
} }
} }
else if (currentArg == Argument.Type.EX_STRING && (node.getFlags() & Command.FLAG_COMPLETE_EX) != 0) { 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); Argument arg = new Argument(text);
Command cmd = currentCmd.peek(); Command cmd = currentCmd.peek();
cmd.setArgument(arg); cmd.setArgument(arg);
@@ -456,23 +500,20 @@ public class KeyHandler {
// The user entered a valid command that doesn't take any arguments // The user entered a valid command that doesn't take any arguments
else { else {
// Create the command and add it to the stack // Create the command and add it to the stack
Command cmd = new Command(count, node.getActionId(), node.getAction(), Command cmd = new Command(count, node.getActionId(), node.getAction(), node.getCmdType(), node.getFlags());
node.getCmdType(), node.getFlags());
cmd.setKeys(keys); cmd.setKeys(keys);
currentCmd.push(cmd); currentCmd.push(cmd);
// This is a sanity check that the command has a valid action. This should only fail if the // This is a sanity check that the command has a valid action. This should only fail if the
// programmer made a typo or forgot to add the action to the plugin.xml file // programmer made a typo or forgot to add the action to the plugin.xml file
if (cmd.getAction() == null) { if (cmd.getAction() == null) {
logger.error("NULL action for keys '" + keys + "'");
state = State.ERROR; state = State.ERROR;
} }
} }
} }
private void handleBranchNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandState editorState, char key, private void handleBranchNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandState editorState,
@NotNull BranchNode node) { char key, @NotNull BranchNode node) {
logger.debug("branch node");
// Flag that we aren't allowing any more count digits (unless it's OK) // Flag that we aren't allowing any more count digits (unless it's OK)
if ((node.getFlags() & Command.FLAG_ALLOW_MID_COUNT) == 0) { if ((node.getFlags() & Command.FLAG_ALLOW_MID_COUNT) == 0) {
state = State.COMMAND; state = State.COMMAND;
@@ -491,10 +532,10 @@ public class KeyHandler {
} }
if (arg.getArgType() == Argument.Type.EX_STRING) { 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; state = State.NEW_COMMAND;
currentArg = Argument.Type.EX_STRING; 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);
} }
} }
} }
@@ -506,15 +547,11 @@ public class KeyHandler {
* @param context The context to run it in * @param context The context to run it in
*/ */
public static void executeAction(@NotNull String name, @NotNull DataContext context) { public static void executeAction(@NotNull String name, @NotNull DataContext context) {
logger.debug("executing action " + name);
ActionManager aMgr = ActionManager.getInstance(); ActionManager aMgr = ActionManager.getInstance();
AnAction action = aMgr.getAction(name); AnAction action = aMgr.getAction(name);
if (action != null) { if (action != null) {
executeAction(action, context); executeAction(action, context);
} }
else {
logger.debug("Unknown action");
}
} }
/** /**
@@ -524,22 +561,15 @@ public class KeyHandler {
* @param context The context to run it in * @param context The context to run it in
*/ */
public static void executeAction(@NotNull AnAction action, @NotNull DataContext context) { public static void executeAction(@NotNull AnAction action, @NotNull DataContext context) {
if (logger.isDebugEnabled()) {
logger.debug("executing action " + action);
}
// Hopefully all the arguments are sufficient. So far they all seem to work OK. // Hopefully all the arguments are sufficient. So far they all seem to work OK.
// We don't have a specific InputEvent so that is null // We don't have a specific InputEvent so that is null
// What is "place"? Leave it the empty string for now. // What is "place"? Leave it the empty string for now.
// Is the template presentation sufficient? // Is the template presentation sufficient?
// What are the modifiers? Is zero OK? // What are the modifiers? Is zero OK?
action.actionPerformed(new AnActionEvent( action.actionPerformed(
null, new AnActionEvent(null, context, "", action.getTemplatePresentation(), ActionManager.getInstance(),
context, // API change - don't merge
"", 0));
action.getTemplatePresentation(),
ActionManager.getInstance(), // API change - don't merge
0));
} }
/** /**
@@ -552,8 +582,9 @@ public class KeyHandler {
count = 0; count = 0;
keys = new ArrayList<KeyStroke>(); keys = new ArrayList<KeyStroke>();
CommandState editorState = CommandState.getInstance(editor); CommandState editorState = CommandState.getInstance(editor);
editorState.setCurrentNode(KeyParser.getInstance().getKeyRoot(editorState.getMappingMode())); editorState.stopMappingTimer();
logger.debug("partialReset"); editorState.getMappingKeys().clear();
editorState.setCurrentNode(VimPlugin.getKey().getKeyRoot(editorState.getMappingMode()));
} }
/** /**
@@ -567,7 +598,6 @@ public class KeyHandler {
currentCmd.clear(); currentCmd.clear();
currentArg = Argument.Type.NONE; currentArg = Argument.Type.NONE;
digraph = null; digraph = null;
logger.debug("reset");
} }
/** /**
@@ -582,7 +612,7 @@ public class KeyHandler {
reset(editor); reset(editor);
lastChar = 0; lastChar = 0;
lastWasBS = false; lastWasBS = false;
CommandGroups.getInstance().getRegister().resetRegister(); VimPlugin.getRegister().resetRegister();
DelegateCommandListener.getInstance().setRunnable(null); DelegateCommandListener.getInstance().setRunnable(null);
} }
@@ -602,9 +632,8 @@ public class KeyHandler {
boolean wasRecording = editorState.isRecording(); boolean wasRecording = editorState.isRecording();
executeAction(cmd.getAction(), context); executeAction(cmd.getAction(), context);
if (editorState.getMode() == CommandState.Mode.INSERT || if (editorState.getMode() == CommandState.Mode.INSERT || editorState.getMode() == CommandState.Mode.REPLACE) {
editorState.getMode() == CommandState.Mode.REPLACE) { VimPlugin.getChange().processCommand(editor, cmd);
CommandGroups.getInstance().getChange().processCommand(editor, cmd);
} }
// Now that the command has been executed let's clean up a few things. // Now that the command has been executed let's clean up a few things.
@@ -612,7 +641,7 @@ public class KeyHandler {
// By default the "empty" register is used by all commands so we want to reset whatever the last register // 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. // selected by the user was to the empty register - unless we just executed the "select register" command.
if (cmd.getType() != Command.Type.SELECT_REGISTER) { 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 // If, at this point, we are not in insert, replace, or visual modes, we need to restore the previous
@@ -627,7 +656,7 @@ public class KeyHandler {
KeyHandler.getInstance().reset(editor); KeyHandler.getInstance().reset(editor);
if (wasRecording && editorState.isRecording()) { if (wasRecording && editorState.isRecording()) {
CommandGroups.getInstance().getRegister().recordKeyStroke(key); VimPlugin.getRegister().recordKeyStroke(key);
} }
} }
@@ -656,5 +685,4 @@ public class KeyHandler {
private boolean lastWasBS; private boolean lastWasBS;
private static KeyHandler instance; private static KeyHandler instance;
private static Logger logger = Logger.getInstance(KeyHandler.class.getName());
} }

View File

@@ -0,0 +1,861 @@
/*
* 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;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
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.group.KeyGroup;
import com.maddyhome.idea.vim.key.Shortcut;
import javax.swing.*;
import java.awt.event.KeyEvent;
public class RegisterActions {
/**
* Register all the key/action mappings for the plugin.
*/
public static void registerActions() {
registerVimCommandActions();
registerInsertModeActions();
registerVisualModeActions();
registerNormalModeActions();
registerNVOModesActions();
registerCommandLineActions();
registerVariousModesActions();
}
private static void registerVimCommandActions() {
final ActionManagerEx manager = ActionManagerEx.getInstanceEx();
for (String actionId : manager.getPluginActions(VimPlugin.getPluginId())) {
final AnAction action = manager.getAction(actionId);
if (action instanceof VimCommandAction) {
VimPlugin.getKey().registerCommandAction((VimCommandAction)action, actionId);
}
}
}
private static void registerVariousModesActions() {
final KeyGroup parser = VimPlugin.getKey();
parser.registerAction(MappingMode.NV, "VimVisualToggleLineMode", Command.Type.OTHER_READONLY, Command.FLAG_MOT_LINEWISE,
new Shortcut('V'));
parser.registerAction(MappingMode.NV, "VimVisualToggleBlockMode", Command.Type.OTHER_READONLY,
Command.FLAG_MOT_BLOCKWISE,
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK))}
);
parser.registerAction(MappingMode.NV, "VimMotionMark", Command.Type.OTHER_READONLY, new Shortcut('m'),
Argument.Type.CHARACTER);
parser.registerAction(MappingMode.NV, "VimGotoDeclaration", Command.Type.OTHER_READONLY, Command.FLAG_SAVE_JUMP,
new Shortcut[]{new Shortcut("gD"), new Shortcut("gd"),
// TODO: <C-]> is a tag command similar to gD, the tag stack is not implemented
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, KeyEvent.CTRL_MASK)),}
);
parser.registerAction(MappingMode.NV, "VimFileGetLocationInfo", Command.Type.OTHER_READONLY, new Shortcut(
new KeyStroke[]{KeyStroke.getKeyStroke('g'),
KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)})
);
// TODO - add zC
// TODO - add zO
parser.registerAction(MappingMode.NV, "CollapseAllRegions", Command.Type.OTHER_READONLY, new Shortcut("zM"));
parser.registerAction(MappingMode.NV, "CollapseRegion", Command.Type.OTHER_READONLY, new Shortcut("zc"));
parser.registerAction(MappingMode.NV, "ExpandAllRegions", Command.Type.OTHER_READONLY, new Shortcut("zR"));
parser.registerAction(MappingMode.NV, "ExpandRegion", Command.Type.OTHER_READONLY, new Shortcut("zo"));
parser.registerAction(MappingMode.NV, "VimToggleRecording",
Command.Type.OTHER_READONLY,
Command.FLAG_NO_ARG_RECORDING,
new Shortcut('q'), Argument.Type.CHARACTER);
// Text Object Actions for Visual and Operator Pending Modes
parser.registerAction(MappingMode.VO, "VimMotionGotoFileMark", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP, new Shortcut('`'),
Argument.Type.CHARACTER);
parser.registerAction(MappingMode.VO, "VimMotionGotoFileMarkLine", Command.Type.MOTION,
Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP, new Shortcut('\''),
Argument.Type.CHARACTER);
parser.registerAction(MappingMode.VO, "VimMotionGotoFileMark", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut("g`"), Argument.Type.CHARACTER);
parser.registerAction(MappingMode.VO, "VimMotionGotoFileMarkLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE,
new Shortcut("g'"), Argument.Type.CHARACTER);
parser.registerAction(MappingMode.VO, "VimMotionTextOuterWord", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE, new Shortcut("aw"));
parser.registerAction(MappingMode.VO, "VimMotionTextOuterBigWord", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE, new Shortcut("aW"));
parser.registerAction(MappingMode.VO, "VimMotionTextInnerWord", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE, new Shortcut("iw"));
parser.registerAction(MappingMode.VO, "VimMotionTextInnerBigWord", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE, new Shortcut("iW"));
parser.registerAction(MappingMode.VO, "VimMotionInnerParagraph", Command.Type.MOTION,
Command.FLAG_MOT_LINEWISE | Command.FLAG_TEXT_BLOCK, new Shortcut("ip"));
parser.registerAction(MappingMode.VO, "VimMotionOuterParagraph", Command.Type.MOTION,
Command.FLAG_MOT_LINEWISE | Command.FLAG_TEXT_BLOCK, new Shortcut("ap"));
parser.registerAction(MappingMode.VO, "VimMotionInnerSentence",
Command.Type.MOTION,
Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut("is"));
parser.registerAction(MappingMode.VO, "VimMotionOuterSentence", Command.Type.MOTION,
Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK, new Shortcut("as"));
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockAngle", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("i<"), new Shortcut("i>")}
);
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockBrace", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("iB"), new Shortcut("i{"), new Shortcut("i}")}
);
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockBracket", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("i["), new Shortcut("i]")}
);
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockParen", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("ib"), new Shortcut("i("), new Shortcut("i)")}
);
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockDoubleQuote", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("i\""),}
);
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockSingleQuote", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("i'"),}
);
parser.registerAction(MappingMode.VO, "VimMotionInnerBlockBackQuote", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("i`"),}
);
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockAngle",
Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK, new Shortcut[]{
new Shortcut("a<"),
new Shortcut("a>")
});
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockBrace", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("aB"), new Shortcut("a{"), new Shortcut("a}")}
);
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockBracket", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("a["), new Shortcut("a]")}
);
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockParen", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("ab"), new Shortcut("a("), new Shortcut("a)")}
);
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockDoubleQuote", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("a\""),}
);
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockSingleQuote", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK,
new Shortcut[]{new Shortcut("a'"),}
);
parser.registerAction(MappingMode.VO, "VimMotionOuterBlockBackQuote", Command.Type.MOTION,
Command.FLAG_MOT_CHARACTERWISE | Command.FLAG_MOT_INCLUSIVE | Command.FLAG_TEXT_BLOCK, new Shortcut[]{
new Shortcut("a`"),
});
parser.registerAction(MappingMode.NO, "VimResetMode", Command.Type.RESET, new Shortcut(new KeyStroke[]{
KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, KeyEvent.CTRL_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)
}));
}
private static void registerCommandLineActions() {
final KeyGroup parser = VimPlugin.getKey();
parser
.registerAction(MappingMode.C, "VimProcessExEntry", Command.Type.OTHER_READ_WRITE, Command.FLAG_COMPLETE_EX,
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke((char)0x0a)),
new Shortcut(KeyStroke.getKeyStroke((char)0x0d))});
}
/**
* Register normal, visual, operator pending modes actions.
*/
private static void registerNVOModesActions() {
final KeyGroup parser = VimPlugin.getKey();
parser.registerAction(MappingMode.NVO, "VimCopySelectRegister", Command.Type.SELECT_REGISTER, Command.FLAG_EXPECT_MORE,
new Shortcut('"'), Argument.Type.CHARACTER);
// Motion Actions
// TODO - add ['
// TODO - add [`
// TODO - add ]'
// TODO - add ]`
// TODO - add zj
// TODO - add zk
parser.registerAction(MappingMode.NVO, "VimMotionNextTab", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("gt"));
parser.registerAction(MappingMode.NVO, "VimMotionPreviousTab", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("gT"));
parser.registerAction(MappingMode.NVO, "VimMotionCamelEndLeft", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("]b"));
parser.registerAction(MappingMode.NVO, "VimMotionCamelEndRight", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("]w"));
parser.registerAction(MappingMode.NVO, "VimMotionCamelLeft", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut("[b"));
parser.registerAction(MappingMode.NVO, "VimMotionCamelRight", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut("[w"));
parser.registerAction(MappingMode.NVO, "VimMotionColumn", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut('|'));
parser.registerAction(MappingMode.NVO, "VimMotionDown", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
new Shortcut('j'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)),
});
parser.registerAction(MappingMode.NVO, "VimMotionDown", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut("gj"),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('g'), KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionDownFirstNonSpace", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
new Shortcut('+'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionDownLess1FirstNonSpace", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE,
new Shortcut('_'));
parser.registerAction(MappingMode.NVO, "VimMotionFirstColumn", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('0'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0))
});
parser.registerAction(MappingMode.NVO, "VimMotionFirstScreenColumn", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut("g0"),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('g'), KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionFirstNonSpace", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('^')
});
parser.registerAction(MappingMode.NVO, "VimMotionFirstScreenNonSpace", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut("g^")
});
parser
.registerAction(MappingMode.NVO, "VimMotionFirstScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut[]{
new Shortcut('H'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, KeyEvent.CTRL_MASK))
});
parser
.registerAction(MappingMode.NVO, "VimMotionGotoLineFirst", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut[]{
new Shortcut("gg"),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, KeyEvent.CTRL_MASK))
});
parser
.registerAction(MappingMode.NVO, "VimMotionGotoLineLast", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut('G'));
parser
.registerAction(MappingMode.NVO, "VimMotionGotoLineLastEnd", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.NVO, "VimMotionLastColumn", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE, new Shortcut[]{
new Shortcut('$'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0))
});
parser.registerAction(MappingMode.NVO, "VimMotionLastScreenColumn", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE, new Shortcut[]{
new Shortcut("g$"),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('g'), KeyStroke.getKeyStroke(KeyEvent.VK_END, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionLastMatchChar", Command.Type.MOTION,
new Shortcut(';'));
parser.registerAction(MappingMode.NVO, "VimMotionLastMatchCharReverse", Command.Type.MOTION,
new Shortcut(','));
parser.registerAction(MappingMode.NVO, "VimMotionLastNonSpace", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("g_"));
parser
.registerAction(MappingMode.NVO, "VimMotionLastScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut('L'));
parser.registerAction(MappingMode.NVO, "VimMotionLastScreenLineEnd", Command.Type.MOTION,
Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.NVO, "VimMotionLeft", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('h'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0))
});
parser.registerAction(MappingMode.NVO, "VimMotionLeftMatchChar", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_ALLOW_DIGRAPH,
new Shortcut('F'), Argument.Type.DIGRAPH);
parser.registerAction(MappingMode.NVO, "VimMotionLeftTillMatchChar", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_ALLOW_DIGRAPH,
new Shortcut('T'), Argument.Type.DIGRAPH);
parser.registerAction(MappingMode.NVO, "VimMotionLeftWrap", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionMiddleColumn", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("gm"));
parser.registerAction(MappingMode.NVO, "VimMotionMiddleScreenLine", Command.Type.MOTION,
Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut('M'));
parser
.registerAction(MappingMode.NVO, "VimMotionNthCharacter", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("go"));
// This represents two commands and one is linewise and the other is inclusive - the handler will fix it
parser.registerAction(MappingMode.NVO, "VimMotionPercentOrMatch", Command.Type.MOTION, Command.FLAG_SAVE_JUMP,
new Shortcut('%'));
parser.registerAction(MappingMode.NVO, "VimMotionRight", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('l'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0))
});
parser.registerAction(MappingMode.NVO, "VimMotionRightMatchChar", Command.Type.MOTION,
Command.FLAG_MOT_INCLUSIVE | Command.FLAG_ALLOW_DIGRAPH,
new Shortcut('f'), Argument.Type.DIGRAPH);
parser.registerAction(MappingMode.NVO, "VimMotionRightTillMatchChar", Command.Type.MOTION,
Command.FLAG_MOT_INCLUSIVE | Command.FLAG_ALLOW_DIGRAPH,
new Shortcut('t'), Argument.Type.DIGRAPH);
parser.registerAction(MappingMode.NVO, "VimMotionRightWrap", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut(' '));
parser.registerAction(MappingMode.NVO, "VimMotionScrollFirstScreenLine", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("zt")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollFirstScreenColumn", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("zs")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollFirstScreenLineStart", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('z'), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollFirstScreenLinePageStart", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("z+")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollHalfPageDown", Command.Type.OTHER_READONLY, Command.FLAG_IGNORE_SCROLL_JUMP,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.NVO, "VimMotionScrollHalfPageUp", Command.Type.OTHER_READONLY, Command.FLAG_IGNORE_SCROLL_JUMP,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.NVO, "VimMotionScrollLastScreenLine", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("zb")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollLastScreenColumn", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("ze")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollLastScreenLineStart", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("z-")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollLastScreenLinePageStart", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("z^")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollLineDown", Command.Type.OTHER_READONLY,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.NVO, "VimMotionScrollLineUp", Command.Type.OTHER_READONLY,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.NVO, "VimMotionScrollMiddleScreenLine", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("zz")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollMiddleScreenLineStart", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut("z.")
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollColumnLeft", Command.Type.OTHER_READONLY, Command.FLAG_IGNORE_SIDE_SCROLL_JUMP,
new Shortcut[]{
new Shortcut("zl"),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('z'), KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollColumnRight", Command.Type.OTHER_READONLY, Command.FLAG_IGNORE_SIDE_SCROLL_JUMP,
new Shortcut[]{
new Shortcut("zh"),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('z'), KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollPageDown", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0))
});
parser.registerAction(MappingMode.NVO, "VimMotionScrollPageUp", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionUp", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
new Shortcut('k'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)),
});
parser.registerAction(MappingMode.NVO, "VimMotionUp", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut("gk"),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke('g'), KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)})
});
parser.registerAction(MappingMode.NVO, "VimMotionUpFirstNonSpace", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE,
new Shortcut('-'));
parser.registerAction(MappingMode.NVO, "VimMotionWordEndLeft", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("ge"));
parser.registerAction(MappingMode.NVO, "VimMotionWordEndRight", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut('e'));
parser.registerAction(MappingMode.NVO, "VimMotionWordLeft", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('b'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionWordRight", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('w'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionBigWordEndLeft", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut("gE"));
parser.registerAction(MappingMode.NVO, "VimMotionBigWordEndRight", Command.Type.MOTION, Command.FLAG_MOT_INCLUSIVE,
new Shortcut('E'));
parser.registerAction(MappingMode.NVO, "VimMotionBigWordLeft", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('B'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionBigWordRight", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
new Shortcut('W'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK))
});
parser.registerAction(MappingMode.NVO, "VimMotionSentenceStartPrevious", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('('));
parser.registerAction(MappingMode.NVO, "VimMotionSentenceStartNext", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut(')'));
parser.registerAction(MappingMode.NVO, "VimMotionSentenceEndPrevious", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("g("));
parser.registerAction(MappingMode.NVO, "VimMotionSentenceEndNext", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("g)"));
parser.registerAction(MappingMode.NVO, "VimMotionParagraphPrevious", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('{'));
parser
.registerAction(MappingMode.NVO, "VimMotionParagraphNext", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('}'));
parser.registerAction(MappingMode.NVO, "VimMotionUnmatchedBraceOpen", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("[{"));
parser.registerAction(MappingMode.NVO, "VimMotionUnmatchedBraceClose", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("]}"));
parser.registerAction(MappingMode.NVO, "VimMotionUnmatchedParenOpen", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("[("));
parser.registerAction(MappingMode.NVO, "VimMotionUnmatchedParenClose", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("])"));
parser.registerAction(MappingMode.NVO, "VimMotionSectionBackwardEnd", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("[]"));
parser.registerAction(MappingMode.NVO, "VimMotionSectionBackwardStart", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("[["));
parser.registerAction(MappingMode.NVO, "VimMotionSectionForwardEnd", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("]]"));
parser.registerAction(MappingMode.NVO, "VimMotionSectionForwardStart", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("]["));
parser.registerAction(MappingMode.NVO, "VimMotionMethodBackwardEnd", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("[M"));
parser.registerAction(MappingMode.NVO, "VimMotionMethodBackwardStart", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("[m"));
parser.registerAction(MappingMode.NVO, "VimMotionMethodForwardEnd", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("]M"));
parser.registerAction(MappingMode.NVO, "VimMotionMethodForwardStart", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("]m"));
// Misc Actions
parser.registerAction(MappingMode.NVO, "VimSearchFwdEntry", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SEARCH_FWD | Command.FLAG_SAVE_JUMP,
new Shortcut('/'), Argument.Type.EX_STRING);
parser.registerAction(MappingMode.NVO, "VimSearchRevEntry", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SEARCH_REV | Command.FLAG_SAVE_JUMP,
new Shortcut('?'), Argument.Type.EX_STRING);
parser.registerAction(MappingMode.NVO, "VimSearchAgainNext", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('n'));
parser
.registerAction(MappingMode.NVO, "VimSearchAgainPrevious", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('N'));
parser.registerAction(MappingMode.NVO, "VimExEntry", Command.Type.OTHER_READ_WRITE,
new Shortcut(':'));
parser.registerAction(MappingMode.NVO, "VimSearchWholeWordForward", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('*'));
parser.registerAction(MappingMode.NVO, "VimSearchWholeWordBackward", Command.Type.MOTION,
Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('#'));
parser
.registerAction(MappingMode.NVO, "VimSearchWordForward", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("g*"));
parser
.registerAction(MappingMode.NVO, "VimSearchWordBackward", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut("g#"));
}
private static void registerNormalModeActions() {
final KeyGroup parser = VimPlugin.getKey();
// Copy/Paste Actions
parser.registerAction(MappingMode.N, "VimCopyPutTextBeforeCursor", Command.Type.PASTE,
new Shortcut('P'));
parser.registerAction(MappingMode.N, "VimCopyPutTextAfterCursor", Command.Type.PASTE,
new Shortcut('p'));
parser.registerAction(MappingMode.N, "VimCopyPutTextBeforeCursorMoveCursor", Command.Type.PASTE,
new Shortcut("gP"));
parser.registerAction(MappingMode.N, "VimCopyPutTextAfterCursorMoveCursor", Command.Type.PASTE,
new Shortcut("gp"));
parser.registerAction(MappingMode.N, "VimCopyPutTextBeforeCursorNoIndent", Command.Type.PASTE, new Shortcut[]{
new Shortcut("[P"),
new Shortcut("]P")
});
parser.registerAction(MappingMode.N, "VimCopyPutTextAfterCursorNoIndent", Command.Type.PASTE, new Shortcut[]{
new Shortcut("[p"),
new Shortcut("]p")
});
parser.registerAction(MappingMode.N, "VimCopyYankLine", Command.Type.COPY,
new Shortcut('Y'));
parser.registerAction(MappingMode.N, "VimCopyYankLine", Command.Type.COPY, Command.FLAG_ALLOW_MID_COUNT,
new Shortcut("yy"));
parser.registerAction(MappingMode.N, "VimCopyYankMotion", Command.Type.COPY, Command.FLAG_OP_PEND,
new Shortcut('y'), Argument.Type.MOTION);
// Insert/Replace/Change Actions
parser.registerAction(MappingMode.N, "VimChangeCaseLowerMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND,
new Shortcut("gu"), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeCaseToggleCharacter", Command.Type.CHANGE,
new Shortcut('~'));
parser.registerAction(MappingMode.N, "VimChangeCaseToggleMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND,
new Shortcut("g~"), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeCaseUpperMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND,
new Shortcut("gU"), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeCharacter", Command.Type.CHANGE, Command.FLAG_ALLOW_DIGRAPH,
new Shortcut('r'), Argument.Type.DIGRAPH);
parser
.registerAction(MappingMode.N, "VimChangeCharacters", Command.Type.CHANGE, Command.FLAG_NO_REPEAT | Command.FLAG_MULTIKEY_UNDO,
new Shortcut('s'));
parser
.registerAction(MappingMode.N, "VimChangeEndOfLine", Command.Type.CHANGE, Command.FLAG_NO_REPEAT | Command.FLAG_MULTIKEY_UNDO,
new Shortcut('C'));
parser.registerAction(MappingMode.N, "VimChangeLine", Command.Type.CHANGE,
Command.FLAG_NO_REPEAT | Command.FLAG_ALLOW_MID_COUNT | Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
new Shortcut("cc"),
new Shortcut('S')
});
parser.registerAction(MappingMode.N, "VimChangeNumberInc", Command.Type.CHANGE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.N, "VimChangeNumberDec", Command.Type.CHANGE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.N, "VimChangeMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND | Command.FLAG_MULTIKEY_UNDO,
new Shortcut('c'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimChangeReplace", Command.Type.CHANGE, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('R'));
parser.registerAction(MappingMode.N, "VimDeleteCharacter", Command.Type.DELETE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)));
parser.registerAction(MappingMode.N, "VimDeleteCharacterLeft", Command.Type.DELETE,
new Shortcut('X'));
parser.registerAction(MappingMode.N, "VimDeleteCharacterRight", Command.Type.DELETE,
new Shortcut('x'));
parser.registerAction(MappingMode.N, "VimDeleteEndOfLine", Command.Type.DELETE,
new Shortcut('D'));
parser.registerAction(MappingMode.N, "VimDeleteJoinLines", Command.Type.DELETE,
new Shortcut("gJ"));
parser.registerAction(MappingMode.N, "VimDeleteJoinLinesSpaces", Command.Type.DELETE,
new Shortcut('J'));
parser.registerAction(MappingMode.N, "VimDeleteLine", Command.Type.DELETE, Command.FLAG_ALLOW_MID_COUNT,
new Shortcut("dd"));
parser.registerAction(MappingMode.N, "VimDeleteMotion", Command.Type.DELETE, Command.FLAG_OP_PEND,
new Shortcut('d'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimFilterCountLines", Command.Type.CHANGE,
new Shortcut("!!"));
parser.registerAction(MappingMode.N, "VimFilterMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND,
new Shortcut('!'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimInsertAfterCursor", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('a'));
parser.registerAction(MappingMode.N, "VimInsertAfterLineEnd", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('A'));
parser.registerAction(MappingMode.N, "VimInsertAtPreviousInsert", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut("gi"));
parser.registerAction(MappingMode.N, "VimInsertBeforeFirstNonBlank", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('I'));
parser.registerAction(MappingMode.N, "VimInsertLineStart", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut("gI"));
parser.registerAction(MappingMode.N, "VimInsertNewLineAbove", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('O'));
parser.registerAction(MappingMode.N, "VimInsertNewLineBelow", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('o'));
// Motion Actions
parser
.registerAction(MappingMode.N, "VimMotionGotoMark", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE | Command.FLAG_SAVE_JUMP,
new Shortcut('`'), Argument.Type.CHARACTER);
parser
.registerAction(MappingMode.N, "VimMotionGotoMarkLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
new Shortcut('\''), Argument.Type.CHARACTER);
parser.registerAction(MappingMode.N, "VimMotionGotoMark", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut("g`"), Argument.Type.CHARACTER);
parser.registerAction(MappingMode.N, "VimMotionGotoMarkLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE,
new Shortcut("g'"), Argument.Type.CHARACTER);
// Misc Actions
parser.registerAction(MappingMode.N, "VimLastSearchReplace", Command.Type.OTHER_WRITABLE,
new Shortcut('&'));
parser.registerAction(MappingMode.N, "VimLastGlobalSearchReplace", Command.Type.OTHER_WRITABLE,
new Shortcut("g&"));
parser.registerAction(MappingMode.N, "VimVisualSelectPrevious", Command.Type.OTHER_READONLY,
new Shortcut("gv"));
parser.registerAction(MappingMode.N, "VimRepeatChange", Command.Type.OTHER_WRITABLE,
new Shortcut('.'));
parser.registerAction(MappingMode.N, "VimRepeatExCommand", Command.Type.OTHER_WRITABLE,
new Shortcut("@:"));
parser.registerAction(MappingMode.N, "QuickJavaDoc", Command.Type.OTHER_READONLY,
new Shortcut('K'));
parser.registerAction(MappingMode.N, "VimRedo", Command.Type.OTHER_WRITABLE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.N, "VimUndo", Command.Type.OTHER_WRITABLE, new Shortcut[]{
new Shortcut('u'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UNDO, 0))
});
// File Actions
parser.registerAction(MappingMode.N, "VimFileSaveClose", Command.Type.OTHER_WRITABLE, new Shortcut[]{
new Shortcut("ZQ"),
new Shortcut("ZZ")
});
parser.registerAction(MappingMode.N, "VimFilePrevious", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_6, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_CIRCUMFLEX, KeyEvent.CTRL_MASK))
});
// Shift Actions
// TODO - add =
// TODO - == will ignore count and only auto-indent 1 lines
parser.registerAction(MappingMode.N, "VimAutoIndentLines", Command.Type.CHANGE,
new Shortcut("=="));
parser.registerAction(MappingMode.N, "VimShiftLeftLines", Command.Type.CHANGE,
new Shortcut("<<"));
parser.registerAction(MappingMode.N, "VimShiftLeftMotion", Command.Type.CHANGE,
new Shortcut('<'), Argument.Type.MOTION);
parser.registerAction(MappingMode.N, "VimShiftRightLines", Command.Type.CHANGE,
new Shortcut(">>"));
parser.registerAction(MappingMode.N, "VimShiftRightMotion", Command.Type.CHANGE,
new Shortcut('>'), Argument.Type.MOTION);
// Jump Actions
parser.registerAction(MappingMode.N, "VimMotionJumpNext", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))
});
parser.registerAction(MappingMode.N, "VimMotionJumpPrevious", Command.Type.OTHER_READONLY,
new Shortcut[] {
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)),
// TODO: <C-T> is a tag command similar to <C-O>, the tag stack is not implemented
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK))
});
parser.registerAction(MappingMode.N, "VimFileGetAscii", Command.Type.OTHER_READONLY,
new Shortcut("ga"));
parser.registerAction(MappingMode.N, "VimFileGetHex", Command.Type.OTHER_READONLY,
new Shortcut("g8"));
parser.registerAction(MappingMode.N, "VimFileGetFileInfo", Command.Type.OTHER_READONLY,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)));
// Window Actions
// TODO - CTRL-W commands: +, -, =, S, s, _, b, c, n, o, q, s, t, <up>, <down>
// Macro Actions
parser.registerAction(MappingMode.N, "VimPlaybackLastRegister", Command.Type.OTHER_WRITABLE,
new Shortcut("@@"));
parser.registerAction(MappingMode.N, "VimPlaybackRegister", Command.Type.OTHER_WRITABLE,
new Shortcut('@'), Argument.Type.CHARACTER);
// TODO - support for :map macros
}
private static void registerVisualModeActions() {
final KeyGroup parser = VimPlugin.getKey();
parser.registerAction(MappingMode.V, "VimAutoIndentVisual", Command.Type.CHANGE,
Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE,
new Shortcut('='));
parser.registerAction(MappingMode.V, "VimReformatVisual", Command.Type.CHANGE,
Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE,
new Shortcut("gq"));
parser.registerAction(MappingMode.V, "VimChangeCaseLowerVisual", Command.Type.CHANGE,
new Shortcut('u'));
parser.registerAction(MappingMode.V, "VimChangeCaseToggleVisual", Command.Type.CHANGE,
new Shortcut('~'));
parser.registerAction(MappingMode.V, "VimChangeCaseUpperVisual", Command.Type.CHANGE,
new Shortcut('U'));
parser.registerAction(MappingMode.V, "VimChangeVisual", Command.Type.CHANGE, Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
new Shortcut('c'),
new Shortcut('s')
});
parser.registerAction(MappingMode.V, "VimChangeVisualCharacter", Command.Type.CHANGE, Command.FLAG_ALLOW_DIGRAPH,
new Shortcut('r'), Argument.Type.DIGRAPH);
parser.registerAction(MappingMode.V, "VimChangeVisualLines", Command.Type.CHANGE,
Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
new Shortcut('R'),
new Shortcut('S')
});
parser.registerAction(MappingMode.V, "VimChangeVisualLinesEnd", Command.Type.CHANGE,
Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO, new Shortcut[]{
new Shortcut('C')
});
parser.registerAction(MappingMode.V, "VimCopyYankVisual", Command.Type.COPY,
new Shortcut('y'));
parser.registerAction(MappingMode.V, "VimCopyYankVisualLines", Command.Type.COPY, Command.FLAG_MOT_LINEWISE,
new Shortcut('Y'));
parser.registerAction(MappingMode.V, "VimDeleteJoinVisualLines", Command.Type.DELETE,
new Shortcut("gJ"));
parser.registerAction(MappingMode.V, "VimDeleteJoinVisualLinesSpaces", Command.Type.DELETE,
new Shortcut('J'));
parser.registerAction(MappingMode.V, "VimDeleteVisual", Command.Type.DELETE, new Shortcut[]{
new Shortcut('d'),
new Shortcut('x'),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0))
});
parser.registerAction(MappingMode.V, "VimDeleteVisualLinesEnd", Command.Type.DELETE, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
new Shortcut('D')
});
parser.registerAction(MappingMode.V, "VimDeleteVisualLines", Command.Type.DELETE, Command.FLAG_MOT_LINEWISE, new Shortcut[]{
new Shortcut('X')
});
parser.registerAction(MappingMode.V, "VimFilterVisualLines", Command.Type.CHANGE, Command.FLAG_MOT_LINEWISE,
new Shortcut('!'));
parser.registerAction(MappingMode.V, "VimShiftLeftVisual", Command.Type.CHANGE,
new Shortcut('<'));
parser.registerAction(MappingMode.V, "VimShiftRightVisual", Command.Type.CHANGE,
new Shortcut('>'));
parser.registerAction(MappingMode.V, "VimVisualExitMode", Command.Type.OTHER_READONLY, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke('[', KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)),
new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, KeyEvent.CTRL_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)})
});
parser.registerAction(MappingMode.V, "VimVisualPutText", Command.Type.PASTE, new Shortcut[]{
new Shortcut('P'),
new Shortcut('p')
});
parser.registerAction(MappingMode.V, "VimVisualPutTextMoveCursor", Command.Type.PASTE, new Shortcut[]{
new Shortcut("gp"),
new Shortcut("gP")
});
parser.registerAction(MappingMode.V, "VimVisualPutTextNoIndent", Command.Type.PASTE, new Shortcut[]{
new Shortcut("[p"),
new Shortcut("]p"),
new Shortcut("[P"),
new Shortcut("]P")
});
parser.registerAction(MappingMode.V, "VimVisualBlockInsert", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('I'));
parser.registerAction(MappingMode.V, "VimVisualBlockAppend", Command.Type.INSERT, Command.FLAG_MULTIKEY_UNDO,
new Shortcut('A'));
parser.registerAction(MappingMode.V, "VimVisualSwapEnds", Command.Type.OTHER_READONLY,
new Shortcut('o'));
parser.registerAction(MappingMode.V, "VimVisualSwapEndsBlock", Command.Type.OTHER_READONLY,
new Shortcut('O'));
parser.registerAction(MappingMode.V, "VimVisualSwapSelections", Command.Type.OTHER_READONLY,
new Shortcut("gv"));
}
private static void registerInsertModeActions() {
final KeyGroup parser = VimPlugin.getKey();
// Other insert actions
parser
.registerAction(MappingMode.I, "EditorBackSpace", Command.Type.INSERT, Command.FLAG_IS_BACKSPACE,
new Shortcut[]{new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0))}
);
parser.registerAction(MappingMode.I, "EditorDelete", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)));
parser.registerAction(MappingMode.I, "EditorDown", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0))
});
parser.registerAction(MappingMode.I, "EditorTab", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))
});
parser.registerAction(MappingMode.I, "EditorUp", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0))
});
parser.registerAction(MappingMode.I, "VimInsertCharacterAboveCursor", Command.Type.INSERT,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimInsertCharacterBelowCursor", Command.Type.INSERT,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimInsertDeleteInsertedText", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimInsertDeletePreviousWord", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimInsertEnter", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0))
});
parser.registerAction(MappingMode.I, "VimInsertPreviousInsert", Command.Type.INSERT,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimInsertPreviousInsertExit", Command.Type.INSERT, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_AT, KeyEvent.CTRL_MASK))
});
parser.registerAction(MappingMode.I, "VimInsertRegister", Command.Type.INSERT,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK)),
Argument.Type.CHARACTER);
parser.registerAction(MappingMode.I, "VimInsertReplaceToggle", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0)));
parser.registerAction(MappingMode.I, "VimInsertSingleCommand", Command.Type.INSERT,
Command.FLAG_CLEAR_STROKES | Command.FLAG_EXPECT_MORE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimMotionFirstColumn", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0)));
parser.registerAction(MappingMode.I, "VimMotionGotoLineFirst", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimMotionGotoLineLastEnd", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimMotionLastColumn", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0)));
parser.registerAction(MappingMode.I, "VimMotionLeft", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0))
});
parser.registerAction(MappingMode.I, "VimMotionRight", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0))
});
parser.registerAction(MappingMode.I, "VimMotionScrollPageUp", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.I, "VimMotionScrollPageDown", Command.Type.INSERT, Command.FLAG_CLEAR_STROKES, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.I, "VimMotionWordLeft", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.I, "VimMotionWordRight", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, KeyEvent.CTRL_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.SHIFT_MASK)),
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, KeyEvent.SHIFT_MASK))
});
parser.registerAction(MappingMode.I, "VimShiftLeftLines", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)));
parser.registerAction(MappingMode.I, "VimShiftRightLines", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK)));
}
}

View File

@@ -1,222 +0,0 @@
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.application.ApplicationManager;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
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.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
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 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 (!ApplicationManager.getApplication().isUnitTestMode()) {
// Prompt user to select the parent for the Vim keyboard
configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH, document, true);
}
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);
}
private static void requestRestartOrShutdown(final Project project) {
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
if (app.isRestartCapable()) {
if (Messages.showDialog(project, "Restart " + ApplicationNamesInfo.getInstance().getProductName() + " to activate changes?",
VimPlugin.IDEAVIM_NOTIFICATION_TITLE, new String[]{"&Restart", "&Postpone"}, 0,
Messages.getQuestionIcon()) == 0) {
app.restart();
}
} else {
if (Messages.showDialog(project, "Shut down " + ApplicationNamesInfo.getInstance().getProductName() + " to activate changes?",
VimPlugin.IDEAVIM_NOTIFICATION_TITLE, new String[]{"&Shut Down", "&Postpone"}, 0,
Messages.getQuestionIcon()) == 0) {
app.exit(true);
}
}
}
/**
* 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 {
final Element rootElement = document.getRootElement();
final String parentKeymap = rootElement.getAttributeValue("parent");
final VimKeymapDialog vimKeymapDialog = new VimKeymapDialog(parentKeymap);
vimKeymapDialog.show();
if (vimKeymapDialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return false;
}
rootElement.removeAttribute("parent");
final Keymap selectedKeymap = vimKeymapDialog.getSelectedKeymap();
final String keymapName = selectedKeymap.getName();
rootElement.setAttribute("parent", keymapName);
VimPlugin.getInstance().setPreviousKeyMap(keymapName);
VimKeymapConflictResolveUtil.resolveConflicts(rootElement, selectedKeymap);
// 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 " +
selectedKeymap.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));
}
@Nullable
public static VirtualFile getVimKeymapFile() {
return LocalFileSystem.getInstance().refreshAndFindFileByPath(INSTALLED_VIM_KEYMAP_PATH);
}
}

View File

@@ -1,217 +0,0 @@
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()));
}
}
private 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;
overridesAction
.addContent(createShortcutElement(KEYBOARD_SHORTCUT_TAG, FIRST_KEYSTROKE_ATTRIBUTE, KeymapImpl.getKeyShortcutString(keyboardShortcut.getFirstKeyStroke())));
}
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();
}
}

View File

@@ -1,24 +1,23 @@
/* /*
* Copyright 2000-2011 JetBrains s.r.o. * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2014 The IdeaVim authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * This program is free software: you can redistribute it and/or modify
* you may not use this file except in compliance with the License. * it under the terms of the GNU General Public License as published by
* You may obtain a copy of the License at * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* *
* http://www.apache.org/licenses/LICENSE-2.0 * 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.
* *
* Unless required by applicable law or agreed to in writing, software * You should have received a copy of the GNU General Public License
* distributed under the License is distributed on an "AS IS" BASIS, * along with this program. If not, see <http://www.gnu.org/licenses/>.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package com.maddyhome.idea.vim; package com.maddyhome.idea.vim;
import com.intellij.notification.Notification; import com.intellij.notification.*;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.application.Application; import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.application.ex.ApplicationEx;
@@ -36,7 +35,12 @@ import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.openapi.editor.event.EditorFactoryAdapter; import com.intellij.openapi.editor.event.EditorFactoryAdapter;
import com.intellij.openapi.editor.event.EditorFactoryEvent; import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
import com.intellij.openapi.keymap.impl.DefaultKeymap;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerAdapter; import com.intellij.openapi.project.ProjectManagerAdapter;
@@ -46,19 +50,22 @@ import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.WindowManager;
import com.maddyhome.idea.vim.command.CommandState; import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.ex.CommandParser; 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.group.*;
import com.maddyhome.idea.vim.helper.*; import com.maddyhome.idea.vim.helper.*;
import com.maddyhome.idea.vim.key.RegisterActions;
import com.maddyhome.idea.vim.option.Options; import com.maddyhome.idea.vim.option.Options;
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
import org.jdom.Element; import org.jdom.Element;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import java.awt.*; import java.awt.*;
import java.io.File;
/** /**
* This plugin attempts to emulate the keybinding and general functionality of Vim and gVim. See the supplied * This plugin attempts to emulate the key binding and general functionality of Vim and gVim. See the supplied
* documentation for a complete list of supported and unsupported Vim emulation. The code base contains some debugging * documentation for a complete list of supported and unsupported Vim emulation. The code base contains some debugging
* output that can be enabled in necessary. * output that can be enabled in necessary.
* <p/> * <p/>
@@ -68,27 +75,23 @@ import java.awt.*;
* @version 0.1 * @version 0.1
*/ */
@State( @State(
name = "VimSettings", name = "VimSettings",
storages = { storages = {@Storage(
@Storage( id = "main",
id = "main", file = "$APP_CONFIG$/vim_settings.xml")})
file = "$APP_CONFIG$/vim_settings.xml" public class VimPlugin implements ApplicationComponent, PersistentStateComponent<Element> {
)}
)
public class VimPlugin implements ApplicationComponent, PersistentStateComponent<Element>
{
private static final String IDEAVIM_COMPONENT_NAME = "VimPlugin"; 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_NOTIFICATION_ID = "ideavim";
public static final String IDEAVIM_STICKY_NOTIFICATION_ID = "ideavim-sticky";
public static final String IDEAVIM_NOTIFICATION_TITLE = "IdeaVim"; public static final String IDEAVIM_NOTIFICATION_TITLE = "IdeaVim";
public static final int STATE_VERSION = 2; public static final int STATE_VERSION = 3;
private static final boolean BLOCK_CURSOR_VIM_VALUE = true; private static final boolean BLOCK_CURSOR_VIM_VALUE = true;
private static final boolean ANIMATED_SCROLLING_VIM_VALUE = false; private static final boolean ANIMATED_SCROLLING_VIM_VALUE = false;
private static final boolean REFRAIN_FROM_SCROLLING_VIM_VALUE = true; private static final boolean REFRAIN_FROM_SCROLLING_VIM_VALUE = true;
private VimTypedActionHandler vimHandler; private VimTypedActionHandler vimHandler;
private RegisterActions actions;
private boolean isBlockCursor = false; private boolean isBlockCursor = false;
private boolean isAnimatedScrolling = false; private boolean isAnimatedScrolling = false;
private boolean isRefrainFromScrolling = false; private boolean isRefrainFromScrolling = false;
@@ -104,48 +107,53 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
private final Application myApp; private final Application myApp;
private MotionGroup motion;
private ChangeGroup change;
private CopyGroup copy;
private MarkGroup mark;
private RegisterGroup register;
private FileGroup file;
private SearchGroup search;
private ProcessGroup process;
private MacroGroup macro;
private DigraphGroup digraph;
private HistoryGroup history;
private KeyGroup key;
/**
* Creates the Vim Plugin
*/
public VimPlugin(final Application app) { public VimPlugin(final Application app) {
myApp = 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"); LOG.debug("VimPlugin ctr");
} }
@NotNull @NotNull
public static VimPlugin getInstance() { @Override
return (VimPlugin)ApplicationManager.getApplication().getComponent(IDEAVIM_COMPONENT_NAME);
}
/**
* Supplies the name of the plugin
*
* @return The plugin name
*/
@NotNull
public String getComponentName() { public String getComponentName() {
return IDEAVIM_COMPONENT_NAME; return IDEAVIM_COMPONENT_NAME;
} }
public String getPreviousKeyMap() { @Override
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.
*/
public void initComponent() { public void initComponent() {
LOG.debug("initComponent"); LOG.debug("initComponent");
Notifications.Bus.register(IDEAVIM_STICKY_NOTIFICATION_ID, NotificationDisplayType.STICKY_BALLOON);
ApplicationManager.getApplication().invokeLater(new Runnable() { ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() { public void run() {
updateState(); updateState();
checkAndInstallKeymap();
} }
}); });
@@ -156,136 +164,26 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
vimHandler = new VimTypedActionHandler(action.getHandler()); vimHandler = new VimTypedActionHandler(action.getHandler());
action.setupHandler(vimHandler); action.setupHandler(vimHandler);
// Register vim actions in command mode
RegisterActions.registerActions();
// Add some listeners so we can handle special events // Add some listeners so we can handle special events
setupListeners(); setupListeners();
getActions(); // Register ex handlers
CommandParser.getInstance().registerHandlers();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
final File vimrc = VimScriptParser.findVimrc();
if (vimrc != null) {
VimScriptParser.executeFile(vimrc);
}
}
LOG.debug("done"); LOG.debug("done");
} }
private void updateState() { @Override
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
boolean requiresRestart = false;
if (previousStateVersion < 1 && 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) && !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
*/
public void disposeComponent() { public void disposeComponent() {
LOG.debug("disposeComponent"); LOG.debug("disposeComponent");
turnOffPlugin(); turnOffPlugin();
@@ -295,6 +193,26 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
LOG.debug("done"); 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 @Override
public void loadState(@NotNull final Element element) { public void loadState(@NotNull final Element element) {
LOG.debug("Loading state"); LOG.debug("Loading state");
@@ -311,30 +229,65 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
previousKeyMap = state.getAttributeValue("keymap"); 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 static MotionGroup getMotion() {
public Element getState() { return getInstance().motion;
LOG.debug("Saving state"); }
final Element element = new Element("ideavim"); public static ChangeGroup getChange() {
// Save whether the plugin is enabled or not return getInstance().change;
final Element state = new Element("state"); }
state.setAttribute("version", Integer.toString(STATE_VERSION));
state.setAttribute("enabled", Boolean.toString(enabled)); public static CopyGroup getCopy() {
state.setAttribute("keymap", previousKeyMap); return getInstance().copy;
element.addContent(state); }
CommandGroups.getInstance().saveData(element); public static MarkGroup getMark() {
return element; return getInstance().mark;
}
public static RegisterGroup getRegister() {
return getInstance().register;
}
public static FileGroup getFile() {
return getInstance().file;
}
public static SearchGroup getSearch() {
return getInstance().search;
}
public static ProcessGroup getProcess() {
return getInstance().process;
}
public static MacroGroup getMacro() {
return getInstance().macro;
}
public static DigraphGroup getDigraph() {
return getInstance().digraph;
}
public static HistoryGroup getHistory() {
return getInstance().history;
}
public static KeyGroup getKey() {
return getInstance().key;
}
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() { public static boolean isEnabled() {
return getInstance().enabled; return getInstance().enabled;
} }
@@ -349,12 +302,14 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
if (enabled) { if (enabled) {
getInstance().turnOnPlugin(); getInstance().turnOnPlugin();
} }
}
VimKeyMapUtil.switchKeymapBindings(enabled); public static boolean isError() {
return getInstance().error;
} }
/** /**
* Inidicate to the user that an error has occurred. Just beep. * Indicate to the user that an error has occurred. Just beep.
*/ */
public static void indicateError() { public static void indicateError() {
if (ApplicationManager.getApplication().isUnitTestMode()) { if (ApplicationManager.getApplication().isUnitTestMode()) {
@@ -365,15 +320,21 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
} }
} }
public static void clearError() {
if (ApplicationManager.getApplication().isUnitTestMode()) {
getInstance().error = false;
}
}
public static void showMode(String msg) { public static void showMode(String msg) {
showMessage(msg); showMessage(msg);
} }
public static void showMessage(@Nullable String msg) { public static void showMessage(@Nullable String msg) {
ProjectManager pm = ProjectManager.getInstance(); ProjectManager pm = ProjectManager.getInstance();
Project[] projs = pm.getOpenProjects(); Project[] projects = pm.getOpenProjects();
for (Project proj : projs) { for (Project project : projects) {
StatusBar bar = WindowManager.getInstance().getStatusBar(proj); StatusBar bar = WindowManager.getInstance().getStatusBar(project);
if (bar != null) { if (bar != null) {
if (msg == null || msg.length() == 0) { if (msg == null || msg.length() == 0) {
bar.setInfo(""); bar.setInfo("");
@@ -385,22 +346,145 @@ 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); KeyHandler.getInstance().fullReset(null);
setCursors(BLOCK_CURSOR_VIM_VALUE); setCursors(BLOCK_CURSOR_VIM_VALUE);
setAnimatedScrolling(ANIMATED_SCROLLING_VIM_VALUE); setAnimatedScrolling(ANIMATED_SCROLLING_VIM_VALUE);
setRefrainFromScrolling(REFRAIN_FROM_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); KeyHandler.getInstance().fullReset(null);
setCursors(isBlockCursor); setCursors(isBlockCursor);
setAnimatedScrolling(isAnimatedScrolling); setAnimatedScrolling(isAnimatedScrolling);
setRefrainFromScrolling(isRefrainFromScrolling); 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 < 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 .vimrc 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 (requiresRestart) {
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
app.restart();
}
}
}
/**
* 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() {
@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);
// 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() {
@Override
public void projectOpened(@NotNull final Project project) {
project.getMessageBus().connect()
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MotionGroup.MotionEditorChange());
project.getMessageBus().connect()
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileGroup.SelectionCheck());
project.getMessageBus().connect()
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new SearchGroup.EditorSelectionCheck());
}
@Override
public void projectClosed(final Project project) {
}
});
CommandProcessor.getInstance().addCommandListener(DelegateCommandListener.getInstance());
} }
private void setCursors(boolean isBlock) { private void setCursors(boolean isBlock) {
@@ -425,25 +509,4 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
editor.getSettings().setRefrainFromScrolling(isOn); editor.getSettings().setRefrainFromScrolling(isOn);
} }
} }
private RegisterActions getActions() {
if (actions == null) {
// Register vim actions in command mode
actions = RegisterActions.getInstance();
// Register ex handlers
CommandParser.getInstance().registerHandlers();
}
return actions;
}
public boolean isError() {
return error;
}
public static void clearError() {
if (ApplicationManager.getApplication().isUnitTestMode()) {
getInstance().error = false;
}
}
} }

View File

@@ -1,23 +0,0 @@
package com.maddyhome.idea.vim;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.NotNull;
/**
* This action allows to reconfigure base parent keymap for the Vim keymap
* @author oleg
*/
public class VimReconfigureKeymapAction extends AnAction implements DumbAware {
@Override
public void update(@NotNull final AnActionEvent e) {
e.getPresentation().setEnabled(VimPlugin.isEnabled());
}
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
VimKeyMapUtil.installKeyBoardBindings();
VimKeyMapUtil.switchKeymapBindings(true);
}
}

View File

@@ -1,80 +0,0 @@
package com.maddyhome.idea.vim;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
public class VimSettings {
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public HashSet getChoices() {
return choices;
}
public void setChoices(HashSet choices) {
this.choices = choices;
}
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final VimSettings that = (VimSettings)o;
if (enabled != that.enabled) {
return false;
}
return choices.equals(that.choices);
}
public int hashCode() {
int result;
result = (enabled ? 1 : 0);
result = 29 * result + choices.hashCode();
return result;
}
@NotNull
public String toString() {
final StringBuffer sb = new StringBuffer();
sb.append("VimSettings");
sb.append("{enabled=").append(enabled);
sb.append(", choices=").append(choices);
sb.append('}');
return sb.toString();
}
private boolean enabled;
private HashSet choices = new HashSet();
}

View File

@@ -1,25 +1,24 @@
package com.maddyhome.idea.vim;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
import com.intellij.codeInsight.lookup.LookupEx; package com.maddyhome.idea.vim;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diagnostic.Logger;
@@ -30,61 +29,52 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*; 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 { public class VimTypedActionHandler implements TypedActionHandler {
/** private static Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
* Creates an instance of the key handler
* private TypedActionHandler origHandler;
* @param origHandler The original key handler private KeyHandler handler;
*/
public VimTypedActionHandler(TypedActionHandler origHandler) { public VimTypedActionHandler(TypedActionHandler origHandler) {
this.origHandler = origHandler; this.origHandler = origHandler;
handler = KeyHandler.getInstance(); handler = KeyHandler.getInstance();
handler.setOriginalHandler(origHandler); handler.setOriginalHandler(origHandler);
} }
/** @Override
* Gives the original key handler public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext context) {
* if (isEnabled(editor)) {
* @return The original key handler // Run key handler outside of the key typed command for creating our own undoable commands
*/ SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), context);
}
catch (Throwable e) {
logger.error(e);
}
}
});
}
else {
origHandler.execute(editor, charTyped, context);
}
}
public TypedActionHandler getOriginalTypedHandler() { public TypedActionHandler getOriginalTypedHandler() {
return origHandler; return origHandler;
} }
/** private boolean isEnabled(@NotNull Editor editor) {
* All characters typed into an editor will get sent to this handler. Only letters, numbers, and punctuation if (VimPlugin.isEnabled()) {
* are sent here. Keys like Tab, Enter, Home, Backspace, etc. and all Control-Letter etc. argType keys are not final Lookup lookup = LookupManager.getActiveLookup(editor);
* sent by Idea to this handler. return lookup == null || !lookup.isFocused();
*
* @param editor The editor the character was typed into
* @param charTyped The character that was typed
* @param context The data context
*/
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;
}
try {
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), context);
}
catch (Throwable e) {
logger.error(e);
} }
return false;
} }
private TypedActionHandler origHandler;
private KeyHandler handler;
private static Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
} }

View File

@@ -1,49 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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());
}

View File

@@ -1,52 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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());
}

View File

@@ -1,28 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import com.intellij.openapi.actionSystem.AnAction;
public interface DelegateAction {
void setOrigAction(AnAction origAction);
AnAction getOrigAction();
}

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -35,9 +34,9 @@ public class ExEntryAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(@NotNull Editor editor, DataContext context, @NotNull Command cmd) { 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; return true;
} }

View File

@@ -1,34 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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);
}
}
}

View File

@@ -1,64 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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());
}

View File

@@ -1,65 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2006 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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 org.jetbrains.annotations.Nullable;
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(@Nullable Editor editor, @NotNull DataContext dataContext) {
if (logger.isDebugEnabled()) {
logger.debug("actionPerformed key=" + stroke);
}
if (editor == null || !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;
}
}

View File

@@ -1,32 +1,40 @@
package com.maddyhome.idea.vim.action;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
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.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 class ResetModeAction extends EditorAction {
public ResetModeAction() { public ResetModeAction() {
super(new ResetModeHandler()); super(new EditorActionHandler() {
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
KeyHandler.getInstance().fullReset(InjectedLanguageUtil.getTopLevelEditor(editor));
}
});
} }
} }

View File

@@ -1,36 +0,0 @@
package com.maddyhome.idea.vim.action;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diagnostic.Logger;
/**
*
*/
public class TxActionWrapper extends AbstractDelegateAction {
public void actionPerformed(AnActionEvent event) {
logger.debug("actionPerformed");
getOrigAction().actionPerformed(event);
}
private static Logger logger = Logger.getInstance(TxActionWrapper.class.getName());
}

View File

@@ -0,0 +1,69 @@
/*
* 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.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 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;
}
}

View File

@@ -1,8 +1,27 @@
package com.maddyhome.idea.vim; /*
* 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.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware; 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 * This class is used to handle the Vim Plugin enabled/disabled toggle. This is most likely used as a menu option

View File

@@ -0,0 +1,208 @@
/*
* 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.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
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 {
@NotNull public static 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, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
.addAll(getKeyStrokes(VK_PAGE_DOWN, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
.build();
@NotNull private static 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();
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));
}
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)) {
if (keyCode == VK_ENTER) {
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();
}
private static List<KeyStroke> getKeyStrokes(int keyCode, 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);
}
}

View File

@@ -1,29 +1,28 @@
package com.maddyhome.idea.vim.action.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.command.Command; 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 com.maddyhome.idea.vim.helper.UndoRedoHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -34,8 +33,8 @@ public class RedoAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(Editor editor, @NotNull DataContext context, Command cmd) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return UndoRedoHelper.redo(context); return UndoRedoHelper.redo(context);
} }
} }

View File

@@ -1,34 +1,33 @@
package com.maddyhome.idea.vim.action.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.KeyHandler; 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.Argument;
import com.maddyhome.idea.vim.command.Command; import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandState; 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.handler.AbstractEditorActionHandler; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.key.KeyParser;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -38,8 +37,8 @@ public class RepeatChangeAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
public boolean execute(Editor editor, @NotNull DataContext context, @NotNull Command command) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
CommandState state = CommandState.getInstance(editor); CommandState state = CommandState.getInstance(editor);
Command cmd = state.getLastChangeCommand(); Command cmd = state.getLastChangeCommand();
if (cmd != null) { if (cmd != null) {
@@ -55,9 +54,9 @@ public class RepeatChangeAction extends EditorAction {
} }
Command save = state.getCommand(); Command save = state.getCommand();
state.setCommand(cmd); state.setCommand(cmd);
state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, KeyParser.MAPPING_NORMAL); state.pushState(CommandState.Mode.REPEAT, CommandState.SubMode.NONE, MappingMode.NORMAL);
char reg = CommandGroups.getInstance().getRegister().getCurrentRegister(); char reg = VimPlugin.getRegister().getCurrentRegister();
CommandGroups.getInstance().getRegister().selectRegister(state.getLastChangeRegister()); VimPlugin.getRegister().selectRegister(state.getLastChangeRegister());
try { try {
KeyHandler.executeAction(cmd.getAction(), context); KeyHandler.executeAction(cmd.getAction(), context);
} }
@@ -65,9 +64,11 @@ public class RepeatChangeAction extends EditorAction {
// oops // oops
} }
state.popState(); state.popState();
state.setCommand(save); if (save != null) {
state.setCommand(save);
}
state.saveLastChangeCommand(cmd); state.saveLastChangeCommand(cmd);
CommandGroups.getInstance().getRegister().selectRegister(reg); VimPlugin.getRegister().selectRegister(reg);
return true; return true;
} }

View File

@@ -1,31 +1,30 @@
package com.maddyhome.idea.vim.action.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.command.Command; import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.ex.CommandParser; import com.maddyhome.idea.vim.ex.CommandParser;
import com.maddyhome.idea.vim.ex.ExException; 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; import org.jetbrains.annotations.NotNull;
/** /**
@@ -35,8 +34,8 @@ public class RepeatExCommandAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
public boolean execute(@NotNull Editor editor, DataContext context, @NotNull Command command) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command command) {
int count = command.getCount(); int count = command.getCount();
try { try {
return CommandParser.getInstance().processLastCommand(editor, context, count); return CommandParser.getInstance().processLastCommand(editor, context, count);

View File

@@ -1,29 +1,28 @@
package com.maddyhome.idea.vim.action.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.command.Command; 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 com.maddyhome.idea.vim.helper.UndoRedoHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -34,8 +33,8 @@ public class UndoAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(Editor editor, @NotNull DataContext context, Command cmd) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return UndoRedoHelper.undo(context); return UndoRedoHelper.undo(context);
} }
} }

View File

@@ -0,0 +1,46 @@
/*
* 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.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author vlan
*/
public class AutoIndentLinesVisualAction extends EditorAction {
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;
}
});
}
}

View File

@@ -1,32 +1,32 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper; import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -36,9 +36,10 @@ public class ChangeCaseLowerMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
return CommandGroups.getInstance().getChange().changeCaseMotion(editor, context, count, rawCount, return argument != null &&
CharacterHelper.CASE_LOWER, argument); VimPlugin.getChange().changeCaseMotion(editor, context, count, rawCount, CharacterHelper.CASE_LOWER,
argument);
} }
} }
} }

View File

@@ -1,31 +1,30 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.command.Command; import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper; import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -38,8 +37,9 @@ public class ChangeCaseLowerVisualAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
return CommandGroups.getInstance().getChange().changeCaseRange(InjectedLanguageUtil.getTopLevelEditor(editor), @NotNull TextRange range) {
return VimPlugin.getChange().changeCaseRange(InjectedLanguageUtil.getTopLevelEditor(editor),
range, CharacterHelper.CASE_LOWER); range, CharacterHelper.CASE_LOWER);
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeCaseToggleCharacterAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeCaseToggleCharacter(editor, count); return VimPlugin.getChange().changeCaseToggleCharacter(editor, count);
} }
} }
} }

View File

@@ -1,32 +1,32 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper; import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -36,9 +36,9 @@ public class ChangeCaseToggleMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
return CommandGroups.getInstance().getChange().changeCaseMotion(editor, context, count, rawCount, return argument != null && VimPlugin.getChange().changeCaseMotion(editor, context, count, rawCount,
CharacterHelper.CASE_TOGGLE, argument); CharacterHelper.CASE_TOGGLE, argument);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper; import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -37,8 +36,9 @@ public class ChangeCaseToggleVisualAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
return CommandGroups.getInstance().getChange().changeCaseRange(editor, range, CharacterHelper.CASE_TOGGLE); @NotNull TextRange range) {
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_TOGGLE);
} }
} }
} }

View File

@@ -1,32 +1,32 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper; import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -36,9 +36,9 @@ public class ChangeCaseUpperMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
return CommandGroups.getInstance().getChange().changeCaseMotion(editor, context, count, rawCount, return argument != null && VimPlugin.getChange().changeCaseMotion(editor, context, count, rawCount,
CharacterHelper.CASE_UPPER, argument); CharacterHelper.CASE_UPPER, argument);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.CharacterHelper; import com.maddyhome.idea.vim.helper.CharacterHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -37,8 +36,9 @@ public class ChangeCaseUpperVisualAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
return CommandGroups.getInstance().getChange().changeCaseRange(editor, range, CharacterHelper.CASE_UPPER); @NotNull TextRange range) {
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_UPPER);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeCharacterAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
return CommandGroups.getInstance().getChange().changeCharacter(editor, count, argument.getCharacter()); return argument != null && VimPlugin.getChange().changeCharacter(editor, count, argument.getCharacter());
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeCharactersAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeCharacters(editor, context, count); return VimPlugin.getChange().changeCharacters(editor, context, count);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeEndOfLineAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeEndOfLine(editor, context, count); return VimPlugin.getChange().changeEndOfLine(editor, context, count);
} }
} }
} }

View File

@@ -1,33 +1,33 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.ex.LineRange; 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.handler.ChangeEditorActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -37,9 +37,9 @@ public class ChangeLastGlobalSearchReplaceAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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); LineRange range = new LineRange(0, EditorHelper.getLineCount(editor) - 1);
return CommandGroups.getInstance().getSearch().searchAndReplace(editor, context, range, "s", "//~/&"); return VimPlugin.getSearch().searchAndReplace(editor, context, range, "s", "//~/&");
} }
} }
} }

View File

@@ -1,32 +1,32 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.ex.LineRange; 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.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -36,10 +36,10 @@ public class ChangeLastSearchReplaceAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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; int line = editor.getCaretModel().getLogicalPosition().line;
LineRange range = new LineRange(line, line); LineRange range = new LineRange(line, line);
return CommandGroups.getInstance().getSearch().searchAndReplace(editor, context, range, "s", "//~/"); return VimPlugin.getSearch().searchAndReplace(editor, context, range, "s", "//~/");
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeLineAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeLine(editor, context, count); return VimPlugin.getChange().changeLine(editor, context, count);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
return CommandGroups.getInstance().getChange().changeMotion(editor, context, count, rawCount, argument); return argument != null && VimPlugin.getChange().changeMotion(editor, context, count, rawCount, argument);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2006 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeNumberDecAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeNumber(editor, -count); return VimPlugin.getChange().changeNumber(editor, -count);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2006 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeNumberIncAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeNumber(editor, count); return VimPlugin.getChange().changeNumber(editor, count);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ChangeReplaceAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().changeReplace(editor, context); return VimPlugin.getChange().changeReplace(editor, context);
} }
} }
} }

View File

@@ -1,31 +1,30 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -37,9 +36,10 @@ public class ChangeVisualAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd, @NotNull TextRange range) { 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; 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);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -36,8 +35,8 @@ public class ChangeVisualCharacterAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, @NotNull Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
return CommandGroups.getInstance().getChange().changeCharacterRange(editor, range, return VimPlugin.getChange().changeCharacterRange(editor, range,
cmd.getArgument().getCharacter()); cmd.getArgument().getCharacter());
} }
} }

View File

@@ -1,31 +1,30 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -38,11 +37,12 @@ public class ChangeVisualLinesAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd, TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()), range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1); EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.LINE_WISE); return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
} }
} }
} }

View File

@@ -1,31 +1,30 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -38,7 +37,8 @@ public class ChangeVisualLinesEndAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
if (range.isMultiple()) { if (range.isMultiple()) {
int[] starts = range.getStartOffsets(); int[] starts = range.getStartOffsets();
int[] ends = range.getEndOffsets(); int[] ends = range.getEndOffsets();
@@ -49,13 +49,13 @@ public class ChangeVisualLinesEndAction extends EditorAction {
} }
range = new TextRange(starts, ends); range = new TextRange(starts, ends);
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.BLOCK_WISE); return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.BLOCK_WISE);
} }
else { else {
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()), range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1); EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
return CommandGroups.getInstance().getChange().changeRange(editor, context, range, SelectionType.LINE_WISE); return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,9 +33,9 @@ public class FilterCountLinesAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(@NotNull Editor editor, DataContext context, @NotNull Command cmd) { 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; return true;
} }

View File

@@ -1,33 +1,32 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.group.MotionGroup;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -37,8 +36,8 @@ public class FilterMotionAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(@NotNull Editor editor, DataContext context, @NotNull Command cmd) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
TextRange range = MotionGroup.getMotionRange(editor, context, cmd.getCount(), cmd.getRawCount(), TextRange range = MotionGroup.getMotionRange(editor, context, cmd.getCount(), cmd.getRawCount(),
cmd.getArgument(), false, false); cmd.getArgument(), false, false);
if (range == null) { if (range == null) {
@@ -61,7 +60,7 @@ public class FilterMotionAction extends EditorAction {
} }
Command command = new Command(count, null, null, Command.Type.UNDEFINED, 0); 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; return true;
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.change;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.change;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,10 +33,10 @@ public class FilterVisualLinesAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(@NotNull Editor editor, DataContext context, @NotNull Command cmd) { 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);
CommandGroups.getInstance().getMotion().resetVisual(editor, true); VimPlugin.getMotion().resetVisual(editor, true);
return true; return true;
} }

View File

@@ -0,0 +1,46 @@
/*
* 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.intellij.openapi.editor.actionSystem.EditorAction;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author vlan
*/
public class ReformatCodeVisualAction extends EditorAction {
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;
}
});
}
}

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class DeleteCharacterAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().deleteCharacter(editor, 1, false); return VimPlugin.getChange().deleteCharacter(editor, 1, false);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class DeleteCharacterLeftAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().deleteCharacter(editor, -count, false); return VimPlugin.getChange().deleteCharacter(editor, -count, false);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class DeleteCharacterRightAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().deleteCharacter(editor, count, false); return VimPlugin.getChange().deleteCharacter(editor, count, false);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class DeleteEndOfLineAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().deleteEndOfLine(editor, count); return VimPlugin.getChange().deleteEndOfLine(editor, count);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,12 +35,12 @@ public class DeleteJoinLinesAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().deleteJoinLines(editor, count, false); return VimPlugin.getChange().deleteJoinLines(editor, count, false);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,12 +35,12 @@ public class DeleteJoinLinesSpacesAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().deleteJoinLines(editor, count, true); return VimPlugin.getChange().deleteJoinLines(editor, count, true);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -36,12 +35,13 @@ public class DeleteJoinVisualLinesAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
if (editor.isOneLineMode()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().deleteJoinRange(editor, range, false); return VimPlugin.getChange().deleteJoinRange(editor, range, false);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -36,12 +35,13 @@ public class DeleteJoinVisualLinesSpacesAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
if (editor.isOneLineMode()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().deleteJoinRange(editor, range, true); return VimPlugin.getChange().deleteJoinRange(editor, range, true);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class DeleteLineAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
return CommandGroups.getInstance().getChange().deleteLine(editor, count); return VimPlugin.getChange().deleteLine(editor, count);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class DeleteMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
return CommandGroups.getInstance().getChange().deleteMotion(editor, context, count, rawCount, argument, false); return argument != null && VimPlugin.getChange().deleteMotion(editor, context, count, rawCount, argument, false);
} }
} }
} }

View File

@@ -1,32 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.command.CommandState; import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -39,14 +38,15 @@ public class DeleteVisualAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode(); CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
if (mode == CommandState.SubMode.VISUAL_LINE) { if (mode == CommandState.SubMode.VISUAL_LINE) {
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()), range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1); EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
} }
return CommandGroups.getInstance().getChange().deleteRange(editor, range, return VimPlugin.getChange().deleteRange(editor, range,
SelectionType.fromSubMode(mode), false); SelectionType.fromSubMode(mode), false);
} }
} }

View File

@@ -1,32 +1,31 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.command.CommandState; import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -39,17 +38,18 @@ public class DeleteVisualLinesAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode(); CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
if (mode == CommandState.SubMode.VISUAL_BLOCK) { if (mode == CommandState.SubMode.VISUAL_BLOCK) {
return CommandGroups.getInstance().getChange().deleteRange(editor, range, return VimPlugin.getChange().deleteRange(editor, range,
SelectionType.fromSubMode(mode), false); SelectionType.fromSubMode(mode), false);
} }
else { else {
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()), range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1); EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
return CommandGroups.getInstance().getChange().deleteRange(editor, range, SelectionType.LINE_WISE, false); return VimPlugin.getChange().deleteRange(editor, range, SelectionType.LINE_WISE, false);
} }
} }
} }

View File

@@ -1,31 +1,30 @@
package com.maddyhome.idea.vim.action.change.delete;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.delete;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -38,7 +37,8 @@ public class DeleteVisualLinesEndAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, DataContext context, Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
if (range.isMultiple()) { if (range.isMultiple()) {
int[] starts = range.getStartOffsets(); int[] starts = range.getStartOffsets();
int[] ends = range.getEndOffsets(); int[] ends = range.getEndOffsets();
@@ -49,14 +49,14 @@ public class DeleteVisualLinesEndAction extends EditorAction {
} }
range = new TextRange(starts, ends); range = new TextRange(starts, ends);
return CommandGroups.getInstance().getChange().deleteRange(editor, range, return VimPlugin.getChange().deleteRange(editor, range,
SelectionType.BLOCK_WISE, false); SelectionType.BLOCK_WISE, false);
} }
else { else {
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()), range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1); EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
return CommandGroups.getInstance().getChange().deleteRange(editor, range, return VimPlugin.getChange().deleteRange(editor, range,
SelectionType.LINE_WISE, false); SelectionType.LINE_WISE, false);
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class InsertAfterCursorAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().insertAfterCursor(editor, context); VimPlugin.getChange().insertAfterCursor(editor, context);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class InsertAfterLineEndAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().insertAfterLineEnd(editor, context); VimPlugin.getChange().insertAfterLineEnd(editor, context);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class InsertAtPreviousInsertAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().insertAtPreviousInsert(editor, context); VimPlugin.getChange().insertAtPreviousInsert(editor, context);
return true; return true;
} }

View File

@@ -1,44 +1,71 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; 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.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 com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** import javax.swing.*;
*/ import java.util.List;
public class InsertBeforeCursorAction extends EditorAction { import java.util.Set;
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
public class InsertBeforeCursorAction extends VimCommandAction {
public InsertBeforeCursorAction() { public InsertBeforeCursorAction() {
super(new Handler()); 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;
}
});
} }
private static class Handler extends ChangeEditorActionHandler { @NotNull
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, Argument argument) { @Override
CommandGroups.getInstance().getChange().insertBeforeCursor(editor, context); public Set<MappingMode> getMappingModes() {
return MappingMode.N;
}
return true; @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;
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class InsertBeforeFirstNonBlankAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().insertBeforeFirstNonBlank(editor, context); VimPlugin.getChange().insertBeforeFirstNonBlank(editor, context);
return true; return true;
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,13 +33,13 @@ public class InsertCharacterAboveCursorAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
if (editor.isOneLineMode()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().insertCharacterAroundCursor(editor, context, -1); return VimPlugin.getChange().insertCharacterAroundCursor(editor, context, -1);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,13 +33,13 @@ public class InsertCharacterBelowCursorAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
if (editor.isOneLineMode()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().insertCharacterAroundCursor(editor, context, 1); return VimPlugin.getChange().insertCharacterAroundCursor(editor, context, 1);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,9 +33,9 @@ public class InsertDeleteInsertedTextAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
public boolean execute(@NotNull Editor editor, DataContext context, Command cmd) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return CommandGroups.getInstance().getChange().insertDeleteInsertedText(editor); return VimPlugin.getChange().insertDeleteInsertedText(editor);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,9 +33,9 @@ public class InsertDeletePreviousWordAction extends EditorAction {
super(new Handler()); super(new Handler());
} }
private static class Handler extends AbstractEditorActionHandler { private static class Handler extends EditorActionHandlerBase {
public boolean execute(@NotNull Editor editor, DataContext context, Command cmd) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return CommandGroups.getInstance().getChange().insertDeletePreviousWord(editor); return VimPlugin.getChange().insertDeletePreviousWord(editor);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; 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; import org.jetbrains.annotations.NotNull;
/** /**
@@ -35,13 +34,8 @@ public class InsertEnterAction extends EditorAction {
} }
private static class Handler extends EditorActionHandler { private static class Handler extends EditorActionHandler {
public void execute(Editor editor, @NotNull DataContext context) { public void execute(@NotNull Editor editor, @NotNull DataContext context) {
editor = InjectedLanguageUtil.getTopLevelEditor(editor); VimPlugin.getChange().processEnter(InjectedLanguageUtil.getTopLevelEditor(editor), context);
if (editor.isOneLineMode()) {
return;
}
CommandGroups.getInstance().getChange().processEnter(editor, context);
} }
} }
} }

View File

@@ -1,42 +1,72 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; 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.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; import org.jetbrains.annotations.NotNull;
/** import javax.swing.*;
*/ import java.util.List;
public class InsertExitModeAction extends EditorAction { import java.util.Set;
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
public class InsertExitModeAction extends VimCommandAction {
private static final String ACTION_ID = "VimInsertExitMode";
public InsertExitModeAction() { 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 { @NotNull
public void execute(@NotNull Editor editor, @NotNull DataContext context) { @Override
CommandGroups.getInstance().getChange().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor), context); 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);
} }
} }

View File

@@ -1,42 +0,0 @@
package com.maddyhome.idea.vim.action.change.insert;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2005 Rick Maddy
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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);
}
}
}

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; 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; import org.jetbrains.annotations.NotNull;
/** /**
@@ -36,7 +35,7 @@ public class InsertInsertAction extends EditorAction {
private static class Handler extends EditorActionHandler { private static class Handler extends EditorActionHandler {
public void execute(@NotNull Editor editor, @NotNull DataContext context) { public void execute(@NotNull Editor editor, @NotNull DataContext context) {
CommandGroups.getInstance().getChange().processInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context); VimPlugin.getChange().processInsert(InjectedLanguageUtil.getTopLevelEditor(editor), context);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class InsertLineStartAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().insertLineStart(editor, context); VimPlugin.getChange().insertLineStart(editor, context);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,12 +35,12 @@ public class InsertNewLineAboveAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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()) { if (editor.isOneLineMode()) {
return false; return false;
} }
CommandGroups.getInstance().getChange().insertNewLineAbove(editor, context); VimPlugin.getChange().insertNewLineAbove(editor, context);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,12 +35,12 @@ public class InsertNewLineBelowAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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()) { if (editor.isOneLineMode()) {
return false; return false;
} }
CommandGroups.getInstance().getChange().insertNewLineBelow(editor, context); VimPlugin.getChange().insertNewLineBelow(editor, context);
return true; return true;
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; 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; import org.jetbrains.annotations.NotNull;
/** /**
@@ -36,7 +35,7 @@ public class InsertPreviousInsertAction extends EditorAction {
private static class Handler extends EditorActionHandler { private static class Handler extends EditorActionHandler {
public void execute(@NotNull Editor editor, @NotNull DataContext context) { 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);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; 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; import org.jetbrains.annotations.NotNull;
/** /**
@@ -36,7 +35,7 @@ public class InsertPreviousInsertExitAction extends EditorAction {
private static class Handler extends EditorActionHandler { private static class Handler extends EditorActionHandler {
public void execute(@NotNull Editor editor, @NotNull DataContext context) { 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);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.group.CommandGroups; import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.handler.AbstractEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -34,9 +33,9 @@ public class InsertRegisterAction extends EditorAction {
super(new Handler()); 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) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
return CommandGroups.getInstance().getChange().insertRegister(editor, context, cmd.getArgument().getCharacter()); return VimPlugin.getChange().insertRegister(editor, context, cmd.getArgument().getCharacter());
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; 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; import org.jetbrains.annotations.NotNull;
/** /**
@@ -35,8 +34,8 @@ public class InsertSingleCommandAction extends EditorAction {
} }
private static class Handler extends EditorActionHandler { private static class Handler extends EditorActionHandler {
public void execute(@NotNull Editor editor, DataContext context) { public void execute(@NotNull Editor editor, @NotNull DataContext context) {
CommandGroups.getInstance().getChange().processSingleCommand(InjectedLanguageUtil.getTopLevelEditor(editor)); VimPlugin.getChange().processSingleCommand(InjectedLanguageUtil.getTopLevelEditor(editor));
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -36,12 +35,13 @@ public class VisualBlockAppendAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
if (editor.isOneLineMode()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().blockInsert(editor, context, range, true); return VimPlugin.getChange().blockInsert(editor, context, range, true);
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.insert;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.insert;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -36,12 +35,13 @@ public class VisualBlockInsertAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, Command cmd, @NotNull TextRange range) { protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
@NotNull TextRange range) {
if (editor.isOneLineMode()) { if (editor.isOneLineMode()) {
return false; return false;
} }
return CommandGroups.getInstance().getChange().blockInsert(editor, context, range, false); return VimPlugin.getChange().blockInsert(editor, context, range, false);
} }
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.shift;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,9 +35,8 @@ public class AutoIndentLinesAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(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) {
CommandGroups.getInstance().getChange().autoIndentLines(context); VimPlugin.getChange().autoIndentLines(context);
return true; return true;
} }
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.shift;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ShiftLeftLinesAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().indentLines(editor, context, count, -1); VimPlugin.getChange().indentLines(editor, context, count, -1);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.shift;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,10 +35,14 @@ public class ShiftLeftMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
CommandGroups.getInstance().getChange().indentMotion(editor, context, count, rawCount, argument, -1); if (argument != null) {
VimPlugin.getChange().indentMotion(editor, context, count, rawCount, argument, -1);
return true; return true;
}
else {
return false;
}
} }
} }
} }

View File

@@ -1,30 +1,29 @@
package com.maddyhome.idea.vim.action.change.shift;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.command.Command;
import com.maddyhome.idea.vim.common.TextRange; 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.handler.VisualOperatorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -36,8 +35,8 @@ public class ShiftLeftVisualAction extends EditorAction {
} }
private static class Handler extends VisualOperatorActionHandler { private static class Handler extends VisualOperatorActionHandler {
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, TextRange range) { 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); VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), -1);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.shift;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,8 +35,8 @@ public class ShiftRightLinesAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { 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) {
CommandGroups.getInstance().getChange().indentLines(editor, context, count, 1); VimPlugin.getChange().indentLines(editor, context, count, 1);
return true; return true;
} }

View File

@@ -1,31 +1,31 @@
package com.maddyhome.idea.vim.action.change.shift;
/* /*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2005 Rick Maddy * Copyright (C) 2003-2014 The IdeaVim authors
* *
* This program is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation, either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package com.maddyhome.idea.vim.action.change.shift;
import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction; 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.Argument;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler; import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
*/ */
@@ -35,10 +35,14 @@ public class ShiftRightMotionAction extends EditorAction {
} }
private static class Handler extends ChangeEditorActionHandler { private static class Handler extends ChangeEditorActionHandler {
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument) { public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
CommandGroups.getInstance().getChange().indentMotion(editor, context, count, rawCount, argument, 1); if (argument != null) {
VimPlugin.getChange().indentMotion(editor, context, count, rawCount, argument, 1);
return true; return true;
}
else {
return false;
}
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More