diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 729ac7cd845b96ed9c1d2f8082e30ab9e4f34d93..eec20a4a05d3bdcace5797d5982e8a5a3752135d 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -65,6 +65,7 @@ enum MakeWritableResult { }; struct EditorManagerPrivate; + namespace Internal { class OpenEditorsWindow; class EditorSplitter; @@ -224,7 +225,8 @@ private: namespace Internal { -class EditorClosingCoreListener : public ICoreListener { +class EditorClosingCoreListener : public ICoreListener +{ Q_OBJECT public: diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 602f0845b976fb17a51849262d603cf7485aa746..fa6f9ab32508631d983ec65eff7a216d7c94c5ae 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -2983,6 +2983,7 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren) nodetype = m_namespace + "QMapNode"; nodetype += data.type.mid(outertype.size()); } else { + // FIXME: doesn't work for QMultiMap nodetype = data.type + "::Node"; } //qDebug() << "OUTERTYPE: " << outertype << " NODETYPE: " << nodetype diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 20b3b082a585d6d28329cb4995638f9cc95614da..e1477c1c0abe4098f5c943afde30a4841dff4ef7 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -75,6 +75,7 @@ namespace FakeVim { namespace Constants { const char * const INSTALL_HANDLER = "FakeVim.InstallHandler"; +const char * const MINI_BUFFER = "FakeVim.MiniBuffer"; const char * const INSTALL_KEY = "Alt+V,Alt+V"; } // namespace Constants @@ -89,7 +90,7 @@ const char * const INSTALL_KEY = "Alt+V,Alt+V"; FakeVimPlugin::FakeVimPlugin() { - m_pm = 0; + m_core = 0; m_handler = 0; } @@ -109,12 +110,10 @@ bool FakeVimPlugin::initialize(const QStringList &arguments, QString *error_mess m_handler = new FakeVimHandler; - m_pm = ExtensionSystem::PluginManager::instance(); + m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + QTC_ASSERT(m_core, return false); - ICore *core = m_pm->getObject<Core::ICore>(); - QTC_ASSERT(core, return false); - - Core::ActionManagerInterface *actionManager = core->actionManager(); + Core::ActionManagerInterface *actionManager = m_core->actionManager(); QTC_ASSERT(actionManager, return false); QList<int> globalcontext; @@ -143,44 +142,32 @@ void FakeVimPlugin::extensionsInitialized() void FakeVimPlugin::installHandler() { - ICore *core = m_pm->getObject<Core::ICore>(); - if (!core || !core->editorManager()) + if (!m_core || !m_core->editorManager()) return; - Core::IEditor *editor = core->editorManager()->currentEditor(); + Core::IEditor *editor = m_core->editorManager()->currentEditor(); ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); if (!textEditor) return; - QWidget *widget = textEditor->widget(); - QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget); - if (!plainTextEdit) - return; - plainTextEdit->removeEventFilter(m_handler); - plainTextEdit->installEventFilter(m_handler); - QFont font = plainTextEdit->font(); - //font.setFamily("Monospace"); - m_savedCursorWidth = plainTextEdit->cursorWidth(); - plainTextEdit->setCursorWidth(QFontMetrics(font).width(QChar('x'))); - - //QMainWindow mw; connect(m_handler, SIGNAL(commandBufferChanged(QString)), this, SLOT(showCommandBuffer(QString))); connect(m_handler, SIGNAL(quitRequested(QWidget *)), this, SLOT(removeHandler(QWidget *))); + + m_handler->addWidget(textEditor->widget()); } void FakeVimPlugin::removeHandler(QWidget *widget) { - widget->removeEventFilter(m_handler); - QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget); - if (!plainTextEdit) - return; - plainTextEdit->setCursorWidth(m_savedCursorWidth); + m_handler->removeWidget(widget); + Core::EditorManager::instance() + ->hideEditorInfoBar(QLatin1String(Constants::MINI_BUFFER)); } void FakeVimPlugin::showCommandBuffer(const QString &contents) { - //qDebug() << "CMD: " << contents; + Core::EditorManager::instance() + ->showEditorInfoBar(QLatin1String(Constants::MINI_BUFFER), contents); } diff --git a/src/plugins/fakevim/fakevimplugin.h b/src/plugins/fakevim/fakevimplugin.h index 6561e871b00dadf8a0da678ad6ab0717007123d9..9025affcec33c6a36a7f8a54c8f44e9002a89d59 100644 --- a/src/plugins/fakevim/fakevimplugin.h +++ b/src/plugins/fakevim/fakevimplugin.h @@ -44,8 +44,21 @@ class QCursor; class QAbstractItemView; QT_END_NAMESPACE -namespace Core { class IEditor; } -namespace TextEditor { class ITextEditor; } + +namespace Core { + +class ICore; +class IEditor; + +} // namespace Core + + +namespace TextEditor { + +class ITextEditor; + +} // namespace TextEditor + namespace FakeVim { namespace Internal { @@ -72,9 +85,8 @@ private slots: private: FakeVimHandler *m_handler; - ExtensionSystem::PluginManager *m_pm; QAction *m_installHandlerAction; - int m_savedCursorWidth; + Core::ICore *m_core; }; } // namespace Internal diff --git a/src/plugins/fakevim/handler.cpp b/src/plugins/fakevim/handler.cpp index 0427a4ee0228a2804f496d0ad7f8b7adcfe96ab8..34ac5777661f0eb483a85d63f33b871bbfcdb904 100644 --- a/src/plugins/fakevim/handler.cpp +++ b/src/plugins/fakevim/handler.cpp @@ -152,10 +152,7 @@ private: void handleRegisterMode(int key, const QString &text); void handleMiniBufferModes(int key, const QString &text); void finishMovement(const QString &text = QString()); - void updateMiniBuffer(); - void updateSelection(); void search(const QString &needle, bool forward); - void showMessage(const QString &msg); int mvCount() const { return m_mvcount.isEmpty() ? 1 : m_mvcount.toInt(); } int opCount() const { return m_opcount.isEmpty() ? 1 : m_opcount.toInt(); } @@ -186,9 +183,12 @@ private: int readLineCode(QString &cmd); QTextCursor selectRange(int beginLine, int endLine); - void enterInsertMode(); public: + void enterInsertMode(); void enterCommandMode(); + void showMessage(const QString &msg); + void updateMiniBuffer(); + void updateSelection(); public: QTextEdit *m_textedit; @@ -816,7 +816,6 @@ void FakeVimHandler::Private::handleMiniBufferModes(int key, const QString &text m_commandHistory.append(m_commandBuffer); handleExCommand(m_commandBuffer); } - enterCommandMode(); } else if (key == Key_Return && isSearchMode()) { if (!m_commandBuffer.isEmpty()) { m_searchHistory.takeLast(); @@ -941,7 +940,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0) endLine = line; } - //qDebug() << "RANGE: " << beginLine << endLine << cmd << cmd0; + qDebug() << "RANGE: " << beginLine << endLine << cmd << cmd0; static QRegExp reWrite("^w!?( (.*))?$"); static QRegExp reDelete("^d( (.*))?$"); @@ -950,8 +949,9 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0) m_tc.setPosition(positionForLine(beginLine)); showMessage(QString()); } else if (cmd == "q!" || cmd == "q") { // :q - q->quitRequested(editor()); showMessage(QString()); + EDITOR(setOverwriteMode(false)); + q->quitRequested(editor()); } else if (reDelete.indexIn(cmd) != -1) { // :d if (beginLine == -1) beginLine = cursorLineInDocument(); @@ -1369,11 +1369,14 @@ void FakeVimHandler::addWidget(QWidget *widget) //ed->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x'))); ed->setLineWrapMode(QPlainTextEdit::NoWrap); } + d->showMessage("vi emulation mode. Hit <Shift+Esc>:q<Return> to quit"); + d->updateMiniBuffer(); } void FakeVimHandler::removeWidget(QWidget *widget) { - d->enterCommandMode(); + d->showMessage(QString()); + d->updateMiniBuffer(); widget->removeEventFilter(this); }