Commit Graph

90 Commits

Author SHA1 Message Date
hluk
227ef8240a FakeVim: Command % jumps to first known parenthesis character
Change-Id: I28988925f397af8c4927c416774d7fe21e982dcb
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-12-30 13:25:27 +01:00
Eike Ziller
920d524d38 Merge remote-tracking branch 'origin/3.0' 2013-12-03 12:46:39 +01:00
hluk
b1a714ed44 FakeVim: Fix infinite loop when replacing empty text
Change-Id: Ie4ba6420889b0a6a5712b43a11f8366aa9a30edc
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-12-03 11:40:51 +01:00
hluk
9e4dabc884 FakeVim: Dot command works for letter case commands in visual mode
Change-Id: I303c464c0ca2fb01f4a951d3fe7b6796f31d0ab2
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-10-10 15:59:57 +02:00
hluk
a636a933d0 FakeVim: Fix searching in visual mode and with commands
Search in visual mode should select text up to matched position.

Using commands should work with search movement; e.g. 'd2/needle<CR>'.
Commands should be also properly canceled if search movement fails.

Change-Id: Ic695dccaf3f36ccae2f2b1a93f888d5ba9805a78
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-09-19 12:17:37 +02:00
hjk
e8b25ac3aa FakeVim: Add another autotest for 'w'
Change-Id: Ice665ca96eb6fc0ad50548e55d29eefe1f20f111
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-09-11 10:58:00 +02:00
hluk
59c35e96c4 FakeVim: Explicitly enable some options for tests
Since there is now separate configuration for tests
(f3ca72f989) it became obvious that
indentation options are disabled by default.

Change-Id: If13b16b05c5f11171aa49d6964d7e55e2a790646
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-09-05 18:55:49 +02:00
hjk
4a24df38a3 EditorManager: Use static pattern, adjust surrounding code
Change-Id: I3255a0150cd9a730336456c5a9f986eb74fefbff
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-08-30 11:22:56 +02:00
hluk
41785890d6 FakeVim: Escape '>' character in mappings
On some keyboards, '>' character can be produced using Shift key. But
recorded macro shouldn't contain '<S->>', which cannot be properly
parsed, instead it will be '<S-<GT>>' (as '<LT>' for '<').

Change-Id: Iac3759029b6ff8c9e690c4728e35048c0b6046f9
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-08-29 11:10:36 +02:00
hluk
6c3972680e FakeVim: Operator-pending mappings
Implements :omap (and :onoremap) for defining user mappings for movement
while in operator-pending mode (after commands 'c', 'd', '>' and
others).

