Commit aedeadf0 authored by hjk's avatar hjk
Browse files

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
parent e5887d9f
......@@ -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()) {
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment