fakevim: change Find plugin's case sensitivity with ':set (no)ignorecase'

- allow for handling unknown arguments to ':set' by the layer having installed the FakeVim handler
- use that to change the Find plugin's case sensitivity

Merge-request: 97
Reviewed-by: hjk <qtc-committer@nokia.com>
This commit is contained in:
Martin Aumüller
2010-01-21 17:23:32 +01:00
committed by hjk
parent f6482a3871
commit bf607962e5
3 changed files with 46 additions and 1 deletions

View File

@@ -283,6 +283,7 @@ private slots:
void checkForElectricCharacter(bool *result, QChar c);
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
void handleExCommand(const QString &cmd);
void handleSetCommand(bool *handled, QString cmd);
void handleDelayedQuitAll(bool forced);
void handleDelayedQuit(bool forced, Core::IEditor *editor);
@@ -297,6 +298,7 @@ private:
QHash<Core::IEditor *, FakeVimHandler *> m_editorToHandler;
void triggerAction(const QString& code);
void setActionChecked(const QString& code, bool check);
};
} // namespace Internal
@@ -380,6 +382,19 @@ void FakeVimPluginPrivate::triggerAction(const QString& code)
action->trigger();
}
void FakeVimPluginPrivate::setActionChecked(const QString& code, bool check)
{
Core::ActionManager *am = Core::ICore::instance()->actionManager();
QTC_ASSERT(am, return);
Core::Command *cmd = am->command(code);
QTC_ASSERT(cmd, return);
QAction *action = cmd->action();
QTC_ASSERT(action, return);
QTC_ASSERT(action->isCheckable(), return);
action->setChecked(check);
action->trigger();
}
void FakeVimPluginPrivate::windowCommand(int key)
{
#define control(n) (256 + n)
@@ -476,6 +491,8 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
connect(handler, SIGNAL(handleExCommandRequested(QString)),
this, SLOT(handleExCommand(QString)));
connect(handler, SIGNAL(handleSetCommandRequested(bool *,QString)),
this, SLOT(handleSetCommand(bool *,QString)));
handler->setCurrentFileName(editor->file()->fileName());
handler->installEventFilter();
@@ -597,6 +614,21 @@ void FakeVimPluginPrivate::handleExCommand(const QString &cmd)
}
}
void FakeVimPluginPrivate::handleSetCommand(bool *handled, QString cmd)
{
*handled = false;
bool value = true;
if (cmd.startsWith("no")) {
value = false;
cmd = cmd.mid(2);
}
if (cmd == "ic" || cmd == "ignorecase") {
setActionChecked(Find::Constants::CASE_SENSITIVE, value);
*handled = true;
}
}
void FakeVimPluginPrivate::handleDelayedQuit(bool forced, Core::IEditor *editor)
{
QList<Core::IEditor *> editors;