Change-Id: I07a1e90bf5c649ef5bb53d1de873817dc7348e19
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-08-13 15:45:16 +02:00
hluk
1843d5ab67 FakeVim: Check first character on line with 'F' and 'T' commands
Change-Id: Icd5c3ca62da0fbff35e2281e04b1fa37a304f64c
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-08-12 12:50:50 +02:00
hluk
76d4084234 FakeVim: Bracket movement commands
Added commands ]], [[, [], ][ for movement.

Task-number: QTCREATORBUG-9527
Change-Id: I0c363427505c9ef6274ed1cf735c9fbc43cb4bd9
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-08-06 10:56:59 +02:00
hluk
e5c323e83a FakeVim: Monitor inserted text using signals from QTextDocument
Use QTextDocument::onContentsChanged() to monitor text inserted and
removed in insert mode for dot command (or just repeat with 2i, 3o etc.)
to re-insert same text.

Works even if auto-completion is replacing '.' with '->' for pointers.

Change-Id: Ie39edcdc9ec60bcf6c7d10f021248c3a0aee76b6
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-08-05 16:09:54 +02:00
hluk
55bb2e42fc FakeVim: Select/unselect line break in visual selection
Task-number: QTCREATORBUG-9289
Change-Id: Ic05b71491f8ed625df0ce514182eff916171666a
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-05-31 10:44:18 +02:00
hluk
2fb8590f87 FakeVim: Fix behavior of 'dw' command
Task-number: QTCREATORBUG-9289
Change-Id: I7ac1c925a13df49d60db410dce2d90b02cac7cfd
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-05-31 10:44:09 +02:00
hluk
cf1b82b152 FakeVim: Emulate insert mode more precisely
Set correct position for commands I, A in visual mode.

Don't repeat insert mode [count] times if cursor moved in insert mode
(or after <C-O> command).

Don't repeat movement in insert mode ([count] is used only to repeat
the first inserted text).

Dot command for insert mode should be cleared if cursor moved and user
started inserting a text.

Change-Id: I4dbd0fa4e7ecedc6623838c9ad855f83276da2ce
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-05-06 08:32:42 +02:00
hluk
2a8a411b21 FakeVim: Fixes and more tests for visual block mode
Task-number: QTCREATORBUG-9190
Change-Id: I4cc3ef675f65edafc1d68ae9dd1521656b5bfdb7
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-04-24 10:16:50 +02:00
hluk
2ed88c44fd FakeVim: Don't overuse cursor setting and scrolling in editor
Set new text cursor and scroll in editor widget only if it's only
needed. Sometimes these action can have side-effects.

Set new cursor and scroll especially after no pending input and commands
are available to process for FakeVim.

Change-Id: I47df4d0328ac990e2e5c6981955ea7d1bd608c71
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-04-19 14:40:30 +02:00
hluk
12deff2fdd FakeVim: Reworked undo/redo
Don't use QTextCursor::beginEditBlock() and others since it can change
the behavior of underlying editor widget. Use these methods only for
interrupting current edit block.

Change-Id: I848d6287faeeaad9c04a76758bd0b2cc673ad2ef
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-04-08 08:41:32 +02:00
hluk
bea40d99b9 FakeVim: More precise scrolling
Emulate Vim scrolling behavior. Consider only fully visible lines in
editor widget.

Don't ignore last empty line in document.

Change-Id: Id2c4fd744fb3c4c69324ea6456db424186563bc9
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-04-08 08:37:47 +02:00
hluk
1bea9b98fb FakeVim: Option 'passcharacters' (not in Vim)
Option to pass some key presses in insert mode to editor widget
(replaces 'passnewline'). This allows to rename symbols in insert mode,
complete parenthesis blocks, expand comments etc.

Macro expansion and code-completion works with dot command.

Task-number:QTCREATORBUG-4828
Change-Id: I5ff43818d4f7f183cd6f4ed8cc3a4586469ab65d
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-04-04 13:50:08 +02:00
hluk
4fc706d7e0 FakeVim: Don't handle user mapping in some commands
Don't handle user mappings in commands that cannot be followed by
movement command. For example, key "<SPACE>" in after "t" command cannot
be handled as user mapping.

Change-Id: I97582d23ae637b30b1058b9d2b381a869bbebb79
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-04-03 12:33:21 +02:00
hluk
70aa000217 FakeVim: Macros with <S-left> and other key combinations
Change-Id: Ie1cc1b290cae271098dd4e82d3ae285ac7013562
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-22 08:22:44 +01:00
hluk
0f25f0c89b FakeVim: Initial support for Vim macro recording and replaying
Record macro with 'q{0-9a-zA-Z"}' command and replay it with
'@{0-9a-z".*+}'. Replaying with prompt ('=' instead of register) not
supported.

Change-Id: I49965a99d10910e8df09e62020ed496542e3b249
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-18 17:18:35 +01:00
hluk
92bd228e95 FakeVim: Correct range mode for registers
Change-Id: Ib58ced12ab8cff5917e17b8fc5022147d6f99f38
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-18 17:16:39 +01:00
hluk
474459f45f FakeVim: Refactored user mappings code
Change-Id: Ib32a97814ce5dc36a5d5ae3cba59bf4968525bad
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-18 17:15:08 +01:00
hluk
4f20799af2 FakeVim: Clear count after insert mode
Change-Id: If02aaecbbbb5e25001d5bafafd0d4228bba5d63e
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-18 17:13:45 +01:00
hluk
70adf53fbd FakeVim: Option 'passnewline' (not in Vim)
Option 'passnewline' ('pnl') passes new line in insert mode and on 'o'
and 'O' commands to editor widget. This way the editor widget can handle
the indentation or insert characters (e.g. asterisk if in C block
comment).

Change-Id: I06afab6b20b49e1b4d31447826c847d36d32806f
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-18 17:11:53 +01:00
hluk
f2f0bf5376 FakeVim: Emulate Vim option "tildeop" ("top")
Change-Id: I61a07f5edc0e2a062ca10cb17f489ac3ce113d9f
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-14 16:22:17 +01:00
hluk
0a86efb8a0 FakeVim: Tilde command moves text cursor to the right
Change-Id: Ieff36ffa06b39dd7ff55551dd0fec627b8561939
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-14 16:21:31 +01:00
hjk
67cc94fd74 FakeVim: Add test for ~
Change-Id: I17f825806c76e1877bbd66d9e66c3e0d63a71b39
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-12 10:53:37 +01:00
Friedemann Kleint
d0c2ceab81 Fix Krazy-warnings about single-character strings in fakevim-test.
Change-Id: Idfe968cd6967e096b8b2b32c02ad7491c7f95a77
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-03-08 10:27:11 +01:00
Lukas Holecek
a2be7db81c FakeVim: Fix usage of copy/paste registers with tests
Change-Id: I9b860a40a9b18286a25e1d919dab1c21ea5def10
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-02-28 15:13:20 +01:00
Lukas Holecek
9b79adc4ba FakeVim: Handle unicode mappings and properly fail on bad mapping
Task-number: QTCREATORBUG-8774
Change-Id: Ic57a01fc13a073f2b13d16daecba9e070e186779
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-02-19 18:41:32 +01:00
Lukas Holecek
e46a63b93e FakeVim: Fixes for visual delete with end of line selected
Change-Id: I486aff7cf6a81b125a9b3b179505656efe997789
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-02-18 13:05:23 +01:00
Robert Loehning
a040424d2a Incremented year in copyright info
Change-Id: Ia11f4d7a94465de7f12cc390855e54e3256e5455
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2013-02-01 09:19:26 +01:00
Lukas Holecek
2622eb2415 FakeVim: Remember that cursor is at the end of line
Change-Id: I62098a409028593664b813931d5974de5e787993
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-17 11:03:33 +01:00
Lukas Holecek
402affa9c2 FakeVim: First <Delete> is part of dot command in insert mode
Change-Id: I9324c65333c0f893541043e953456e83a9986bf7
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-17 11:02:45 +01:00
Lukas Holecek
b74ae13491 fakevim: Set correct cursor column after a command
Set cursor column after some commands and position the cursor on same
column after vertical movement. If line is too short set cursor to the
end of line but don't remember the new cursor column.

Change-Id: I4f5592925b9b360e7393f6ac966025f1466f483d
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-26 15:58:44 +01:00
Lukas Holecek
9a774254bf fakevim: Escape insert command and correct undo position for "I"
Escape inserted string for repeatition, e.g. command "2i<up>" will
insert text "<up><up>".

Undo position for "I" is start of selection or line.

Change-Id: Ic7e6d8dbf712197b36be20b17ef6d1c0814b1a51
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-21 01:10:22 +01:00
Lukas Holecek
3eedd06ce5 fakevim: Restore FakeVim state before any text processing
Restore selection and cursor position (may have been changed externally)
before any text processing.

Change-Id: I424523512f8f83c276e7d29760aad29bf7921dab
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-18 19:41:12 +01:00
Lukas Holecek
f377264128 fakevim: Use _ instead of QLatin1String
Change-Id: Ibc00ed4cbc54fc78fa815277387c01a3436cc688
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-18 19:23:28 +01:00
Orgad Shaneh
1f74468a56 FakeVim: Compile with QT_NO_CAST_FROM_ASCII
Change-Id: I5ed7bb6f39689d5657709e2ab4a2fa90594abb0e
Reviewed-by: hjk <qthjk@ovi.com>
Reviewed-by: Lukas Holecek <hluk@email.cz>
2012-12-09 22:08:51 +01:00
Lukas Holecek
05261e4d0b fakevim: Fix word selection in visual mode
Change-Id: I11a9831f2178f818639e04d7aad0eeb6c3f627fc
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-04 23:40:06 +01:00
Lukas Holecek
234a04f814 fakevim: Correct movement mode for yanking lines
Change-Id: I936574d9220d11031e1f68600bec6e33c88808a5
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-04 22:23:48 +01:00
Lukas Holecek
baa4db2499 fakevim: Fix insert mode after visual block selection
Commands in visual block mode '[count]A', '[count]I' and 's' (ignores
[count]) are repeated on every selected line (before or after the block
selection).

Task-number: QTCREATORBUG-8366
Change-Id: I9832656248a8706d1bd4066bd8cf49beded1d8aa
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-04 22:23:14 +01:00
Lukas Holecek
00a10fcfa8 fakevim: Correct undo/redo position for changing numbers
Restore position on undo and redo after <C-A> and <C-X> commands.

Do not set dot command if no number was found.

Change-Id: Ia4e6d53ecfbd7f56e874d6a39c0939557f6cdc3d
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-29 22:44:43 +01:00
Lukas Holecek
5919416eab fakevim: Increase/decrease octal and hexadecimal numbers
Hexadecimal (prefix '0x' or '0X') and octal (prefix '0') numbers are
unsigned. Decimal number can be signed (with leading '-').

Preserve width of hexadecimal and octal numbers (i.e. append leading
zeroes if result is shorter or remove leading zeroes if any and result
is longer).

Change-Id: I93769546ff40a586458986909fcee1e4e9143bc2
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-29 16:53:44 +01:00
Lukas Holecek
ec3f4d3801 fakevim: Handle completion in insert and replace modes
Text inserted without FakeVim's intervention (code completion) is
handled in insert and replace mode so that '.' command also inserts any
externally inserted text.

After movement in insert mode last command (initiated by '.') is not
cleared until new text is inserted.

Deletion in insert mode is part of dot command.

Change-Id: Ic55b3cdecaf4323e88cd321b218fae661de7a63e
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-29 10:40:04 +01:00
Lukas Holecek
0e6041ed45 fakevim: Paragraph movement using '{' and '}'
Change-Id: Ie156438b6633b7e9680e028fca7eca1b8788a63d
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-27 08:19:35 +01:00