Commit Graph

678 Commits

Author SHA1 Message Date
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
hjk
26275fb175 FakeVim: initialize variables
Compiler complains about potential use of uninitialized value.

Change-Id: I120329351983ab795f0dae0ebcc87cd53762f0bd
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-16 19:22:34 +01:00
Orgad Shaneh
29a93998df Remove braces for single lines of conditions
#!/usr/bin/env ruby

Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}

Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 10:48:18 +01:00
Lukas Holecek
2af8015941 FakeVim: Allow to delete selected text in command buffer
Change-Id: Ia3074053da465b5ce999955f428c970f1b01a265
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-30 16:08:36 +01:00
hjk
a570e7327f FakeVim: handle keyboard selection in command buffer
Change-Id: I6a1f605fc77b9af596ee60c5f98e1b3252333284
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-30 11:18:39 +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
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
c50c4269ad fakevim: Display visual block selection correctly
Change-Id: Id33544265c0266e0a43a811b5a00aa94dfcc4f37
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-05 19:35:47 +01:00
Lukas Holecek
f50dc8e06f fakevim: Restore last selection with proper position
Command 'gv' restores proper position in selection -- except in visual
line mode ('V') only positions at beginning and end are supported.

Change-Id: I0810808606c340b5c18fe7551a2d5fda29abfeca
Reviewed-by: hjk <qthjk@ovi.com>
2012-12-05 19:35:09 +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
61c3de01a8 fakevim: Commands '[z' and ']z' to move to top or bottom of fold
Commands '[z' and ']z' to move [count] times to top or bottom of current
folds.

Change-Id: Ia087e47bd5f9d63a2b9a4b2ffd3fc57559dfba6b
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-30 14:34:43 +01:00
Lukas Holecek
9d2f1f6769 fakevim: Commands 'zj' and 'zk' to move [count] folds down and up
It's possible to do '2dzj' to delete everything up to beginning of
second unfolded block or whole folded block.

Change-Id: I080c9ec4d12471faf09cabea3c96b448b5fc7f4d
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-30 14:33:44 +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
Lukas Holecek
6868fedf4d fakevim: Yank with up/down movement ends in same column
Yank followed by vertical movement ends in same column as at the
beginning of the command (or at the end of line if line ha less
columns).

Change-Id: I573a8435ba9b76430fa3778e536726882f4c6ce1
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-27 08:18:27 +01:00
Lukas Holecek
ece5a4a33b fakevim: Merge marks on undo so new marks are not lost
Overwriting a mark with new position and undoing restores the previous
state of the mark.

Creating new mark (not overwriting old value) on a position and undoing
won't remove the mark.

Change-Id: I673874ef9df0aae16f86efe8599a43a77aae19ee
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:17:37 +01:00
Lukas Holecek
9ed83d4e2b fakevim: Correct visual selection of a quoted object
Change-Id: I76eb6d39efb384cb706847b07bb282a8b2f1a6d3
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:16:52 +01:00
Lukas Holecek
fc47af3ab7 fakevim: In insert mode <C-J> and <C-M> are aliases for return key
Change-Id: I825d82c8577d2e9163248f4e968e177741683145
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:16:25 +01:00
Lukas Holecek
2e1f898c9d fakevim: <C-W> in insert mode stops deleting at end of previous line
Change-Id: I6733c0de42215b9cf2f662836e4e5956eab1c0e2
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:16:03 +01:00
Lukas Holecek
6547845d27 fakevim: Fix movement with '%'
Change-Id: I6c4bf3b39b334ae621e4648bbc57f50ba8d418ec
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:15:28 +01:00
Lukas Holecek
6e5018ef5d fakevim: Fix inclusive/exclusive delete
Change-Id: I1b46bda3f70a533d149cf38de02d89e2cf706f3f
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:13:42 +01:00
Lukas Holecek
a99874c0db fakevim: Correct cursor position after 'J'
Change-Id: Iff0c719c6b301dac333a55acfb073c7d1e1a27c8
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:12:53 +01:00
Lukas Holecek
477285b93c fakevim: Correct cursor position after yank
Change-Id: I845eeebe44ed859cc96d69fbd660fce56cc1418b
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:11:05 +01:00
Lukas Holecek
611be1ae19 fakevim: Command 's' has exclusive motion
Change-Id: I3d4642ebf69055722568cf0e59f5480ad5b2c418
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-26 17:10:29 +01:00
Lukas Holecek
ab7ef16030 fakevim: Correct visual selection of a text object
Change-Id: Ib4996a88d1bbbec25ab864a37f62825e5b0a2b27
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-22 18:39:11 +01:00
hjk
bfd5519caf fakevim: compile fix
Change-Id: I9b82afa882845e9a3d251619ad87fe18343b6a7a
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-22 10:29:21 +01:00
Lukas Holecek
66aa861c51 fakevim: Allow to set g flag for movement
Enabled commands are for example 'dgg', 'cge', 'y10gg' etc.

Change-Id: I084991f1d352ee8bcec97cf756f7884d64b4e502
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-22 08:27:07 +01:00
Lukas Holecek
f302f3b8c2 fakevim: <C-O> to execute single command and return to insert mode
After Ctrl+O combination in insert or replace mode enter command mode
and after a single command (can consist of entering Ex command or can be
switch to other buffer) or escape key return to previous insert or
replace mode. One exception is that if entering insert mode is part of
the command after <C-O> pressing escape key will exit to command mode
(Vim behavior).

