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