forked from qt-creator/qt-creator
FakeVim: Merge Plugin and PluginPrivate classes
There were different from the PluginPrivate-created-in-initialize pattern anyway. Change-Id: I690c9c0511203f3c4d6ec9eeca85c0a277330e2f Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -96,7 +96,7 @@ const char SETTINGS_ID[] = "A.FakeVim.General";
|
||||
const char SETTINGS_EX_CMDS_ID[] = "B.FakeVim.ExCommands";
|
||||
const char SETTINGS_USER_CMDS_ID[] = "C.FakeVim.UserCommands";
|
||||
|
||||
static class FakeVimPluginPrivate *dd = nullptr;
|
||||
static class FakeVimPlugin *dd = nullptr;
|
||||
|
||||
class MiniBuffer : public QStackedWidget
|
||||
{
|
||||
@@ -213,8 +213,6 @@ private:
|
||||
|
||||
class RelativeNumbersColumn : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RelativeNumbersColumn(TextEditorWidget *baseTextEditor)
|
||||
: QWidget(baseTextEditor)
|
||||
@@ -332,28 +330,37 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FakeVimOptionPage
|
||||
// FakeVimPlugin
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
using ExCommandMap = QMap<QString, QRegularExpression>;
|
||||
using UserCommandMap = QMap<int, QString>;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FakeVimPluginPrivate
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FakeVimPluginPrivate : public QObject
|
||||
class FakeVimPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "FakeVim.json")
|
||||
|
||||
public:
|
||||
FakeVimPluginPrivate();
|
||||
FakeVimPlugin();
|
||||
|
||||
void initialize();
|
||||
~FakeVimPlugin() final { dd = nullptr; }
|
||||
|
||||
void initialize() final;
|
||||
|
||||
void extensionsInitialized() final
|
||||
{
|
||||
m_miniBuffer = new MiniBuffer;
|
||||
StatusBarManager::addStatusBarWidget(m_miniBuffer, StatusBarManager::LastLeftAligned);
|
||||
}
|
||||
|
||||
ExtensionSystem::IPlugin::ShutdownFlag aboutToShutdown() final
|
||||
{
|
||||
StatusBarManager::destroyStatusBarWidget(m_miniBuffer);
|
||||
m_miniBuffer = nullptr;
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
void editorOpened(Core::IEditor *);
|
||||
void editorAboutToClose(Core::IEditor *);
|
||||
@@ -964,7 +971,6 @@ IAssistProcessor *FakeVimCompletionAssistProvider::createProcessor(const AssistI
|
||||
return new FakeVimCompletionAssistProcessor(this);
|
||||
}
|
||||
|
||||
|
||||
// FakeVimUserCommandsModel
|
||||
|
||||
QVariant FakeVimUserCommandsModel::data(const QModelIndex &index, int role) const
|
||||
@@ -993,8 +999,55 @@ bool FakeVimUserCommandsModel::setData(const QModelIndex &index,
|
||||
return true;
|
||||
}
|
||||
|
||||
FakeVimPluginPrivate::FakeVimPluginPrivate()
|
||||
static void setupTest(QString *title, FakeVimHandler **handler, QWidget **edit)
|
||||
{
|
||||
*title = QString::fromLatin1("test.cpp");
|
||||
IEditor *iedit = EditorManager::openEditorWithContents(Id(), title);
|
||||
EditorManager::activateEditor(iedit);
|
||||
*edit = iedit->widget();
|
||||
*handler = dd->m_editorToHandler.value(iedit, {}).handler;
|
||||
(*handler)->setupWidget();
|
||||
(*handler)->handleCommand("set startofline");
|
||||
|
||||
// *handler = 0;
|
||||
// m_statusMessage.clear();
|
||||
// m_statusData.clear();
|
||||
// m_infoMessage.clear();
|
||||
// if (m_textedit) {
|
||||
// m_textedit->setPlainText(lines);
|
||||
// QTextCursor tc = m_textedit->textCursor();
|
||||
// tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||
// m_textedit->setTextCursor(tc);
|
||||
// m_textedit->setPlainText(lines);
|
||||
// *handler = new FakeVimHandler(m_textedit);
|
||||
// } else {
|
||||
// m_plaintextedit->setPlainText(lines);
|
||||
// QTextCursor tc = m_plaintextedit->textCursor();
|
||||
// tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||
// m_plaintextedit->setTextCursor(tc);
|
||||
// m_plaintextedit->setPlainText(lines);
|
||||
// *handler = new FakeVimHandler(m_plaintextedit);
|
||||
// }
|
||||
|
||||
// connect(*handler, &FakeVimHandler::commandBufferChanged,
|
||||
// this, &FakeVimPlugin::changeStatusMessage);
|
||||
// connect(*handler, &FakeVimHandler::extraInformationChanged,
|
||||
// this, &FakeVimPlugin::changeExtraInformation);
|
||||
// connect(*handler, &FakeVimHandler::statusDataChanged,
|
||||
// this, &FakeVimPlugin::changeStatusData);
|
||||
|
||||
// QCOMPARE(EDITOR(toPlainText()), lines);
|
||||
(*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z");
|
||||
}
|
||||
|
||||
QObject *createFakeVimTester( void (*setupTest)(QString *, FakeVimHandler **, QWidget **) ); // in fakevim_test.cpp
|
||||
|
||||
FakeVimPlugin::FakeVimPlugin()
|
||||
{
|
||||
dd = this;
|
||||
|
||||
addTestCreator([] { return createFakeVimTester(&setupTest); });
|
||||
|
||||
m_defaultExCommandMap[CppEditor::Constants::SWITCH_HEADER_SOURCE] =
|
||||
QRegularExpression("^A$");
|
||||
m_defaultExCommandMap["Coreplugin.OutputPane.previtem"] =
|
||||
@@ -1014,7 +1067,7 @@ FakeVimPluginPrivate::FakeVimPluginPrivate()
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::initialize()
|
||||
void FakeVimPlugin::initialize()
|
||||
{
|
||||
/*
|
||||
// Set completion settings and keep them up to date.
|
||||
@@ -1053,44 +1106,44 @@ void FakeVimPluginPrivate::initialize()
|
||||
connect(ICore::instance(), &ICore::coreAboutToClose, this, [] {
|
||||
// Don't attach to editors anymore.
|
||||
disconnect(EditorManager::instance(), &EditorManager::editorOpened,
|
||||
dd, &FakeVimPluginPrivate::editorOpened);
|
||||
dd, &FakeVimPlugin::editorOpened);
|
||||
});
|
||||
|
||||
// EditorManager
|
||||
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
|
||||
this, &FakeVimPluginPrivate::editorAboutToClose);
|
||||
this, &FakeVimPlugin::editorAboutToClose);
|
||||
connect(EditorManager::instance(), &EditorManager::editorOpened,
|
||||
this, &FakeVimPluginPrivate::editorOpened);
|
||||
this, &FakeVimPlugin::editorOpened);
|
||||
connect(EditorManager::instance(), &EditorManager::currentEditorAboutToChange,
|
||||
this, &FakeVimPluginPrivate::currentEditorAboutToChange);
|
||||
this, &FakeVimPlugin::currentEditorAboutToChange);
|
||||
|
||||
connect(DocumentManager::instance(), &DocumentManager::allDocumentsRenamed,
|
||||
this, &FakeVimPluginPrivate::allDocumentsRenamed);
|
||||
this, &FakeVimPlugin::allDocumentsRenamed);
|
||||
connect(DocumentManager::instance(), &DocumentManager::documentRenamed,
|
||||
this, &FakeVimPluginPrivate::documentRenamed);
|
||||
this, &FakeVimPlugin::documentRenamed);
|
||||
|
||||
FakeVimSettings &s = settings();
|
||||
connect(&s.useFakeVim, &FvBoolAspect::changed,
|
||||
this, [this, &s] { setUseFakeVim(s.useFakeVim()); });
|
||||
connect(&s.readVimRc, &FvBaseAspect::changed,
|
||||
this, &FakeVimPluginPrivate::maybeReadVimRc);
|
||||
this, &FakeVimPlugin::maybeReadVimRc);
|
||||
connect(&s.vimRcPath, &FvBaseAspect::changed,
|
||||
this, &FakeVimPluginPrivate::maybeReadVimRc);
|
||||
this, &FakeVimPlugin::maybeReadVimRc);
|
||||
connect(&s.relativeNumber, &FvBoolAspect::changed,
|
||||
this, [this, &s] { setShowRelativeLineNumbers(s.relativeNumber()); });
|
||||
connect(&s.blinkingCursor, &FvBoolAspect::changed,
|
||||
this, [this, &s] { setCursorBlinking(s.blinkingCursor()); });
|
||||
|
||||
// Delayed operations.
|
||||
connect(this, &FakeVimPluginPrivate::delayedQuitRequested,
|
||||
this, &FakeVimPluginPrivate::handleDelayedQuit, Qt::QueuedConnection);
|
||||
connect(this, &FakeVimPluginPrivate::delayedQuitAllRequested,
|
||||
this, &FakeVimPluginPrivate::handleDelayedQuitAll, Qt::QueuedConnection);
|
||||
connect(this, &FakeVimPlugin::delayedQuitRequested,
|
||||
this, &FakeVimPlugin::handleDelayedQuit, Qt::QueuedConnection);
|
||||
connect(this, &FakeVimPlugin::delayedQuitAllRequested,
|
||||
this, &FakeVimPlugin::handleDelayedQuitAll, Qt::QueuedConnection);
|
||||
|
||||
setCursorBlinking(s.blinkingCursor());
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::userActionTriggered(int key)
|
||||
void FakeVimPlugin::userActionTriggered(int key)
|
||||
{
|
||||
IEditor *editor = EditorManager::currentEditor();
|
||||
FakeVimHandler *handler = m_editorToHandler[editor].handler;
|
||||
@@ -1108,7 +1161,7 @@ void FakeVimPluginPrivate::userActionTriggered(int key)
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::updateAllHightLights()
|
||||
void FakeVimPlugin::updateAllHightLights()
|
||||
{
|
||||
const QList<IEditor *> editors = EditorManager::visibleEditors();
|
||||
for (IEditor *editor : editors) {
|
||||
@@ -1118,7 +1171,7 @@ void FakeVimPluginPrivate::updateAllHightLights()
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor)
|
||||
void FakeVimPlugin::createRelativeNumberWidget(IEditor *editor)
|
||||
{
|
||||
if (auto textEditor = TextEditorWidget::fromEditor(editor)) {
|
||||
auto relativeNumbers = new RelativeNumbersColumn(textEditor);
|
||||
@@ -1130,7 +1183,7 @@ void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor)
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::readSettings()
|
||||
void FakeVimPlugin::readSettings()
|
||||
{
|
||||
QtcSettings *settings = ICore::settings();
|
||||
|
||||
@@ -1157,7 +1210,7 @@ void FakeVimPluginPrivate::readSettings()
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::maybeReadVimRc()
|
||||
void FakeVimPlugin::maybeReadVimRc()
|
||||
{
|
||||
//qDebug() << theFakeVimSetting(ConfigReadVimRc)
|
||||
// << theFakeVimSetting(ConfigReadVimRc)->value();
|
||||
@@ -1186,7 +1239,7 @@ static void triggerAction(Id id)
|
||||
action->trigger();
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::setActionChecked(Id id, bool check)
|
||||
void FakeVimPlugin::setActionChecked(Id id, bool check)
|
||||
{
|
||||
Command *cmd = ActionManager::command(id);
|
||||
QTC_ASSERT(cmd, return);
|
||||
@@ -1237,7 +1290,7 @@ static int moveDownWeight(const QRect &cursor, const QRect &other)
|
||||
return w;
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::moveSomewhere(FakeVimHandler *handler, DistFunction f, int count)
|
||||
void FakeVimPlugin::moveSomewhere(FakeVimHandler *handler, DistFunction f, int count)
|
||||
{
|
||||
QTC_ASSERT(handler, return);
|
||||
QWidget *w = handler->widget();
|
||||
@@ -1281,7 +1334,7 @@ void FakeVimPluginPrivate::moveSomewhere(FakeVimHandler *handler, DistFunction f
|
||||
EditorManager::activateEditor(bestEditor);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::keepOnlyWindow()
|
||||
void FakeVimPlugin::keepOnlyWindow()
|
||||
{
|
||||
IEditor *currentEditor = EditorManager::currentEditor();
|
||||
QList<IEditor *> editors = EditorManager::visibleEditors();
|
||||
@@ -1293,7 +1346,7 @@ void FakeVimPluginPrivate::keepOnlyWindow()
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::fold(FakeVimHandler *handler, int depth, bool fold)
|
||||
void FakeVimPlugin::fold(FakeVimHandler *handler, int depth, bool fold)
|
||||
{
|
||||
QTC_ASSERT(handler, return);
|
||||
QTextDocument *doc = handler->textCursor().document();
|
||||
@@ -1368,7 +1421,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
||||
void FakeVimPlugin::editorOpened(IEditor *editor)
|
||||
{
|
||||
if (!editor)
|
||||
return;
|
||||
@@ -1741,31 +1794,31 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::editorAboutToClose(IEditor *editor)
|
||||
void FakeVimPlugin::editorAboutToClose(IEditor *editor)
|
||||
{
|
||||
//qDebug() << "CLOSING: " << editor << editor->widget();
|
||||
m_editorToHandler.remove(editor);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::currentEditorAboutToChange(IEditor *editor)
|
||||
void FakeVimPlugin::currentEditorAboutToChange(IEditor *editor)
|
||||
{
|
||||
if (FakeVimHandler *handler = m_editorToHandler.value(editor, {}).handler)
|
||||
handler->enterCommandMode();
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::allDocumentsRenamed(const FilePath &oldPath, const FilePath &newPath)
|
||||
void FakeVimPlugin::allDocumentsRenamed(const FilePath &oldPath, const FilePath &newPath)
|
||||
{
|
||||
renameFileNameInEditors(oldPath, newPath);
|
||||
FakeVimHandler::updateGlobalMarksFilenames(oldPath.toString(), newPath.toString());
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::documentRenamed(
|
||||
void FakeVimPlugin::documentRenamed(
|
||||
IDocument *, const FilePath &oldPath, const FilePath &newPath)
|
||||
{
|
||||
renameFileNameInEditors(oldPath, newPath);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::renameFileNameInEditors(const FilePath &oldPath, const FilePath &newPath)
|
||||
void FakeVimPlugin::renameFileNameInEditors(const FilePath &oldPath, const FilePath &newPath)
|
||||
{
|
||||
for (const HandlerAndData &handlerAndData : m_editorToHandler) {
|
||||
if (handlerAndData.handler->currentFileName() == oldPath.toString())
|
||||
@@ -1773,7 +1826,7 @@ void FakeVimPluginPrivate::renameFileNameInEditors(const FilePath &oldPath, cons
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::setUseFakeVim(bool on)
|
||||
void FakeVimPlugin::setUseFakeVim(bool on)
|
||||
{
|
||||
//qDebug() << "SET USE FAKEVIM" << on;
|
||||
Find::setUseFakeVim(on);
|
||||
@@ -1782,7 +1835,7 @@ void FakeVimPluginPrivate::setUseFakeVim(bool on)
|
||||
setCursorBlinking(settings().blinkingCursor());
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
||||
void FakeVimPlugin::setUseFakeVimInternal(bool on)
|
||||
{
|
||||
if (on) {
|
||||
//ICore *core = ICore::instance();
|
||||
@@ -1805,7 +1858,7 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::setShowRelativeLineNumbers(bool on)
|
||||
void FakeVimPlugin::setShowRelativeLineNumbers(bool on)
|
||||
{
|
||||
if (on && settings().useFakeVim()) {
|
||||
for (auto it = m_editorToHandler.constBegin(); it != m_editorToHandler.constEnd(); ++it)
|
||||
@@ -1813,7 +1866,7 @@ void FakeVimPluginPrivate::setShowRelativeLineNumbers(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::setCursorBlinking(bool on)
|
||||
void FakeVimPlugin::setCursorBlinking(bool on)
|
||||
{
|
||||
if (m_savedCursorFlashTime == 0)
|
||||
m_savedCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime();
|
||||
@@ -1822,7 +1875,7 @@ void FakeVimPluginPrivate::setCursorBlinking(bool on)
|
||||
QGuiApplication::styleHints()->setCursorFlashTime(blink ? m_savedCursorFlashTime : 0);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handled, const ExCommand &cmd)
|
||||
void FakeVimPlugin::handleExCommand(FakeVimHandler *handler, bool *handled, const ExCommand &cmd)
|
||||
{
|
||||
QTC_ASSERT(handler, return);
|
||||
using namespace Core;
|
||||
@@ -1944,7 +1997,7 @@ void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handle
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::handleDelayedQuit(bool forced, IEditor *editor)
|
||||
void FakeVimPlugin::handleDelayedQuit(bool forced, IEditor *editor)
|
||||
{
|
||||
// This tries to simulate vim behaviour. But the models of vim and
|
||||
// Qt Creator core do not match well...
|
||||
@@ -1954,23 +2007,23 @@ void FakeVimPluginPrivate::handleDelayedQuit(bool forced, IEditor *editor)
|
||||
EditorManager::closeEditors({editor}, !forced);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::handleDelayedQuitAll(bool forced)
|
||||
void FakeVimPlugin::handleDelayedQuitAll(bool forced)
|
||||
{
|
||||
triggerAction(Core::Constants::REMOVE_ALL_SPLITS);
|
||||
EditorManager::closeAllEditors(!forced);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::quitFakeVim()
|
||||
void FakeVimPlugin::quitFakeVim()
|
||||
{
|
||||
settings().useFakeVim.setValue(false);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::resetCommandBuffer()
|
||||
void FakeVimPlugin::resetCommandBuffer()
|
||||
{
|
||||
showCommandBuffer(nullptr, QString(), -1, -1, 0);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::showCommandBuffer(FakeVimHandler *handler, const QString &contents, int cursorPos, int anchorPos,
|
||||
void FakeVimPlugin::showCommandBuffer(FakeVimHandler *handler, const QString &contents, int cursorPos, int anchorPos,
|
||||
int messageLevel)
|
||||
{
|
||||
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
||||
@@ -1978,7 +2031,7 @@ void FakeVimPluginPrivate::showCommandBuffer(FakeVimHandler *handler, const QStr
|
||||
m_miniBuffer->setContents(contents, cursorPos, anchorPos, messageLevel, handler);
|
||||
}
|
||||
|
||||
int FakeVimPluginPrivate::currentFile() const
|
||||
int FakeVimPlugin::currentFile() const
|
||||
{
|
||||
IEditor *editor = EditorManager::currentEditor();
|
||||
if (editor) {
|
||||
@@ -1989,7 +2042,7 @@ int FakeVimPluginPrivate::currentFile() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::switchToFile(int n)
|
||||
void FakeVimPlugin::switchToFile(int n)
|
||||
{
|
||||
int size = DocumentModel::entryCount();
|
||||
QTC_ASSERT(size, return);
|
||||
@@ -1999,92 +2052,6 @@ void FakeVimPluginPrivate::switchToFile(int n)
|
||||
EditorManager::activateEditorForEntry(DocumentModel::entries().at(n));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FakeVimPlugin
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void setupTest(QString *title, FakeVimHandler **handler, QWidget **edit)
|
||||
{
|
||||
*title = QString::fromLatin1("test.cpp");
|
||||
IEditor *iedit = EditorManager::openEditorWithContents(Id(), title);
|
||||
EditorManager::activateEditor(iedit);
|
||||
*edit = iedit->widget();
|
||||
*handler = dd->m_editorToHandler.value(iedit, {}).handler;
|
||||
(*handler)->setupWidget();
|
||||
(*handler)->handleCommand("set startofline");
|
||||
|
||||
// *handler = 0;
|
||||
// m_statusMessage.clear();
|
||||
// m_statusData.clear();
|
||||
// m_infoMessage.clear();
|
||||
// if (m_textedit) {
|
||||
// m_textedit->setPlainText(lines);
|
||||
// QTextCursor tc = m_textedit->textCursor();
|
||||
// tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||
// m_textedit->setTextCursor(tc);
|
||||
// m_textedit->setPlainText(lines);
|
||||
// *handler = new FakeVimHandler(m_textedit);
|
||||
// } else {
|
||||
// m_plaintextedit->setPlainText(lines);
|
||||
// QTextCursor tc = m_plaintextedit->textCursor();
|
||||
// tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||
// m_plaintextedit->setTextCursor(tc);
|
||||
// m_plaintextedit->setPlainText(lines);
|
||||
// *handler = new FakeVimHandler(m_plaintextedit);
|
||||
// }
|
||||
|
||||
// connect(*handler, &FakeVimHandler::commandBufferChanged,
|
||||
// this, &FakeVimPlugin::changeStatusMessage);
|
||||
// connect(*handler, &FakeVimHandler::extraInformationChanged,
|
||||
// this, &FakeVimPlugin::changeExtraInformation);
|
||||
// connect(*handler, &FakeVimHandler::statusDataChanged,
|
||||
// this, &FakeVimPlugin::changeStatusData);
|
||||
|
||||
// QCOMPARE(EDITOR(toPlainText()), lines);
|
||||
(*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z");
|
||||
}
|
||||
|
||||
QObject *createFakeVimTester( void (*setupTest)(QString *, FakeVimHandler **, QWidget **) ); // in fakevim_test.cpp
|
||||
|
||||
class FakeVimPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "FakeVim.json")
|
||||
|
||||
public:
|
||||
FakeVimPlugin()
|
||||
{
|
||||
addTestCreator([] { return createFakeVimTester(&setupTest); });
|
||||
dd = new FakeVimPluginPrivate;
|
||||
}
|
||||
~FakeVimPlugin() override
|
||||
{
|
||||
delete dd;
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
ExtensionSystem::IPlugin::ShutdownFlag aboutToShutdown()
|
||||
{
|
||||
StatusBarManager::destroyStatusBarWidget(dd->m_miniBuffer);
|
||||
dd->m_miniBuffer = nullptr;
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
void initialize() override
|
||||
{
|
||||
dd->initialize();
|
||||
}
|
||||
|
||||
void extensionsInitialized() override
|
||||
{
|
||||
dd->m_miniBuffer = new MiniBuffer;
|
||||
StatusBarManager::addStatusBarWidget(dd->m_miniBuffer, StatusBarManager::LastLeftAligned);
|
||||
}
|
||||
};
|
||||
|
||||
} // FakeVim::Internal
|
||||
|
||||
#include "fakevimplugin.moc"
|
||||
|
||||
Reference in New Issue
Block a user