Change-Id: I37d684b691157001e2cab156687d6771afdec7b9
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-22 08:26:11 +01:00
Lukas Holecek
9ab2d3d0a7 fakevim: Removed 'J' from movement commands
Change-Id: I5d3e39c6ea717008a3e555f4370827ed876affd1
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-22 08:24:45 +01:00
Orgad Shaneh
74387106d3 Fix build
qt-creator/src/plugins/fakevim/fakevimhandler.cpp:409:64: error: ambiguous overload for ‘operator+’ in ‘(& c)->QChar::toLower() + (& c)->QChar::toUpper()’
qt-creator/src/plugins/fakevim/fakevimhandler.cpp:409:64: note: candidates are:
/usr/include/qt4/QtCore/qstring.h:1021:22: note: const QString operator+(const QString&, const QString&)
/usr/include/qt4/QtCore/qstring.h:1023:22: note: const QString operator+(const QString&, QChar)
/usr/include/qt4/QtCore/qstring.h:1025:22: note: const QString operator+(QChar, const QString&)

Change-Id: I7f3c1b7a8fa13d01fd020eb828eb33970cf18a67
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2012-11-20 19:16:36 +01:00
Lukas Holecek
216db6320c fakevim: Fix search for [a-z]* and other character ranges
Correctly convert Vim regular expression with braces to QRegExp.
E.g. [a-z] in case insensitive mode should be [a-zA-Z].

Change-Id: Iea4e0220ef7d82041884f61b3ee0fed9f912e7b0
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-20 10:47:31 +01:00
Lukas Holecek
f31da9ac55 fakevim: Show current command in minibuffer (showcmd option)
Use showcmd Vim option to show current partial command.

Removed unneeded updateMiniBuffer() calls.

Change-Id: Iddacd364b7c92882b6169a6894c89cdb202a32bf
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-20 08:29:37 +01:00
Lukas Holecek
cd7c91d440 fakevim: Match same text with same regular expression
Match same text on same regex in forward and backward search modes.
E.g. with '\w\{2}' Vim regex and 'abc' text always match '<ab>c'
(should never match 'a<bc>' as with QTextDocument::find()).

Change-Id: Ie920c76540f3be426fc7b842d38137e95c1a65b2
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-19 08:54:10 +01:00
Lukas Holecek
29c448edb1 fakevim: Methods for handling input in sub-modes
Code from handleCommandMode*() was moved to separate handle*SubMode()
methods. The common code is in handleCommandMode() which is called on
user input in command mode. This method additionally handles clearing
flags for command submodes.

Method handleMovement() handles movement input. This method is called if
no command is active (from handleNoSubMode()) or if current incomplete
command can be followed by movement (finishMovement() is called to
finalize the command).

Unneeded finishMovement() calls were removed.

Change-Id: Ib5ca5b6ec252224eee3285680572fb9fcefd0d46
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-16 17:30:50 +01:00
Lukas Holecek
88814c64b5 fakevim: Stop dot command or mapping after an unhandled input
Stop processing dot command or user mapping after it's no longer valid.

For example do not process the "text" part of command "ci)text" if
cursor is not in parenthesis block or "ctXtext" if character 'X' was not
found on current line after cursor. In these cases insert mode is not
set.

Change-Id: I54588f3beeb803e42a566f6381352aff7bb602c7
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-07 18:11:17 +01:00
Lukas Holecek
709c142717 fakevim: Fix commands ci* and di*
Commands ciw and diw should work on a single character.

Commands ci), di" and similar should work on in an empty block.

Change-Id: Id166a3fb80fc5ba2672231638ce126bd88b4f3ff
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-06 17:34:16 +01:00
Lukas Holecek
67bf8aa863 fakevim: Fix crash when setting cursor position in edit block
Workaround for crash when setting text cursor position while in edit
block (after QTextCursor::beginEditBlock() call and before
QTextCursor::endEditBlock() call).

Task-number: QTCREATORBUG-8148
Change-Id: I7faab2e878efea4106e375b32526ecd5984feac2
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-06 16:27:14 +01:00
Lukas Holecek
f4626e6850 fakevim: Fix exclusive movement type for some commands
Change-Id: Ia9dc3a7063b921bd90bddd52e1df1e6b8b8b3796
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-02 17:41:32 +01:00
Lukas Holecek
afc8cd6932 fakevim: Fix crash when adding text to last line
Workaround for crash when in edit block and adding text to the last
empty line.

Change-Id: I46b84074bd6f6fbcae698671716e151ebab98f5b
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-02 09:24:55 +01:00
Lukas Holecek
82a55d4b9e fakevim: Global file marks
Uppercase marks for jumping to a line in a different file.

Change-Id: I2f05389956e1f3d6ae557f6545de3bec30673203
Reviewed-by: hjk <qthjk@ovi.com>
2012-11-02 08:16:21 +01:00
Lukas Holecek
94d36078aa fakevim: Better input key comparison
Change-Id: I47ca07f8ef54f8f7f38d467ea0aa2c087ee95a37
Reviewed-by: hjk <qthjk@ovi.com>
2012-10-31 19:03:53 +01:00
Lukas Holecek
c55620000c fakevim: Undo/redo last selection and cleanup
Change-Id: I09b825349c01e2cbcebc446fdf8843aaf8793e6f
Reviewed-by: hjk <qthjk@ovi.com>
2012-10-31 15:04:17 +01:00
Lukas Holecek
f7fa450a1c fakevim: Improved range modifying Ex commands.
Added change and join Ex commands.

Ex command range and address with /.../, ?...?, \/, \? and \&.

Change-Id: I23f16d3e454f28bcfcf87aeab500830136546345
Reviewed-by: hjk <qthjk@ovi.com>
2012-10-29 10:04:57 +01:00
Lukas Holecek
8994bb2d4a fakevim: Added move and yank Ex commands
Change-Id: I4138a2035e338b665d91704b7c53117c4d924472
Reviewed-by: hjk <qthjk@ovi.com>
2012-10-26 09:31:10 +02:00