mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-17 16:31:45 +02:00
Compare commits
296 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0da8625f30 | ||
![]() |
4cc784eb95 | ||
![]() |
ee3bec9eed | ||
![]() |
24788ac86f | ||
![]() |
9af3c732b5 | ||
![]() |
e5873fe5f9 | ||
![]() |
39f088cdcd | ||
![]() |
e805852721 | ||
![]() |
e136ecc1f8 | ||
![]() |
efa4001440 | ||
![]() |
68c20ed48d | ||
![]() |
c5760ceaab | ||
![]() |
8c7c9a67a6 | ||
![]() |
85231b314f | ||
![]() |
210b2efd47 | ||
![]() |
ae5b1385ea | ||
![]() |
011ce28251 | ||
![]() |
efb58b45df | ||
![]() |
7d033787eb | ||
![]() |
3a47583cf9 | ||
![]() |
565b4b3f2f | ||
![]() |
574f32a6dd | ||
![]() |
0e67c8ff69 | ||
![]() |
b886073c11 | ||
![]() |
57c35b9a74 | ||
![]() |
f5100694d6 | ||
![]() |
3ff9bfcc13 | ||
![]() |
6c8d2bfd9e | ||
![]() |
637f7f48ad | ||
![]() |
8eae80d30f | ||
![]() |
9a103276e3 | ||
![]() |
6386f011f7 | ||
![]() |
742d6e63d9 | ||
![]() |
f6141603ef | ||
![]() |
7a5b4e565a | ||
![]() |
373e1527c1 | ||
![]() |
9cb05b6a7d | ||
![]() |
74bf5ff044 | ||
![]() |
0f7e9d11b6 | ||
![]() |
5fadc2fb9f | ||
![]() |
96bbcf623f | ||
![]() |
89e853158c | ||
![]() |
5c31fcc03e | ||
![]() |
3fee4a803b | ||
![]() |
8b61f559d7 | ||
![]() |
4bd058f5dc | ||
![]() |
999ccf87fc | ||
![]() |
4e45e885b9 | ||
![]() |
6aee9ccaf1 | ||
![]() |
af3c6ff012 | ||
![]() |
0c9bdf5168 | ||
![]() |
82a9587b4f | ||
![]() |
850f4d7ec5 | ||
![]() |
8d1dcc4568 | ||
![]() |
3650ab85df | ||
![]() |
e1e1cc2666 | ||
![]() |
79fd32088b | ||
![]() |
458e0fc76d | ||
![]() |
5090c81632 | ||
![]() |
dcd035353b | ||
![]() |
8606ce21bd | ||
![]() |
72537c6ffb | ||
![]() |
30f9888f51 | ||
![]() |
d5a2b92121 | ||
![]() |
fd3eee6870 | ||
![]() |
2d6d1003b7 | ||
![]() |
499c590f5a | ||
![]() |
787b78ef36 | ||
![]() |
88a0b0fa23 | ||
![]() |
1519f04930 | ||
![]() |
e0a1291de0 | ||
![]() |
8a2d881002 | ||
![]() |
4802b6f460 | ||
![]() |
8c0e116a1c | ||
![]() |
8862878011 | ||
![]() |
bdf3361243 | ||
![]() |
6b5216077b | ||
![]() |
7e119f7963 | ||
![]() |
933cbc7e51 | ||
![]() |
65f30d4480 | ||
![]() |
1f8d3f119e | ||
![]() |
45fe858503 | ||
![]() |
0cc06ad186 | ||
![]() |
18cd7547ad | ||
![]() |
7746a26062 | ||
![]() |
a47fc9d3be | ||
![]() |
8fdf75330c | ||
![]() |
d6ebaa26b0 | ||
![]() |
27bd7ec836 | ||
![]() |
6752058922 | ||
![]() |
b965108dad | ||
![]() |
6bf0f36567 | ||
![]() |
69f1a70968 | ||
![]() |
47edfcac5e | ||
![]() |
c34599b954 | ||
![]() |
48b371c985 | ||
![]() |
47165e7b9d | ||
![]() |
69f4611552 | ||
![]() |
31a25449a8 | ||
![]() |
26a247c0bf | ||
![]() |
1c7cd23475 | ||
![]() |
296ef1bdf9 | ||
![]() |
f2a0408801 | ||
![]() |
642659bc9b | ||
![]() |
f0e8d065b7 | ||
![]() |
520d852c04 | ||
![]() |
8d4d7a421a | ||
![]() |
802b83b0fe | ||
![]() |
7ccb6c8411 | ||
![]() |
1518831f37 | ||
![]() |
3bdfaa02e1 | ||
![]() |
e8de9f915c | ||
![]() |
31f598d1e1 | ||
![]() |
46e6fd0847 | ||
![]() |
1441a60f4b | ||
![]() |
ebdf107946 | ||
![]() |
38d672c9f9 | ||
![]() |
75d34abd45 | ||
![]() |
1d98738e4d | ||
![]() |
3cfa0e1844 | ||
![]() |
82211a4373 | ||
![]() |
e324b04a94 | ||
![]() |
49d0c51d97 | ||
![]() |
fe4bc3b4a9 | ||
![]() |
58d964063c | ||
![]() |
17d3e37e1d | ||
![]() |
54f6a16bd6 | ||
![]() |
f4ffc5d198 | ||
![]() |
3d8010bf88 | ||
![]() |
ec2cc3a7f9 | ||
![]() |
52b7b9bcd8 | ||
![]() |
8ad0fcf42d | ||
![]() |
aa6cc45988 | ||
![]() |
da22b8297b | ||
![]() |
798d82e941 | ||
![]() |
ac8ac302ca | ||
![]() |
22c3a73102 | ||
![]() |
1222fdb043 | ||
![]() |
78a50c2f53 | ||
![]() |
6d261a7afa | ||
![]() |
2e37292478 | ||
![]() |
a4907ec9c8 | ||
![]() |
992bfe73b6 | ||
![]() |
c186254a7e | ||
![]() |
1dc739f32c | ||
![]() |
9804cd83a6 | ||
![]() |
aa5b99c47a | ||
![]() |
f95f5e8901 | ||
![]() |
206b303407 | ||
![]() |
751bff53ee | ||
![]() |
b6ef0c509d | ||
![]() |
30304d6836 | ||
![]() |
f5df49b139 | ||
![]() |
bf8ba1a49b | ||
![]() |
9f2697658b | ||
![]() |
36fd59b92c | ||
![]() |
88d946546a | ||
![]() |
6036c0c262 | ||
![]() |
20e831b56a | ||
![]() |
72b74e075c | ||
![]() |
3c6ede2f8f | ||
![]() |
5434edbd54 | ||
![]() |
6a8c7e4b17 | ||
![]() |
0ac659f2d1 | ||
![]() |
7eae40ca9a | ||
![]() |
b3d12c8b58 | ||
![]() |
3f92dba1b7 | ||
![]() |
0aedc08cfa | ||
![]() |
8312f5cffd | ||
![]() |
9f6338441e | ||
![]() |
27efe0c9d6 | ||
![]() |
b5bf6c08d8 | ||
![]() |
e3fce51ea1 | ||
![]() |
13b4e93bf4 | ||
![]() |
4ec0ab281f | ||
![]() |
39c96019b6 | ||
![]() |
21f2f60355 | ||
![]() |
0de654dcaf | ||
![]() |
d59e472814 | ||
![]() |
cc2ed452f0 | ||
![]() |
d4d3843725 | ||
![]() |
dee16da1c2 | ||
![]() |
e09b85870f | ||
![]() |
8596911a0e | ||
![]() |
6c2de9f151 | ||
![]() |
d3a6b1e39e | ||
![]() |
3cb9b19aea | ||
![]() |
86aa59bb29 | ||
![]() |
c6eeaed7da | ||
![]() |
edba90f188 | ||
![]() |
26b49b1a0c | ||
![]() |
ef32648ddc | ||
![]() |
c873524cb1 | ||
![]() |
7943e34bde | ||
![]() |
74970c74b4 | ||
![]() |
2d11561041 | ||
![]() |
f7643b6bb3 | ||
![]() |
d3afd83e8e | ||
![]() |
969ca0119a | ||
![]() |
722431f5b2 | ||
![]() |
6a1c792cda | ||
![]() |
c0ba39ab40 | ||
![]() |
3e0e08c5e1 | ||
![]() |
3d64373c22 | ||
![]() |
2557688657 | ||
![]() |
fcc564df25 | ||
![]() |
4ecbb93d01 | ||
![]() |
9bdc9b3634 | ||
![]() |
f46c3b0aa9 | ||
![]() |
095fdf07c5 | ||
![]() |
648e988b64 | ||
![]() |
b1add735d6 | ||
![]() |
3f5882118e | ||
![]() |
4e83f56696 | ||
![]() |
ab250f1d9c | ||
![]() |
4672dece51 | ||
![]() |
a632de9214 | ||
![]() |
e8ebba8b3d | ||
![]() |
5cf8181474 | ||
![]() |
a717e4785d | ||
![]() |
16ce16c632 | ||
![]() |
8d7bf2661a | ||
![]() |
9e1b026a88 | ||
![]() |
df8e455a6d | ||
![]() |
b35bec2839 | ||
![]() |
19365effa9 | ||
![]() |
3750417323 | ||
![]() |
d7bfb1ff10 | ||
![]() |
1797771527 | ||
![]() |
e564eb5878 | ||
![]() |
9cd620af58 | ||
![]() |
1414ef8a4f | ||
![]() |
110623f6ef | ||
![]() |
0887c72486 | ||
![]() |
a516fd880e | ||
![]() |
50e15112d6 | ||
![]() |
8b6f99385a | ||
![]() |
2d1b40f00c | ||
![]() |
2fc2f30055 | ||
![]() |
2094a19723 | ||
![]() |
5b1416424d | ||
![]() |
8b9e737c05 | ||
![]() |
cc0f4acec6 | ||
![]() |
30884162a0 | ||
![]() |
f1e7a8c444 | ||
![]() |
3271939c87 | ||
![]() |
c9cb487cbc | ||
![]() |
56f6b69adf | ||
![]() |
77dcee1269 | ||
![]() |
c9068ee4d1 | ||
![]() |
e7addf7fa8 | ||
![]() |
7cc0a8db92 | ||
![]() |
bccb62a84f | ||
![]() |
d47570664b | ||
![]() |
a7137558cc | ||
![]() |
0251c5a33d | ||
![]() |
365722ef7e | ||
![]() |
77e0c30e57 | ||
![]() |
8a0cad765a | ||
![]() |
272378b800 | ||
![]() |
a34d17ff95 | ||
![]() |
82c782e9f0 | ||
![]() |
b7b46d2fee | ||
![]() |
8916f0f314 | ||
![]() |
8d727ef508 | ||
![]() |
fd0be10492 | ||
![]() |
a810f95101 | ||
![]() |
8857545cf0 | ||
![]() |
2300c0005f | ||
![]() |
827b91286f | ||
![]() |
4d8e35655d | ||
![]() |
f7e6ae9f3c | ||
![]() |
67679843b4 | ||
![]() |
b67b072be2 | ||
![]() |
d6896e4e76 | ||
![]() |
f86c24a695 | ||
![]() |
b200c842b4 | ||
![]() |
c8df52a86c | ||
![]() |
b17a592c95 | ||
![]() |
f71d6c7fab | ||
![]() |
30cfae91c0 | ||
![]() |
5332128852 | ||
![]() |
b593d90dff | ||
![]() |
02fac3b931 | ||
![]() |
446ffc3602 | ||
![]() |
44c1a2e139 | ||
![]() |
f6cb04c7ef | ||
![]() |
276755ae9d | ||
![]() |
6ee0b821cc | ||
![]() |
72dc121fcd | ||
![]() |
786c4dc817 | ||
![]() |
c7cfbaed0a | ||
![]() |
4351d5c366 | ||
![]() |
ff3795798f | ||
![]() |
45281adfd9 | ||
![]() |
0d813afc67 |
14
.idea/codeStyleSettings.xml
generated
14
.idea/codeStyleSettings.xml
generated
@@ -141,11 +141,8 @@
|
|||||||
</indentOptions>
|
</indentOptions>
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="Groovy">
|
<codeStyleSettings language="Groovy">
|
||||||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
|
||||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||||
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
||||||
@@ -154,7 +151,6 @@
|
|||||||
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
|
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
|
||||||
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
|
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
|
||||||
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
|
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
|
||||||
<option name="ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION" value="true" />
|
|
||||||
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||||
<option name="METHOD_PARAMETERS_WRAP" value="5" />
|
<option name="METHOD_PARAMETERS_WRAP" value="5" />
|
||||||
@@ -165,12 +161,9 @@
|
|||||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||||
<option name="BINARY_OPERATION_WRAP" value="5" />
|
<option name="BINARY_OPERATION_WRAP" value="5" />
|
||||||
<option name="TERNARY_OPERATION_WRAP" value="5" />
|
<option name="TERNARY_OPERATION_WRAP" value="5" />
|
||||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
|
||||||
<option name="FOR_STATEMENT_WRAP" value="5" />
|
<option name="FOR_STATEMENT_WRAP" value="5" />
|
||||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
|
||||||
<option name="ASSIGNMENT_WRAP" value="1" />
|
<option name="ASSIGNMENT_WRAP" value="1" />
|
||||||
<option name="IF_BRACE_FORCE" value="1" />
|
<option name="IF_BRACE_FORCE" value="1" />
|
||||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
|
||||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||||
<option name="FOR_BRACE_FORCE" value="1" />
|
<option name="FOR_BRACE_FORCE" value="1" />
|
||||||
<option name="FIELD_ANNOTATION_WRAP" value="0" />
|
<option name="FIELD_ANNOTATION_WRAP" value="0" />
|
||||||
@@ -227,6 +220,10 @@
|
|||||||
<option name="TAB_SIZE" value="8" />
|
<option name="TAB_SIZE" value="8" />
|
||||||
</indentOptions>
|
</indentOptions>
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JSON">
|
||||||
|
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||||
|
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||||
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="JSP">
|
<codeStyleSettings language="JSP">
|
||||||
<indentOptions>
|
<indentOptions>
|
||||||
<option name="INDENT_SIZE" value="2" />
|
<option name="INDENT_SIZE" value="2" />
|
||||||
@@ -276,5 +273,4 @@
|
|||||||
</option>
|
</option>
|
||||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
10
AUTHORS.md
10
AUTHORS.md
@@ -24,6 +24,16 @@ Contributors:
|
|||||||
* [John Lindquist](mailto:johnlindquist@gmail.com)
|
* [John Lindquist](mailto:johnlindquist@gmail.com)
|
||||||
* [Ira Klotzko](mailto:iklotzko@ltech.com)
|
* [Ira Klotzko](mailto:iklotzko@ltech.com)
|
||||||
* [Alex Selesse](mailto:alex@selesse.com)
|
* [Alex Selesse](mailto:alex@selesse.com)
|
||||||
|
* [Dathan Bennett](mailto:dbennett@palantir.com)
|
||||||
|
* [salaam](mailto:kphayen@gmail.com)
|
||||||
|
* [Alexey Shmalko](mailto:rasen.dubi@gmail.com)
|
||||||
|
* [Andrew Brookins](mailto:a.m.brookins@gmail.com)
|
||||||
|
* [Chang Wang](mailto:changwang83@gmail.com)
|
||||||
|
* [Jaime Sanchez](mailto:josejaime.sanchez@gmail.com)
|
||||||
|
* [Thomas B Homburg](mailto:thomas@homburg.dk)
|
||||||
|
* [smartbomb](mailto:smartbomb@server.fake)
|
||||||
|
* [Tuomas Tynkkynen](mailto:tuomas.tynkkynen@iki.fi)
|
||||||
|
* [Jackson Popkin](mailto:jackson@donorschoose.org)
|
||||||
|
|
||||||
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.
|
||||||
|
178
CHANGES.md
178
CHANGES.md
@@ -3,6 +3,184 @@ The Changelog
|
|||||||
|
|
||||||
History of changes in IdeaVim for the IntelliJ platform.
|
History of changes in IdeaVim for the IntelliJ platform.
|
||||||
|
|
||||||
|
0.44, 2015-11-02
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
|
||||||
|
* VIM-1040 Fixed typing keys in completion menus and typing with the
|
||||||
|
plugin disabled
|
||||||
|
|
||||||
|
|
||||||
|
0.43, 2015-11-02
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
* VIM-1039 Fixed running the plugin with Java 6
|
||||||
|
|
||||||
|
|
||||||
|
0.42, 2015-11-01
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This release is compatible with IntelliJ 15+ and other IDEs based on the
|
||||||
|
IntelliJ platform branch 143+.
|
||||||
|
|
||||||
|
* VIM-970 Fixed move commands in read-only files
|
||||||
|
|
||||||
|
|
||||||
|
0.41, 2015-06-10
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
* VIM-957 Fixed plugin version 0.40 is not compatible with IDEs other than
|
||||||
|
IntelliJ
|
||||||
|
|
||||||
|
|
||||||
|
0.40, 2015-06-09
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Added support for `mapleader`. Support comments in `%` brace matching. Various
|
||||||
|
bug fixes.
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
* VIM-650 Added support for `mapleader`
|
||||||
|
* VIM-932 Support comments in `%` brace matching
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-586 Invoke Vim shortcuts handler later to restore the sequence of input
|
||||||
|
events
|
||||||
|
* VIM-838 `J` shouldn't add whitespace if there is a trailing space
|
||||||
|
* VIM-855 Fixed regexp character class problem
|
||||||
|
* VIM-210 Fix focus issues with the Ex panel and splits
|
||||||
|
* VIM-575 Don't change cursor position of other splits in visual mode
|
||||||
|
* VIM-864 Fixed visual marks getting changed during visual substitute
|
||||||
|
* VIM-856 Fixed regex look-behind problem
|
||||||
|
* VIM-868 Allow count on `gt` and `gT`
|
||||||
|
* VIM-700 Remapping `0` should still allow it to be entered in command count
|
||||||
|
* VIM-781 Fixed expanding visual block selection past empty lines
|
||||||
|
* VIM-845 Fixed `c` and `x` functionality for visual block selections
|
||||||
|
* VIM-930 Fixed editor focus issues after closing Ex entry box on Oracle Java 6
|
||||||
|
|
||||||
|
|
||||||
|
0.39, 2014-12-03
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-848 Show line numbers if they are enabled in the settings and there is
|
||||||
|
no `set number`
|
||||||
|
* VIM-702 Fix infinite loop on `s/$/\r/g`
|
||||||
|
* EA-63022 Don't update line numbers in the caret movement event listener
|
||||||
|
|
||||||
|
|
||||||
|
0.38, 2014-12-01
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Added support for `number` and `relativenumber` options, `clipboard=unnamed`
|
||||||
|
option. Added `:action` and `:actionlist` commands for executing arbitrary
|
||||||
|
IDE actions. Various bug fixes.
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
* VIM-476 Added support for `clipboard=unnamed` option
|
||||||
|
* VIM-410 Added support for `relativenumber` option
|
||||||
|
* VIM-483 Added support for `number` option
|
||||||
|
* VIM-652 Added `:action` and `:actionlist` commands for executing arbitrary
|
||||||
|
IDE actions
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-818 Enable key repeat on Mac OS X every time it gets reset by the OS
|
||||||
|
* VIM-624 Deselect visual selection range on opening the Ex entry field
|
||||||
|
* VIM-511 Fixed editing offset after `<BS>` for `.` command
|
||||||
|
* VIM-792 Fixed line-wise and block-wise paste commands for `*` and `+`
|
||||||
|
registers
|
||||||
|
* VIM-501 Fixed off-by-1 error in visual block-wise selection
|
||||||
|
* VIM-613 Fixed repeat after `d$`
|
||||||
|
* VIM-705 Fixed repeated multiline indent
|
||||||
|
* VIM-567 Fixed `:!` to allow running non-filter commands
|
||||||
|
* VIM-536 Fixed `cc` on the second-to-last line
|
||||||
|
* VIM-515 Fixed `cW` command detecting end-of-word incorrectly
|
||||||
|
* VIM-794 Fixed NCDFE related to 'number' in IDEs other than IntelliJ
|
||||||
|
* VIM-771 Fix semicolon repeat for 'till char' motion
|
||||||
|
* VIM-723 Fix pasting to an empty line
|
||||||
|
|
||||||
|
|
||||||
|
0.37, 2014-10-15
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-784 Fixed visual line selection where the start of the selection range
|
||||||
|
was greater than its end
|
||||||
|
* VIM-407 Fixed `>>` to work if a line contains only one character
|
||||||
|
|
||||||
|
|
||||||
|
0.36, 2014-10-14
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Added support for common window splitting and navigation commands. Various bug
|
||||||
|
fixes.
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
* VIM-171 Window `<C-W>` commands: split, close, next/previous windows,
|
||||||
|
left/right/up/down windows
|
||||||
|
* VIM-265 Window `:split` and `:vsplit` commands
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-632 Restored visual block mode that was broken due to multiple carets support
|
||||||
|
* VIM-770 Close the current tab on `:quit` instead of all tabs with the current
|
||||||
|
file
|
||||||
|
* VIM-569 Fixed `<C-W>` when the caret is at the end of a line
|
||||||
|
|
||||||
|
|
||||||
|
0.35, 2014-05-15
|
||||||
|
----------------
|
||||||
|
|
||||||
|
The `~/.vimrc` initialization file is no longer read by default, use
|
||||||
|
`~/.ideavimrc` instead.
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
* VIM-690 Read initialization commands only from `~/.ideavimrc`
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-676 Handle control characters in `.ideavimrc` as pressed, not typed
|
||||||
|
keystrokes
|
||||||
|
* VIM-679 Parse characters less than U+0020 as `<C-$CHAR>`
|
||||||
|
* VIM-683 Allow `<C-PageUp>`/`<C-PagDown>` to be used outside of Vim emulation
|
||||||
|
* VIM-646 Don't update the visual selection if a command moves the caret and exits
|
||||||
|
the visual mode
|
||||||
|
* VIM-213 Use `'<` and `'>` marks for saving and restoring the last visual
|
||||||
|
selection
|
||||||
|
|
||||||
|
|
||||||
|
0.34, 2014-04-29
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-674 Don't handle `<Tab>` in Insert mode in Vim emulation
|
||||||
|
* VIM-672 Ignore mappings that contain `<Plug>` and `<SID>`
|
||||||
|
* VIM-670 First character of a recursive mapping shouldn't be mapped again
|
||||||
|
* VIM-666 Support `<Bar>` in Vim key notation
|
||||||
|
* VIM-666 Ignore characters after `|` in `:map` commands
|
||||||
|
* VIM-667 Ignore potentially nested lines of .vimrc based on leading whitespace
|
||||||
|
|
||||||
|
|
||||||
0.33, 2014-04-28
|
0.33, 2014-04-28
|
||||||
----------------
|
----------------
|
||||||
|
62
README.md
62
README.md
@@ -2,22 +2,22 @@ IdeaVim
|
|||||||
=======
|
=======
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt299&guest=1">
|
<a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_Build&guest=1">
|
||||||
<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:bt299)/statusIcon"/>
|
<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_Build)/statusIcon"/>
|
||||||
</a>
|
</a>
|
||||||
<span>Build<span>
|
<span>Build<span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt453&guest=1">
|
<a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_TestsForIntelliJ15&guest=1">
|
||||||
<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:bt453)/statusIcon"/>
|
<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_TestsForIntelliJ15)/statusIcon"/>
|
||||||
</a>
|
</a>
|
||||||
<span>Tests</span>
|
<span>Tests</span>
|
||||||
</div>
|
</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,
|
||||||
AppCode and Android Studio.
|
AppCode, CLion and Android Studio.
|
||||||
|
|
||||||
Resources:
|
Resources:
|
||||||
|
|
||||||
@@ -36,9 +36,13 @@ 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 its regular keyboard
|
||||||
shortcuts.
|
shortcuts.
|
||||||
|
|
||||||
|
Keyboard shortcut conflicts between the Vim emulation and the IDE can be
|
||||||
|
resolved via "File | Settings | Vim Emulation", "File | Settings | Keymap"
|
||||||
|
and key mapping commands in your ~/.ideavimrc file.
|
||||||
|
|
||||||
|
|
||||||
Summary of Supported Vim Features
|
Summary of Supported Vim Features
|
||||||
---------------------------------
|
---------------------------------
|
||||||
@@ -59,21 +63,40 @@ Supported:
|
|||||||
* Macros
|
* Macros
|
||||||
* Digraphs
|
* Digraphs
|
||||||
* Command line and search history
|
* Command line and search history
|
||||||
|
* Window commands
|
||||||
* Vim web help
|
* Vim web help
|
||||||
|
|
||||||
Not supported (yet):
|
Not supported (yet):
|
||||||
|
|
||||||
* Window commands
|
|
||||||
* Jump lists
|
* Jump lists
|
||||||
* Various less used commands
|
* Various less used commands
|
||||||
|
|
||||||
See also:
|
See also:
|
||||||
|
|
||||||
* [List of recently added commands](https://github.com/JetBrains/ideavim/blob/master/src/com/maddyhome/idea/vim/package-info.java)
|
* [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)
|
* [Top features and bugs](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+sort+by%3A+votes)
|
||||||
|
|
||||||
|
|
||||||
|
Files
|
||||||
|
-----
|
||||||
|
|
||||||
|
* ~/.ideavimrc
|
||||||
|
* Your IdeaVim-specific Vim initialization commands
|
||||||
|
|
||||||
|
You can read your ~/.vimrc file from ~/.ideavimrc using this command:
|
||||||
|
|
||||||
|
source ~/.vimrc
|
||||||
|
|
||||||
|
Note, that IdeaVim currently parses ~/.ideavimrc file via simple pattern matching,
|
||||||
|
see [VIM-669](http://youtrack.jetbrains.com/issue/VIM-669) for proper parsing
|
||||||
|
of VimL files.
|
||||||
|
|
||||||
|
Also note that if you have overridden the `user.home` JVM option, this will
|
||||||
|
will affect where IdeaVim looks for your .ideavimrc file. For example, if you
|
||||||
|
have `-Duser.home=/my/alternate/home` then IdeaVim will source
|
||||||
|
`/my/alternate/home/.ideavimrc` instead of `~/.ideavimrc`.
|
||||||
|
|
||||||
|
|
||||||
Changes to the IDE
|
Changes to the IDE
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
@@ -94,6 +117,20 @@ usage of the Vim emulator in dialog windows is an area for improvements.
|
|||||||
|
|
||||||
See also [unresolved escape issues](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+i_Esc).
|
See also [unresolved escape issues](http://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+i_Esc).
|
||||||
|
|
||||||
|
### Executing IDE Actions
|
||||||
|
|
||||||
|
IdeaVim adds two commands for listing and executing arbitrary IDE actions as
|
||||||
|
Ex commands or via `:map` command mappings:
|
||||||
|
|
||||||
|
* `:actionlist [pattern]`
|
||||||
|
* Find IDE actions by name pattern
|
||||||
|
* `:action {name}`
|
||||||
|
* Execute an action named `NAME`
|
||||||
|
|
||||||
|
For example, here `\r` is mapped to the Reformat Code action:
|
||||||
|
|
||||||
|
:map \r :action ReformatCode<CR>
|
||||||
|
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
@@ -116,7 +153,7 @@ in the issue tracker.
|
|||||||
|
|
||||||
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 12+ (Community or Ultimate) using "File |
|
2. Open the project in IntelliJ IDEA 13.1+ (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
|
||||||
@@ -134,7 +171,12 @@ in the issue tracker.
|
|||||||
previous step.
|
previous step.
|
||||||
|
|
||||||
6. Build IdeaVim and run IntelliJ with IdeaVim enabled using the "IdeaVim" run
|
6. Build IdeaVim and run IntelliJ with IdeaVim enabled using the "IdeaVim" run
|
||||||
configuration (use "Run | Run... | IdeaVim").
|
configuration (use "Run | Run... | IdeaVim"). This will launch a spare
|
||||||
|
instance of IntelliJ running the compiled plugin in a sandboxed enviroment.
|
||||||
|
To actually deploy the plugin the recommended way is executing `ant dist`
|
||||||
|
from command line, which will update versions in plugin.xml among other
|
||||||
|
tasks. Install the generated "ideavim.jar" file from
|
||||||
|
"Settings | Plugins | Install plugin from disk".
|
||||||
|
|
||||||
7. In order to be able to run tests in your IntelliJ edition uncomment the
|
7. In order to be able to run tests in your IntelliJ edition uncomment the
|
||||||
appropriate lines in the constructor of the `VimTestCase` class.
|
appropriate lines in the constructor of the `VimTestCase` class.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
version-id:0.33
|
version-id:0.44
|
||||||
platform-version:120.0
|
platform-version:143.0
|
||||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-13.zip
|
idea.download.url=http://download.jetbrains.com/idea/ideaIC-143.380.20.tar.gz
|
||||||
build.number=dev
|
build.number=dev
|
||||||
|
@@ -105,9 +105,9 @@
|
|||||||
<delete dir="${idea}/unzip"/>
|
<delete dir="${idea}/unzip"/>
|
||||||
<mkdir dir="${idea}/unzip"/>
|
<mkdir dir="${idea}/unzip"/>
|
||||||
<basename property="idea.filename" file="${idea.download.url}"/>
|
<basename property="idea.filename" file="${idea.download.url}"/>
|
||||||
<unzip dest="${idea}/unzip">
|
<untar src="${idea}/${idea.filename}" dest="${idea}/unzip" compression="gzip">
|
||||||
<fileset dir="${idea}" includes="${idea.filename}"/>
|
<cutdirsmapper dirs="1"/>
|
||||||
</unzip>
|
</untar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="dist" depends="dist-src, dist-bin" description="Creates the src and bin distribution files"/>
|
<target name="dist" depends="dist-src, dist-bin" description="Creates the src and bin distribution files"/>
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
|
|
||||||
<target name="test" depends="unzip, clean, prepare-tests">
|
<target name="test" depends="unzip, clean, prepare-tests">
|
||||||
<mkdir dir="${test-reports}"/>
|
<mkdir dir="${test-reports}"/>
|
||||||
<junit fork="true" logfailedtests="false" printsummary="true">
|
<junit fork="true" forkmode="once" logfailedtests="false" printsummary="true">
|
||||||
<classpath refid="test.classpath"/>
|
<classpath refid="test.classpath"/>
|
||||||
|
|
||||||
<jvmarg value="-Xmx256M"/>
|
<jvmarg value="-Xmx256M"/>
|
||||||
@@ -169,6 +169,7 @@
|
|||||||
<jvmarg value="-Didea.load.plugins.id=IdeaVIM"/>
|
<jvmarg value="-Didea.load.plugins.id=IdeaVIM"/>
|
||||||
|
|
||||||
<formatter type="plain"/>
|
<formatter type="plain"/>
|
||||||
|
<formatter type="xml" usefile="true" />
|
||||||
|
|
||||||
<batchtest todir="${test-reports}">
|
<batchtest todir="${test-reports}">
|
||||||
<fileset dir="${test}">
|
<fileset dir="${test}">
|
||||||
|
@@ -1,24 +1,28 @@
|
|||||||
List of Supported Set Commands
|
List of Supported Set Commands
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
The following `:set` commands can appear in `~/.vimrc` or set manually in the command mode:
|
The following `:set` commands can appear in `~/.ideavimrc` or set manually in the command mode:
|
||||||
|
|
||||||
'digraph' 'dg' enable the entering of digraphs in Insert mode
|
'clipboard' 'cb' clipboard options
|
||||||
'gdefault' 'gd' the ":substitute" flag 'g' is default on
|
'digraph' 'dg' enable the entering of digraphs in Insert mode
|
||||||
'history' 'hi' number of command-lines that are remembered
|
'gdefault' 'gd' the ":substitute" flag 'g' is default on
|
||||||
'hlsearch' 'hls' highlight matches with last search pattern
|
'history' 'hi' number of command-lines that are remembered
|
||||||
'ignorecase' 'ic' ignore case in search patterns
|
'hlsearch' 'hls' highlight matches with last search pattern
|
||||||
'matchpairs' 'mps' pairs of characters that "%" can match
|
'ignorecase' 'ic' ignore case in search patterns
|
||||||
'nrformats' 'nf' number formats recognized for CTRL-A command
|
'matchpairs' 'mps' pairs of characters that "%" can match
|
||||||
'scroll' 'scr' lines to scroll with CTRL-U and CTRL-D
|
'nrformats' 'nf' number formats recognized for CTRL-A command
|
||||||
'scrolljump' 'sj' minimum number of lines to scroll
|
'number' 'nu' print the line number in front of each line
|
||||||
'scrolloff' 'so' minimum nr. of lines above and below cursor
|
'relativenumber' 'rnu' show the line number relative to the line with
|
||||||
'selection' 'sel' what type of selection to use
|
the cursor
|
||||||
'showmode' 'smd' message on status line to show current mode
|
'scroll' 'scr' lines to scroll with CTRL-U and CTRL-D
|
||||||
'sidescroll' 'ss' minimum number of columns to scroll horizontal
|
'scrolljump' 'sj' minimum number of lines to scroll
|
||||||
'sidescrolloff' 'siso' min. nr. of columns to left and right of cursor
|
'scrolloff' 'so' minimum nr. of lines above and below cursor
|
||||||
'smartcase' 'scs' no ignore case when pattern has uppercase
|
'selection' 'sel' what type of selection to use
|
||||||
'timeoutlen' 'tm' time that is waited for a mapped key sequence
|
'showmode' 'smd' message on status line to show current mode
|
||||||
'undolevels' 'ul' maximum number of changes that can be undone
|
'sidescroll' 'ss' minimum number of columns to scroll horizontal
|
||||||
'visualbell' 'vb' use visual bell instead of beeping
|
'sidescrolloff' 'siso' min. nr. of columns to left and right of cursor
|
||||||
'wrapscan' 'ws' searches wrap around the end of the file
|
'smartcase' 'scs' no ignore case when pattern has uppercase
|
||||||
|
'timeoutlen' 'tm' time that is waited for a mapped key sequence
|
||||||
|
'undolevels' 'ul' maximum number of changes that can be undone
|
||||||
|
'visualbell' 'vb' use visual bell instead of beeping
|
||||||
|
'wrapscan' 'ws' searches wrap around the end of the file
|
||||||
|
@@ -7,9 +7,9 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/idea" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
@@ -1,63 +1,63 @@
|
|||||||
<idea-plugin url="http://plugins.jetbrains.com/plugin/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.44:</p>
|
||||||
<p>0.33:</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Support for <code>:map</code> key mapping commands</li>
|
<li>Fixed typing keys in completion menus and typing with the plugin disabled</li>
|
||||||
<li>New keyboard shortcuts handler that doesn't require a separate keymap for Vim emulation</li>
|
|
||||||
<li>Support for <code>:source</code> command</li>
|
|
||||||
<li>Support for <code>:sort</code> command</li>
|
|
||||||
<li>Various bug fixes</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<p>0.32:</p>
|
<p>0.43:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Fixed API compatibility with IntelliJ platform builds 132.1052+</li>
|
<li>Fixed running the plugin with Java 6</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>0.31:</p>
|
<p>0.42:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Fixed move commands in read-only files</li>
|
||||||
|
</ul>
|
||||||
|
<p>0.41:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Various bug fixes</li>
|
<li>Various bug fixes</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>0.30:</p>
|
<p>0.40:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Support for a separate <code>.ideavimrc</code> config file</li>
|
<li>Support for <code>mapleader</code></li>
|
||||||
<li>Fixed long-standing issues with merged undo/redo commands and <code><Esc></code> during completion</li>
|
<li>Support comments in <code>%</code> brace matching</li>
|
||||||
<li>Various bug fixes</li>
|
<li>Various bug fixes</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>0.29:</p>
|
<p>0.39:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Fixed repeat buffer limits</li>
|
<li>Various bug fixes</li>
|
||||||
<li>Enable normal <code><Enter></code> handling for one-line editors</li>
|
</ul>
|
||||||
<li>Don't move cursor while scrolling</li>
|
<p>0.38:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Support for <code>:action</code> and <code>:actionlist</code> for executing arbitrary IDE actions</li>
|
||||||
|
<li>Support for <code>number</code> and <code>relativenumber</code> options</li>
|
||||||
|
<li>Support for <code>clipboard=unnamed</code> option</li>
|
||||||
|
<li>Various bug fixes</li>
|
||||||
|
</ul>
|
||||||
|
<p>0.37:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Various bug fixes</li>
|
||||||
|
</ul>
|
||||||
|
<p>0.36:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Window commands from the <code><C-W></code> family</li>
|
||||||
|
<li>Support for <code>:split</code>/<code>:vsplit</code> commands</li>
|
||||||
|
<li>Fixed visual block selection mode</li>
|
||||||
|
<li>Various bug fixes</li>
|
||||||
</ul>
|
</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><![CDATA[
|
||||||
<description>
|
|
||||||
<![CDATA[
|
|
||||||
<p>Build @VERSION@-@BUILD-NUMBER@</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>Vim emulation plug-in for IDEs based on the IntelliJ platform.</p>
|
||||||
<p>Supported functionality:</p>
|
<p>IdeaVim supports many Vim features including normal/insert/visual modes, motion keys, deletion/changing, marks, registers, some Ex commands, Vim regexps, configuration via ~/.ideavimrc, macros, window commands, etc.</p>
|
||||||
|
<p>See also:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Motion keys</li>
|
<li><a href="https://github.com/JetBrains/ideavim">GitHub repository</a>: documentation and contributing</li>
|
||||||
<li>Deletion/Changing</li>
|
<li><a href="http://youtrack.jetbrains.com/issues/VIM">Issue tracker</a>: feature requests and bug reports</li>
|
||||||
<li>Insert mode commands</li>
|
|
||||||
<li>Marks</li>
|
|
||||||
<li>Registers</li>
|
|
||||||
<li>Undo/redo</li>
|
|
||||||
<li>Visual mode commands</li>
|
|
||||||
<li>Some Ex commands</li>
|
|
||||||
<li>Some :set options</li>
|
|
||||||
<li>Full Vim regexps for search and search/replace</li>
|
|
||||||
<li>Key mappings</li>
|
|
||||||
<li>Macros</li>
|
|
||||||
<li>Digraphs</li>
|
|
||||||
<li>Command line and search history</li>
|
|
||||||
<li>Vim web help</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
]]>
|
]]></description>
|
||||||
</description>
|
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<vendor>JetBrains</vendor>
|
<vendor>JetBrains</vendor>
|
||||||
|
|
||||||
@@ -185,7 +185,6 @@
|
|||||||
<!-- Screen -->
|
<!-- Screen -->
|
||||||
<action id="VimMotionFirstScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionFirstScreenLineAction" text="First Screen Line"/>
|
<action id="VimMotionFirstScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionFirstScreenLineAction" text="First Screen Line"/>
|
||||||
<action id="VimMotionLastScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionLastScreenLineAction" text="Last Screen Line"/>
|
<action id="VimMotionLastScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionLastScreenLineAction" text="Last Screen Line"/>
|
||||||
<action id="VimMotionLastScreenLineEnd" class="com.maddyhome.idea.vim.action.motion.screen.MotionLastScreenLineEndAction" text="Last Screen Line End"/>
|
|
||||||
<action id="VimMotionMiddleScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionMiddleScreenLineAction" text="Middle Screen Line"/>
|
<action id="VimMotionMiddleScreenLine" class="com.maddyhome.idea.vim.action.motion.screen.MotionMiddleScreenLineAction" text="Middle Screen Line"/>
|
||||||
<!-- Scroll -->
|
<!-- Scroll -->
|
||||||
<action id="VimMotionScrollFirstScreenLinePageStart" class="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollFirstScreenLinePageStartAction" text="Scroll Line to Top"/>
|
<action id="VimMotionScrollFirstScreenLinePageStart" class="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollFirstScreenLinePageStartAction" text="Scroll Line to Top"/>
|
||||||
@@ -213,7 +212,7 @@
|
|||||||
<action id="VimVisualToggleBlockMode" class="com.maddyhome.idea.vim.action.motion.visual.VisualToggleBlockModeAction" text="Toggle Block Selection"/>
|
<action id="VimVisualToggleBlockMode" class="com.maddyhome.idea.vim.action.motion.visual.VisualToggleBlockModeAction" text="Toggle Block Selection"/>
|
||||||
<action id="VimVisualSwapEnds" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapEndsAction" text="Swap Visual Selection Ends"/>
|
<action id="VimVisualSwapEnds" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapEndsAction" text="Swap Visual Selection Ends"/>
|
||||||
<action id="VimVisualSwapEndsBlock" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapEndsBlockAction" text="Swap Visual Selection Ends"/>
|
<action id="VimVisualSwapEndsBlock" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapEndsBlockAction" text="Swap Visual Selection Ends"/>
|
||||||
<action id="VimVisualSelectPrevious" class="com.maddyhome.idea.vim.action.motion.visual.VisualSelectPreviousAction" text="Swap Visual Selection Ends"/>
|
<action id="VimVisualSelectPrevious" class="com.maddyhome.idea.vim.action.motion.visual.VisualSelectPreviousAction" text="Visual Select Previous"/>
|
||||||
<action id="VimVisualSwapSelections" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapSelectionsAction" text="Swap Visual Selection Ends"/>
|
<action id="VimVisualSwapSelections" class="com.maddyhome.idea.vim.action.motion.visual.VisualSwapSelectionsAction" text="Swap Visual Selection Ends"/>
|
||||||
|
|
||||||
<!-- Insert -->
|
<!-- Insert -->
|
||||||
@@ -313,6 +312,18 @@
|
|||||||
<action id="VimFileGetFileInfo" class="com.maddyhome.idea.vim.action.file.FileGetFileInfoAction" text="Get File Info"/>
|
<action id="VimFileGetFileInfo" class="com.maddyhome.idea.vim.action.file.FileGetFileInfoAction" text="Get File Info"/>
|
||||||
<action id="VimFileGetLocationInfo" class="com.maddyhome.idea.vim.action.file.FileGetLocationInfoAction" text="Get Location Info"/>
|
<action id="VimFileGetLocationInfo" class="com.maddyhome.idea.vim.action.file.FileGetLocationInfoAction" text="Get Location Info"/>
|
||||||
|
|
||||||
|
<!-- Window -->
|
||||||
|
<action id="VimWindowSplitVertical" class="com.maddyhome.idea.vim.action.window.VerticalSplitAction" text="Split window vertically"/>
|
||||||
|
<action id="VimWindowSplitHorizontal" class="com.maddyhome.idea.vim.action.window.HorizontalSplitAction" text="Split window horizontally"/>
|
||||||
|
<action id="VimWindowClose" class="com.maddyhome.idea.vim.action.window.CloseWindowAction" text="Close current window"/>
|
||||||
|
<action id="VimWindowOnly" class="com.maddyhome.idea.vim.action.window.WindowOnlyAction" text="Close all windows except current"/>
|
||||||
|
<action id="VimWindowNext" class="com.maddyhome.idea.vim.action.window.WindowNextAction" text="Select next window"/>
|
||||||
|
<action id="VimWindowPrev" class="com.maddyhome.idea.vim.action.window.WindowPrevAction" text="Select previous window"/>
|
||||||
|
<action id="VimWindowLeft" class="com.maddyhome.idea.vim.action.window.WindowLeftAction" text="Go to left window"/>
|
||||||
|
<action id="VimWindowRight" class="com.maddyhome.idea.vim.action.window.WindowRightAction" text="Go to right window"/>
|
||||||
|
<action id="VimWindowUp" class="com.maddyhome.idea.vim.action.window.WindowUpAction" text="Go to window up"/>
|
||||||
|
<action id="VimWindowDown" class="com.maddyhome.idea.vim.action.window.WindowDownAction" text="Go to window down"/>
|
||||||
|
|
||||||
<!-- Search -->
|
<!-- Search -->
|
||||||
<action id="VimSearchFwdEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryFwdAction" text="Search Forward"/>
|
<action id="VimSearchFwdEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryFwdAction" text="Search Forward"/>
|
||||||
<action id="VimSearchRevEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryRevAction" text="Search Backward"/>
|
<action id="VimSearchRevEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryRevAction" text="Search Backward"/>
|
||||||
|
109
src/com/maddyhome/idea/vim/EventFacade.java
Normal file
109
src/com/maddyhome/idea/vim/EventFacade.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package com.maddyhome.idea.vim;
|
||||||
|
|
||||||
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
|
import com.intellij.openapi.actionSystem.ShortcutSet;
|
||||||
|
import com.intellij.openapi.editor.Document;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.intellij.openapi.editor.EditorFactory;
|
||||||
|
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||||
|
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||||
|
import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
|
||||||
|
import com.intellij.openapi.editor.event.*;
|
||||||
|
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.project.ProjectManager;
|
||||||
|
import com.intellij.openapi.project.ProjectManagerListener;
|
||||||
|
import com.intellij.util.messages.MessageBusConnection;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vlan
|
||||||
|
*/
|
||||||
|
public class EventFacade {
|
||||||
|
@NotNull private static final EventFacade ourInstance = new EventFacade();
|
||||||
|
|
||||||
|
@Nullable private TypedActionHandler myOriginalTypedActionHandler;
|
||||||
|
|
||||||
|
private EventFacade() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static EventFacade getInstance() {
|
||||||
|
return ourInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProjectManagerListener(@NotNull ProjectManagerListener listener) {
|
||||||
|
ProjectManager.getInstance().addProjectManagerListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupTypedActionHandler(@NotNull TypedActionHandler handler) {
|
||||||
|
final TypedAction typedAction = getTypedAction();
|
||||||
|
myOriginalTypedActionHandler = typedAction.getRawHandler();
|
||||||
|
typedAction.setupRawHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreTypedActionHandler() {
|
||||||
|
if (myOriginalTypedActionHandler != null) {
|
||||||
|
getTypedAction().setupRawHandler(myOriginalTypedActionHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCustomShortcutSet(@NotNull AnAction action, @NotNull ShortcutSet shortcutSet,
|
||||||
|
@Nullable JComponent component) {
|
||||||
|
action.registerCustomShortcutSet(shortcutSet, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregisterCustomShortcutSet(@NotNull AnAction action, @Nullable JComponent component) {
|
||||||
|
action.unregisterCustomShortcutSet(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFileEditorManagerListener(@NotNull Project project, @NotNull FileEditorManagerListener listener) {
|
||||||
|
final MessageBusConnection connection = project.getMessageBus().connect();
|
||||||
|
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDocumentListener(@NotNull Document document, @NotNull DocumentListener listener) {
|
||||||
|
document.addDocumentListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDocumentListener(@NotNull Document document, @NotNull DocumentListener listener) {
|
||||||
|
document.removeDocumentListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEditorFactoryListener(@NotNull EditorFactoryListener listener, @NotNull Disposable parentDisposable) {
|
||||||
|
EditorFactory.getInstance().addEditorFactoryListener(listener, parentDisposable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEditorMouseListener(@NotNull Editor editor, @NotNull EditorMouseListener listener) {
|
||||||
|
editor.addEditorMouseListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEditorMouseListener(@NotNull Editor editor, @NotNull EditorMouseListener listener) {
|
||||||
|
editor.removeEditorMouseListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEditorMouseMotionListener(@NotNull Editor editor, @NotNull EditorMouseMotionListener listener) {
|
||||||
|
editor.addEditorMouseMotionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEditorMouseMotionListener(@NotNull Editor editor, @NotNull EditorMouseMotionListener listener) {
|
||||||
|
editor.removeEditorMouseMotionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEditorSelectionListener(@NotNull Editor editor, @NotNull SelectionListener listener) {
|
||||||
|
editor.getSelectionModel().addSelectionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEditorSelectionListener(@NotNull Editor editor, @NotNull SelectionListener listener) {
|
||||||
|
editor.getSelectionModel().removeSelectionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private TypedAction getTypedAction() {
|
||||||
|
return EditorActionManager.getInstance().getTypedAction();
|
||||||
|
}
|
||||||
|
}
|
@@ -111,29 +111,29 @@ public class KeyHandler {
|
|||||||
editor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
editor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||||
final CommandState editorState = CommandState.getInstance(editor);
|
final CommandState editorState = CommandState.getInstance(editor);
|
||||||
|
|
||||||
if (allowKeyMappings && handleKeyMapping(editor, key, context)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean isRecording = editorState.isRecording();
|
|
||||||
boolean shouldRecord = true;
|
|
||||||
// If this is a "regular" character keystroke, get the character
|
// If this is a "regular" character keystroke, get the character
|
||||||
char chKey = key.getKeyChar() == KeyEvent.CHAR_UNDEFINED ? 0 : key.getKeyChar();
|
char chKey = key.getKeyChar() == KeyEvent.CHAR_UNDEFINED ? 0 : key.getKeyChar();
|
||||||
|
|
||||||
if (isEditorReset(key, editorState)) {
|
final boolean isRecording = editorState.isRecording();
|
||||||
handleEditorReset(editor, key, context);
|
boolean shouldRecord = true;
|
||||||
}
|
|
||||||
// At this point the user must be typing in a command. Most commands can be preceded by a number. Let's
|
// Check for command count before key mappings - otherwise e.g. ':map 0 ^' breaks command counts that contain a zero
|
||||||
// check if a number can be entered at this point, and if so, did the user send us a digit.
|
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');
|
||||||
}
|
}
|
||||||
|
else if (allowKeyMappings && handleKeyMapping(editor, key, context)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Pressing delete while entering a count "removes" the last digit entered
|
// Pressing delete while entering a count "removes" the last digit entered
|
||||||
|
// Unlike the digits, this must be checked *after* checking for key mappings
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
else if (isEditorReset(key, editorState)) {
|
||||||
|
handleEditorReset(editor, key, context);
|
||||||
|
}
|
||||||
// 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.
|
||||||
else if (currentArg == Argument.Type.CHARACTER) {
|
else if (currentArg == Argument.Type.CHARACTER) {
|
||||||
@@ -164,7 +164,7 @@ public class KeyHandler {
|
|||||||
// If this is an argument node then the last keystroke was not part of the current command but should
|
// 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, true, (ArgumentNode)node);
|
shouldRecord = handleArgumentNode(editor, key, context, editorState, (ArgumentNode)node);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (lastWasBS && lastChar != 0 && Options.getInstance().isSet("digraph")) {
|
if (lastWasBS && lastChar != 0 && Options.getInstance().isSet("digraph")) {
|
||||||
@@ -179,7 +179,7 @@ public class KeyHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (editorState.getMappingMode() == MappingMode.CMD_LINE) {
|
else if (editorState.getMappingMode() == MappingMode.CMD_LINE) {
|
||||||
if (!VimPlugin.getProcess().processExKey(editor, key, true)) {
|
if (!VimPlugin.getProcess().processExKey(editor, key)) {
|
||||||
shouldRecord = false;
|
shouldRecord = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,8 +252,12 @@ public class KeyHandler {
|
|||||||
final Runnable handleMappedKeys = new Runnable() {
|
final Runnable handleMappedKeys = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
final boolean fromIsPrefix = isPrefix(mappingInfo.getFromKeys(), mappingInfo.getToKeys());
|
||||||
|
boolean first = true;
|
||||||
for (KeyStroke keyStroke : mappingInfo.getToKeys()) {
|
for (KeyStroke keyStroke : mappingInfo.getToKeys()) {
|
||||||
handleKey(editor, keyStroke, new EditorDataContext(editor), mappingInfo.isRecursive());
|
final boolean recursive = mappingInfo.isRecursive() && !(first && fromIsPrefix);
|
||||||
|
handleKey(editor, keyStroke, new EditorDataContext(editor), recursive);
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -275,18 +279,32 @@ public class KeyHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull final DataContext context) {
|
private static <T> boolean isPrefix(@NotNull List<T> list1, @NotNull List<T> list2) {
|
||||||
if (state != State.COMMAND && count == 0 && currentArg == Argument.Type.NONE && currentCmd.size() == 0 &&
|
if (list1.size() > list2.size()) {
|
||||||
VimPlugin.getRegister().getCurrentRegister() == RegisterGroup.REGISTER_DEFAULT) {
|
return false;
|
||||||
if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
}
|
||||||
CommandProcessor.getInstance().executeCommand(editor.getProject(), new Runnable() {
|
for (int i = 0; i < list1.size(); i++) {
|
||||||
@Override
|
if (!list1.get(i).equals(list2.get(i))) {
|
||||||
public void run() {
|
return false;
|
||||||
KeyHandler.executeAction("EditorEscape", context);
|
}
|
||||||
}
|
}
|
||||||
}, "", null);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull final DataContext context) {
|
||||||
|
if (state != State.COMMAND && count == 0 && currentArg == Argument.Type.NONE && currentCmd.size() == 0) {
|
||||||
|
RegisterGroup register = VimPlugin.getRegister();
|
||||||
|
if (register.getCurrentRegister() == register.getDefaultRegister()) {
|
||||||
|
if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||||
|
CommandProcessor.getInstance().executeCommand(editor.getProject(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
KeyHandler.executeAction("EditorEscape", context);
|
||||||
|
}
|
||||||
|
}, "", null);
|
||||||
|
}
|
||||||
|
VimPlugin.indicateError();
|
||||||
}
|
}
|
||||||
VimPlugin.indicateError();
|
|
||||||
}
|
}
|
||||||
reset(editor);
|
reset(editor);
|
||||||
}
|
}
|
||||||
@@ -370,7 +388,6 @@ public class KeyHandler {
|
|||||||
|
|
||||||
private void executeCommand(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
private void executeCommand(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
||||||
@NotNull CommandState editorState) {
|
@NotNull CommandState editorState) {
|
||||||
DelegateCommandListener.getInstance().setRunnable(null);
|
|
||||||
// Let's go through the command stack and merge it all into one command. At this time there should never
|
// Let's go through the command stack and merge it all into one command. At this time there should never
|
||||||
// be more than two commands on the stack - one is the actual command and the other would be a motion
|
// be more than two commands on the stack - one is the actual command and the other would be a motion
|
||||||
// command argument needed by the first command
|
// command argument needed by the first command
|
||||||
@@ -427,8 +444,7 @@ public class KeyHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleArgumentNode(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
private boolean handleArgumentNode(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull DataContext context,
|
||||||
@NotNull CommandState editorState, boolean shouldRecord,
|
@NotNull CommandState editorState, @NotNull ArgumentNode node) {
|
||||||
@NotNull ArgumentNode 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);
|
||||||
@@ -462,9 +478,9 @@ public class KeyHandler {
|
|||||||
if (currentArg != Argument.Type.NONE) {
|
if (currentArg != Argument.Type.NONE) {
|
||||||
partialReset(editor);
|
partialReset(editor);
|
||||||
handleKey(editor, key, context);
|
handleKey(editor, key, context);
|
||||||
shouldRecord = false; // Prevent this from getting recorded twice
|
return false;
|
||||||
}
|
}
|
||||||
return shouldRecord;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCommandNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandNode node) {
|
private void handleCommandNode(@NotNull Editor editor, @NotNull DataContext context, @NotNull CommandNode node) {
|
||||||
@@ -546,12 +562,10 @@ public class KeyHandler {
|
|||||||
* @param name The name of the action to execute
|
* @param name The name of the action to execute
|
||||||
* @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 boolean executeAction(@NotNull String name, @NotNull DataContext context) {
|
||||||
ActionManager aMgr = ActionManager.getInstance();
|
ActionManager aMgr = ActionManager.getInstance();
|
||||||
AnAction action = aMgr.getAction(name);
|
AnAction action = aMgr.getAction(name);
|
||||||
if (action != null) {
|
return action != null && executeAction(action, context);
|
||||||
executeAction(action, context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -560,16 +574,20 @@ public class KeyHandler {
|
|||||||
* @param action The action to execute
|
* @param action The action to execute
|
||||||
* @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 boolean executeAction(@NotNull AnAction action, @NotNull DataContext context) {
|
||||||
// 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(
|
final AnActionEvent event = new AnActionEvent(null, context, "", action.getTemplatePresentation(),
|
||||||
new AnActionEvent(null, context, "", action.getTemplatePresentation(), ActionManager.getInstance(),
|
ActionManager.getInstance(), 0);
|
||||||
// API change - don't merge
|
action.update(event);
|
||||||
0));
|
if (event.getPresentation().isEnabled()) {
|
||||||
|
action.actionPerformed(event);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,7 +631,6 @@ public class KeyHandler {
|
|||||||
lastChar = 0;
|
lastChar = 0;
|
||||||
lastWasBS = false;
|
lastWasBS = false;
|
||||||
VimPlugin.getRegister().resetRegister();
|
VimPlugin.getRegister().resetRegister();
|
||||||
DelegateCommandListener.getInstance().setRunnable(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -660,10 +677,10 @@ public class KeyHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Editor editor;
|
private final Editor editor;
|
||||||
private DataContext context;
|
private final DataContext context;
|
||||||
private Command cmd;
|
private final Command cmd;
|
||||||
private KeyStroke key;
|
private final KeyStroke key;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static enum State {
|
private static enum State {
|
||||||
@@ -677,7 +694,7 @@ public class KeyHandler {
|
|||||||
private int count;
|
private int count;
|
||||||
private List<KeyStroke> keys;
|
private List<KeyStroke> keys;
|
||||||
private State state;
|
private State state;
|
||||||
@NotNull private Stack<Command> currentCmd = new Stack<Command>();
|
@NotNull private final Stack<Command> currentCmd = new Stack<Command>();
|
||||||
@NotNull private Argument.Type currentArg;
|
@NotNull private Argument.Type currentArg;
|
||||||
private TypedActionHandler origHandler;
|
private TypedActionHandler origHandler;
|
||||||
@Nullable private DigraphSequence digraph = null;
|
@Nullable private DigraphSequence digraph = null;
|
||||||
|
@@ -37,7 +37,6 @@ public class RegisterActions {
|
|||||||
registerVimCommandActions();
|
registerVimCommandActions();
|
||||||
|
|
||||||
registerInsertModeActions();
|
registerInsertModeActions();
|
||||||
registerVisualModeActions();
|
|
||||||
registerNormalModeActions();
|
registerNormalModeActions();
|
||||||
registerNVOModesActions();
|
registerNVOModesActions();
|
||||||
registerCommandLineActions();
|
registerCommandLineActions();
|
||||||
@@ -251,8 +250,7 @@ public class RegisterActions {
|
|||||||
parser
|
parser
|
||||||
.registerAction(MappingMode.NVO, "VimMotionFirstScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
.registerAction(MappingMode.NVO, "VimMotionFirstScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||||
new Shortcut[]{
|
new Shortcut[]{
|
||||||
new Shortcut('H'),
|
new Shortcut('H')
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, KeyEvent.CTRL_MASK))
|
|
||||||
});
|
});
|
||||||
parser
|
parser
|
||||||
.registerAction(MappingMode.NVO, "VimMotionGotoLineFirst", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
.registerAction(MappingMode.NVO, "VimMotionGotoLineFirst", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||||
@@ -283,9 +281,6 @@ public class RegisterActions {
|
|||||||
parser
|
parser
|
||||||
.registerAction(MappingMode.NVO, "VimMotionLastScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
.registerAction(MappingMode.NVO, "VimMotionLastScreenLine", Command.Type.MOTION, Command.FLAG_MOT_LINEWISE | Command.FLAG_SAVE_JUMP,
|
||||||
new Shortcut('L'));
|
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[]{
|
parser.registerAction(MappingMode.NVO, "VimMotionLeft", Command.Type.MOTION, Command.FLAG_MOT_EXCLUSIVE, new Shortcut[]{
|
||||||
new Shortcut('h'),
|
new Shortcut('h'),
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0))
|
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0))
|
||||||
@@ -605,8 +600,6 @@ public class RegisterActions {
|
|||||||
new Shortcut('&'));
|
new Shortcut('&'));
|
||||||
parser.registerAction(MappingMode.N, "VimLastGlobalSearchReplace", Command.Type.OTHER_WRITABLE,
|
parser.registerAction(MappingMode.N, "VimLastGlobalSearchReplace", Command.Type.OTHER_WRITABLE,
|
||||||
new Shortcut("g&"));
|
new Shortcut("g&"));
|
||||||
parser.registerAction(MappingMode.N, "VimVisualSelectPrevious", Command.Type.OTHER_READONLY,
|
|
||||||
new Shortcut("gv"));
|
|
||||||
parser.registerAction(MappingMode.N, "VimRepeatChange", Command.Type.OTHER_WRITABLE,
|
parser.registerAction(MappingMode.N, "VimRepeatChange", Command.Type.OTHER_WRITABLE,
|
||||||
new Shortcut('.'));
|
new Shortcut('.'));
|
||||||
parser.registerAction(MappingMode.N, "VimRepeatExCommand", Command.Type.OTHER_WRITABLE,
|
parser.registerAction(MappingMode.N, "VimRepeatExCommand", Command.Type.OTHER_WRITABLE,
|
||||||
@@ -637,11 +630,11 @@ public class RegisterActions {
|
|||||||
new Shortcut("=="));
|
new Shortcut("=="));
|
||||||
parser.registerAction(MappingMode.N, "VimShiftLeftLines", Command.Type.CHANGE,
|
parser.registerAction(MappingMode.N, "VimShiftLeftLines", Command.Type.CHANGE,
|
||||||
new Shortcut("<<"));
|
new Shortcut("<<"));
|
||||||
parser.registerAction(MappingMode.N, "VimShiftLeftMotion", Command.Type.CHANGE,
|
parser.registerAction(MappingMode.N, "VimShiftLeftMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND,
|
||||||
new Shortcut('<'), Argument.Type.MOTION);
|
new Shortcut('<'), Argument.Type.MOTION);
|
||||||
parser.registerAction(MappingMode.N, "VimShiftRightLines", Command.Type.CHANGE,
|
parser.registerAction(MappingMode.N, "VimShiftRightLines", Command.Type.CHANGE,
|
||||||
new Shortcut(">>"));
|
new Shortcut(">>"));
|
||||||
parser.registerAction(MappingMode.N, "VimShiftRightMotion", Command.Type.CHANGE,
|
parser.registerAction(MappingMode.N, "VimShiftRightMotion", Command.Type.CHANGE, Command.FLAG_OP_PEND,
|
||||||
new Shortcut('>'), Argument.Type.MOTION);
|
new Shortcut('>'), Argument.Type.MOTION);
|
||||||
|
|
||||||
// Jump Actions
|
// Jump Actions
|
||||||
@@ -664,9 +657,6 @@ public class RegisterActions {
|
|||||||
parser.registerAction(MappingMode.N, "VimFileGetFileInfo", Command.Type.OTHER_READONLY,
|
parser.registerAction(MappingMode.N, "VimFileGetFileInfo", Command.Type.OTHER_READONLY,
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)));
|
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
|
// Macro Actions
|
||||||
parser.registerAction(MappingMode.N, "VimPlaybackLastRegister", Command.Type.OTHER_WRITABLE,
|
parser.registerAction(MappingMode.N, "VimPlaybackLastRegister", Command.Type.OTHER_WRITABLE,
|
||||||
new Shortcut("@@"));
|
new Shortcut("@@"));
|
||||||
@@ -675,93 +665,6 @@ public class RegisterActions {
|
|||||||
// TODO - support for :map macros
|
// 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() {
|
private static void registerInsertModeActions() {
|
||||||
final KeyGroup parser = VimPlugin.getKey();
|
final KeyGroup parser = VimPlugin.getKey();
|
||||||
// Other insert actions
|
// Other insert actions
|
||||||
@@ -819,11 +722,11 @@ public class RegisterActions {
|
|||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, KeyEvent.CTRL_MASK)));
|
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, KeyEvent.CTRL_MASK)));
|
||||||
parser.registerAction(MappingMode.I, "VimMotionLastColumn", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
|
parser.registerAction(MappingMode.I, "VimMotionLastColumn", Command.Type.INSERT, Command.FLAG_SAVE_STROKE,
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0)));
|
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0)));
|
||||||
parser.registerAction(MappingMode.I, "VimMotionLeft", Command.Type.INSERT, Command.FLAG_SAVE_STROKE, new Shortcut[]{
|
parser.registerAction(MappingMode.I, "VimMotionLeft", Command.Type.INSERT, new Shortcut[]{
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)),
|
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)),
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_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[]{
|
parser.registerAction(MappingMode.I, "VimMotionRight", Command.Type.INSERT, new Shortcut[]{
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)),
|
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)),
|
||||||
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0))
|
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0))
|
||||||
});
|
});
|
||||||
|
@@ -18,25 +18,17 @@
|
|||||||
package com.maddyhome.idea.vim;
|
package com.maddyhome.idea.vim;
|
||||||
|
|
||||||
import com.intellij.notification.*;
|
import com.intellij.notification.*;
|
||||||
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;
|
||||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||||
import com.intellij.openapi.command.CommandProcessor;
|
|
||||||
import com.intellij.openapi.components.ApplicationComponent;
|
import com.intellij.openapi.components.ApplicationComponent;
|
||||||
import com.intellij.openapi.components.PersistentStateComponent;
|
import com.intellij.openapi.components.PersistentStateComponent;
|
||||||
import com.intellij.openapi.components.State;
|
import com.intellij.openapi.components.State;
|
||||||
import com.intellij.openapi.components.Storage;
|
import com.intellij.openapi.components.Storage;
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.editor.Editor;
|
|
||||||
import com.intellij.openapi.editor.EditorFactory;
|
|
||||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||||
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||||
import com.intellij.openapi.editor.event.EditorFactoryAdapter;
|
|
||||||
import com.intellij.openapi.editor.event.EditorFactoryEvent;
|
|
||||||
import com.intellij.openapi.editor.ex.EditorEx;
|
|
||||||
import com.intellij.openapi.extensions.PluginId;
|
import com.intellij.openapi.extensions.PluginId;
|
||||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
|
||||||
import com.intellij.openapi.keymap.Keymap;
|
import com.intellij.openapi.keymap.Keymap;
|
||||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||||
import com.intellij.openapi.keymap.impl.DefaultKeymap;
|
import com.intellij.openapi.keymap.impl.DefaultKeymap;
|
||||||
@@ -48,18 +40,17 @@ import com.intellij.openapi.ui.Messages;
|
|||||||
import com.intellij.openapi.util.SystemInfo;
|
import com.intellij.openapi.util.SystemInfo;
|
||||||
import com.intellij.openapi.wm.StatusBar;
|
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.ex.CommandParser;
|
import com.maddyhome.idea.vim.ex.CommandParser;
|
||||||
import com.maddyhome.idea.vim.ex.VimScriptParser;
|
import com.maddyhome.idea.vim.ex.vimscript.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.DocumentManager;
|
||||||
|
import com.maddyhome.idea.vim.helper.MacKeyRepeat;
|
||||||
import com.maddyhome.idea.vim.option.Options;
|
import com.maddyhome.idea.vim.option.Options;
|
||||||
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
|
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.event.HyperlinkEvent;
|
import javax.swing.event.HyperlinkEvent;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -85,16 +76,8 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
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_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 = 3;
|
public static final int STATE_VERSION = 4;
|
||||||
|
|
||||||
private static final boolean BLOCK_CURSOR_VIM_VALUE = true;
|
|
||||||
private static final boolean ANIMATED_SCROLLING_VIM_VALUE = false;
|
|
||||||
private static final boolean REFRAIN_FROM_SCROLLING_VIM_VALUE = true;
|
|
||||||
|
|
||||||
private VimTypedActionHandler vimHandler;
|
|
||||||
private boolean isBlockCursor = false;
|
|
||||||
private boolean isAnimatedScrolling = false;
|
|
||||||
private boolean isRefrainFromScrolling = false;
|
|
||||||
private boolean error = false;
|
private boolean error = false;
|
||||||
|
|
||||||
private int previousStateVersion = 0;
|
private int previousStateVersion = 0;
|
||||||
@@ -103,26 +86,24 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
// It is enabled by default to avoid any special configuration after plugin installation
|
// It is enabled by default to avoid any special configuration after plugin installation
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
|
||||||
private static Logger LOG = Logger.getInstance(VimPlugin.class);
|
private static final Logger LOG = Logger.getInstance(VimPlugin.class);
|
||||||
|
|
||||||
private final Application myApp;
|
@NotNull private final MotionGroup motion;
|
||||||
|
@NotNull private final ChangeGroup change;
|
||||||
private MotionGroup motion;
|
@NotNull private final CopyGroup copy;
|
||||||
private ChangeGroup change;
|
@NotNull private final MarkGroup mark;
|
||||||
private CopyGroup copy;
|
@NotNull private final RegisterGroup register;
|
||||||
private MarkGroup mark;
|
@NotNull private final FileGroup file;
|
||||||
private RegisterGroup register;
|
@NotNull private final SearchGroup search;
|
||||||
private FileGroup file;
|
@NotNull private final ProcessGroup process;
|
||||||
private SearchGroup search;
|
@NotNull private final MacroGroup macro;
|
||||||
private ProcessGroup process;
|
@NotNull private final DigraphGroup digraph;
|
||||||
private MacroGroup macro;
|
@NotNull private final HistoryGroup history;
|
||||||
private DigraphGroup digraph;
|
@NotNull private final KeyGroup key;
|
||||||
private HistoryGroup history;
|
@NotNull private final WindowGroup window;
|
||||||
private KeyGroup key;
|
@NotNull private final EditorGroup editor;
|
||||||
|
|
||||||
public VimPlugin(final Application app) {
|
|
||||||
myApp = app;
|
|
||||||
|
|
||||||
|
public VimPlugin() {
|
||||||
motion = new MotionGroup();
|
motion = new MotionGroup();
|
||||||
change = new ChangeGroup();
|
change = new ChangeGroup();
|
||||||
copy = new CopyGroup();
|
copy = new CopyGroup();
|
||||||
@@ -135,6 +116,8 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
digraph = new DigraphGroup();
|
digraph = new DigraphGroup();
|
||||||
history = new HistoryGroup();
|
history = new HistoryGroup();
|
||||||
key = new KeyGroup();
|
key = new KeyGroup();
|
||||||
|
window = new WindowGroup();
|
||||||
|
editor = new EditorGroup();
|
||||||
|
|
||||||
LOG.debug("VimPlugin ctr");
|
LOG.debug("VimPlugin ctr");
|
||||||
}
|
}
|
||||||
@@ -157,12 +140,8 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EditorActionManager manager = EditorActionManager.getInstance();
|
final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
|
||||||
TypedAction action = manager.getTypedAction();
|
EventFacade.getInstance().setupTypedActionHandler(new VimTypedActionHandler(typedAction.getRawHandler()));
|
||||||
|
|
||||||
// Replace the default key handler with the Vim key handler
|
|
||||||
vimHandler = new VimTypedActionHandler(action.getHandler());
|
|
||||||
action.setupHandler(vimHandler);
|
|
||||||
|
|
||||||
// Register vim actions in command mode
|
// Register vim actions in command mode
|
||||||
RegisterActions.registerActions();
|
RegisterActions.registerActions();
|
||||||
@@ -174,9 +153,9 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
CommandParser.getInstance().registerHandlers();
|
CommandParser.getInstance().registerHandlers();
|
||||||
|
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
final File vimrc = VimScriptParser.findVimrc();
|
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
|
||||||
if (vimrc != null) {
|
if (ideaVimRc != null) {
|
||||||
VimScriptParser.executeFile(vimrc);
|
VimScriptParser.executeFile(ideaVimRc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,9 +166,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
public void disposeComponent() {
|
public void disposeComponent() {
|
||||||
LOG.debug("disposeComponent");
|
LOG.debug("disposeComponent");
|
||||||
turnOffPlugin();
|
turnOffPlugin();
|
||||||
EditorActionManager manager = EditorActionManager.getInstance();
|
EventFacade.getInstance().restoreTypedActionHandler();
|
||||||
TypedAction action = manager.getTypedAction();
|
|
||||||
action.setupHandler(vimHandler.getOriginalTypedHandler());
|
|
||||||
LOG.debug("done");
|
LOG.debug("done");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +186,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
search.saveData(element);
|
search.saveData(element);
|
||||||
history.saveData(element);
|
history.saveData(element);
|
||||||
key.saveData(element);
|
key.saveData(element);
|
||||||
|
editor.saveData(element);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
@@ -234,56 +212,80 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
search.readData(element);
|
search.readData(element);
|
||||||
history.readData(element);
|
history.readData(element);
|
||||||
key.readData(element);
|
key.readData(element);
|
||||||
|
editor.readData(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static MotionGroup getMotion() {
|
public static MotionGroup getMotion() {
|
||||||
return getInstance().motion;
|
return getInstance().motion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static ChangeGroup getChange() {
|
public static ChangeGroup getChange() {
|
||||||
return getInstance().change;
|
return getInstance().change;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static CopyGroup getCopy() {
|
public static CopyGroup getCopy() {
|
||||||
return getInstance().copy;
|
return getInstance().copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static MarkGroup getMark() {
|
public static MarkGroup getMark() {
|
||||||
return getInstance().mark;
|
return getInstance().mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static RegisterGroup getRegister() {
|
public static RegisterGroup getRegister() {
|
||||||
return getInstance().register;
|
return getInstance().register;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static FileGroup getFile() {
|
public static FileGroup getFile() {
|
||||||
return getInstance().file;
|
return getInstance().file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static SearchGroup getSearch() {
|
public static SearchGroup getSearch() {
|
||||||
return getInstance().search;
|
return getInstance().search;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static ProcessGroup getProcess() {
|
public static ProcessGroup getProcess() {
|
||||||
return getInstance().process;
|
return getInstance().process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static MacroGroup getMacro() {
|
public static MacroGroup getMacro() {
|
||||||
return getInstance().macro;
|
return getInstance().macro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static DigraphGroup getDigraph() {
|
public static DigraphGroup getDigraph() {
|
||||||
return getInstance().digraph;
|
return getInstance().digraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HistoryGroup getHistory() {
|
public static HistoryGroup getHistory() {
|
||||||
return getInstance().history;
|
return getInstance().history;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static KeyGroup getKey() {
|
public static KeyGroup getKey() {
|
||||||
return getInstance().key;
|
return getInstance().key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static WindowGroup getWindow() {
|
||||||
|
return getInstance().window;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static EditorGroup getEditor() {
|
||||||
|
return getInstance().editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static PluginId getPluginId() {
|
public static PluginId getPluginId() {
|
||||||
return PluginId.getId(IDEAVIM_PLUGIN_ID);
|
return PluginId.getId(IDEAVIM_PLUGIN_ID);
|
||||||
}
|
}
|
||||||
@@ -353,41 +355,41 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
|
|
||||||
private void turnOnPlugin() {
|
private void turnOnPlugin() {
|
||||||
KeyHandler.getInstance().fullReset(null);
|
KeyHandler.getInstance().fullReset(null);
|
||||||
setCursors(BLOCK_CURSOR_VIM_VALUE);
|
|
||||||
setAnimatedScrolling(ANIMATED_SCROLLING_VIM_VALUE);
|
|
||||||
setRefrainFromScrolling(REFRAIN_FROM_SCROLLING_VIM_VALUE);
|
|
||||||
|
|
||||||
|
getEditor().turnOn();
|
||||||
getMotion().turnOn();
|
getMotion().turnOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void turnOffPlugin() {
|
private void turnOffPlugin() {
|
||||||
KeyHandler.getInstance().fullReset(null);
|
KeyHandler.getInstance().fullReset(null);
|
||||||
setCursors(isBlockCursor);
|
|
||||||
setAnimatedScrolling(isAnimatedScrolling);
|
|
||||||
setRefrainFromScrolling(isRefrainFromScrolling);
|
|
||||||
|
|
||||||
|
getEditor().turnOff();
|
||||||
getMotion().turnOff();
|
getMotion().turnOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
boolean requiresRestart = false;
|
boolean requiresRestart = false;
|
||||||
if (previousStateVersion < 2 && SystemInfo.isMac) {
|
if (SystemInfo.isMac) {
|
||||||
final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
|
final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
|
||||||
final Boolean enabled = keyRepeat.isEnabled();
|
final Boolean enabled = keyRepeat.isEnabled();
|
||||||
if (enabled == null || !enabled) {
|
final Boolean isKeyRepeat = editor.isKeyRepeat();
|
||||||
|
if ((enabled == null || !enabled) && (isKeyRepeat == null || isKeyRepeat)) {
|
||||||
if (Messages.showYesNoDialog("Do you want to enable repeating keys in Mac OS X on press and hold " +
|
if (Messages.showYesNoDialog("Do you want to enable repeating keys in Mac OS X on press and hold " +
|
||||||
"(requires restart)?\n\n" +
|
"(requires restart)?\n\n" +
|
||||||
"(You can do it manually by running 'defaults write -g " +
|
"(You can do it manually by running 'defaults write -g " +
|
||||||
"ApplePressAndHoldEnabled 0' in the console).", IDEAVIM_NOTIFICATION_TITLE,
|
"ApplePressAndHoldEnabled 0' in the console).", IDEAVIM_NOTIFICATION_TITLE,
|
||||||
Messages.getQuestionIcon()
|
Messages.getQuestionIcon()) == Messages.YES) {
|
||||||
) == Messages.YES) {
|
editor.setKeyRepeat(true);
|
||||||
keyRepeat.setEnabled(true);
|
keyRepeat.setEnabled(true);
|
||||||
requiresRestart = true;
|
requiresRestart = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
editor.setKeyRepeat(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (previousStateVersion < 3) {
|
if (previousStateVersion > 0 && previousStateVersion < 3) {
|
||||||
final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
|
final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
|
||||||
Keymap keymap = null;
|
Keymap keymap = null;
|
||||||
if (previousKeyMap != null) {
|
if (previousKeyMap != null) {
|
||||||
@@ -404,7 +406,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
"Switching to \"%s\" keymap.<br/><br/>" +
|
"Switching to \"%s\" keymap.<br/><br/>" +
|
||||||
"Now it is possible to set up:<br/>" +
|
"Now it is possible to set up:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li>Vim keys in your .vimrc file using key mapping commands</li>" +
|
"<li>Vim keys in your ~/.ideavimrc file using key mapping commands</li>" +
|
||||||
"<li>IDE action shortcuts in \"File | Settings | Keymap\"</li>" +
|
"<li>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>" +
|
"<li>Vim or IDE handlers for conflicting shortcuts in <a href='#settings'>Vim Emulation</a> settings</li>" +
|
||||||
"</ul>", keymap.getPresentableName()),
|
"</ul>", keymap.getPresentableName()),
|
||||||
@@ -417,6 +419,15 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
}).notify(null);
|
}).notify(null);
|
||||||
manager.setActiveKeymap(keymap);
|
manager.setActiveKeymap(keymap);
|
||||||
}
|
}
|
||||||
|
if (previousStateVersion > 0 && previousStateVersion < 4) {
|
||||||
|
new Notification(
|
||||||
|
VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID,
|
||||||
|
VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||||
|
"The ~/.vimrc file is no longer read by default, use ~/.ideavimrc instead. You can read it from your " +
|
||||||
|
"~/.ideavimrc using this command:<br/><br/>" +
|
||||||
|
"<code>source ~/.vimrc</code>",
|
||||||
|
NotificationType.INFORMATION).notify(null);
|
||||||
|
}
|
||||||
if (requiresRestart) {
|
if (requiresRestart) {
|
||||||
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||||
app.restart();
|
app.restart();
|
||||||
@@ -428,85 +439,18 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
* This sets up some listeners so we can handle various events that occur
|
* This sets up some listeners so we can handle various events that occur
|
||||||
*/
|
*/
|
||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
|
final EventFacade eventFacade = EventFacade.getInstance();
|
||||||
|
|
||||||
DocumentManager.getInstance().addDocumentListener(new MarkGroup.MarkUpdater());
|
DocumentManager.getInstance().addDocumentListener(new MarkGroup.MarkUpdater());
|
||||||
DocumentManager.getInstance().addDocumentListener(new SearchGroup.DocumentSearchListener());
|
DocumentManager.getInstance().addDocumentListener(new SearchGroup.DocumentSearchListener());
|
||||||
DocumentManager.getInstance().init();
|
|
||||||
|
|
||||||
EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
|
eventFacade.addProjectManagerListener(new ProjectManagerAdapter() {
|
||||||
@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
|
@Override
|
||||||
public void projectOpened(@NotNull final Project project) {
|
public void projectOpened(@NotNull final Project project) {
|
||||||
project.getMessageBus().connect()
|
eventFacade.addFileEditorManagerListener(project, new MotionGroup.MotionEditorChange());
|
||||||
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MotionGroup.MotionEditorChange());
|
eventFacade.addFileEditorManagerListener(project, new FileGroup.SelectionCheck());
|
||||||
project.getMessageBus().connect()
|
eventFacade.addFileEditorManagerListener(project, new SearchGroup.EditorSelectionCheck());
|
||||||
.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) {
|
|
||||||
Editor[] editors = EditorFactory.getInstance().getAllEditors();
|
|
||||||
for (Editor editor : editors) {
|
|
||||||
// Vim plugin should be turned on in insert mode
|
|
||||||
((EditorEx)editor).setInsertMode(true);
|
|
||||||
editor.getSettings().setBlockCursor(isBlock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAnimatedScrolling(boolean isOn) {
|
|
||||||
Editor[] editors = EditorFactory.getInstance().getAllEditors();
|
|
||||||
for (Editor editor : editors) {
|
|
||||||
editor.getSettings().setAnimatedScrolling(isOn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRefrainFromScrolling(boolean isOn) {
|
|
||||||
Editor[] editors = EditorFactory.getInstance().getAllEditors();
|
|
||||||
for (Editor editor : editors) {
|
|
||||||
editor.getSettings().setRefrainFromScrolling(isOn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
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.maddyhome.idea.vim.helper.EditorDataContext;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -34,10 +35,10 @@ import javax.swing.*;
|
|||||||
* IDE shortcut keys used by Vim commands are handled by {@link com.maddyhome.idea.vim.action.VimShortcutKeyAction}.
|
* 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());
|
private static final Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
|
||||||
|
|
||||||
private TypedActionHandler origHandler;
|
private final TypedActionHandler origHandler;
|
||||||
private KeyHandler handler;
|
@NotNull private final KeyHandler handler;
|
||||||
|
|
||||||
public VimTypedActionHandler(TypedActionHandler origHandler) {
|
public VimTypedActionHandler(TypedActionHandler origHandler) {
|
||||||
this.origHandler = origHandler;
|
this.origHandler = origHandler;
|
||||||
@@ -53,7 +54,7 @@ public class VimTypedActionHandler implements TypedActionHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), context);
|
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), new EditorDataContext(editor));
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
@@ -66,10 +67,6 @@ public class VimTypedActionHandler implements TypedActionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypedActionHandler getOriginalTypedHandler() {
|
|
||||||
return origHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isEnabled(@NotNull Editor editor) {
|
private boolean isEnabled(@NotNull Editor editor) {
|
||||||
if (VimPlugin.isEnabled()) {
|
if (VimPlugin.isEnabled()) {
|
||||||
final Lookup lookup = LookupManager.getActiveLookup(editor);
|
final Lookup lookup = LookupManager.getActiveLookup(editor);
|
||||||
|
@@ -18,11 +18,13 @@
|
|||||||
|
|
||||||
package com.maddyhome.idea.vim.action;
|
package com.maddyhome.idea.vim.action;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||||
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.MappingMode;
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.helper.StringHelper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -66,4 +68,13 @@ public abstract class VimCommandAction extends EditorAction {
|
|||||||
public int getFlags() {
|
public int getFlags() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
protected static Set<List<KeyStroke>> parseKeysSet(@NotNull String... keyStrings) {
|
||||||
|
final ImmutableSet.Builder<List<KeyStroke>> builder = ImmutableSet.builder();
|
||||||
|
for (String keyString : keyStrings) {
|
||||||
|
builder.add(StringHelper.parseKeys(keyString));
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,10 +23,8 @@ import com.intellij.codeInsight.lookup.LookupManager;
|
|||||||
import com.intellij.notification.Notification;
|
import com.intellij.notification.Notification;
|
||||||
import com.intellij.notification.NotificationListener;
|
import com.intellij.notification.NotificationListener;
|
||||||
import com.intellij.notification.NotificationType;
|
import com.intellij.notification.NotificationType;
|
||||||
import com.intellij.openapi.actionSystem.AnAction;
|
import com.intellij.openapi.actionSystem.*;
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
|
||||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.keymap.KeymapUtil;
|
import com.intellij.openapi.keymap.KeymapUtil;
|
||||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||||
@@ -37,6 +35,7 @@ import com.maddyhome.idea.vim.VimPlugin;
|
|||||||
import com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction;
|
import com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction;
|
||||||
import com.maddyhome.idea.vim.command.CommandState;
|
import com.maddyhome.idea.vim.command.CommandState;
|
||||||
import com.maddyhome.idea.vim.helper.EditorData;
|
import com.maddyhome.idea.vim.helper.EditorData;
|
||||||
|
import com.maddyhome.idea.vim.helper.EditorDataContext;
|
||||||
import com.maddyhome.idea.vim.key.ShortcutOwner;
|
import com.maddyhome.idea.vim.key.ShortcutOwner;
|
||||||
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
|
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -59,7 +58,9 @@ import static java.awt.event.KeyEvent.*;
|
|||||||
* These keys are not passed to {@link com.maddyhome.idea.vim.VimTypedActionHandler} and should be handled by actions.
|
* 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 {
|
public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
||||||
@NotNull public static Set<KeyStroke> VIM_ONLY_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
private static final String ACTION_ID = "VimShortcutKeyAction";
|
||||||
|
|
||||||
|
@NotNull public static final Set<KeyStroke> VIM_ONLY_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
||||||
.addAll(getKeyStrokes(VK_ENTER, 0))
|
.addAll(getKeyStrokes(VK_ENTER, 0))
|
||||||
.addAll(getKeyStrokes(VK_ESCAPE, 0))
|
.addAll(getKeyStrokes(VK_ESCAPE, 0))
|
||||||
.addAll(getKeyStrokes(VK_TAB, 0))
|
.addAll(getKeyStrokes(VK_TAB, 0))
|
||||||
@@ -72,17 +73,21 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
|||||||
.addAll(getKeyStrokes(VK_RIGHT, 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_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_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_UP, 0, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||||
.addAll(getKeyStrokes(VK_PAGE_DOWN, 0, CTRL_MASK, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
.addAll(getKeyStrokes(VK_PAGE_DOWN, 0, SHIFT_MASK, CTRL_MASK | SHIFT_MASK))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@NotNull private static Set<KeyStroke> NON_FILE_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
@NotNull private static final Set<KeyStroke> NON_FILE_EDITOR_KEYS = ImmutableSet.<KeyStroke>builder()
|
||||||
|
.addAll(getKeyStrokes(VK_ENTER, 0))
|
||||||
.addAll(getKeyStrokes(VK_ESCAPE, 0))
|
.addAll(getKeyStrokes(VK_ESCAPE, 0))
|
||||||
.addAll(getKeyStrokes(VK_TAB, 0))
|
.addAll(getKeyStrokes(VK_TAB, 0))
|
||||||
.addAll(getKeyStrokes(VK_UP, 0))
|
.addAll(getKeyStrokes(VK_UP, 0))
|
||||||
.addAll(getKeyStrokes(VK_DOWN, 0))
|
.addAll(getKeyStrokes(VK_DOWN, 0))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
private static final Logger ourLogger = Logger.getInstance(VimShortcutKeyAction.class.getName());
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||||
final Editor editor = getEditor(e);
|
final Editor editor = getEditor(e);
|
||||||
final KeyStroke keyStroke = getKeyStroke(e);
|
final KeyStroke keyStroke = getKeyStroke(e);
|
||||||
@@ -92,7 +97,18 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
|||||||
notifyAboutShortcutConflict(keyStroke);
|
notifyAboutShortcutConflict(keyStroke);
|
||||||
}
|
}
|
||||||
// Should we use InjectedLanguageUtil.getTopLevelEditor(editor) here, as we did in former EditorKeyHandler?
|
// Should we use InjectedLanguageUtil.getTopLevelEditor(editor) here, as we did in former EditorKeyHandler?
|
||||||
KeyHandler.getInstance().handleKey(editor, keyStroke, e.getDataContext());
|
// Run key handler later to restore input events sequence due to VimTypedActionHandler
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
KeyHandler.getInstance().handleKey(editor, keyStroke, new EditorDataContext(editor));
|
||||||
|
}
|
||||||
|
catch (Throwable throwable) {
|
||||||
|
ourLogger.error(throwable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +117,11 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
|||||||
e.getPresentation().setEnabled(isEnabled(e));
|
e.getPresentation().setEnabled(isEnabled(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static AnAction getInstance() {
|
||||||
|
return ActionManager.getInstance().getAction(ACTION_ID);
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyAboutShortcutConflict(@NotNull final KeyStroke keyStroke) {
|
private void notifyAboutShortcutConflict(@NotNull final KeyStroke keyStroke) {
|
||||||
VimPlugin.getKey().getSavedShortcutConflicts().put(keyStroke, ShortcutOwner.VIM);
|
VimPlugin.getKey().getSavedShortcutConflicts().put(keyStroke, ShortcutOwner.VIM);
|
||||||
final String message = String.format(
|
final String message = String.format(
|
||||||
@@ -139,7 +160,8 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
|||||||
return isExitInsertMode(keyStroke);
|
return isExitInsertMode(keyStroke);
|
||||||
}
|
}
|
||||||
if (CommandState.inInsertMode(editor)) {
|
if (CommandState.inInsertMode(editor)) {
|
||||||
if (keyCode == VK_ENTER) {
|
// XXX: <Tab> won't be recorded in macros
|
||||||
|
if (keyCode == VK_TAB) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Debug watch, Python console, etc.
|
// Debug watch, Python console, etc.
|
||||||
@@ -183,7 +205,8 @@ public class VimShortcutKeyAction extends AnAction implements DumbAware {
|
|||||||
return !VimPlugin.getKey().getKeymapConflicts(keyStroke).isEmpty();
|
return !VimPlugin.getKey().getKeymapConflicts(keyStroke).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<KeyStroke> getKeyStrokes(int keyCode, int... modifiers) {
|
@NotNull
|
||||||
|
private static List<KeyStroke> getKeyStrokes(int keyCode, @NotNull int... modifiers) {
|
||||||
final List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>();
|
final List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>();
|
||||||
for (int modifier : modifiers) {
|
for (int modifier : modifiers) {
|
||||||
keyStrokes.add(KeyStroke.getKeyStroke(keyCode, modifier));
|
keyStrokes.add(KeyStroke.getKeyStroke(keyCode, modifier));
|
||||||
|
@@ -20,17 +20,22 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author vlan
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class AutoIndentLinesVisualAction extends EditorAction {
|
public class AutoIndentLinesVisualAction extends VimCommandAction {
|
||||||
public AutoIndentLinesVisualAction() {
|
public AutoIndentLinesVisualAction() {
|
||||||
super(new VisualOperatorActionHandler() {
|
super(new VisualOperatorActionHandler() {
|
||||||
@Override
|
@Override
|
||||||
@@ -43,4 +48,27 @@ public class AutoIndentLinesVisualAction extends EditorAction {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("=");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,28 +20,54 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeCaseLowerVisualAction extends EditorAction {
|
public class ChangeCaseLowerVisualAction extends VimCommandAction {
|
||||||
public ChangeCaseLowerVisualAction() {
|
public ChangeCaseLowerVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||||
|
return VimPlugin.getChange().changeCaseRange(topLevelEditor, range, CharacterHelper.CASE_LOWER);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
return VimPlugin.getChange().changeCaseRange(InjectedLanguageUtil.getTopLevelEditor(editor),
|
return MappingMode.V;
|
||||||
range, CharacterHelper.CASE_LOWER);
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("u");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeCaseToggleVisualAction extends EditorAction {
|
public class ChangeCaseToggleVisualAction extends VimCommandAction {
|
||||||
public ChangeCaseToggleVisualAction() {
|
public ChangeCaseToggleVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_TOGGLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_TOGGLE);
|
return MappingMode.V;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("~");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeCaseUpperVisualAction extends EditorAction {
|
public class ChangeCaseUpperVisualAction extends VimCommandAction {
|
||||||
public ChangeCaseUpperVisualAction() {
|
public ChangeCaseUpperVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_UPPER);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
return VimPlugin.getChange().changeCaseRange(editor, range, CharacterHelper.CASE_UPPER);
|
return MappingMode.V;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("U");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ public class ChangeLastGlobalSearchReplaceAction extends EditorAction {
|
|||||||
private static class Handler extends ChangeEditorActionHandler {
|
private static class Handler extends ChangeEditorActionHandler {
|
||||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable 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 VimPlugin.getSearch().searchAndReplace(editor, context, range, "s", "//~/&");
|
return VimPlugin.getSearch().searchAndReplace(editor, range, "s", "//~/&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ public class ChangeLastSearchReplaceAction extends EditorAction {
|
|||||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
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 VimPlugin.getSearch().searchAndReplace(editor, context, range, "s", "//~/");
|
return VimPlugin.getSearch().searchAndReplace(editor, range, "s", "//~/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,26 +20,53 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.command.SelectionType;
|
import com.maddyhome.idea.vim.command.SelectionType;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeVisualAction extends EditorAction {
|
public class ChangeVisualAction extends VimCommandAction {
|
||||||
public ChangeVisualAction() {
|
public ChangeVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final SelectionType type = range.isMultiple() ? SelectionType.BLOCK_WISE : SelectionType.CHARACTER_WISE;
|
||||||
|
return VimPlugin.getChange().changeRange(editor, context, range, type);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
final SelectionType type = range.isMultiple() ? SelectionType.BLOCK_WISE : SelectionType.CHARACTER_WISE;
|
return MappingMode.V;
|
||||||
return VimPlugin.getChange().changeRange(editor, context, range, type);
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("c", "s");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,24 +20,59 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Argument;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeVisualCharacterAction extends EditorAction {
|
public class ChangeVisualCharacterAction extends VimCommandAction {
|
||||||
public ChangeVisualCharacterAction() {
|
public ChangeVisualCharacterAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final Argument argument = cmd.getArgument();
|
||||||
|
return argument != null && VimPlugin.getChange().changeCharacterRange(editor, range, argument.getCharacter());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
@Override
|
||||||
return VimPlugin.getChange().changeCharacterRange(editor, range,
|
public Set<MappingMode> getMappingModes() {
|
||||||
cmd.getArgument().getCharacter());
|
return MappingMode.V;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("r");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Argument.Type getArgumentType() {
|
||||||
|
return Argument.Type.DIGRAPH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_ALLOW_DIGRAPH | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,29 +20,55 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.command.SelectionType;
|
import com.maddyhome.idea.vim.command.SelectionType;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeVisualLinesAction extends EditorAction {
|
public class ChangeVisualLinesAction extends VimCommandAction {
|
||||||
public ChangeVisualLinesAction() {
|
public ChangeVisualLinesAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||||
|
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||||
|
return VimPlugin.getChange().changeRange(editor, context, lineRange, SelectionType.LINE_WISE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
return MappingMode.V;
|
||||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
}
|
||||||
|
|
||||||
return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("R", "S");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,43 +20,68 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.command.SelectionType;
|
import com.maddyhome.idea.vim.command.SelectionType;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ChangeVisualLinesEndAction extends EditorAction {
|
public class ChangeVisualLinesEndAction extends VimCommandAction {
|
||||||
public ChangeVisualLinesEndAction() {
|
public ChangeVisualLinesEndAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
if (range.isMultiple()) {
|
||||||
|
final int[] starts = range.getStartOffsets();
|
||||||
|
final int[] ends = range.getEndOffsets();
|
||||||
|
for (int i = 0; i < starts.length; i++) {
|
||||||
|
if (ends[i] > starts[i]) {
|
||||||
|
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final TextRange blockRange = new TextRange(starts, ends);
|
||||||
|
return VimPlugin.getChange().changeRange(editor, context, blockRange, SelectionType.BLOCK_WISE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||||
|
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||||
|
return VimPlugin.getChange().changeRange(editor, context, lineRange, SelectionType.LINE_WISE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
if (range.isMultiple()) {
|
return MappingMode.V;
|
||||||
int[] starts = range.getStartOffsets();
|
}
|
||||||
int[] ends = range.getEndOffsets();
|
|
||||||
for (int i = 0; i < starts.length; i++) {
|
|
||||||
if (ends[i] > starts[i]) {
|
|
||||||
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
range = new TextRange(starts, ends);
|
@NotNull
|
||||||
return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.BLOCK_WISE);
|
@Override
|
||||||
}
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
else {
|
return parseKeysSet("C");
|
||||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
}
|
||||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
|
||||||
|
|
||||||
return VimPlugin.getChange().changeRange(editor, context, range, SelectionType.LINE_WISE);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
}
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Editor;
|
|||||||
import com.intellij.openapi.editor.LogicalPosition;
|
import com.intellij.openapi.editor.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.VimPlugin;
|
||||||
|
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.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.group.MotionGroup;
|
import com.maddyhome.idea.vim.group.MotionGroup;
|
||||||
@@ -38,8 +39,11 @@ public class FilterMotionAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull 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(),
|
final Argument argument = cmd.getArgument();
|
||||||
cmd.getArgument(), false, false);
|
if (argument == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TextRange range = MotionGroup.getMotionRange(editor, context, cmd.getCount(), cmd.getRawCount(), argument, false);
|
||||||
if (range == null) {
|
if (range == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -20,25 +20,51 @@ 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.maddyhome.idea.vim.VimPlugin;
|
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.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class FilterVisualLinesAction extends EditorAction {
|
public class FilterVisualLinesAction extends VimCommandAction {
|
||||||
public FilterVisualLinesAction() {
|
public FilterVisualLinesAction() {
|
||||||
super(new Handler());
|
super(new EditorActionHandlerBase() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
|
||||||
|
VimPlugin.getMotion().resetVisual(editor, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
@Override
|
||||||
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
|
public Set<MappingMode> getMappingModes() {
|
||||||
VimPlugin.getMotion().resetVisual(editor, true);
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,27 +20,53 @@ package com.maddyhome.idea.vim.action.change.change;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author vlan
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ReformatCodeVisualAction extends EditorAction {
|
public class ReformatCodeVisualAction extends VimCommandAction {
|
||||||
public ReformatCodeVisualAction() {
|
public ReformatCodeVisualAction() {
|
||||||
super(new VisualOperatorActionHandler() {
|
super(new VisualOperatorActionHandler() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean execute(@NotNull Editor editor,
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
@NotNull DataContext context,
|
|
||||||
@NotNull Command cmd,
|
|
||||||
@NotNull TextRange range) {
|
@NotNull TextRange range) {
|
||||||
VimPlugin.getChange().reformatCode(context);
|
VimPlugin.getChange().reformatCode(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("gq");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_FORCE_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.delete;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class DeleteJoinVisualLinesAction extends EditorAction {
|
public class DeleteJoinVisualLinesAction extends VimCommandAction {
|
||||||
public DeleteJoinVisualLinesAction() {
|
public DeleteJoinVisualLinesAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return !editor.isOneLineMode() && VimPlugin.getChange().deleteJoinRange(editor, range, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
if (editor.isOneLineMode()) {
|
return MappingMode.V;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return VimPlugin.getChange().deleteJoinRange(editor, range, false);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("gJ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.delete;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class DeleteJoinVisualLinesSpacesAction extends EditorAction {
|
public class DeleteJoinVisualLinesSpacesAction extends VimCommandAction {
|
||||||
public DeleteJoinVisualLinesSpacesAction() {
|
public DeleteJoinVisualLinesSpacesAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return !editor.isOneLineMode() && VimPlugin.getChange().deleteJoinRange(editor, range, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
if (editor.isOneLineMode()) {
|
return MappingMode.V;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return VimPlugin.getChange().deleteJoinRange(editor, range, true);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("J");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,34 +20,62 @@ package com.maddyhome.idea.vim.action.change.delete;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
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.MappingMode;
|
||||||
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.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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class DeleteVisualAction extends EditorAction {
|
public class DeleteVisualAction extends VimCommandAction {
|
||||||
public DeleteVisualAction() {
|
public DeleteVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||||
|
if (mode == CommandState.SubMode.VISUAL_LINE) {
|
||||||
|
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||||
|
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||||
|
return VimPlugin.getChange().deleteRange(editor, lineRange, SelectionType.fromSubMode(mode), false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return VimPlugin.getChange().deleteRange(editor, range, SelectionType.fromSubMode(mode), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
return MappingMode.V;
|
||||||
if (mode == CommandState.SubMode.VISUAL_LINE) {
|
}
|
||||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
|
||||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return VimPlugin.getChange().deleteRange(editor, range,
|
@NotNull
|
||||||
SelectionType.fromSubMode(mode), false);
|
@Override
|
||||||
}
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("d", "x", "<Del>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,37 +20,62 @@ package com.maddyhome.idea.vim.action.change.delete;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
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.MappingMode;
|
||||||
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.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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class DeleteVisualLinesAction extends EditorAction {
|
public class DeleteVisualLinesAction extends VimCommandAction {
|
||||||
public DeleteVisualLinesAction() {
|
public DeleteVisualLinesAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||||
|
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
||||||
|
return VimPlugin.getChange().deleteRange(editor, range, SelectionType.fromSubMode(mode), false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||||
|
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||||
|
return VimPlugin.getChange().deleteRange(editor, lineRange, SelectionType.LINE_WISE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
return MappingMode.V;
|
||||||
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
}
|
||||||
return VimPlugin.getChange().deleteRange(editor, range,
|
|
||||||
SelectionType.fromSubMode(mode), false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
|
||||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
|
||||||
|
|
||||||
return VimPlugin.getChange().deleteRange(editor, range, SelectionType.LINE_WISE, false);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
}
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("X");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,45 +20,68 @@ package com.maddyhome.idea.vim.action.change.delete;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.command.SelectionType;
|
import com.maddyhome.idea.vim.command.SelectionType;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class DeleteVisualLinesEndAction extends EditorAction {
|
public class DeleteVisualLinesEndAction extends VimCommandAction {
|
||||||
public DeleteVisualLinesEndAction() {
|
public DeleteVisualLinesEndAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
if (range.isMultiple()) {
|
||||||
|
final int[] starts = range.getStartOffsets();
|
||||||
|
final int[] ends = range.getEndOffsets();
|
||||||
|
for (int i = 0; i < starts.length; i++) {
|
||||||
|
if (ends[i] > starts[i]) {
|
||||||
|
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final TextRange blockRange = new TextRange(starts, ends);
|
||||||
|
return VimPlugin.getChange().deleteRange(editor, blockRange, SelectionType.BLOCK_WISE, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||||
|
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||||
|
return VimPlugin.getChange().deleteRange(editor, lineRange, SelectionType.LINE_WISE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
if (range.isMultiple()) {
|
return MappingMode.V;
|
||||||
int[] starts = range.getStartOffsets();
|
}
|
||||||
int[] ends = range.getEndOffsets();
|
|
||||||
for (int i = 0; i < starts.length; i++) {
|
|
||||||
if (ends[i] > starts[i]) {
|
|
||||||
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
range = new TextRange(starts, ends);
|
@NotNull
|
||||||
return VimPlugin.getChange().deleteRange(editor, range,
|
@Override
|
||||||
SelectionType.BLOCK_WISE, false);
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
}
|
return parseKeysSet("D");
|
||||||
else {
|
}
|
||||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
|
||||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
|
||||||
|
|
||||||
return VimPlugin.getChange().deleteRange(editor, range,
|
@NotNull
|
||||||
SelectionType.LINE_WISE, false);
|
@Override
|
||||||
}
|
public Command.Type getType() {
|
||||||
}
|
return Command.Type.DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,8 +33,6 @@ import javax.swing.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
|
|
||||||
|
|
||||||
public class InsertBeforeCursorAction extends VimCommandAction {
|
public class InsertBeforeCursorAction extends VimCommandAction {
|
||||||
public InsertBeforeCursorAction() {
|
public InsertBeforeCursorAction() {
|
||||||
super(new ChangeEditorActionHandler() {
|
super(new ChangeEditorActionHandler() {
|
||||||
|
@@ -33,8 +33,6 @@ import javax.swing.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
|
|
||||||
|
|
||||||
public class InsertExitModeAction extends VimCommandAction {
|
public class InsertExitModeAction extends VimCommandAction {
|
||||||
private static final String ACTION_ID = "VimInsertExitMode";
|
private static final String ACTION_ID = "VimInsertExitMode";
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.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.VimPlugin;
|
||||||
|
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.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,7 +36,8 @@ public class InsertRegisterAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
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 VimPlugin.getChange().insertRegister(editor, context, cmd.getArgument().getCharacter());
|
final Argument argument = cmd.getArgument();
|
||||||
|
return argument != null && VimPlugin.getChange().insertRegister(editor, context, argument.getCharacter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.insert;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualBlockAppendAction extends EditorAction {
|
public class VisualBlockAppendAction extends VimCommandAction {
|
||||||
public VisualBlockAppendAction() {
|
public VisualBlockAppendAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return !editor.isOneLineMode() && VimPlugin.getChange().blockInsert(editor, context, range, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
if (editor.isOneLineMode()) {
|
return MappingMode.V;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return VimPlugin.getChange().blockInsert(editor, context, range, true);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("A");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.INSERT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,28 +20,51 @@ package com.maddyhome.idea.vim.action.change.insert;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualBlockInsertAction extends EditorAction {
|
public class VisualBlockInsertAction extends VimCommandAction {
|
||||||
public VisualBlockInsertAction() {
|
public VisualBlockInsertAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return !editor.isOneLineMode() && VimPlugin.getChange().blockInsert(editor, context, range, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
if (editor.isOneLineMode()) {
|
return MappingMode.V;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return VimPlugin.getChange().blockInsert(editor, context, range, false);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("I");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.INSERT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MULTIKEY_UNDO | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.shift;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ShiftLeftVisualAction extends EditorAction {
|
public class ShiftLeftVisualAction extends VimCommandAction {
|
||||||
public ShiftLeftVisualAction() {
|
public ShiftLeftVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), -1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
@Override
|
||||||
VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), -1);
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,25 +20,52 @@ package com.maddyhome.idea.vim.action.change.shift;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class ShiftRightVisualAction extends EditorAction {
|
public class ShiftRightVisualAction extends VimCommandAction {
|
||||||
public ShiftRightVisualAction() {
|
public ShiftRightVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
@Override
|
||||||
VimPlugin.getChange().indentRange(editor, context, range, cmd.getCount(), 1);
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
@NotNull
|
||||||
}
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet(">");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,23 +20,51 @@ package com.maddyhome.idea.vim.action.copy;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class PutVisualTextAction extends EditorAction {
|
public class PutVisualTextAction extends VimCommandAction {
|
||||||
public PutVisualTextAction() {
|
public PutVisualTextAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), true, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
@Override
|
||||||
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), true, false);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("p", "P");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.PASTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,23 +20,51 @@ package com.maddyhome.idea.vim.action.copy;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class PutVisualTextMoveCursorAction extends EditorAction {
|
public class PutVisualTextMoveCursorAction extends VimCommandAction {
|
||||||
public PutVisualTextMoveCursorAction() {
|
public PutVisualTextMoveCursorAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), true, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
@Override
|
||||||
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), true, true);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("gp", "gP");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.PASTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,23 +20,51 @@ package com.maddyhome.idea.vim.action.copy;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.common.TextRange;
|
import com.maddyhome.idea.vim.common.TextRange;
|
||||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class PutVisualTextNoIndentAction extends EditorAction {
|
public class PutVisualTextNoIndentAction extends VimCommandAction {
|
||||||
public PutVisualTextNoIndentAction() {
|
public PutVisualTextNoIndentAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), false, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd, @NotNull TextRange range) {
|
@Override
|
||||||
return VimPlugin.getCopy().putVisualRange(editor, context, range, cmd.getCount(), false, false);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("[p", "]p", "[P", "]P");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.PASTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.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.VimPlugin;
|
||||||
|
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.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -37,7 +38,8 @@ public class SelectRegisterAction extends EditorAction {
|
|||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
@Override
|
@Override
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
return VimPlugin.getRegister().selectRegister(cmd.getArgument().getCharacter());
|
final Argument argument = cmd.getArgument();
|
||||||
|
return argument != null && VimPlugin.getRegister().selectRegister(argument.getCharacter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.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.VimPlugin;
|
||||||
|
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.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,7 +36,9 @@ public class YankMotionAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
return VimPlugin.getCopy().yankMotion(editor, context, cmd.getCount(), cmd.getRawCount(), cmd.getArgument());
|
final Argument argument = cmd.getArgument();
|
||||||
|
return argument != null && VimPlugin.getCopy().yankMotion(editor, context, cmd.getCount(), cmd.getRawCount(),
|
||||||
|
argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,28 +20,54 @@ package com.maddyhome.idea.vim.action.copy;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
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.MappingMode;
|
||||||
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.handler.VisualOperatorActionHandler;
|
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class YankVisualAction extends EditorAction {
|
public class YankVisualAction extends VimCommandAction {
|
||||||
public YankVisualAction() {
|
public YankVisualAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final CommandState.SubMode subMode = CommandState.getInstance(editor).getSubMode();
|
||||||
|
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.fromSubMode(subMode), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
final CommandState.SubMode subMode = CommandState.getInstance(editor).getSubMode();
|
return MappingMode.V;
|
||||||
return VimPlugin.getCopy().yankRange(editor, range,
|
}
|
||||||
SelectionType.fromSubMode(subMode), true);
|
|
||||||
}
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("y");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.COPY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,37 +20,62 @@ package com.maddyhome.idea.vim.action.copy;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
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.MappingMode;
|
||||||
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.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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class YankVisualLinesAction extends EditorAction {
|
public class YankVisualLinesAction extends VimCommandAction {
|
||||||
public YankVisualLinesAction() {
|
public YankVisualLinesAction() {
|
||||||
super(new Handler());
|
super(new VisualOperatorActionHandler() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
||||||
|
@NotNull TextRange range) {
|
||||||
|
final CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
||||||
|
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
||||||
|
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.fromSubMode(mode), true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final TextRange lineRange = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
||||||
|
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
||||||
|
return VimPlugin.getCopy().yankRange(editor, lineRange, SelectionType.LINE_WISE, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends VisualOperatorActionHandler {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd,
|
@Override
|
||||||
@NotNull TextRange range) {
|
public Set<MappingMode> getMappingModes() {
|
||||||
CommandState.SubMode mode = CommandState.getInstance(editor).getSubMode();
|
return MappingMode.V;
|
||||||
if (mode == CommandState.SubMode.VISUAL_BLOCK) {
|
}
|
||||||
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.fromSubMode(mode),
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
range = new TextRange(EditorHelper.getLineStartForOffset(editor, range.getStartOffset()),
|
|
||||||
EditorHelper.getLineEndForOffset(editor, range.getEndOffset()) + 1);
|
|
||||||
|
|
||||||
return VimPlugin.getCopy().yankRange(editor, range, SelectionType.LINE_WISE, true);
|
@NotNull
|
||||||
}
|
@Override
|
||||||
}
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("Y");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.COPY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFlags() {
|
||||||
|
return Command.FLAG_MOT_LINEWISE | Command.FLAG_EXIT_VISUAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,6 @@ import com.maddyhome.idea.vim.command.Command;
|
|||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class BackspaceAction extends EditorAction {
|
public class BackspaceAction extends EditorAction {
|
||||||
@@ -37,8 +35,7 @@ public class BackspaceAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
return VimPlugin.getProcess().processExKey(editor,
|
return VimPlugin.getProcess().processExKey(editor, cmd.getKeys().get(0));
|
||||||
(KeyStroke)cmd.getKeys().get(0), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,6 @@ import com.maddyhome.idea.vim.command.Command;
|
|||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ProcessExKeyAction extends EditorAction {
|
public class ProcessExKeyAction extends EditorAction {
|
||||||
@@ -37,8 +35,7 @@ public class ProcessExKeyAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
return VimPlugin.getProcess().processExKey(editor,
|
return VimPlugin.getProcess().processExKey(editor, cmd.getKeys().get(0));
|
||||||
(KeyStroke)cmd.getKeys().get(0), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||||
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.project.Project;
|
||||||
import com.maddyhome.idea.vim.VimPlugin;
|
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.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
@@ -36,9 +37,8 @@ public class PlaybackLastRegisterAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
return VimPlugin.getMacro().playbackLastRegister(editor, context,
|
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||||
PlatformDataKeys.PROJECT.getData(context),
|
return VimPlugin.getMacro().playbackLastRegister(editor, context, project, cmd.getCount());
|
||||||
cmd.getCount()); // API change - don't merge
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,9 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||||
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.project.Project;
|
||||||
import com.maddyhome.idea.vim.VimPlugin;
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.command.Argument;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -36,10 +38,13 @@ public class PlaybackRegisterAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
char reg = cmd.getArgument().getCharacter();
|
final Argument argument = cmd.getArgument();
|
||||||
return VimPlugin.getMacro().playbackRegister(editor, context,
|
if (argument == null) {
|
||||||
PlatformDataKeys.PROJECT.getData(context), reg,
|
return false;
|
||||||
cmd.getCount()); // API change - don't merge
|
}
|
||||||
|
final char reg = argument.getCharacter();
|
||||||
|
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||||
|
return VimPlugin.getMacro().playbackRegister(editor, context, project, reg, cmd.getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.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.VimPlugin;
|
||||||
|
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.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
@@ -37,7 +38,11 @@ public class ToggleRecordingAction extends EditorAction {
|
|||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
if (!CommandState.getInstance(editor).isRecording()) {
|
if (!CommandState.getInstance(editor).isRecording()) {
|
||||||
char reg = cmd.getArgument().getCharacter();
|
final Argument argument = cmd.getArgument();
|
||||||
|
if (argument == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
char reg = argument.getCharacter();
|
||||||
return VimPlugin.getRegister().startRecording(editor, reg);
|
return VimPlugin.getRegister().startRecording(editor, reg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -36,5 +36,5 @@ public abstract class MotionEditorAction extends EditorAction {
|
|||||||
return handler.getOffset(editor, context, count, rawCount, argument);
|
return handler.getOffset(editor, context, count, rawCount, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MotionEditorActionHandler handler;
|
private final MotionEditorActionHandler handler;
|
||||||
}
|
}
|
||||||
|
@@ -39,5 +39,5 @@ public abstract class TextObjectAction extends EditorAction {
|
|||||||
return handler.getRange(editor, context, count, rawCount, argument);
|
return handler.getRange(editor, context, count, rawCount, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextObjectActionHandler handler;
|
private final TextObjectActionHandler handler;
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ public class MotionLastColumnAction extends MotionEditorAction {
|
|||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||||
boolean allow = false;
|
boolean allow = false;
|
||||||
if (CommandState.inInsertMode(editor) || CommandState.inRepeatMode(editor)) {
|
if (CommandState.inInsertMode(editor)) {
|
||||||
allow = true;
|
allow = true;
|
||||||
}
|
}
|
||||||
else if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
else if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
||||||
|
@@ -35,7 +35,7 @@ public class MotionJumpNextAction extends MotionEditorAction {
|
|||||||
|
|
||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||||
return VimPlugin.getMotion().moveCaretToJump(editor, context, count);
|
return VimPlugin.getMotion().moveCaretToJump(editor, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ public class MotionJumpPreviousAction extends MotionEditorAction {
|
|||||||
|
|
||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, Argument argument) {
|
||||||
return VimPlugin.getMotion().moveCaretToJump(editor, context, -count);
|
return VimPlugin.getMotion().moveCaretToJump(editor, -count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
|||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.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.VimPlugin;
|
||||||
|
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.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,7 +36,8 @@ public class MotionMarkAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
private static class Handler extends EditorActionHandlerBase {
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
return VimPlugin.getMark().setMark(editor, cmd.getArgument().getCharacter());
|
final Argument argument = cmd.getArgument();
|
||||||
|
return argument != null && VimPlugin.getMark().setMark(editor, argument.getCharacter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,11 @@ public class SearchEntryFwdAction extends MotionEditorAction {
|
|||||||
|
|
||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||||
return VimPlugin.getSearch().search(editor, argument.getString(),
|
final String command = argument.getString();
|
||||||
count, Command.FLAG_SEARCH_FWD, false);
|
if (command == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return VimPlugin.getSearch().search(editor, command, count, Command.FLAG_SEARCH_FWD, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,11 @@ public class SearchEntryRevAction extends MotionEditorAction {
|
|||||||
|
|
||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
public int getOffset(@NotNull Editor editor, DataContext context, int count, int rawCount, @NotNull Argument argument) {
|
||||||
return VimPlugin.getSearch().search(editor, argument.getString(),
|
final String command = argument.getString();
|
||||||
count, Command.FLAG_SEARCH_REV, false);
|
if (command == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return VimPlugin.getSearch().search(editor, command, count, Command.FLAG_SEARCH_REV, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,8 @@ public class MotionNextTabAction extends MotionEditorAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
public int getOffset(@NotNull final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
||||||
return VimPlugin.getMotion().moveCaretGotoNextTab(editor, context);
|
return VimPlugin.getMotion().moveCaretGotoNextTab(editor, context, rawCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,8 @@ public class MotionPreviousTabAction extends MotionEditorAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends MotionEditorActionHandler {
|
private static class Handler extends MotionEditorActionHandler {
|
||||||
public int getOffset(final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
public int getOffset(@NotNull final Editor editor, @NotNull final DataContext context, final int count, final int rawCount, final Argument argument) {
|
||||||
return VimPlugin.getMotion().moveCaretGotoPreviousTab(editor, context);
|
return VimPlugin.getMotion().moveCaretGotoPreviousTab(editor, context, rawCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,24 +20,46 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
|||||||
|
|
||||||
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.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.VimPlugin;
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualExitModeAction extends EditorAction {
|
public class VisualExitModeAction extends VimCommandAction {
|
||||||
public VisualExitModeAction() {
|
public VisualExitModeAction() {
|
||||||
super(new Handler());
|
super(new EditorActionHandler() {
|
||||||
|
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
||||||
|
VimPlugin.getMotion().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends EditorActionHandler {
|
@NotNull
|
||||||
public void execute(@NotNull Editor editor, @NotNull DataContext context) {
|
@Override
|
||||||
VimPlugin.getMotion().processEscape(InjectedLanguageUtil.getTopLevelEditor(editor));
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<Esc>", "<C-[>", "<C-C>", "<C-\\><C-N>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,24 +20,44 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualSelectPreviousAction extends EditorAction {
|
public class VisualSelectPreviousAction extends VimCommandAction {
|
||||||
public VisualSelectPreviousAction() {
|
public VisualSelectPreviousAction() {
|
||||||
super(new Handler());
|
super(new EditorActionHandlerBase() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
return VimPlugin.getMotion().selectPreviousVisualMode(editor);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
@Override
|
||||||
return VimPlugin.getMotion().selectPreviousVisualMode(editor);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("gv");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,24 +20,45 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualSwapEndsAction extends EditorAction {
|
public class VisualSwapEndsAction extends VimCommandAction {
|
||||||
public VisualSwapEndsAction() {
|
public VisualSwapEndsAction() {
|
||||||
super(new Handler());
|
super(new EditorActionHandlerBase() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
return VimPlugin.getMotion().swapVisualEnds(editor);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
@Override
|
||||||
return VimPlugin.getMotion().swapVisualEnds(editor);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("o");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,24 +20,45 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualSwapEndsBlockAction extends EditorAction {
|
public class VisualSwapEndsBlockAction extends VimCommandAction {
|
||||||
public VisualSwapEndsBlockAction() {
|
public VisualSwapEndsBlockAction() {
|
||||||
super(new Handler());
|
super(new EditorActionHandlerBase() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
return VimPlugin.getMotion().swapVisualEndsBlock(editor);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
@Override
|
||||||
return VimPlugin.getMotion().swapVisualEndsBlock(editor);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("O");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,24 +20,45 @@ package com.maddyhome.idea.vim.action.motion.visual;
|
|||||||
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.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.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
import com.maddyhome.idea.vim.command.Command;
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class VisualSwapSelectionsAction extends EditorAction {
|
public class VisualSwapSelectionsAction extends VimCommandAction {
|
||||||
public VisualSwapSelectionsAction() {
|
public VisualSwapSelectionsAction() {
|
||||||
super(new Handler());
|
super(new EditorActionHandlerBase() {
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
return VimPlugin.getMotion().swapVisualSelections(editor);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler extends EditorActionHandlerBase {
|
@NotNull
|
||||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
@Override
|
||||||
return VimPlugin.getMotion().swapVisualSelections(editor);
|
public Set<MappingMode> getMappingModes() {
|
||||||
}
|
return MappingMode.V;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("gv");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,8 +32,6 @@ import javax.swing.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.maddyhome.idea.vim.helper.StringHelper.parseKeysSet;
|
|
||||||
|
|
||||||
public class VisualToggleCharacterModeAction extends VimCommandAction {
|
public class VisualToggleCharacterModeAction extends VimCommandAction {
|
||||||
public VisualToggleCharacterModeAction() {
|
public VisualToggleCharacterModeAction() {
|
||||||
super(new EditorActionHandlerBase() {
|
super(new EditorActionHandlerBase() {
|
||||||
|
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author rasendubi
|
||||||
|
*/
|
||||||
|
public class CloseWindowAction extends VimCommandAction {
|
||||||
|
public CloseWindowAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().closeCurrentWindow(context);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>c");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author rasendubi
|
||||||
|
*/
|
||||||
|
public class HorizontalSplitAction extends VimCommandAction {
|
||||||
|
public HorizontalSplitAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().splitWindowHorizontal(context, "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>s", "<C-W>S", "<C-W><C-S>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author rasendubi
|
||||||
|
*/
|
||||||
|
public class VerticalSplitAction extends VimCommandAction {
|
||||||
|
public VerticalSplitAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().splitWindowVertical(context, "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>v", "<C-W><C-V>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vlan
|
||||||
|
*/
|
||||||
|
public class WindowDownAction extends VimCommandAction {
|
||||||
|
public WindowDownAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount(), true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>j");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vlan
|
||||||
|
*/
|
||||||
|
public class WindowLeftAction extends VimCommandAction {
|
||||||
|
public WindowLeftAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount() * -1, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>h");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author rasendubi
|
||||||
|
*/
|
||||||
|
public class WindowNextAction extends VimCommandAction {
|
||||||
|
public WindowNextAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
if (cmd.getRawCount() == 0) {
|
||||||
|
VimPlugin.getWindow().selectNextWindow(context);
|
||||||
|
} else {
|
||||||
|
VimPlugin.getWindow().selectWindow(context, cmd.getCount());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>w", "<C-W><C-W>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author rasendubi
|
||||||
|
*/
|
||||||
|
public class WindowOnlyAction extends VimCommandAction {
|
||||||
|
public WindowOnlyAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().closeAllExceptCurrent(context);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>o", "<C-W><C-O>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class WindowPrevAction extends VimCommandAction {
|
||||||
|
public WindowPrevAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
if (cmd.getRawCount() == 0) {
|
||||||
|
VimPlugin.getWindow().selectPreviousWindow(context);
|
||||||
|
} else {
|
||||||
|
VimPlugin.getWindow().selectWindow(context, cmd.getCount());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>W");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vlan
|
||||||
|
*/
|
||||||
|
public class WindowRightAction extends VimCommandAction {
|
||||||
|
public WindowRightAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount(), false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>l");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
65
src/com/maddyhome/idea/vim/action/window/WindowUpAction.java
Normal file
65
src/com/maddyhome/idea/vim/action/window/WindowUpAction.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maddyhome.idea.vim.action.window;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.action.VimCommandAction;
|
||||||
|
import com.maddyhome.idea.vim.command.Command;
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode;
|
||||||
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vlan
|
||||||
|
*/
|
||||||
|
public class WindowUpAction extends VimCommandAction {
|
||||||
|
public WindowUpAction() {
|
||||||
|
super(new EditorActionHandlerBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||||
|
VimPlugin.getWindow().selectWindowInRow(context, cmd.getCount() * -1, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<MappingMode> getMappingModes() {
|
||||||
|
return MappingMode.N;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||||
|
return parseKeysSet("<C-W>k");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Command.Type getType() {
|
||||||
|
return Command.Type.OTHER_READONLY;
|
||||||
|
}
|
||||||
|
}
|
@@ -32,7 +32,7 @@ public class Argument {
|
|||||||
CHARACTER,
|
CHARACTER,
|
||||||
STRING,
|
STRING,
|
||||||
DIGRAPH,
|
DIGRAPH,
|
||||||
EX_STRING;
|
EX_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +50,7 @@ public class Argument {
|
|||||||
*
|
*
|
||||||
* @param motionArg The motion command
|
* @param motionArg The motion command
|
||||||
*/
|
*/
|
||||||
public Argument(Command motionArg) {
|
public Argument(@Nullable Command motionArg) {
|
||||||
this.motionArg = motionArg;
|
this.motionArg = motionArg;
|
||||||
type = Type.MOTION;
|
type = Type.MOTION;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class Argument {
|
|||||||
*
|
*
|
||||||
* @param strArg The string
|
* @param strArg The string
|
||||||
*/
|
*/
|
||||||
public Argument(String strArg) {
|
public Argument(@Nullable String strArg) {
|
||||||
this.strArg = strArg;
|
this.strArg = strArg;
|
||||||
type = Type.STRING;
|
type = Type.STRING;
|
||||||
}
|
}
|
||||||
@@ -126,19 +126,21 @@ public class Argument {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer res = new StringBuffer();
|
|
||||||
res.append("Argument [");
|
|
||||||
res.append("charArg=").append(charArg);
|
|
||||||
res.append(", motionArg=").append(motionArg);
|
|
||||||
res.append(", strArg=").append(strArg);
|
|
||||||
res.append(", type=").append(type);
|
|
||||||
res.append("]");
|
|
||||||
|
|
||||||
return res.toString();
|
return "Argument [" +
|
||||||
|
"charArg=" +
|
||||||
|
charArg +
|
||||||
|
", motionArg=" +
|
||||||
|
motionArg +
|
||||||
|
", strArg=" +
|
||||||
|
strArg +
|
||||||
|
", type=" +
|
||||||
|
type +
|
||||||
|
"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private char charArg = 0;
|
private char charArg = 0;
|
||||||
@Nullable private Command motionArg = null;
|
@Nullable private Command motionArg = null;
|
||||||
@Nullable private String strArg = null;
|
@Nullable private String strArg = null;
|
||||||
@NotNull private Type type;
|
@NotNull private final Type type;
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.actionSystem.EditorAction;
|
|||||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -80,10 +81,13 @@ public class Command {
|
|||||||
public static final int FLAG_SEARCH_FWD = 1 << 16;
|
public static final int FLAG_SEARCH_FWD = 1 << 16;
|
||||||
public static final int FLAG_SEARCH_REV = 1 << 17;
|
public static final int FLAG_SEARCH_REV = 1 << 17;
|
||||||
|
|
||||||
public static final int FLAG_KEEP_VISUAL = 1 << 20;
|
/**
|
||||||
|
* Command exits the visual mode, so caret movement shouldn't update visual selection
|
||||||
|
*/
|
||||||
|
public static final int FLAG_EXIT_VISUAL = 1 << 20;
|
||||||
public static final int FLAG_FORCE_VISUAL = 1 << 21;
|
public static final int FLAG_FORCE_VISUAL = 1 << 21;
|
||||||
public static final int FLAG_FORCE_LINEWISE = 1 << 22;
|
public static final int FLAG_FORCE_LINEWISE = 1 << 22;
|
||||||
public static final int FLAG_DELEGATE = 1 << 23;
|
|
||||||
/**
|
/**
|
||||||
* Special flag used for any mappings involving operators
|
* Special flag used for any mappings involving operators
|
||||||
*/
|
*/
|
||||||
@@ -182,24 +186,11 @@ public class Command {
|
|||||||
* @param flags Any custom flags specific to this command
|
* @param flags Any custom flags specific to this command
|
||||||
*/
|
*/
|
||||||
public Command(int count, String actionId, AnAction action, @NotNull Type type, int flags) {
|
public Command(int count, String actionId, AnAction action, @NotNull Type type, int flags) {
|
||||||
this(count, actionId, action, type, flags, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a command that requires an argument
|
|
||||||
*
|
|
||||||
* @param count The number entered prior to the command (zero if no specific number)
|
|
||||||
* @param action The action to be executed when the command is run
|
|
||||||
* @param type The type of the command
|
|
||||||
* @param flags Any custom flags specific to this command
|
|
||||||
* @param arg The argument to this command
|
|
||||||
*/
|
|
||||||
public Command(int count, String actionId, AnAction action, @NotNull Type type, int flags, Argument arg) {
|
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
this.argument = arg;
|
this.argument = null;
|
||||||
|
|
||||||
if (action instanceof EditorAction) {
|
if (action instanceof EditorAction) {
|
||||||
EditorAction eaction = (EditorAction)action;
|
EditorAction eaction = (EditorAction)action;
|
||||||
@@ -289,6 +280,7 @@ public class Command {
|
|||||||
*
|
*
|
||||||
* @return The command's argument, null if there isn't one
|
* @return The command's argument, null if there isn't one
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Argument getArgument() {
|
public Argument getArgument() {
|
||||||
return argument;
|
return argument;
|
||||||
}
|
}
|
||||||
@@ -298,7 +290,7 @@ public class Command {
|
|||||||
*
|
*
|
||||||
* @param argument The new argument, can be null to clear the argument
|
* @param argument The new argument, can be null to clear the argument
|
||||||
*/
|
*/
|
||||||
public void setArgument(Argument argument) {
|
public void setArgument(@Nullable Argument argument) {
|
||||||
this.argument = argument;
|
this.argument = argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,23 +304,27 @@ public class Command {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer res = new StringBuffer();
|
|
||||||
res.append("Command[");
|
|
||||||
res.append("count=").append(count);
|
|
||||||
res.append(", action=").append(action);
|
|
||||||
res.append(", type=").append(type);
|
|
||||||
res.append(", flags=").append(flags);
|
|
||||||
res.append(", argument=").append(argument);
|
|
||||||
res.append(", keys=").append(keys);
|
|
||||||
res.append("]");
|
|
||||||
|
|
||||||
return res.toString();
|
return "Command[" +
|
||||||
|
"count=" +
|
||||||
|
count +
|
||||||
|
", action=" +
|
||||||
|
action +
|
||||||
|
", type=" +
|
||||||
|
type +
|
||||||
|
", flags=" +
|
||||||
|
flags +
|
||||||
|
", argument=" +
|
||||||
|
argument +
|
||||||
|
", keys=" +
|
||||||
|
keys +
|
||||||
|
"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private int count;
|
private int count;
|
||||||
private AnAction action;
|
private AnAction action;
|
||||||
@NotNull private Type type;
|
@NotNull private final Type type;
|
||||||
private int flags;
|
private int flags;
|
||||||
private Argument argument;
|
@Nullable private Argument argument;
|
||||||
private List<KeyStroke> keys;
|
private List<KeyStroke> keys;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@ package com.maddyhome.idea.vim.command;
|
|||||||
|
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.maddyhome.idea.vim.VimPlugin;
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
import com.maddyhome.idea.vim.group.RegisterGroup;
|
|
||||||
import com.maddyhome.idea.vim.helper.EditorData;
|
import com.maddyhome.idea.vim.helper.EditorData;
|
||||||
import com.maddyhome.idea.vim.key.ParentNode;
|
import com.maddyhome.idea.vim.key.ParentNode;
|
||||||
import com.maddyhome.idea.vim.option.NumberOption;
|
import com.maddyhome.idea.vim.option.NumberOption;
|
||||||
@@ -38,10 +37,10 @@ public class CommandState {
|
|||||||
public static final int DEFAULT_TIMEOUT_LENGTH = 1000;
|
public static final int DEFAULT_TIMEOUT_LENGTH = 1000;
|
||||||
|
|
||||||
@Nullable private static Command ourLastChange = null;
|
@Nullable private static Command ourLastChange = null;
|
||||||
private static char ourLastRegister = RegisterGroup.REGISTER_DEFAULT;
|
private char myLastChangeRegister;
|
||||||
|
|
||||||
@NotNull private Stack<State> myStates = new Stack<State>();
|
@NotNull private final Stack<State> myStates = new Stack<State>();
|
||||||
@NotNull private State myDefaultState = new State(Mode.COMMAND, SubMode.NONE, MappingMode.NORMAL);
|
@NotNull private final State myDefaultState = new State(Mode.COMMAND, SubMode.NONE, MappingMode.NORMAL);
|
||||||
@Nullable private Command myCommand;
|
@Nullable private Command myCommand;
|
||||||
@NotNull private ParentNode myCurrentNode = VimPlugin.getKey().getKeyRoot(getMappingMode());
|
@NotNull private ParentNode myCurrentNode = VimPlugin.getKey().getKeyRoot(getMappingMode());
|
||||||
@NotNull private final List<KeyStroke> myMappingKeys = new ArrayList<KeyStroke>();
|
@NotNull private final List<KeyStroke> myMappingKeys = new ArrayList<KeyStroke>();
|
||||||
@@ -53,6 +52,7 @@ public class CommandState {
|
|||||||
myMappingTimer = new Timer(DEFAULT_TIMEOUT_LENGTH, null);
|
myMappingTimer = new Timer(DEFAULT_TIMEOUT_LENGTH, null);
|
||||||
myMappingTimer.setRepeats(false);
|
myMappingTimer.setRepeats(false);
|
||||||
myStates.push(new State(Mode.COMMAND, SubMode.NONE, MappingMode.NORMAL));
|
myStates.push(new State(Mode.COMMAND, SubMode.NONE, MappingMode.NORMAL));
|
||||||
|
myLastChangeRegister = VimPlugin.getRegister().getDefaultRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -85,6 +85,11 @@ public class CommandState {
|
|||||||
return state.getMode() == Mode.VISUAL && state.getSubMode() == SubMode.VISUAL_CHARACTER;
|
return state.getMode() == Mode.VISUAL && state.getSubMode() == SubMode.VISUAL_CHARACTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean inVisualBlockMode(@Nullable Editor editor) {
|
||||||
|
final CommandState state = getInstance(editor);
|
||||||
|
return state.getMode() == Mode.VISUAL && state.getSubMode() == SubMode.VISUAL_BLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Command getCommand() {
|
public Command getCommand() {
|
||||||
return myCommand;
|
return myCommand;
|
||||||
@@ -255,7 +260,7 @@ public class CommandState {
|
|||||||
* @return The register key
|
* @return The register key
|
||||||
*/
|
*/
|
||||||
public char getLastChangeRegister() {
|
public char getLastChangeRegister() {
|
||||||
return ourLastRegister;
|
return myLastChangeRegister;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -265,7 +270,7 @@ public class CommandState {
|
|||||||
*/
|
*/
|
||||||
public void saveLastChangeCommand(Command cmd) {
|
public void saveLastChangeCommand(Command cmd) {
|
||||||
ourLastChange = cmd;
|
ourLastChange = cmd;
|
||||||
ourLastRegister = VimPlugin.getRegister().getCurrentRegister();
|
myLastChangeRegister = VimPlugin.getRegister().getCurrentRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRecording() {
|
public boolean isRecording() {
|
||||||
@@ -311,7 +316,7 @@ public class CommandState {
|
|||||||
VimPlugin.showMode(msg.toString());
|
VimPlugin.showMode(msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Mode {
|
public enum Mode {
|
||||||
COMMAND,
|
COMMAND,
|
||||||
INSERT,
|
INSERT,
|
||||||
REPLACE,
|
REPLACE,
|
||||||
@@ -320,7 +325,7 @@ public class CommandState {
|
|||||||
EX_ENTRY
|
EX_ENTRY
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum SubMode {
|
public enum SubMode {
|
||||||
NONE,
|
NONE,
|
||||||
SINGLE_COMMAND,
|
SINGLE_COMMAND,
|
||||||
VISUAL_CHARACTER,
|
VISUAL_CHARACTER,
|
||||||
@@ -329,9 +334,9 @@ public class CommandState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class State {
|
private class State {
|
||||||
@NotNull private Mode myMode;
|
@NotNull private final Mode myMode;
|
||||||
@NotNull private SubMode mySubMode;
|
@NotNull private SubMode mySubMode;
|
||||||
@NotNull private MappingMode myMappingMode;
|
@NotNull private final MappingMode myMappingMode;
|
||||||
|
|
||||||
public State(@NotNull Mode mode, @NotNull SubMode subMode, @NotNull MappingMode mappingMode) {
|
public State(@NotNull Mode mode, @NotNull SubMode subMode, @NotNull MappingMode mappingMode) {
|
||||||
this.myMode = mode;
|
this.myMode = mode;
|
||||||
|
@@ -62,6 +62,19 @@ public enum SelectionType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
public CommandState.SubMode toSubMode() {
|
||||||
|
switch (this) {
|
||||||
|
case LINE_WISE:
|
||||||
|
return CommandState.SubMode.VISUAL_LINE;
|
||||||
|
case CHARACTER_WISE:
|
||||||
|
return CommandState.SubMode.VISUAL_CHARACTER;
|
||||||
|
case BLOCK_WISE:
|
||||||
|
return CommandState.SubMode.VISUAL_BLOCK;
|
||||||
|
default:
|
||||||
|
return CommandState.SubMode.VISUAL_CHARACTER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static SelectionType fromCommandFlags(int flags) {
|
public static SelectionType fromCommandFlags(int flags) {
|
||||||
if ((flags & Command.FLAG_MOT_LINEWISE) != 0) {
|
if ((flags & Command.FLAG_MOT_LINEWISE) != 0) {
|
||||||
return SelectionType.LINE_WISE;
|
return SelectionType.LINE_WISE;
|
||||||
|
@@ -42,17 +42,11 @@ public class VisualChange {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer res = new StringBuffer();
|
|
||||||
res.append("VisualChange[");
|
|
||||||
res.append("lines=").append(lines);
|
|
||||||
res.append(", columns=").append(columns);
|
|
||||||
res.append(", type=").append(type);
|
|
||||||
res.append("]");
|
|
||||||
|
|
||||||
return res.toString();
|
return "VisualChange[" + "lines=" + lines + ", columns=" + columns + ", type=" + type + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
int lines;
|
final int lines;
|
||||||
int columns;
|
final int columns;
|
||||||
@NotNull SelectionType type;
|
@NotNull final SelectionType type;
|
||||||
}
|
}
|
||||||
|
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
|
||||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.maddyhome.idea.vim.command;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class VisualRange {
|
|
||||||
public VisualRange(int start, int end, @NotNull CommandState.SubMode type, int offset) {
|
|
||||||
this.start = start;
|
|
||||||
this.end = end;
|
|
||||||
this.type = type;
|
|
||||||
this.offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStart() {
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEnd() {
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public CommandState.SubMode getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOffset() {
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public String toString() {
|
|
||||||
StringBuffer res = new StringBuffer();
|
|
||||||
res.append("VisualRange[");
|
|
||||||
res.append("start=").append(start);
|
|
||||||
res.append(", end=").append(end);
|
|
||||||
res.append(", type=").append(type);
|
|
||||||
res.append(", offset=").append(offset);
|
|
||||||
res.append("]");
|
|
||||||
|
|
||||||
return res.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
int start;
|
|
||||||
int end;
|
|
||||||
@NotNull CommandState.SubMode type;
|
|
||||||
int offset;
|
|
||||||
}
|
|
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public abstract class FileLocation {
|
public abstract class FileLocation {
|
||||||
protected FileLocation(int lline, int col, String filename) {
|
protected FileLocation(int lline, int col, @Nullable String filename) {
|
||||||
this.line = lline;
|
this.line = lline;
|
||||||
this.col = col;
|
this.col = col;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
@@ -90,13 +90,7 @@ public abstract class FileLocation {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuffer sb = new StringBuffer();
|
return "FileLocation" + "{col=" + col + ", line=" + line + ", filename='" + filename + '\'' + '}';
|
||||||
sb.append("FileLocation");
|
|
||||||
sb.append("{col=").append(col);
|
|
||||||
sb.append(", line=").append(line);
|
|
||||||
sb.append(", filename='").append(filename).append('\'');
|
|
||||||
sb.append('}');
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int line;
|
private int line;
|
||||||
|
@@ -62,12 +62,7 @@ public class Mark extends FileLocation {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuffer sb = new StringBuffer();
|
return "Mark{" + super.toString() + ",key=" + key + '}';
|
||||||
sb.append("Mark{");
|
|
||||||
sb.append(super.toString());
|
|
||||||
sb.append(",key=").append(key);
|
|
||||||
sb.append('}');
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeySorter<V> implements Comparator<V> {
|
public static class KeySorter<V> implements Comparator<V> {
|
||||||
@@ -86,5 +81,5 @@ public class Mark extends FileLocation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private char key;
|
private final char key;
|
||||||
}
|
}
|
||||||
|
@@ -33,8 +33,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Register {
|
public class Register {
|
||||||
private char name;
|
private char name;
|
||||||
@NotNull private SelectionType type;
|
@NotNull private final SelectionType type;
|
||||||
@NotNull private List<KeyStroke> keys;
|
@NotNull private final List<KeyStroke> keys;
|
||||||
|
|
||||||
public Register(char name, @NotNull SelectionType type, @NotNull String text) {
|
public Register(char name, @NotNull SelectionType type, @NotNull String text) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@@ -100,7 +100,7 @@ public class TextRange {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("TextRange");
|
sb.append("TextRange");
|
||||||
sb.append("{starts=").append(starts == null ? "null" : "");
|
sb.append("{starts=").append(starts == null ? "null" : "");
|
||||||
for (int i = 0; starts != null && i < starts.length; ++i) {
|
for (int i = 0; starts != null && i < starts.length; ++i) {
|
||||||
@@ -114,6 +114,6 @@ public class TextRange {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] starts;
|
private final int[] starts;
|
||||||
private int[] ends;
|
private final int[] ends;
|
||||||
}
|
}
|
@@ -89,7 +89,7 @@ public abstract class CommandHandler {
|
|||||||
* @param argFlags Range and Arguments commands
|
* @param argFlags Range and Arguments commands
|
||||||
* @param optFlags Other command specific flags
|
* @param optFlags Other command specific flags
|
||||||
*/
|
*/
|
||||||
public CommandHandler(CommandName[] names, int argFlags, int optFlags) {
|
public CommandHandler(@Nullable CommandName[] names, int argFlags, int optFlags) {
|
||||||
this.names = names;
|
this.names = names;
|
||||||
this.argFlags = argFlags;
|
this.argFlags = argFlags;
|
||||||
this.optFlags = optFlags;
|
this.optFlags = optFlags;
|
||||||
@@ -261,7 +261,7 @@ public abstract class CommandHandler {
|
|||||||
*/
|
*/
|
||||||
public abstract boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException;
|
public abstract boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException;
|
||||||
|
|
||||||
@Nullable protected CommandName[] names;
|
@Nullable protected final CommandName[] names;
|
||||||
protected int argFlags;
|
protected final int argFlags;
|
||||||
protected int optFlags;
|
protected final int optFlags;
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,6 @@ public class CommandName {
|
|||||||
return optional;
|
return optional;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String required;
|
private final String required;
|
||||||
private String optional;
|
private final String optional;
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ public class CommandNode {
|
|||||||
command = null;
|
command = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandNode(CommandHandler command) {
|
public CommandNode(@Nullable CommandHandler command) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,5 +57,5 @@ public class CommandNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable private CommandHandler command;
|
@Nullable private CommandHandler command;
|
||||||
@NotNull private HashMap<Character, CommandNode> nodes = new HashMap<Character, CommandNode>();
|
@NotNull private final HashMap<Character, CommandNode> nodes = new HashMap<Character, CommandNode>();
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,9 @@ import com.maddyhome.idea.vim.helper.Msg;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintains a tree of Ex commands based on the required and optional parts of the command names. Parses and
|
* Maintains a tree of Ex commands based on the required and optional parts of the command names. Parses and
|
||||||
* executes Ex commands entered by the user.
|
* executes Ex commands entered by the user.
|
||||||
@@ -41,6 +44,7 @@ public class CommandParser {
|
|||||||
public static final int RES_ERROR = 1;
|
public static final int RES_ERROR = 1;
|
||||||
public static final int RES_READONLY = 1;
|
public static final int RES_READONLY = 1;
|
||||||
public static final int RES_DONT_REOPEN = 4;
|
public static final int RES_DONT_REOPEN = 4;
|
||||||
|
public static final Pattern TRIM_WHITESPACE = Pattern.compile("[ \\t]*(.*)[ \\t\\n\\r]+", Pattern.DOTALL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There is only one parser.
|
* There is only one parser.
|
||||||
@@ -66,6 +70,7 @@ public class CommandParser {
|
|||||||
public void registerHandlers() {
|
public void registerHandlers() {
|
||||||
if (registered) return;
|
if (registered) return;
|
||||||
|
|
||||||
|
new ActionListHandler();
|
||||||
new AsciiHandler();
|
new AsciiHandler();
|
||||||
new CmdFilterHandler();
|
new CmdFilterHandler();
|
||||||
new CopyTextHandler();
|
new CopyTextHandler();
|
||||||
@@ -73,6 +78,8 @@ public class CommandParser {
|
|||||||
new DigraphHandler();
|
new DigraphHandler();
|
||||||
new DumpLineHandler();
|
new DumpLineHandler();
|
||||||
new EditFileHandler();
|
new EditFileHandler();
|
||||||
|
new ActionHandler();
|
||||||
|
new EchoHandler();
|
||||||
new ExitHandler();
|
new ExitHandler();
|
||||||
new FindClassHandler();
|
new FindClassHandler();
|
||||||
new FindFileHandler();
|
new FindFileHandler();
|
||||||
@@ -83,6 +90,7 @@ public class CommandParser {
|
|||||||
new HistoryHandler();
|
new HistoryHandler();
|
||||||
new JoinLinesHandler();
|
new JoinLinesHandler();
|
||||||
new JumpsHandler();
|
new JumpsHandler();
|
||||||
|
new LetHandler();
|
||||||
new MapHandler();
|
new MapHandler();
|
||||||
new MarkHandler();
|
new MarkHandler();
|
||||||
new MarksHandler();
|
new MarksHandler();
|
||||||
@@ -106,6 +114,7 @@ public class CommandParser {
|
|||||||
new ShiftRightHandler();
|
new ShiftRightHandler();
|
||||||
new SourceHandler();
|
new SourceHandler();
|
||||||
new SortHandler();
|
new SortHandler();
|
||||||
|
new SplitHandler();
|
||||||
new SubstituteHandler();
|
new SubstituteHandler();
|
||||||
new UndoHandler();
|
new UndoHandler();
|
||||||
new WriteAllHandler();
|
new WriteAllHandler();
|
||||||
@@ -222,8 +231,8 @@ public class CommandParser {
|
|||||||
}
|
}
|
||||||
int state = STATE_START;
|
int state = STATE_START;
|
||||||
Ranges ranges = new Ranges(); // The list of ranges
|
Ranges ranges = new Ranges(); // The list of ranges
|
||||||
StringBuffer command = new StringBuffer(); // The command
|
StringBuilder command = new StringBuilder(); // The command
|
||||||
StringBuffer argument = new StringBuffer(); // The command's argument(s)
|
StringBuilder argument = new StringBuilder(); // The command's argument(s)
|
||||||
StringBuffer location = null; // The current range text
|
StringBuffer location = null; // The current range text
|
||||||
int offsetSign = 1; // Sign of current range offset
|
int offsetSign = 1; // Sign of current range offset
|
||||||
int offsetNumber = 0; // The value of the current range offset
|
int offsetNumber = 0; // The value of the current range offset
|
||||||
@@ -294,7 +303,7 @@ public class CommandParser {
|
|||||||
state = STATE_RANGE_MARK;
|
state = STATE_RANGE_MARK;
|
||||||
}
|
}
|
||||||
else if (ch == '+' || ch == '-') {
|
else if (ch == '+' || ch == '-') {
|
||||||
location.append('0');
|
location.append('.');
|
||||||
state = STATE_RANGE_OFFSET;
|
state = STATE_RANGE_OFFSET;
|
||||||
}
|
}
|
||||||
else if (ch == '\\') {
|
else if (ch == '\\') {
|
||||||
@@ -533,7 +542,12 @@ public class CommandParser {
|
|||||||
logger.debug("argument = " + argument);
|
logger.debug("argument = " + argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ExCommand(ranges, command.toString(), argument.toString().trim());
|
String argumentString = argument.toString();
|
||||||
|
final Matcher matcher = TRIM_WHITESPACE.matcher(argumentString);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
argumentString = matcher.group(1);
|
||||||
|
}
|
||||||
|
return new ExCommand(ranges, command.toString(), argumentString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -544,6 +558,9 @@ public class CommandParser {
|
|||||||
public void addHandler(@NotNull CommandHandler handler) {
|
public void addHandler(@NotNull CommandHandler handler) {
|
||||||
// Iterator through each command name alias
|
// Iterator through each command name alias
|
||||||
CommandName[] names = handler.getNames();
|
CommandName[] names = handler.getNames();
|
||||||
|
if (names == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (CommandName name : names) {
|
for (CommandName name : names) {
|
||||||
CommandNode node = root;
|
CommandNode node = root;
|
||||||
String text = name.getRequired();
|
String text = name.getRequired();
|
||||||
@@ -583,7 +600,7 @@ public class CommandParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull private CommandNode root = new CommandNode();
|
@NotNull private final CommandNode root = new CommandNode();
|
||||||
private boolean registered = false;
|
private boolean registered = false;
|
||||||
|
|
||||||
private static CommandParser ourInstance;
|
private static CommandParser ourInstance;
|
||||||
@@ -610,5 +627,5 @@ public class CommandParser {
|
|||||||
private static final int STATE_RANGE_DONE = 51;
|
private static final int STATE_RANGE_DONE = 51;
|
||||||
private static final int STATE_ERROR = 99;
|
private static final int STATE_ERROR = 99;
|
||||||
|
|
||||||
private static Logger logger = Logger.getInstance(CommandParser.class.getName());
|
private static final Logger logger = Logger.getInstance(CommandParser.class.getName());
|
||||||
}
|
}
|
||||||
|
@@ -53,13 +53,8 @@ public class ExCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public LineRange getLineRange(@NotNull Editor editor, DataContext context, boolean checkCount) {
|
public LineRange getLineRange(@NotNull Editor editor, DataContext context) {
|
||||||
int count = -1;
|
return ranges.getLineRange(editor, context, -1);
|
||||||
if (checkCount) {
|
|
||||||
count = getCountArgument();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ranges.getLineRange(editor, context, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -100,8 +95,8 @@ public class ExCommand {
|
|||||||
return ranges;
|
return ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull private Ranges ranges;
|
@NotNull private final Ranges ranges;
|
||||||
@NotNull private String command;
|
@NotNull private final String command;
|
||||||
@NotNull private String argument;
|
@NotNull private String argument;
|
||||||
|
|
||||||
private static Logger logger = Logger.getInstance(ExCommand.class.getName());
|
private static Logger logger = Logger.getInstance(ExCommand.class.getName());
|
||||||
|
@@ -56,7 +56,7 @@ public class ExOutputModel {
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
myText = null;
|
myText = null;
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
ExOutputPanel.getInstance(myEditor).deactivate();
|
ExOutputPanel.getInstance(myEditor).deactivate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,6 @@ public class LineRange {
|
|||||||
return endLine;
|
return endLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int startLine;
|
private final int startLine;
|
||||||
private int endLine;
|
private final int endLine;
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ParseResult {
|
public class ParseResult {
|
||||||
@NotNull private Ranges ranges;
|
@NotNull private final Ranges ranges;
|
||||||
@NotNull private String command;
|
@NotNull private final String command;
|
||||||
@NotNull private String argument;
|
@NotNull private final String argument;
|
||||||
|
|
||||||
public ParseResult(@NotNull Ranges ranges, @NotNull String command, @NotNull String argument) {
|
public ParseResult(@NotNull Ranges ranges, @NotNull String command, @NotNull String argument) {
|
||||||
this.ranges = ranges;
|
this.ranges = ranges;
|
||||||
|
@@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.helper.EditorHelper;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,9 +48,7 @@ public class Ranges {
|
|||||||
* @param range The list of ranges to append to the current list
|
* @param range The list of ranges to append to the current list
|
||||||
*/
|
*/
|
||||||
public void addRange(@NotNull Range[] range) {
|
public void addRange(@NotNull Range[] range) {
|
||||||
for (Range aRange : range) {
|
Collections.addAll(ranges, range);
|
||||||
ranges.add(aRange);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,7 +183,10 @@ public class Ranges {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static TextRange getFileTextRange(@NotNull Editor editor, DataContext context) {
|
public static TextRange getFileTextRange(@NotNull Editor editor, DataContext context) {
|
||||||
Ranges ranges = new Ranges();
|
Ranges ranges = new Ranges();
|
||||||
ranges.addRange(AbstractRange.createRange("%", 0, false));
|
final Range[] range = AbstractRange.createRange("%", 0, false);
|
||||||
|
if (range != null) {
|
||||||
|
ranges.addRange(range);
|
||||||
|
}
|
||||||
|
|
||||||
return ranges.getTextRange(editor, context, -1);
|
return ranges.getTextRange(editor, context, -1);
|
||||||
}
|
}
|
||||||
@@ -225,11 +227,8 @@ public class Ranges {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer res = new StringBuffer();
|
|
||||||
res.append("Ranges[ranges=").append(ranges);
|
|
||||||
res.append("]");
|
|
||||||
|
|
||||||
return res.toString();
|
return "Ranges[ranges=" + ranges + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private int startLine = 0;
|
private int startLine = 0;
|
||||||
@@ -237,5 +236,5 @@ public class Ranges {
|
|||||||
private int count = 0;
|
private int count = 0;
|
||||||
private int defaultLine = -1;
|
private int defaultLine = -1;
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
private List<Range> ranges;
|
@NotNull private final List<Range> ranges;
|
||||||
}
|
}
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
|
||||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.maddyhome.idea.vim.ex;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author vlan
|
|
||||||
*/
|
|
||||||
public class VimScriptParser {
|
|
||||||
public static final String[] VIMRC_FILES = {".ideavimrc", "_ideavimrc", ".vimrc", "_vimrc"};
|
|
||||||
|
|
||||||
private VimScriptParser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static File findVimrc() {
|
|
||||||
final String homeDirName = System.getProperty("user.home");
|
|
||||||
if (homeDirName != null) {
|
|
||||||
for (String fileName : VIMRC_FILES) {
|
|
||||||
final File file = new File(homeDirName, fileName);
|
|
||||||
if (file.exists()) {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void executeFile(@NotNull File file) {
|
|
||||||
try {
|
|
||||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
try {
|
|
||||||
line = line.trim();
|
|
||||||
if (line.startsWith(":")) {
|
|
||||||
line = line.substring(1);
|
|
||||||
}
|
|
||||||
final CommandParser commandParser = CommandParser.getInstance();
|
|
||||||
final ExCommand command = commandParser.parse(line);
|
|
||||||
final CommandHandler commandHandler = commandParser.getCommandHandler(command);
|
|
||||||
if (commandHandler instanceof VimScriptCommandHandler) {
|
|
||||||
final VimScriptCommandHandler handler = (VimScriptCommandHandler)commandHandler;
|
|
||||||
handler.execute(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ExException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
74
src/com/maddyhome/idea/vim/ex/handler/ActionHandler.java
Normal file
74
src/com/maddyhome/idea/vim/ex/handler/ActionHandler.java
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||||
|
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maddyhome.idea.vim.ex.handler;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.ActionManager;
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.application.Application;
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.maddyhome.idea.vim.KeyHandler;
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin;
|
||||||
|
import com.maddyhome.idea.vim.ex.CommandHandler;
|
||||||
|
import com.maddyhome.idea.vim.ex.ExCommand;
|
||||||
|
import com.maddyhome.idea.vim.ex.ExException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author smartbomb
|
||||||
|
*/
|
||||||
|
public class ActionHandler extends CommandHandler {
|
||||||
|
public ActionHandler() {
|
||||||
|
super("action", "", RANGE_FORBIDDEN | DONT_REOPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean execute(@NotNull Editor editor, @NotNull final DataContext context,
|
||||||
|
@NotNull ExCommand cmd) throws ExException {
|
||||||
|
final String actionName = cmd.getArgument().trim();
|
||||||
|
final AnAction action = ActionManager.getInstance().getAction(actionName);
|
||||||
|
if (action == null) {
|
||||||
|
VimPlugin.showMessage("Action not found: " + actionName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Application application = ApplicationManager.getApplication();
|
||||||
|
if (application.isUnitTestMode()) {
|
||||||
|
executeAction(action, context, actionName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
application.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
executeAction(action, context, actionName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executeAction(@NotNull AnAction action, @NotNull DataContext context, @NotNull String actionName) {
|
||||||
|
try {
|
||||||
|
KeyHandler.executeAction(action, context);
|
||||||
|
}
|
||||||
|
catch (RuntimeException e) {
|
||||||
|
// TODO: Find out if any runtime exceptions may happen here
|
||||||
|
assert false : "Error while executing :action " + actionName + " (" + action + "): " + e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user