From 1dc1a64e1913f31b5cff5a1fef4b6b62160b5294 Mon Sep 17 00:00:00 2001 From: Martin Aumueller Date: Wed, 28 Jan 2009 20:49:38 +0100 Subject: [PATCH 1/8] fakevim: if Escape key serves no function, ignore it and let it be handled by the application --- src/plugins/fakevim/fakevimhandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 00f30f4e248..57f212ea7e7 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1221,6 +1221,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } else if (key == Key_Escape) { if (m_visualMode != NoVisualMode) leaveVisualMode(); + else + handled = false; } else { qDebug() << "IGNORED IN COMMAND MODE: " << key << text; if (text.isEmpty()) From 23a9971ad2aa336043ed24ab1c6996221ec6d626 Mon Sep 17 00:00:00 2001 From: Martin Aumueller Date: Wed, 28 Jan 2009 22:03:51 +0100 Subject: [PATCH 2/8] fakevim: implement paren matching w/o making FakeVimHandler depend on Qt Creator's TextEditor --- src/plugins/fakevim/fakevimhandler.cpp | 10 +++++++ src/plugins/fakevim/fakevimhandler.h | 1 + src/plugins/fakevim/fakevimplugin.cpp | 39 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 57f212ea7e7..6c179cf902b 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1846,6 +1846,16 @@ void FakeVimHandler::Private::moveToNextWord(bool simple) void FakeVimHandler::Private::moveToMatchingParanthesis() { + bool moved = false; + bool forward = false; + + emit q->moveToMatchingParenthesis(&moved, &forward, &m_tc); + + if (moved && forward) { + if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) + m_tc.movePosition(Left, KeepAnchor, 1); + } + #if 0 // FIXME: remove TextEditor dependency bool undoFakeEOL = false; diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index a083f346dd4..c308c3cb94e 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -79,6 +79,7 @@ signals: void selectionChanged(const QList &selection); void writeFileRequested(bool *handled, const QString &fileName, const QString &contents); + void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor); private: bool eventFilter(QObject *ob, QEvent *ev); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 50d45ff8769..c8b2898d88e 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -122,6 +122,7 @@ private slots: void showExtraInformation(const QString &msg); void changeSelection(const QList &selections); void writeFile(bool *handled, const QString &fileName, const QString &contents); + void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor); private: FakeVimPlugin *q; @@ -203,6 +204,8 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor) this, SLOT(writeFile(bool*,QString,QString))); connect(handler, SIGNAL(selectionChanged(QList)), this, SLOT(changeSelection(QList))); + connect(handler, SIGNAL(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)), + this, SLOT(moveToMatchingParenthesis(bool*,bool*,QTextCursor*))); handler->setupWidget(); handler->setExtraData(editor); @@ -250,6 +253,42 @@ void FakeVimPluginPrivate::writeFile(bool *handled, } } +void FakeVimPluginPrivate::moveToMatchingParenthesis(bool *moved, bool *forward, + QTextCursor *cursor) +{ + *moved = false; + + bool undoFakeEOL = false; + if (cursor->atBlockEnd() && cursor->block().length() > 1) { + cursor->movePosition(QTextCursor::Left, QTextCursor::KeepAnchor, 1); + undoFakeEOL = true; + } + TextEditor::TextBlockUserData::MatchType match + = TextEditor::TextBlockUserData::matchCursorForward(cursor); + if (match == TextEditor::TextBlockUserData::Match) { + *moved = true; + *forward = true; + } else { + if (undoFakeEOL) + cursor->movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 1); + if (match == TextEditor::TextBlockUserData::NoMatch) { + // backward matching is according to the character before the cursor + bool undoMove = false; + if (!cursor->atBlockEnd()) { + cursor->movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 1); + undoMove = true; + } + match = TextEditor::TextBlockUserData::matchCursorBackward(cursor); + if (match == TextEditor::TextBlockUserData::Match) { + *moved = true; + *forward = false; + } else if (undoMove) { + cursor->movePosition(QTextCursor::Left, QTextCursor::KeepAnchor, 1); + } + } + } +} + void FakeVimPluginPrivate::removeHandler() { if (FakeVimHandler *handler = qobject_cast(sender())) { From 06dfd937d8719bc925145a03bdf34bb35a019972 Mon Sep 17 00:00:00 2001 From: Martin Aumueller Date: Sun, 1 Feb 2009 21:35:14 +0100 Subject: [PATCH 3/8] fakevim: implement 'gg' for moving to first line --- src/plugins/fakevim/fakevimhandler.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 6c179cf902b..bdb46f0824a 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -951,7 +951,15 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, m_subsubmode = FtSubSubMode; m_subsubdata = key; } else if (key == 'g') { - m_gflag = true; + if (m_gflag) { + m_gflag = false; + m_tc.setPosition(firstPositionInLine(1), KeepAnchor); + if (m_config[ConfigStartOfLine] == ConfigOn) + moveToFirstNonBlankOnLine(); + finishMovement(); + } else { + m_gflag = true; + } } else if (key == 'G') { int n = m_mvcount.isEmpty() ? linesInDocument() : count(); m_tc.setPosition(firstPositionInLine(n), KeepAnchor); From c446f9efc652dd925bc09b3e441186a83ef2f213 Mon Sep 17 00:00:00 2001 From: Martin Aumueller Date: Sun, 1 Feb 2009 22:04:51 +0100 Subject: [PATCH 4/8] fakevim: dj/dk would not delete whole lines --- src/plugins/fakevim/fakevimhandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index bdb46f0824a..0615f7318a1 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1004,7 +1004,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveDown(count()); moveToDesiredColumn(); } else { + m_moveType = MoveLineWise; moveToStartOfLine(); + setAnchor(); moveDown(count() + 1); } finishMovement(); @@ -1029,8 +1031,10 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveUp(count()); moveToDesiredColumn(); } else { + m_moveType = MoveLineWise; moveToStartOfLine(); moveDown(); + setAnchor(); moveUp(count() + 1); } finishMovement(); From f2940adb4d5e07bcb970b1be78c619090cb1aa54 Mon Sep 17 00:00:00 2001 From: Martin Aumueller Date: Tue, 3 Feb 2009 10:39:57 +0100 Subject: [PATCH 5/8] fakevim: implement indenting a block and autoindent --- src/plugins/fakevim/fakevimhandler.cpp | 8 +++-- src/plugins/fakevim/fakevimhandler.h | 2 ++ src/plugins/fakevim/fakevimplugin.cpp | 45 ++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 0615f7318a1..7b477c48176 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -40,8 +40,6 @@ // Qt Creator. The idea is to keep this file here in a "clean" state that // allows easy reuse with any QTextEdit or QPlainTextEdit derived class. -//#include - #include #include #include @@ -1718,11 +1716,15 @@ int FakeVimHandler::Private::indentDist() const const TextEditor::TextBlockIterator end(m_tc.block().next()); return indenter.indentForBottomLine(current, begin, end, QChar(' ')); #endif - return 0; + int amount = 0; + emit q->indentRegion(&amount, m_tc.block(), m_tc.block(), QChar(' ')); + return amount; } void FakeVimHandler::Private::indentRegion(QTextBlock begin, QTextBlock end, QChar typedChar) { + int amount = 0; + emit q->indentRegion(&amount, begin, end, typedChar); #if 0 // FIXME: Make independent of TextEditor if (!m_texteditor) diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index c308c3cb94e..f5b4101996c 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -36,6 +36,7 @@ #include #include +#include QT_BEGIN_NAMESPACE class QString; @@ -80,6 +81,7 @@ signals: void writeFileRequested(bool *handled, const QString &fileName, const QString &contents); void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor); + void indentRegion(int *amount, QTextBlock begin, QTextBlock end, QChar typedChar); private: bool eventFilter(QObject *ob, QEvent *ev); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index c8b2898d88e..fe60eaa2de6 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -56,9 +56,12 @@ #include #include #include +#include #include +#include + #include #include #include @@ -123,6 +126,7 @@ private slots: void changeSelection(const QList &selections); void writeFile(bool *handled, const QString &fileName, const QString &contents); void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor); + void indentRegion(int *amount, QTextBlock begin, QTextBlock end, QChar typedChar); private: FakeVimPlugin *q; @@ -206,6 +210,8 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor) this, SLOT(changeSelection(QList))); connect(handler, SIGNAL(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)), this, SLOT(moveToMatchingParenthesis(bool*,bool*,QTextCursor*))); + connect(handler, SIGNAL(indentRegion(int*,QTextBlock,QTextBlock,QChar)), + this, SLOT(indentRegion(int*,QTextBlock,QTextBlock,QChar))); handler->setupWidget(); handler->setExtraData(editor); @@ -289,6 +295,45 @@ void FakeVimPluginPrivate::moveToMatchingParenthesis(bool *moved, bool *forward, } } +void FakeVimPluginPrivate::indentRegion(int *amount, QTextBlock begin, QTextBlock end, + QChar typedChar) +{ + FakeVimHandler *handler = qobject_cast(sender()); + if (!handler) + return; + + BaseTextEditor *bt = qobject_cast(handler->widget()); + if (!bt) + return; + + typedef SharedTools::Indenter Indenter; + Indenter &indenter = Indenter::instance(); + indenter.setIndentSize(bt->tabSettings().m_indentSize); + indenter.setTabSize(bt->tabSettings().m_tabSize); + + const QTextDocument *doc = begin.document(); + const TextEditor::TextBlockIterator docStart(doc->begin()); + QTextBlock cur = begin; + do { + if (typedChar == 0 && cur.text().simplified().isEmpty()) { + *amount = 0; + if (cur != end) { + QTextCursor cursor(cur); + while (!cursor.atBlockEnd()) + cursor.deleteChar(); + } + } else { + const TextEditor::TextBlockIterator current(cur); + const TextEditor::TextBlockIterator next(cur.next()); + *amount = indenter.indentForBottomLine(current, docStart, next, typedChar); + if (cur != end) + bt->tabSettings().indentLine(cur, *amount); + } + if (cur != end) + cur = cur.next(); + } while (cur != end); +} + void FakeVimPluginPrivate::removeHandler() { if (FakeVimHandler *handler = qobject_cast(sender())) { From 3be27a7040f1d5782fae9781c243214595ede3e4 Mon Sep 17 00:00:00 2001 From: Martin Aumueller Date: Thu, 5 Feb 2009 16:07:40 +0100 Subject: [PATCH 6/8] fakevim: 0 would go to first non-blank instead of first character of a line, implement ^ and 0 --- src/plugins/fakevim/fakevimhandler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 7b477c48176..11b4cc86cc3 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -788,11 +788,14 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, m_subsubmode = NoSubSubMode; } else if (key >= '0' && key <= '9') { if (key == '0' && m_mvcount.isEmpty()) { - moveToFirstNonBlankOnLine(); + moveToStartOfLine(); finishMovement(); } else { m_mvcount.append(QChar(key)); } + } else if (key == '^') { + moveToFirstNonBlankOnLine(); + finishMovement(); } else if (0 && key == ',') { // FIXME: fakevim uses ',' by itself, so it is incompatible m_subsubmode = FtSubSubMode; From 20939198fa9060bd1b487a2136ee030c6d7d0f68 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 11 Feb 2009 15:24:01 +0100 Subject: [PATCH 7/8] Fixes: Missing export macro. --- src/plugins/projectexplorer/cesdkhandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/cesdkhandler.h b/src/plugins/projectexplorer/cesdkhandler.h index 3fdb1382c99..db346ea926e 100644 --- a/src/plugins/projectexplorer/cesdkhandler.h +++ b/src/plugins/projectexplorer/cesdkhandler.h @@ -44,7 +44,7 @@ namespace ProjectExplorer { -class CeSdkInfo +class PROJECTEXPLORER_EXPORT CeSdkInfo { public: CeSdkInfo(); @@ -76,7 +76,7 @@ inline int CeSdkInfo::majorVersion() { return m_major; } inline int CeSdkInfo::minorVersion() { return m_minor; } inline bool CeSdkInfo::isSupported() { return m_major >= 5; } -class CeSdkHandler +class PROJECTEXPLORER_EXPORT CeSdkHandler { public: CeSdkHandler(); From b8e51e28572eb6859fb1161563a1bbce709ad113 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 11 Feb 2009 15:27:39 +0100 Subject: [PATCH 8/8] Fixes: compilation fix --- src/plugins/projectexplorer/toolchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 92760dc7cf9..96b16d59d31 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -304,7 +304,7 @@ QList WinCEToolChain::systemHeaderPaths() #ifdef QTCREATOR_WITH_MSVC_INCLUDES return env.value("INCLUDE").split(QLatin1Char(';')); #endif - return QStringList(); + return QList(); } void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env)