diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 00f30f4e248d82db20c9fc26b2eb89d8c2dd4678..11b4cc86cc3d35c51e9cb5447b8e6ead91af081b 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 <indenter.h> - #include <QtCore/QDebug> #include <QtCore/QFile> #include <QtCore/QObject> @@ -790,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; @@ -951,7 +952,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); @@ -996,7 +1005,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveDown(count()); moveToDesiredColumn(); } else { + m_moveType = MoveLineWise; moveToStartOfLine(); + setAnchor(); moveDown(count() + 1); } finishMovement(); @@ -1021,8 +1032,10 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, moveUp(count()); moveToDesiredColumn(); } else { + m_moveType = MoveLineWise; moveToStartOfLine(); moveDown(); + setAnchor(); moveUp(count() + 1); } finishMovement(); @@ -1221,6 +1234,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()) @@ -1704,11 +1719,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) @@ -1844,6 +1863,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 a083f346dd4d25ddd629c5c26b01b7aeab8287fe..f5b4101996cbb01efbb73612b84ea44c4a24d883 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -36,6 +36,7 @@ #include <QtCore/QObject> #include <QtGui/QTextEdit> +#include <QtGui/QTextBlock> QT_BEGIN_NAMESPACE class QString; @@ -79,6 +80,8 @@ signals: void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection); 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 50d45ff8769f1731c67317ca938dca7be727a9fd..fe60eaa2de6d2d5361ffe441eed3c02bc2ddd387 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -56,9 +56,12 @@ #include <texteditor/interactionsettings.h> #include <texteditor/tabsettings.h> #include <texteditor/texteditorsettings.h> +#include <texteditor/textblockiterator.h> #include <utils/qtcassert.h> +#include <indenter.h> + #include <QtCore/QDebug> #include <QtCore/QtPlugin> #include <QtCore/QObject> @@ -122,6 +125,8 @@ private slots: void showExtraInformation(const QString &msg); void changeSelection(const QList<QTextEdit::ExtraSelection> &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; @@ -203,6 +208,10 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor) this, SLOT(writeFile(bool*,QString,QString))); connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)), this, SLOT(changeSelection(QList<QTextEdit::ExtraSelection>))); + 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); @@ -250,6 +259,81 @@ 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::indentRegion(int *amount, QTextBlock begin, QTextBlock end, + QChar typedChar) +{ + FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender()); + if (!handler) + return; + + BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget()); + if (!bt) + return; + + typedef SharedTools::Indenter<TextEditor::TextBlockIterator> 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<FakeVimHandler *>(sender())) { diff --git a/src/plugins/projectexplorer/cesdkhandler.h b/src/plugins/projectexplorer/cesdkhandler.h index 3fdb1382c99146d0e0439a7bc6127ad188a16372..db346ea926e3ff7ff7218f38b258302d6f74c19b 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(); diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 92760dc7cf9d40b841c274a10862a1a103802c7b..96b16d59d31731bd465ef1f93aac14c9c6c72d16 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -304,7 +304,7 @@ QList<HeaderPath> WinCEToolChain::systemHeaderPaths() #ifdef QTCREATOR_WITH_MSVC_INCLUDES return env.value("INCLUDE").split(QLatin1Char(';')); #endif - return QStringList(); + return QList<HeaderPath>(); } void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env)