Commit 790a7879 authored by Rhys Weatherley's avatar Rhys Weatherley

Make FakeVim use the default find box instead of mini-buffer

Creator already has a find box that works fairly well, so there
is no need for a mini-buffer mode for searching.  This change makes
FakeVim activate the standard find box when the user hits '/' or '?'.

Note: right now both '/' and '?' do forward searching by default
because the Creator find box lacks a "find backwards by default" mode.
This can be added later to the find box if considered useful.
parent 653223a8
......@@ -1010,12 +1010,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_commandHistoryIndex = m_commandHistory.size() - 1;
updateMiniBuffer();
} else if (key == '/' || key == '?') {
enterExMode(); // to get the cursor disabled
m_mode = (key == '/') ? SearchForwardMode : SearchBackwardMode;
m_commandBuffer.clear();
m_searchHistory.append(QString());
m_searchHistoryIndex = m_searchHistory.size() - 1;
updateMiniBuffer();
emit q->findRequested(key == '?');
} else if (key == '`') {
m_subsubmode = BackTickSubSubMode;
} else if (key == '#' || key == '*') {
......
......@@ -73,6 +73,7 @@ signals:
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
void completionRequested();
void windowCommandRequested(int key);
void findRequested(bool reverse);
public:
class Private;
......
......@@ -56,6 +56,8 @@
#include <texteditor/texteditorsettings.h>
#include <texteditor/textblockiterator.h>
#include <find/textfindconstants.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
......@@ -232,6 +234,7 @@ private slots:
void quitFakeVim();
void triggerCompletions();
void windowCommand(int key);
void find(bool reverse);
void showSettingsDialog();
void showCommandBuffer(const QString &contents);
......@@ -246,6 +249,8 @@ private:
FakeVimPlugin *q;
FakeVimOptionPage *m_fakeVimOptionsPage;
QHash<Core::IEditor *, FakeVimHandler *> m_editorToHandler;
void triggerAction(const QString& code);
};
} // namespace Internal
......@@ -310,6 +315,17 @@ void FakeVimPluginPrivate::showSettingsDialog()
Core::ICore::instance()->showOptionsDialog("FakeVim", "General");
}
void FakeVimPluginPrivate::triggerAction(const QString& code)
{
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);
action->trigger();
}
void FakeVimPluginPrivate::windowCommand(int key)
{
#define control(n) (256 + n)
......@@ -341,13 +357,13 @@ void FakeVimPluginPrivate::windowCommand(int key)
qDebug() << "UNKNOWN WINDOWS COMMAND: " << key;
return;
}
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);
action->trigger();
triggerAction(code);
}
void FakeVimPluginPrivate::find(bool reverse)
{
Q_UNUSED(reverse); // TODO: Creator needs an action for find in reverse.
triggerAction(Find::Constants::FIND_IN_DOCUMENT);
}
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
......@@ -387,6 +403,8 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
this, SLOT(triggerCompletions()));
connect(handler, SIGNAL(windowCommandRequested(int)),
this, SLOT(windowCommand(int)));
connect(handler, SIGNAL(findRequested(bool)),
this, SLOT(find(bool)));
handler->setCurrentFileName(editor->file()->fileName());
handler->installEventFilter();
......
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