forked from qt-creator/qt-creator
FakeVim: Reorganize internal class dependencies
Initially, this was just meant to remove the nowadays unneeded object pool registrations, but some of the internal encapsalization is not much more than line noise. So do what most other plugins do: Keep a global pointer to most of the 'singleton' data, instead of passing around one value that will never be different. Change-Id: I24bf02d1ffa53c8f0d4890db3579a434b1233d42 Reviewed-by: Lukas Holecek <hluk@email.cz> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -110,6 +110,8 @@ const char SETTINGS_ID[] = "A.FakeVim.General";
|
|||||||
const char SETTINGS_EX_CMDS_ID[] = "B.FakeVim.ExCommands";
|
const char SETTINGS_EX_CMDS_ID[] = "B.FakeVim.ExCommands";
|
||||||
const char SETTINGS_USER_CMDS_ID[] = "C.FakeVim.UserCommands";
|
const char SETTINGS_USER_CMDS_ID[] = "C.FakeVim.UserCommands";
|
||||||
|
|
||||||
|
static class FakeVimPluginPrivate *dd = nullptr;
|
||||||
|
|
||||||
class MiniBuffer : public QStackedWidget
|
class MiniBuffer : public QStackedWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -181,11 +183,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_eventFilter != eventFilter) {
|
if (m_eventFilter != eventFilter) {
|
||||||
if (m_eventFilter != 0) {
|
if (m_eventFilter != nullptr) {
|
||||||
m_edit->removeEventFilter(m_eventFilter);
|
m_edit->removeEventFilter(m_eventFilter);
|
||||||
disconnect(this, &MiniBuffer::edited, 0, 0);
|
disconnect(this, &MiniBuffer::edited, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
if (eventFilter != 0) {
|
if (eventFilter != nullptr) {
|
||||||
m_edit->installEventFilter(eventFilter);
|
m_edit->installEventFilter(eventFilter);
|
||||||
connect(this, &MiniBuffer::edited,
|
connect(this, &MiniBuffer::edited,
|
||||||
eventFilter, &FakeVimHandler::miniBufferTextEdited);
|
eventFilter, &FakeVimHandler::miniBufferTextEdited);
|
||||||
@@ -353,8 +355,6 @@ typedef QMap<int, QString> UserCommandMap;
|
|||||||
|
|
||||||
class FakeVimOptionPage : public IOptionsPage
|
class FakeVimOptionPage : public IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimOptionPage()
|
FakeVimOptionPage()
|
||||||
{
|
{
|
||||||
@@ -393,60 +393,36 @@ QWidget *FakeVimOptionPage::widget()
|
|||||||
m_ui.pathChooserVimRcPath->lineEdit()->setPlaceholderText(Tr::tr("Default: %1").arg(vimrcDefault));
|
m_ui.pathChooserVimRcPath->lineEdit()->setPlaceholderText(Tr::tr("Default: %1").arg(vimrcDefault));
|
||||||
|
|
||||||
m_group.clear();
|
m_group.clear();
|
||||||
m_group.insert(theFakeVimSetting(ConfigUseFakeVim),
|
m_group.insert(theFakeVimSetting(ConfigUseFakeVim), m_ui.checkBoxUseFakeVim);
|
||||||
m_ui.checkBoxUseFakeVim);
|
m_group.insert(theFakeVimSetting(ConfigReadVimRc), m_ui.checkBoxReadVimRc);
|
||||||
m_group.insert(theFakeVimSetting(ConfigReadVimRc),
|
m_group.insert(theFakeVimSetting(ConfigVimRcPath), m_ui.pathChooserVimRcPath);
|
||||||
m_ui.checkBoxReadVimRc);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigVimRcPath),
|
|
||||||
m_ui.pathChooserVimRcPath);
|
|
||||||
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigExpandTab),
|
m_group.insert(theFakeVimSetting(ConfigExpandTab), m_ui.checkBoxExpandTab);
|
||||||
m_ui.checkBoxExpandTab);
|
m_group.insert(theFakeVimSetting(ConfigHlSearch), m_ui.checkBoxHlSearch);
|
||||||
m_group.insert(theFakeVimSetting(ConfigHlSearch),
|
m_group.insert(theFakeVimSetting(ConfigShiftWidth), m_ui.spinBoxShiftWidth);
|
||||||
m_ui.checkBoxHlSearch);
|
m_group.insert(theFakeVimSetting(ConfigShowMarks), m_ui.checkBoxShowMarks);
|
||||||
m_group.insert(theFakeVimSetting(ConfigShiftWidth),
|
|
||||||
m_ui.spinBoxShiftWidth);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigShowMarks),
|
|
||||||
m_ui.checkBoxShowMarks);
|
|
||||||
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigSmartTab),
|
m_group.insert(theFakeVimSetting(ConfigSmartTab), m_ui.checkBoxSmartTab);
|
||||||
m_ui.checkBoxSmartTab);
|
m_group.insert(theFakeVimSetting(ConfigStartOfLine), m_ui.checkBoxStartOfLine);
|
||||||
m_group.insert(theFakeVimSetting(ConfigStartOfLine),
|
m_group.insert(theFakeVimSetting(ConfigPassKeys), m_ui.checkBoxPassKeys);
|
||||||
m_ui.checkBoxStartOfLine);
|
m_group.insert(theFakeVimSetting(ConfigTabStop), m_ui.spinBoxTabStop);
|
||||||
m_group.insert(theFakeVimSetting(ConfigPassKeys),
|
m_group.insert(theFakeVimSetting(ConfigScrollOff), m_ui.spinBoxScrollOff);
|
||||||
m_ui.checkBoxPassKeys);
|
m_group.insert(theFakeVimSetting(ConfigBackspace), m_ui.lineEditBackspace);
|
||||||
m_group.insert(theFakeVimSetting(ConfigTabStop),
|
m_group.insert(theFakeVimSetting(ConfigIsKeyword), m_ui.lineEditIsKeyword);
|
||||||
m_ui.spinBoxTabStop);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigScrollOff),
|
|
||||||
m_ui.spinBoxScrollOff);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigBackspace),
|
|
||||||
m_ui.lineEditBackspace);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigIsKeyword),
|
|
||||||
m_ui.lineEditIsKeyword);
|
|
||||||
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigPassControlKey),
|
m_group.insert(theFakeVimSetting(ConfigPassControlKey), m_ui.checkBoxPassControlKey);
|
||||||
m_ui.checkBoxPassControlKey);
|
m_group.insert(theFakeVimSetting(ConfigAutoIndent), m_ui.checkBoxAutoIndent);
|
||||||
m_group.insert(theFakeVimSetting(ConfigAutoIndent),
|
m_group.insert(theFakeVimSetting(ConfigSmartIndent), m_ui.checkBoxSmartIndent);
|
||||||
m_ui.checkBoxAutoIndent);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigSmartIndent),
|
|
||||||
m_ui.checkBoxSmartIndent);
|
|
||||||
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigIncSearch),
|
m_group.insert(theFakeVimSetting(ConfigIncSearch), m_ui.checkBoxIncSearch);
|
||||||
m_ui.checkBoxIncSearch);
|
m_group.insert(theFakeVimSetting(ConfigUseCoreSearch), m_ui.checkBoxUseCoreSearch);
|
||||||
m_group.insert(theFakeVimSetting(ConfigUseCoreSearch),
|
m_group.insert(theFakeVimSetting(ConfigSmartCase), m_ui.checkBoxSmartCase);
|
||||||
m_ui.checkBoxUseCoreSearch);
|
m_group.insert(theFakeVimSetting(ConfigIgnoreCase), m_ui.checkBoxIgnoreCase);
|
||||||
m_group.insert(theFakeVimSetting(ConfigSmartCase),
|
m_group.insert(theFakeVimSetting(ConfigWrapScan), m_ui.checkBoxWrapScan);
|
||||||
m_ui.checkBoxSmartCase);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigIgnoreCase),
|
|
||||||
m_ui.checkBoxIgnoreCase);
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigWrapScan),
|
|
||||||
m_ui.checkBoxWrapScan);
|
|
||||||
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigShowCmd),
|
m_group.insert(theFakeVimSetting(ConfigShowCmd), m_ui.checkBoxShowCmd);
|
||||||
m_ui.checkBoxShowCmd);
|
|
||||||
|
|
||||||
m_group.insert(theFakeVimSetting(ConfigRelativeNumber),
|
m_group.insert(theFakeVimSetting(ConfigRelativeNumber), m_ui.checkBoxRelativeNumber);
|
||||||
m_ui.checkBoxRelativeNumber);
|
|
||||||
|
|
||||||
connect(m_ui.pushButtonCopyTextEditorSettings, &QAbstractButton::clicked,
|
connect(m_ui.pushButtonCopyTextEditorSettings, &QAbstractButton::clicked,
|
||||||
this, &FakeVimOptionPage::copyTextEditorSettings);
|
this, &FakeVimOptionPage::copyTextEditorSettings);
|
||||||
@@ -518,7 +494,99 @@ void FakeVimOptionPage::updateVimRcWidgets()
|
|||||||
m_ui.pathChooserVimRcPath->setEnabled(m_ui.checkBoxReadVimRc->isChecked());
|
m_ui.pathChooserVimRcPath->setEnabled(m_ui.checkBoxReadVimRc->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
//const char *FAKEVIM_CONTEXT = "FakeVim";
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// FakeVimPluginPrivate
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class FakeVimPluginRunData;
|
||||||
|
|
||||||
|
class FakeVimPluginPrivate : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FakeVimPluginPrivate();
|
||||||
|
|
||||||
|
bool initialize();
|
||||||
|
|
||||||
|
void editorOpened(Core::IEditor *);
|
||||||
|
void editorAboutToClose(Core::IEditor *);
|
||||||
|
void currentEditorAboutToChange(Core::IEditor *);
|
||||||
|
|
||||||
|
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
||||||
|
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
|
||||||
|
void renameFileNameInEditors(const QString &oldName, const QString &newName);
|
||||||
|
|
||||||
|
void setUseFakeVim(const QVariant &value);
|
||||||
|
void setUseFakeVimInternal(bool on);
|
||||||
|
void quitFakeVim();
|
||||||
|
void triggerCompletions(FakeVimHandler *handler);
|
||||||
|
void triggerSimpleCompletions(FakeVimHandler *handler, const QString &needle, bool forward);
|
||||||
|
void windowCommand(FakeVimHandler *handler, const QString &key, int count);
|
||||||
|
void find(bool reverse);
|
||||||
|
void findNext(bool reverse);
|
||||||
|
void foldToggle(FakeVimHandler *handler, int depth);
|
||||||
|
void foldAll(FakeVimHandler *handler, bool fold);
|
||||||
|
void fold(FakeVimHandler *handler, int depth, bool fold);
|
||||||
|
void foldGoTo(FakeVimHandler *handler, int count, bool current);
|
||||||
|
void jumpToGlobalMark(FakeVimHandler *, QChar mark, bool backTickMode, const QString &fileName);
|
||||||
|
void maybeReadVimRc();
|
||||||
|
void disableBlockSelection(FakeVimHandler *handler);
|
||||||
|
void setBlockSelection(FakeVimHandler *handler, const QTextCursor &cursor);
|
||||||
|
void blockSelection(FakeVimHandler *handler, QTextCursor *cursor);
|
||||||
|
void hasBlockSelection(FakeVimHandler *handler, bool *on);
|
||||||
|
void setShowRelativeLineNumbers(const QVariant &value);
|
||||||
|
|
||||||
|
void resetCommandBuffer();
|
||||||
|
void showCommandBuffer(FakeVimHandler *handler, const QString &contents,
|
||||||
|
int cursorPos, int anchorPos, int messageLevel);
|
||||||
|
void showExtraInformation(FakeVimHandler *handler, const QString &msg);
|
||||||
|
void changeSelection(FakeVimHandler *handler, const QList<QTextEdit::ExtraSelection> &selections);
|
||||||
|
void highlightMatches(FakeVimHandler *handler, const QString &needle);
|
||||||
|
void moveToMatchingParenthesis(FakeVimHandler *handler, bool *moved, bool *forward, QTextCursor *cursor);
|
||||||
|
void checkForElectricCharacter(FakeVimHandler *handler, bool *result, QChar c);
|
||||||
|
void indentRegion(FakeVimHandler *handler, int beginBlock, int endBlock, QChar typedChar);
|
||||||
|
void handleExCommand(FakeVimHandler *handler, bool *handled, const ExCommand &cmd);
|
||||||
|
|
||||||
|
void writeSettings();
|
||||||
|
void readSettings();
|
||||||
|
|
||||||
|
void handleDelayedQuitAll(bool forced);
|
||||||
|
void handleDelayedQuit(bool forced, Core::IEditor *editor);
|
||||||
|
void userActionTriggered(int key);
|
||||||
|
|
||||||
|
void switchToFile(int n);
|
||||||
|
int currentFile() const;
|
||||||
|
|
||||||
|
void createRelativeNumberWidget(IEditor *editor);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void delayedQuitRequested(bool forced, Core::IEditor *editor);
|
||||||
|
void delayedQuitAllRequested(bool forced);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QHash<IEditor *, FakeVimHandler *> m_editorToHandler;
|
||||||
|
|
||||||
|
void triggerAction(Id id);
|
||||||
|
void setActionChecked(Id id, bool check);
|
||||||
|
|
||||||
|
typedef int (*DistFunction)(const QRect &cursor, const QRect &other);
|
||||||
|
void moveSomewhere(FakeVimHandler *handler, DistFunction f, int count);
|
||||||
|
|
||||||
|
void keepOnlyWindow(); // :only
|
||||||
|
|
||||||
|
ExCommandMap m_exCommandMap;
|
||||||
|
ExCommandMap m_defaultExCommandMap;
|
||||||
|
|
||||||
|
UserCommandMap m_userCommandMap;
|
||||||
|
UserCommandMap m_defaultUserCommandMap;
|
||||||
|
|
||||||
|
MiniBuffer *m_miniBuffer = nullptr;
|
||||||
|
FakeVimPluginRunData *runData = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -530,10 +598,8 @@ enum { CommandRole = Qt::UserRole };
|
|||||||
|
|
||||||
class FakeVimExCommandsWidget : public CommandMappings
|
class FakeVimExCommandsWidget : public CommandMappings
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent = 0);
|
FakeVimExCommandsWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void commandChanged();
|
void commandChanged();
|
||||||
@@ -545,19 +611,15 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
ExCommandMap &exCommandMap();
|
|
||||||
ExCommandMap &defaultExCommandMap();
|
|
||||||
ExCommandMap exCommandMapFromWidget();
|
ExCommandMap exCommandMapFromWidget();
|
||||||
|
|
||||||
FakeVimPluginPrivate *m_q;
|
|
||||||
QGroupBox *m_commandBox;
|
QGroupBox *m_commandBox;
|
||||||
FancyLineEdit *m_commandEdit;
|
FancyLineEdit *m_commandEdit;
|
||||||
|
|
||||||
friend class FakeVimExCommandsPage; // allow the page accessing the ExCommandMaps
|
friend class FakeVimExCommandsPage; // allow the page accessing the ExCommandMaps
|
||||||
};
|
};
|
||||||
|
|
||||||
FakeVimExCommandsWidget::FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent)
|
FakeVimExCommandsWidget::FakeVimExCommandsWidget()
|
||||||
: CommandMappings(parent), m_q(q)
|
|
||||||
{
|
{
|
||||||
setPageTitle(Tr::tr("Ex Command Mapping"));
|
setPageTitle(Tr::tr("Ex Command Mapping"));
|
||||||
setTargetHeader(Tr::tr("Ex Trigger Expression"));
|
setTargetHeader(Tr::tr("Ex Trigger Expression"));
|
||||||
@@ -589,11 +651,8 @@ FakeVimExCommandsWidget::FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidge
|
|||||||
|
|
||||||
class FakeVimExCommandsPage : public IOptionsPage
|
class FakeVimExCommandsPage : public IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimExCommandsPage(FakeVimPluginPrivate *q)
|
FakeVimExCommandsPage()
|
||||||
: m_q(q)
|
|
||||||
{
|
{
|
||||||
setId(SETTINGS_EX_CMDS_ID);
|
setId(SETTINGS_EX_CMDS_ID);
|
||||||
setDisplayName(Tr::tr("Ex Command Mapping"));
|
setDisplayName(Tr::tr("Ex Command Mapping"));
|
||||||
@@ -602,21 +661,20 @@ public:
|
|||||||
setCategoryIcon(Utils::Icon(SETTINGS_CATEGORY_FAKEVIM_ICON));
|
setCategoryIcon(Utils::Icon(SETTINGS_CATEGORY_FAKEVIM_ICON));
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *widget() override;
|
QWidget *widget() override
|
||||||
|
{
|
||||||
|
if (!m_widget)
|
||||||
|
m_widget = new FakeVimExCommandsWidget;
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
void apply() override;
|
void apply() override;
|
||||||
void finish() override {}
|
void finish() override {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FakeVimPluginPrivate *m_q;
|
|
||||||
QPointer<FakeVimExCommandsWidget> m_widget;
|
QPointer<FakeVimExCommandsWidget> m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
QWidget *FakeVimExCommandsPage::widget()
|
|
||||||
{
|
|
||||||
if (!m_widget)
|
|
||||||
m_widget = new FakeVimExCommandsWidget(m_q);
|
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char exCommandMapGroup[] = "FakeVimExCommand";
|
const char exCommandMapGroup[] = "FakeVimExCommand";
|
||||||
const char userCommandMapGroup[] = "FakeVimUserCommand";
|
const char userCommandMapGroup[] = "FakeVimUserCommand";
|
||||||
@@ -630,10 +688,10 @@ void FakeVimExCommandsPage::apply()
|
|||||||
return;
|
return;
|
||||||
// now save the mappings if necessary
|
// now save the mappings if necessary
|
||||||
const ExCommandMap &newMapping = m_widget->exCommandMapFromWidget();
|
const ExCommandMap &newMapping = m_widget->exCommandMapFromWidget();
|
||||||
ExCommandMap &globalCommandMapping = m_widget->exCommandMap();
|
ExCommandMap &globalCommandMapping = dd->m_exCommandMap;
|
||||||
|
|
||||||
if (newMapping != globalCommandMapping) {
|
if (newMapping != globalCommandMapping) {
|
||||||
const ExCommandMap &defaultMap = m_widget->defaultExCommandMap();
|
const ExCommandMap &defaultMap = dd->m_defaultExCommandMap;
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginWriteArray(exCommandMapGroup);
|
settings->beginWriteArray(exCommandMapGroup);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -687,11 +745,11 @@ void FakeVimExCommandsWidget::initialize()
|
|||||||
item->setText(1, c->description());
|
item->setText(1, c->description());
|
||||||
|
|
||||||
QString regex;
|
QString regex;
|
||||||
if (exCommandMap().contains(name))
|
if (dd->m_exCommandMap.contains(name))
|
||||||
regex = exCommandMap()[name].pattern();
|
regex = dd->m_exCommandMap[name].pattern();
|
||||||
item->setText(2, regex);
|
item->setText(2, regex);
|
||||||
|
|
||||||
if (regex != defaultExCommandMap()[name].pattern())
|
if (regex != dd->m_defaultExCommandMap[name].pattern())
|
||||||
setModified(item, true);
|
setModified(item, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,7 +779,7 @@ void FakeVimExCommandsWidget::commandChanged()
|
|||||||
if (current->data(0, Qt::UserRole).isValid())
|
if (current->data(0, Qt::UserRole).isValid())
|
||||||
current->setText(2, regex);
|
current->setText(2, regex);
|
||||||
|
|
||||||
setModified(current, regex != defaultExCommandMap()[name].pattern());
|
setModified(current, regex != dd->m_defaultExCommandMap[name].pattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimExCommandsWidget::resetToDefault()
|
void FakeVimExCommandsWidget::resetToDefault()
|
||||||
@@ -731,8 +789,8 @@ void FakeVimExCommandsWidget::resetToDefault()
|
|||||||
return;
|
return;
|
||||||
const QString name = current->data(0, CommandRole).toString();
|
const QString name = current->data(0, CommandRole).toString();
|
||||||
QString regex;
|
QString regex;
|
||||||
if (defaultExCommandMap().contains(name))
|
if (dd->m_defaultExCommandMap.contains(name))
|
||||||
regex = defaultExCommandMap()[name].pattern();
|
regex = dd->m_defaultExCommandMap[name].pattern();
|
||||||
m_commandEdit->setText(regex);
|
m_commandEdit->setText(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,8 +804,8 @@ void FakeVimExCommandsWidget::defaultAction()
|
|||||||
QTreeWidgetItem *item = section->child(j);
|
QTreeWidgetItem *item = section->child(j);
|
||||||
const QString name = item->data(0, CommandRole).toString();
|
const QString name = item->data(0, CommandRole).toString();
|
||||||
QString regex;
|
QString regex;
|
||||||
if (defaultExCommandMap().contains(name))
|
if (dd->m_defaultExCommandMap.contains(name))
|
||||||
regex = defaultExCommandMap()[name].pattern();
|
regex = dd->m_defaultExCommandMap[name].pattern();
|
||||||
setModified(item, false);
|
setModified(item, false);
|
||||||
item->setText(2, regex);
|
item->setText(2, regex);
|
||||||
if (item == commandList()->currentItem())
|
if (item == commandList()->currentItem())
|
||||||
@@ -764,12 +822,9 @@ void FakeVimExCommandsWidget::defaultAction()
|
|||||||
|
|
||||||
class FakeVimUserCommandsModel : public QAbstractTableModel
|
class FakeVimUserCommandsModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
FakeVimUserCommandsModel(FakeVimPluginPrivate *q) : m_q(q) {}
|
FakeVimUserCommandsModel() { m_commandMap = dd->m_userCommandMap; }
|
||||||
~FakeVimUserCommandsModel() {}
|
|
||||||
|
|
||||||
void initCommandMap(const UserCommandMap &commandMap) { m_commandMap = commandMap; }
|
|
||||||
UserCommandMap commandMap() const { return m_commandMap; }
|
UserCommandMap commandMap() const { return m_commandMap; }
|
||||||
int rowCount(const QModelIndex &parent) const;
|
int rowCount(const QModelIndex &parent) const;
|
||||||
int columnCount(const QModelIndex &parent) const;
|
int columnCount(const QModelIndex &parent) const;
|
||||||
@@ -779,7 +834,6 @@ public:
|
|||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FakeVimPluginPrivate *m_q;
|
|
||||||
UserCommandMap m_commandMap;
|
UserCommandMap m_commandMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -839,11 +893,8 @@ public:
|
|||||||
|
|
||||||
class FakeVimUserCommandsPage : public IOptionsPage
|
class FakeVimUserCommandsPage : public IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimUserCommandsPage(FakeVimPluginPrivate *q)
|
FakeVimUserCommandsPage()
|
||||||
: m_q(q)
|
|
||||||
{
|
{
|
||||||
setId(SETTINGS_USER_CMDS_ID);
|
setId(SETTINGS_USER_CMDS_ID);
|
||||||
setDisplayName(Tr::tr("User Command Mapping"));
|
setDisplayName(Tr::tr("User Command Mapping"));
|
||||||
@@ -857,12 +908,9 @@ public:
|
|||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget();
|
||||||
void initialize() {}
|
void initialize() {}
|
||||||
UserCommandMap &userCommandMap();
|
UserCommandMap currentCommandMap() { return m_model->commandMap(); }
|
||||||
UserCommandMap &defaultUserCommandMap();
|
|
||||||
UserCommandMap currentCommandMap();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FakeVimPluginPrivate *m_q;
|
|
||||||
QPointer<QWidget> m_widget;
|
QPointer<QWidget> m_widget;
|
||||||
FakeVimUserCommandsModel *m_model;
|
FakeVimUserCommandsModel *m_model;
|
||||||
};
|
};
|
||||||
@@ -872,8 +920,7 @@ QWidget *FakeVimUserCommandsPage::widget()
|
|||||||
if (!m_widget) {
|
if (!m_widget) {
|
||||||
m_widget = new QWidget;
|
m_widget = new QWidget;
|
||||||
|
|
||||||
m_model = new FakeVimUserCommandsModel(m_q);
|
m_model = new FakeVimUserCommandsModel;
|
||||||
m_model->initCommandMap(userCommandMap());
|
|
||||||
auto widget = new QTreeView;
|
auto widget = new QTreeView;
|
||||||
m_model->setParent(widget);
|
m_model->setParent(widget);
|
||||||
widget->setModel(m_model);
|
widget->setModel(m_model);
|
||||||
@@ -896,7 +943,7 @@ void FakeVimUserCommandsPage::apply()
|
|||||||
|
|
||||||
// now save the mappings if necessary
|
// now save the mappings if necessary
|
||||||
const UserCommandMap ¤t = currentCommandMap();
|
const UserCommandMap ¤t = currentCommandMap();
|
||||||
UserCommandMap &userMap = userCommandMap();
|
UserCommandMap &userMap = dd->m_userCommandMap;
|
||||||
|
|
||||||
if (current != userMap) {
|
if (current != userMap) {
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
@@ -908,9 +955,9 @@ void FakeVimUserCommandsPage::apply()
|
|||||||
const int key = it.key();
|
const int key = it.key();
|
||||||
const QString cmd = it.value();
|
const QString cmd = it.value();
|
||||||
|
|
||||||
if ((defaultUserCommandMap().contains(key)
|
if ((dd->m_defaultUserCommandMap.contains(key)
|
||||||
&& defaultUserCommandMap()[key] != cmd)
|
&& dd->m_defaultUserCommandMap[key] != cmd)
|
||||||
|| (!defaultUserCommandMap().contains(key) && !cmd.isEmpty())) {
|
|| (!dd->m_defaultUserCommandMap.contains(key) && !cmd.isEmpty())) {
|
||||||
settings->setArrayIndex(count);
|
settings->setArrayIndex(count);
|
||||||
settings->setValue(idKey, key);
|
settings->setValue(idKey, key);
|
||||||
settings->setValue(cmdKey, cmd);
|
settings->setValue(cmdKey, cmd);
|
||||||
@@ -919,7 +966,7 @@ void FakeVimUserCommandsPage::apply()
|
|||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
userMap.clear();
|
userMap.clear();
|
||||||
userMap.unite(defaultUserCommandMap());
|
userMap.unite(dd->m_defaultUserCommandMap);
|
||||||
userMap.unite(current);
|
userMap.unite(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -955,7 +1002,7 @@ public:
|
|||||||
void setInactive()
|
void setInactive()
|
||||||
{
|
{
|
||||||
m_needle.clear();
|
m_needle.clear();
|
||||||
m_handler = 0;
|
m_handler = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &needle() const
|
const QString &needle() const
|
||||||
@@ -1078,108 +1125,18 @@ IAssistProcessor *FakeVimCompletionAssistProvider::createProcessor() const
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// FakeVimPluginPrivate
|
// FakeVimPluginRunData
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class FakeVimPluginPrivate : public QObject
|
class FakeVimPluginRunData
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimPluginPrivate(FakeVimPlugin *);
|
FakeVimOptionPage optionsPage;
|
||||||
|
FakeVimExCommandsPage exCommandsPage;
|
||||||
|
FakeVimUserCommandsPage userCommandsPage;
|
||||||
|
|
||||||
friend class FakeVimPlugin;
|
FakeVimCompletionAssistProvider wordProvider;
|
||||||
friend class FakeVimExCommandsWidget;
|
|
||||||
friend class FakeVimUserCommandsPage;
|
|
||||||
friend class FakeVimUserCommandsModel;
|
|
||||||
|
|
||||||
bool initialize();
|
|
||||||
void aboutToShutdown();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void onCoreAboutToClose();
|
|
||||||
void editorOpened(Core::IEditor *);
|
|
||||||
void editorAboutToClose(Core::IEditor *);
|
|
||||||
void currentEditorAboutToChange(Core::IEditor *);
|
|
||||||
|
|
||||||
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
|
||||||
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
|
|
||||||
void renameFileNameInEditors(const QString &oldName, const QString &newName);
|
|
||||||
|
|
||||||
void setUseFakeVim(const QVariant &value);
|
|
||||||
void setUseFakeVimInternal(bool on);
|
|
||||||
void quitFakeVim();
|
|
||||||
void triggerCompletions(FakeVimHandler *handler);
|
|
||||||
void triggerSimpleCompletions(FakeVimHandler *handler, const QString &needle, bool forward);
|
|
||||||
void windowCommand(FakeVimHandler *handler, const QString &key, int count);
|
|
||||||
void find(bool reverse);
|
|
||||||
void findNext(bool reverse);
|
|
||||||
void foldToggle(FakeVimHandler *handler, int depth);
|
|
||||||
void foldAll(FakeVimHandler *handler, bool fold);
|
|
||||||
void fold(FakeVimHandler *handler, int depth, bool fold);
|
|
||||||
void foldGoTo(FakeVimHandler *handler, int count, bool current);
|
|
||||||
void jumpToGlobalMark(FakeVimHandler *, QChar mark, bool backTickMode, const QString &fileName);
|
|
||||||
void maybeReadVimRc();
|
|
||||||
void disableBlockSelection(FakeVimHandler *handler);
|
|
||||||
void setBlockSelection(FakeVimHandler *handler, const QTextCursor &cursor);
|
|
||||||
void blockSelection(FakeVimHandler *handler, QTextCursor *cursor);
|
|
||||||
void hasBlockSelection(FakeVimHandler *handler, bool *on);
|
|
||||||
void setShowRelativeLineNumbers(const QVariant &value);
|
|
||||||
|
|
||||||
void resetCommandBuffer();
|
|
||||||
void showCommandBuffer(FakeVimHandler *handler, const QString &contents,
|
|
||||||
int cursorPos, int anchorPos, int messageLevel);
|
|
||||||
void showExtraInformation(FakeVimHandler *handler, const QString &msg);
|
|
||||||
void changeSelection(FakeVimHandler *handler, const QList<QTextEdit::ExtraSelection> &selections);
|
|
||||||
void highlightMatches(FakeVimHandler *handler, const QString &needle);
|
|
||||||
void moveToMatchingParenthesis(FakeVimHandler *handler, bool *moved, bool *forward, QTextCursor *cursor);
|
|
||||||
void checkForElectricCharacter(FakeVimHandler *handler, bool *result, QChar c);
|
|
||||||
void indentRegion(FakeVimHandler *handler, int beginBlock, int endBlock, QChar typedChar);
|
|
||||||
void handleExCommand(FakeVimHandler *handler, bool *handled, const ExCommand &cmd);
|
|
||||||
|
|
||||||
void writeSettings();
|
|
||||||
void readSettings();
|
|
||||||
|
|
||||||
void handleDelayedQuitAll(bool forced);
|
|
||||||
void handleDelayedQuit(bool forced, Core::IEditor *editor);
|
|
||||||
void userActionTriggered(int key);
|
|
||||||
|
|
||||||
void switchToFile(int n);
|
|
||||||
int currentFile() const;
|
|
||||||
|
|
||||||
void createRelativeNumberWidget(IEditor *editor);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void delayedQuitRequested(bool forced, Core::IEditor *editor);
|
|
||||||
void delayedQuitAllRequested(bool forced);
|
|
||||||
|
|
||||||
private:
|
|
||||||
FakeVimPlugin *q;
|
|
||||||
QHash<IEditor *, FakeVimHandler *> m_editorToHandler;
|
|
||||||
|
|
||||||
void triggerAction(Id id);
|
|
||||||
void setActionChecked(Id id, bool check);
|
|
||||||
|
|
||||||
typedef int (*DistFunction)(const QRect &cursor, const QRect &other);
|
|
||||||
void moveSomewhere(FakeVimHandler *handler, DistFunction f, int count);
|
|
||||||
|
|
||||||
void keepOnlyWindow(); // :only
|
|
||||||
|
|
||||||
ExCommandMap &exCommandMap() { return m_exCommandMap; }
|
|
||||||
ExCommandMap &defaultExCommandMap() { return m_defaultExCommandMap; }
|
|
||||||
ExCommandMap m_exCommandMap;
|
|
||||||
ExCommandMap m_defaultExCommandMap;
|
|
||||||
|
|
||||||
UserCommandMap &userCommandMap() { return m_userCommandMap; }
|
|
||||||
UserCommandMap &defaultUserCommandMap() { return m_defaultUserCommandMap; }
|
|
||||||
UserCommandMap m_userCommandMap;
|
|
||||||
UserCommandMap m_defaultUserCommandMap;
|
|
||||||
|
|
||||||
MiniBuffer *m_miniBuffer = nullptr;
|
|
||||||
// @TODO: Delete
|
|
||||||
//WordCompletion *m_wordCompletion;
|
|
||||||
FakeVimCompletionAssistProvider *m_wordProvider = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QVariant FakeVimUserCommandsModel::data(const QModelIndex &index, int role) const
|
QVariant FakeVimUserCommandsModel::data(const QModelIndex &index, int role) const
|
||||||
@@ -1208,47 +1165,30 @@ bool FakeVimUserCommandsModel::setData(const QModelIndex &index,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
|
FakeVimPluginPrivate::FakeVimPluginPrivate()
|
||||||
: q(plugin)
|
|
||||||
{
|
{
|
||||||
defaultExCommandMap()[CppTools::Constants::SWITCH_HEADER_SOURCE] =
|
m_defaultExCommandMap[CppTools::Constants::SWITCH_HEADER_SOURCE] =
|
||||||
QRegExp("^A$");
|
QRegExp("^A$");
|
||||||
defaultExCommandMap()["Coreplugin.OutputPane.previtem"] =
|
m_defaultExCommandMap["Coreplugin.OutputPane.previtem"] =
|
||||||
QRegExp("^(cN(ext)?|cp(revious)?)!?( (.*))?$");
|
QRegExp("^(cN(ext)?|cp(revious)?)!?( (.*))?$");
|
||||||
defaultExCommandMap()["Coreplugin.OutputPane.nextitem"] =
|
m_defaultExCommandMap["Coreplugin.OutputPane.nextitem"] =
|
||||||
QRegExp("^cn(ext)?!?( (.*))?$");
|
QRegExp("^cn(ext)?!?( (.*))?$");
|
||||||
defaultExCommandMap()[TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR] =
|
m_defaultExCommandMap[TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR] =
|
||||||
QRegExp("^tag?$");
|
QRegExp("^tag?$");
|
||||||
defaultExCommandMap()[Core::Constants::GO_BACK] =
|
m_defaultExCommandMap[Core::Constants::GO_BACK] =
|
||||||
QRegExp("^pop?$");
|
QRegExp("^pop?$");
|
||||||
defaultExCommandMap()["QtCreator.Locate"] =
|
m_defaultExCommandMap["QtCreator.Locate"] =
|
||||||
QRegExp("^e$");
|
QRegExp("^e$");
|
||||||
|
|
||||||
for (int i = 1; i < 10; ++i) {
|
for (int i = 1; i < 10; ++i) {
|
||||||
QString cmd = QString::fromLatin1(":echo User command %1 executed.<CR>");
|
QString cmd = QString::fromLatin1(":echo User command %1 executed.<CR>");
|
||||||
defaultUserCommandMap().insert(i, cmd.arg(i));
|
m_defaultUserCommandMap.insert(i, cmd.arg(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::onCoreAboutToClose()
|
|
||||||
{
|
|
||||||
// Don't attach to editors anymore.
|
|
||||||
disconnect(EditorManager::instance(), &EditorManager::editorOpened,
|
|
||||||
this, &FakeVimPluginPrivate::editorOpened);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeVimPluginPrivate::aboutToShutdown()
|
|
||||||
{
|
|
||||||
delete m_wordProvider;
|
|
||||||
m_wordProvider = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FakeVimPluginPrivate::initialize()
|
bool FakeVimPluginPrivate::initialize()
|
||||||
{
|
{
|
||||||
//m_wordCompletion = new WordCompletion;
|
runData = new FakeVimPluginRunData;
|
||||||
//q->addAutoReleasedObject(m_wordCompletion);
|
|
||||||
m_wordProvider = new FakeVimCompletionAssistProvider;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Set completion settings and keep them up to date.
|
// Set completion settings and keep them up to date.
|
||||||
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
||||||
@@ -1256,18 +1196,11 @@ bool FakeVimPluginPrivate::initialize()
|
|||||||
connect(textEditorSettings, &TextEditorSettings::completionSettingsChanged,
|
connect(textEditorSettings, &TextEditorSettings::completionSettingsChanged,
|
||||||
completion, &TextEditorWidget::setCompletionSettings);
|
completion, &TextEditorWidget::setCompletionSettings);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Context globalcontext(Core::Constants::C_GLOBAL);
|
|
||||||
|
|
||||||
q->addAutoReleasedObject(new FakeVimOptionPage);
|
|
||||||
q->addAutoReleasedObject(new FakeVimExCommandsPage(this));
|
|
||||||
q->addAutoReleasedObject(new FakeVimUserCommandsPage(this));
|
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
Command *cmd = 0;
|
Command *cmd = nullptr;
|
||||||
cmd = ActionManager::registerAction(theFakeVimSetting(ConfigUseFakeVim),
|
cmd = ActionManager::registerAction(theFakeVimSetting(ConfigUseFakeVim),
|
||||||
INSTALL_HANDLER, globalcontext, true);
|
INSTALL_HANDLER, Context(Core::Constants::C_GLOBAL), true);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? Tr::tr("Meta+Shift+V,Meta+Shift+V") : Tr::tr("Alt+V,Alt+V")));
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? Tr::tr("Meta+Shift+V,Meta+Shift+V") : Tr::tr("Alt+V,Alt+V")));
|
||||||
|
|
||||||
ActionContainer *advancedMenu =
|
ActionContainer *advancedMenu =
|
||||||
@@ -1283,8 +1216,11 @@ bool FakeVimPluginPrivate::initialize()
|
|||||||
connect(act, &QAction::triggered, this, [this, i] { userActionTriggered(i); });
|
connect(act, &QAction::triggered, this, [this, i] { userActionTriggered(i); });
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ICore::instance(), &ICore::coreAboutToClose,
|
connect(ICore::instance(), &ICore::coreAboutToClose, this, [] {
|
||||||
this, &FakeVimPluginPrivate::onCoreAboutToClose);
|
// Don't attach to editors anymore.
|
||||||
|
disconnect(EditorManager::instance(), &EditorManager::editorOpened,
|
||||||
|
dd, &FakeVimPluginPrivate::editorOpened);
|
||||||
|
});
|
||||||
|
|
||||||
// EditorManager
|
// EditorManager
|
||||||
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
|
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
|
||||||
@@ -1332,7 +1268,7 @@ void FakeVimPluginPrivate::userActionTriggered(int key)
|
|||||||
if (enableFakeVim)
|
if (enableFakeVim)
|
||||||
setUseFakeVimInternal(true);
|
setUseFakeVimInternal(true);
|
||||||
|
|
||||||
const QString cmd = userCommandMap().value(key);
|
const QString cmd = m_userCommandMap.value(key);
|
||||||
handler->handleInput(cmd);
|
handler->handleInput(cmd);
|
||||||
|
|
||||||
if (enableFakeVim)
|
if (enableFakeVim)
|
||||||
@@ -1364,23 +1300,23 @@ void FakeVimPluginPrivate::readSettings()
|
|||||||
|
|
||||||
theFakeVimSettings()->readSettings(settings);
|
theFakeVimSettings()->readSettings(settings);
|
||||||
|
|
||||||
exCommandMap() = defaultExCommandMap();
|
m_exCommandMap = m_defaultExCommandMap;
|
||||||
int size = settings->beginReadArray(exCommandMapGroup);
|
int size = settings->beginReadArray(exCommandMapGroup);
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
const QString id = settings->value(idKey).toString();
|
const QString id = settings->value(idKey).toString();
|
||||||
const QString re = settings->value(reKey).toString();
|
const QString re = settings->value(reKey).toString();
|
||||||
exCommandMap()[id] = QRegExp(re);
|
m_exCommandMap[id] = QRegExp(re);
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
|
|
||||||
userCommandMap() = defaultUserCommandMap();
|
m_userCommandMap = m_defaultUserCommandMap;
|
||||||
size = settings->beginReadArray(userCommandMapGroup);
|
size = settings->beginReadArray(userCommandMapGroup);
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
const int id = settings->value(idKey).toInt();
|
const int id = settings->value(idKey).toInt();
|
||||||
const QString cmd = settings->value(cmdKey).toString();
|
const QString cmd = settings->value(cmdKey).toString();
|
||||||
userCommandMap()[id] = cmd;
|
m_userCommandMap[id] = cmd;
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
}
|
}
|
||||||
@@ -1705,7 +1641,7 @@ void FakeVimPluginPrivate::jumpToGlobalMark(FakeVimHandler *,
|
|||||||
IEditor *iedit = EditorManager::openEditor(fileName);
|
IEditor *iedit = EditorManager::openEditor(fileName);
|
||||||
if (!iedit)
|
if (!iedit)
|
||||||
return;
|
return;
|
||||||
FakeVimHandler *handler = m_editorToHandler.value(iedit, 0);
|
FakeVimHandler *handler = m_editorToHandler.value(iedit, nullptr);
|
||||||
if (handler)
|
if (handler)
|
||||||
handler->jumpToLocalMark(mark, backTickMode);
|
handler->jumpToLocalMark(mark, backTickMode);
|
||||||
}
|
}
|
||||||
@@ -1886,15 +1822,14 @@ void FakeVimPluginPrivate::triggerCompletions(FakeVimHandler *handler)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(handler, return);
|
QTC_ASSERT(handler, return);
|
||||||
if (TextEditorWidget *editor = qobject_cast<TextEditorWidget *>(handler->widget()))
|
if (TextEditorWidget *editor = qobject_cast<TextEditorWidget *>(handler->widget()))
|
||||||
editor->invokeAssist(Completion, m_wordProvider);
|
editor->invokeAssist(Completion, &runData->wordProvider);
|
||||||
// CompletionSupport::instance()->complete(editor->editor(), TextCompletion, false);
|
// CompletionSupport::instance()->complete(editor->editor(), TextCompletion, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::triggerSimpleCompletions(FakeVimHandler *handler, const QString &needle, bool forward)
|
void FakeVimPluginPrivate::triggerSimpleCompletions(FakeVimHandler *handler, const QString &needle, bool forward)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(handler, return);
|
QTC_ASSERT(handler, return);
|
||||||
// m_wordCompletion->setActive(needle, forward, handler);
|
runData->wordProvider.setActive(needle, forward, handler);
|
||||||
m_wordProvider->setActive(needle, forward, handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::disableBlockSelection(FakeVimHandler *handler)
|
void FakeVimPluginPrivate::disableBlockSelection(FakeVimHandler *handler)
|
||||||
@@ -2035,9 +1970,8 @@ void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handle
|
|||||||
triggerAction(CppTools::Constants::SWITCH_HEADER_SOURCE);
|
triggerAction(CppTools::Constants::SWITCH_HEADER_SOURCE);
|
||||||
} else {
|
} else {
|
||||||
// Check whether one of the configure commands matches.
|
// Check whether one of the configure commands matches.
|
||||||
typedef ExCommandMap::const_iterator Iterator;
|
const auto end = m_exCommandMap.constEnd();
|
||||||
const Iterator end = exCommandMap().constEnd();
|
for (auto it = m_exCommandMap.constBegin(); it != end; ++it) {
|
||||||
for (Iterator it = exCommandMap().constBegin(); it != end; ++it) {
|
|
||||||
const QString &id = it.key();
|
const QString &id = it.key();
|
||||||
QRegExp re = it.value();
|
QRegExp re = it.value();
|
||||||
if (!re.pattern().isEmpty() && re.indexIn(cmd.cmd) != -1) {
|
if (!re.pattern().isEmpty() && re.indexIn(cmd.cmd) != -1) {
|
||||||
@@ -2201,16 +2135,6 @@ void FakeVimPluginPrivate::switchToFile(int n)
|
|||||||
EditorManager::activateEditorForEntry(DocumentModel::entries().at(n));
|
EditorManager::activateEditorForEntry(DocumentModel::entries().at(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExCommandMap &FakeVimExCommandsWidget::exCommandMap()
|
|
||||||
{
|
|
||||||
return m_q->exCommandMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExCommandMap &FakeVimExCommandsWidget::defaultExCommandMap()
|
|
||||||
{
|
|
||||||
return m_q->defaultExCommandMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExCommandMap FakeVimExCommandsWidget::exCommandMapFromWidget()
|
ExCommandMap FakeVimExCommandsWidget::exCommandMapFromWidget()
|
||||||
{
|
{
|
||||||
ExCommandMap map;
|
ExCommandMap map;
|
||||||
@@ -2222,8 +2146,8 @@ ExCommandMap FakeVimExCommandsWidget::exCommandMapFromWidget()
|
|||||||
QTreeWidgetItem *item = section->child(j);
|
QTreeWidgetItem *item = section->child(j);
|
||||||
const QString name = item->data(0, CommandRole).toString();
|
const QString name = item->data(0, CommandRole).toString();
|
||||||
const QString regex = item->data(2, Qt::DisplayRole).toString();
|
const QString regex = item->data(2, Qt::DisplayRole).toString();
|
||||||
if ((regex.isEmpty() && defaultExCommandMap().value(name).isEmpty())
|
if ((regex.isEmpty() && dd->m_defaultExCommandMap.value(name).isEmpty())
|
||||||
|| (!regex.isEmpty() && defaultExCommandMap().value(name).pattern() == regex))
|
|| (!regex.isEmpty() && dd->m_defaultExCommandMap.value(name).pattern() == regex))
|
||||||
continue;
|
continue;
|
||||||
map[name] = QRegExp(regex);
|
map[name] = QRegExp(regex);
|
||||||
}
|
}
|
||||||
@@ -2231,20 +2155,7 @@ ExCommandMap FakeVimExCommandsWidget::exCommandMapFromWidget()
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserCommandMap &FakeVimUserCommandsPage::userCommandMap()
|
|
||||||
{
|
|
||||||
return m_q->userCommandMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
UserCommandMap &FakeVimUserCommandsPage::defaultUserCommandMap()
|
|
||||||
{
|
|
||||||
return m_q->defaultUserCommandMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
UserCommandMap FakeVimUserCommandsPage::currentCommandMap()
|
|
||||||
{
|
|
||||||
return m_model->commandMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -2253,32 +2164,37 @@ UserCommandMap FakeVimUserCommandsPage::currentCommandMap()
|
|||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FakeVimPlugin::FakeVimPlugin()
|
FakeVimPlugin::FakeVimPlugin()
|
||||||
: d(new FakeVimPluginPrivate(this))
|
{
|
||||||
{}
|
dd = new FakeVimPluginPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
FakeVimPlugin::~FakeVimPlugin()
|
FakeVimPlugin::~FakeVimPlugin()
|
||||||
{
|
{
|
||||||
delete d;
|
delete dd;
|
||||||
|
dd = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FakeVimPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
bool FakeVimPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
Q_UNUSED(errorMessage)
|
Q_UNUSED(errorMessage)
|
||||||
return d->initialize();
|
return dd->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
StatusBarManager::destroyStatusBarWidget(d->m_miniBuffer);
|
delete dd->runData;
|
||||||
d->m_miniBuffer = nullptr;
|
dd->runData = nullptr;
|
||||||
|
|
||||||
|
StatusBarManager::destroyStatusBarWidget(dd->m_miniBuffer);
|
||||||
|
dd->m_miniBuffer = nullptr;
|
||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPlugin::extensionsInitialized()
|
void FakeVimPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
d->m_miniBuffer = new MiniBuffer;
|
dd->m_miniBuffer = new MiniBuffer;
|
||||||
StatusBarManager::addStatusBarWidget(d->m_miniBuffer, StatusBarManager::LastLeftAligned);
|
StatusBarManager::addStatusBarWidget(dd->m_miniBuffer, StatusBarManager::LastLeftAligned);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
@@ -2288,7 +2204,7 @@ void FakeVimPlugin::setupTest(QString *title, FakeVimHandler **handler, QWidget
|
|||||||
IEditor *iedit = EditorManager::openEditorWithContents(Id(), title);
|
IEditor *iedit = EditorManager::openEditorWithContents(Id(), title);
|
||||||
EditorManager::activateEditor(iedit);
|
EditorManager::activateEditor(iedit);
|
||||||
*edit = iedit->widget();
|
*edit = iedit->widget();
|
||||||
*handler = d->m_editorToHandler.value(iedit, 0);
|
*handler = dd->m_editorToHandler.value(iedit, 0);
|
||||||
(*handler)->setupWidget();
|
(*handler)->setupWidget();
|
||||||
(*handler)->handleCommand("set startofline");
|
(*handler)->handleCommand("set startofline");
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace FakeVim {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class FakeVimHandler;
|
class FakeVimHandler;
|
||||||
class FakeVimPluginPrivate;
|
|
||||||
|
|
||||||
class FakeVimPlugin : public ExtensionSystem::IPlugin
|
class FakeVimPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@@ -50,7 +49,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class FakeVimPluginPrivate;
|
friend class FakeVimPluginPrivate;
|
||||||
FakeVimPluginPrivate *d;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user