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

fakevim: implement incremental backward search '?' using Find plugin



Merge-request: 97
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent 474d883e
......@@ -103,7 +103,6 @@ public:
m_incrementalStartPos = m_editor->selectionStart();
if (m_contPos == -1)
m_contPos = m_incrementalStartPos;
findFlags &= ~Find::IFindSupport::FindBackward;
int found = find(pattern, m_contPos, findFlags);
Result result;
if (found >= 0) {
......
......@@ -416,10 +416,12 @@ void FakeVimPluginPrivate::windowCommand(int key)
void FakeVimPluginPrivate::find(bool reverse)
{
Q_UNUSED(reverse) // TODO: Creator needs an action for find in reverse.
if (Find::Internal::FindPlugin::instance())
Find::Internal::FindPlugin::instance()->setUseFakeVim(true);
triggerAction(Find::Constants::FIND_IN_DOCUMENT);
if (Find::Internal::FindPlugin *plugin = Find::Internal::FindPlugin::instance()) {
plugin->setUseFakeVim(true);
plugin->openFindToolBar(reverse
? Find::Internal::FindPlugin::FindBackward
: Find::Internal::FindPlugin::FindForward);
}
}
void FakeVimPluginPrivate::findNext(bool reverse)
......
......@@ -132,7 +132,6 @@ IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, IFindSupp
if (m_incrementalStartPos < 0)
m_incrementalStartPos = cursor.selectionStart();
cursor.setPosition(m_incrementalStartPos);
findFlags &= ~IFindSupport::FindBackward;
bool found = find(txt, findFlags, cursor);
if (found)
emit highlightAll(txt, findFlags);
......
......@@ -314,4 +314,12 @@ void FindPlugin::setUseFakeVim(bool on)
m_findToolBar->setUseFakeVim(on);
}
void FindPlugin::openFindToolBar(FindDirection direction)
{
if (m_findToolBar) {
m_findToolBar->setBackward(direction == FindBackward);
m_findToolBar->openFindToolBar();
}
}
Q_EXPORT_PLUGIN(FindPlugin)
......@@ -56,6 +56,11 @@ public:
virtual ~FindPlugin();
static FindPlugin *instance();
enum FindDirection {
FindForward,
FindBackward
};
// IPlugin
bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized();
......@@ -67,6 +72,7 @@ public:
QStringListModel *findCompletionModel() { return m_findCompletionModel; }
QStringListModel *replaceCompletionModel() { return m_replaceCompletionModel; }
void setUseFakeVim(bool on);
void openFindToolBar(FindDirection direction);
public slots:
void setCaseSensitive(bool sensitive);
......
......@@ -571,6 +571,12 @@ Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const
}
void FindToolBar::openFind()
{
setBackward(false);
openFindToolBar();
}
void FindToolBar::openFindToolBar()
{
if (!m_currentDocumentFind->candidateIsEnabled())
return;
......@@ -676,3 +682,8 @@ void FindToolBar::setRegularExpressions(bool regexp)
{
setFindFlag(IFindSupport::FindRegularExpression, regexp);
}
void FindToolBar::setBackward(bool backward)
{
setFindFlag(IFindSupport::FindBackward, backward);
}
......@@ -50,6 +50,7 @@ class FindPlugin;
class FindToolBar : public Utils::StyledBar
{
friend class FindPlugin;
Q_OBJECT
public:
......@@ -86,6 +87,7 @@ private slots:
void setCaseSensitive(bool sensitive);
void setWholeWord(bool wholeOnly);
void setRegularExpressions(bool regexp);
void setBackward(bool backward);
void adaptToCandidate();
......@@ -93,6 +95,7 @@ protected:
bool focusNextPrevChild(bool next);
private:
void openFindToolBar();
void invokeClearResults();
bool setFocusToCurrentFindSupport();
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
......
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