Commit bf607962 authored by Martin Aumüller's avatar Martin Aumüller Committed by hjk
Browse files

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: default avatarhjk <qtc-committer@nokia.com>
parent f6482a38
......@@ -377,6 +377,9 @@ public:
// this asks the layer above (e.g. the fake vim plugin or the
// stand-alone test application to handle the command)
void passUnknownExCommand(const QString &cmd);
// this asks the layer above (e.g. the fake vim plugin or the
// stand-alone test application to handle the set command)
void passUnknownSetCommand(const QString &cmd);
bool isVisualMode() const { return m_visualMode != NoVisualMode; }
bool isNoVisualMode() const { return m_visualMode == NoVisualMode; }
......@@ -2304,7 +2307,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
if (act)
act->setValue(arg.mid(p + 1));
} else {
showRedMessage(FakeVimHandler::tr("E512: Unknown option: ") + arg);
passUnknownSetCommand(arg);
}
updateMiniBuffer();
} else if (reHistory.indexIn(cmd) != -1) { // :history
......@@ -2332,6 +2335,15 @@ void FakeVimHandler::Private::passUnknownExCommand(const QString &cmd)
emit q->handleExCommandRequested(cmd);
}
void FakeVimHandler::Private::passUnknownSetCommand(const QString &arg)
{
bool handled = false;
emit q->handleSetCommandRequested(&handled, arg);
if (!handled) {
showRedMessage(FakeVimHandler::tr("E512: Unknown option: ") + arg);
}
}
static void vimPatternToQtPattern(QString *needle, QTextDocument::FindFlags *flags)
{
// FIXME: Rough mapping of a common case
......
......@@ -84,6 +84,7 @@ signals:
void findRequested(bool reverse);
void findNextRequested(bool reverse);
void handleExCommandRequested(const QString &cmd);
void handleSetCommandRequested(bool *handled, const QString &cmd);
public:
class Private;
......
......@@ -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;
......
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