summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Aumueller <aumuell@reserv.at>2008-12-25 10:43:28 +0100
committerhjk <qtc-committer@nokia.com>2009-01-13 11:14:03 +0100
commit33721acf82f97b14613796722b5515c3ccf6148b (patch)
tree2ed545acddb849b94ce998da4efb4f8623cb0d4a /src
parentd2c031d481e42cecaa94c0b21352ffc13b4bc709 (diff)
downloadqt-creator-33721acf82f97b14613796722b5515c3ccf6148b.tar.gz
fakevim: implement '%' for moving between matching parentheses
Diffstat (limited to 'src')
-rw-r--r--src/plugins/fakevim/FakeVim.pluginspec1
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp27
2 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/fakevim/FakeVim.pluginspec b/src/plugins/fakevim/FakeVim.pluginspec
index 66a091e283..a420040ac8 100644
--- a/src/plugins/fakevim/FakeVim.pluginspec
+++ b/src/plugins/fakevim/FakeVim.pluginspec
@@ -6,6 +6,7 @@
<url>http://www.trolltech.com/</url>
<dependencyList>
<dependency name="CppEditor" version="0.9.2"/><!-- Plugin adds items to the editor's context menu -->
+ <dependency name="TextEditor" version="0.9.2"/>
<dependency name="ProjectExplorer" version="0.9.2"/>
<dependency name="Core" version="0.9.2"/>
</dependencyList>
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index b93bacb823..45c1d56b33 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -669,6 +669,33 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
handleKey(c.unicode(), QString(c));
} else if (key == '=') {
m_submode = IndentSubMode;
+ } else if (key == '%') {
+ bool undoFakeEOL = false;
+ if (atEol()) {
+ m_tc.movePosition(Left, KeepAnchor, 1);
+ undoFakeEOL = true;
+ }
+ TextEditor::TextBlockUserData::MatchType match
+ = TextEditor::TextBlockUserData::matchCursorForward(&m_tc);
+ if (match == TextEditor::TextBlockUserData::Match) {
+ if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode)
+ m_tc.movePosition(Left, KeepAnchor, 1);
+ } else {
+ if (undoFakeEOL)
+ m_tc.movePosition(Right, KeepAnchor, 1);
+ if (match == TextEditor::TextBlockUserData::NoMatch) {
+ // backward matching is according to the character before the cursor
+ bool undoMove = false;
+ if (!m_tc.atBlockEnd()) {
+ m_tc.movePosition(Right, KeepAnchor, 1);
+ undoMove = true;
+ }
+ match = TextEditor::TextBlockUserData::matchCursorBackward(&m_tc);
+ if (match != TextEditor::TextBlockUserData::Match && undoMove)
+ m_tc.movePosition(Left, KeepAnchor, 1);
+ }
+ }
+ finishMovement();
} else if (key == 'a') {
m_mode = InsertMode;
m_lastInsertion.clear();