From aedeadf01bc42d5fb296349f73c69f7d9cfbca9e Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 31 Mar 2009 11:44:18 +0200 Subject: [PATCH] fakevim: use :q to quit the editor, not fakevim mode. Quitting the fakevim mode is still possible using the options, or Alt-V,Alt-V, or clicking the button --- src/plugins/fakevim/fakevimhandler.cpp | 2 ++ src/plugins/fakevim/fakevimplugin.cpp | 32 +++++++++++++++++--------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 4d7927e8c6d..8e0f21e3c01 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1695,6 +1695,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0) showBlackMessage(QString()); enterCommandMode(); } else if (cmd == "q!" || cmd == "q") { // :q + showBlackMessage(QString()); quit(); } else if (reDelete.indexIn(cmd) != -1) { // :d selectRange(beginLine, endLine); @@ -1799,6 +1800,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0) enterCommandMode(); updateMiniBuffer(); } else if (reSet.indexIn(cmd) != -1) { // :set + showBlackMessage(QString()); QString arg = reSet.cap(2); SavedAction *act = theFakeVimSettings()->item(arg); if (arg.isEmpty()) { diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index b0a5539560c..9be9950e829 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -229,7 +229,7 @@ private slots: void editorAboutToClose(Core::IEditor *); void setUseFakeVim(const QVariant &value); - void quit(); + void quitFakeVim(); void triggerCompletions(); void showSettingsDialog(); @@ -237,6 +237,7 @@ 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 quitFile(); void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor); void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar); @@ -332,7 +333,7 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor) connect(handler, SIGNAL(commandBufferChanged(QString)), this, SLOT(showCommandBuffer(QString))); connect(handler, SIGNAL(quitRequested()), - this, SLOT(quit()), Qt::QueuedConnection); + this, SLOT(quitFile()), Qt::QueuedConnection); connect(handler, SIGNAL(writeFileRequested(bool*,QString,QString)), this, SLOT(writeFile(bool*,QString,QString))); connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)), @@ -346,6 +347,10 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor) handler->setCurrentFileName(editor->file()->fileName()); handler->installEventFilter(); + + // pop up the bar + if (theFakeVimSetting(ConfigUseFakeVim)->value().toBool()) + showCommandBuffer(""); } void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor) @@ -356,21 +361,20 @@ void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor) void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value) { + //qDebug() << "SET USE FAKEVIM" << value; bool on = value.toBool(); if (on) { Core::EditorManager::instance()->showEditorStatusBar( QLatin1String(Constants::MINI_BUFFER), "vi emulation mode. Type :q to leave. Use , Ctrl-R to trigger run.", - tr("Quit FakeVim"), this, SLOT(quit())); + tr("Quit FakeVim"), this, SLOT(quitFakeVim())); foreach (Core::IEditor *editor, m_editorToHandler.keys()) m_editorToHandler[editor]->setupWidget(); - //qDebug() << "SETTING" << m_editorToHandler.keys(); } else { Core::EditorManager::instance()->hideEditorStatusBar( QLatin1String(Constants::MINI_BUFFER)); foreach (Core::IEditor *editor, m_editorToHandler.keys()) m_editorToHandler[editor]->restoreWidget(); - //qDebug() << "REMOVING" << m_editorToHandler.keys(); } } @@ -385,6 +389,16 @@ void FakeVimPluginPrivate::triggerCompletions() // bt->triggerCompletions(); } +void FakeVimPluginPrivate::quitFile() +{ + FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender()); + if (!handler) + return; + QList<Core::IEditor *> editors; + editors.append(m_editorToHandler.key(handler)); + Core::EditorManager::instance()->closeEditors(editors, true); +} + void FakeVimPluginPrivate::writeFile(bool *handled, const QString &fileName, const QString &contents) { @@ -484,12 +498,8 @@ void FakeVimPluginPrivate::indentRegion(int *amount, int beginLine, int endLine, } while (cur != end); } -void FakeVimPluginPrivate::quit() +void FakeVimPluginPrivate::quitFakeVim() { - //if (FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender())) { - // handler->restoreWidget(); - // handler->deleteLater(); - //} setUseFakeVim(false); } @@ -498,7 +508,7 @@ void FakeVimPluginPrivate::showCommandBuffer(const QString &contents) //qDebug() << "SHOW COMMAND BUFFER" << contents; Core::EditorManager::instance()->showEditorStatusBar( QLatin1String(Constants::MINI_BUFFER), contents, - tr("Quit FakeVim"), this, SLOT(quit())); + tr("Quit FakeVim"), this, SLOT(quitFakeVim())); } void FakeVimPluginPrivate::showExtraInformation(const QString &text) -- GitLab