forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -1010,12 +1010,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_commandHistoryIndex = m_commandHistory.size() - 1;
|
m_commandHistoryIndex = m_commandHistory.size() - 1;
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == '/' || key == '?') {
|
} else if (key == '/' || key == '?') {
|
||||||
enterExMode(); // to get the cursor disabled
|
emit q->findRequested(key == '?');
|
||||||
m_mode = (key == '/') ? SearchForwardMode : SearchBackwardMode;
|
|
||||||
m_commandBuffer.clear();
|
|
||||||
m_searchHistory.append(QString());
|
|
||||||
m_searchHistoryIndex = m_searchHistory.size() - 1;
|
|
||||||
updateMiniBuffer();
|
|
||||||
} else if (key == '`') {
|
} else if (key == '`') {
|
||||||
m_subsubmode = BackTickSubSubMode;
|
m_subsubmode = BackTickSubSubMode;
|
||||||
} else if (key == '#' || key == '*') {
|
} else if (key == '#' || key == '*') {
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ signals:
|
|||||||
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
|
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
|
||||||
void completionRequested();
|
void completionRequested();
|
||||||
void windowCommandRequested(int key);
|
void windowCommandRequested(int key);
|
||||||
|
void findRequested(bool reverse);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Private;
|
class Private;
|
||||||
|
|||||||
@@ -56,6 +56,8 @@
|
|||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <texteditor/textblockiterator.h>
|
#include <texteditor/textblockiterator.h>
|
||||||
|
|
||||||
|
#include <find/textfindconstants.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/savedaction.h>
|
#include <utils/savedaction.h>
|
||||||
|
|
||||||
@@ -232,6 +234,7 @@ private slots:
|
|||||||
void quitFakeVim();
|
void quitFakeVim();
|
||||||
void triggerCompletions();
|
void triggerCompletions();
|
||||||
void windowCommand(int key);
|
void windowCommand(int key);
|
||||||
|
void find(bool reverse);
|
||||||
void showSettingsDialog();
|
void showSettingsDialog();
|
||||||
|
|
||||||
void showCommandBuffer(const QString &contents);
|
void showCommandBuffer(const QString &contents);
|
||||||
@@ -246,6 +249,8 @@ private:
|
|||||||
FakeVimPlugin *q;
|
FakeVimPlugin *q;
|
||||||
FakeVimOptionPage *m_fakeVimOptionsPage;
|
FakeVimOptionPage *m_fakeVimOptionsPage;
|
||||||
QHash<Core::IEditor *, FakeVimHandler *> m_editorToHandler;
|
QHash<Core::IEditor *, FakeVimHandler *> m_editorToHandler;
|
||||||
|
|
||||||
|
void triggerAction(const QString& code);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -310,6 +315,17 @@ void FakeVimPluginPrivate::showSettingsDialog()
|
|||||||
Core::ICore::instance()->showOptionsDialog("FakeVim", "General");
|
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)
|
void FakeVimPluginPrivate::windowCommand(int key)
|
||||||
{
|
{
|
||||||
#define control(n) (256 + n)
|
#define control(n) (256 + n)
|
||||||
@@ -341,13 +357,13 @@ void FakeVimPluginPrivate::windowCommand(int key)
|
|||||||
qDebug() << "UNKNOWN WINDOWS COMMAND: " << key;
|
qDebug() << "UNKNOWN WINDOWS COMMAND: " << key;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Core::ActionManager *am = Core::ICore::instance()->actionManager();
|
triggerAction(code);
|
||||||
QTC_ASSERT(am, return);
|
}
|
||||||
Core::Command *cmd = am->command(code);
|
|
||||||
QTC_ASSERT(cmd, return);
|
void FakeVimPluginPrivate::find(bool reverse)
|
||||||
QAction *action = cmd->action();
|
{
|
||||||
QTC_ASSERT(action, return);
|
Q_UNUSED(reverse); // TODO: Creator needs an action for find in reverse.
|
||||||
action->trigger();
|
triggerAction(Find::Constants::FIND_IN_DOCUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
||||||
@@ -387,6 +403,8 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
|||||||
this, SLOT(triggerCompletions()));
|
this, SLOT(triggerCompletions()));
|
||||||
connect(handler, SIGNAL(windowCommandRequested(int)),
|
connect(handler, SIGNAL(windowCommandRequested(int)),
|
||||||
this, SLOT(windowCommand(int)));
|
this, SLOT(windowCommand(int)));
|
||||||
|
connect(handler, SIGNAL(findRequested(bool)),
|
||||||
|
this, SLOT(find(bool)));
|
||||||
|
|
||||||
handler->setCurrentFileName(editor->file()->fileName());
|
handler->setCurrentFileName(editor->file()->fileName());
|
||||||
handler->installEventFilter();
|
handler->installEventFilter();
|
||||||
|
|||||||
Reference in New Issue
Block a user