- enhancement: add "wrap around" option to find/replace

This commit is contained in:
Roy Qu 2022-01-13 12:55:55 +08:00
parent a3e4f333ab
commit bab728e792
7 changed files with 70 additions and 30 deletions

View File

@ -16,6 +16,7 @@ Red Panda C++ Version 0.13.2
- fix: parser can't correctly handle function parameters like 'int *x'
- fix: caret dispears when at '\t' under Windows 7
- enhancement: ctrl+up/down scrolls in the editor
- enhancement: add "wrap around" option to find/replace
Red Panda C++ Version 0.13.1
- enhancement: suppoort localization info in project templates

Binary file not shown.

View File

@ -1247,40 +1247,40 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="3073"/>
<location filename="editor.cpp" line="3112"/>
<location filename="editor.cpp" line="3163"/>
<location filename="editor.cpp" line="3072"/>
<location filename="editor.cpp" line="3111"/>
<location filename="editor.cpp" line="3162"/>
<source>Ctrl+click for more info</source>
<translation>Ctrl+</translation>
</message>
<message>
<location filename="editor.cpp" line="3550"/>
<location filename="editor.cpp" line="3580"/>
<location filename="editor.cpp" line="3549"/>
<location filename="editor.cpp" line="3579"/>
<source>Symbol &apos;%1&apos; not found!</source>
<translation>&apos;%1&apos;!</translation>
</message>
<message>
<location filename="editor.cpp" line="3873"/>
<location filename="editor.cpp" line="3872"/>
<source>astyle not found</source>
<translation>astyle程序</translation>
</message>
<message>
<location filename="editor.cpp" line="3874"/>
<location filename="editor.cpp" line="3873"/>
<source>Can&apos;t find astyle in &quot;%1&quot;.</source>
<translation>astyle程序&quot;%1&quot;.</translation>
</message>
<message>
<location filename="editor.cpp" line="4019"/>
<location filename="editor.cpp" line="4018"/>
<source>Break point condition</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="4020"/>
<location filename="editor.cpp" line="4019"/>
<source>Enter the condition of the breakpoint:</source>
<translation>:</translation>
</message>
<message>
<location filename="editor.cpp" line="4230"/>
<location filename="editor.cpp" line="4229"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -6614,88 +6614,93 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="131"/>
<source>Wrap Around</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="141"/>
<source>Regular Expression</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="138"/>
<location filename="widgets/searchdialog.ui" line="148"/>
<source>Prompt on replace</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="151"/>
<location filename="widgets/searchdialog.ui" line="161"/>
<source>Scope:</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="157"/>
<location filename="widgets/searchdialog.ui" line="167"/>
<source>Global</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="164"/>
<location filename="widgets/searchdialog.ui" line="174"/>
<source>Selection</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="174"/>
<location filename="widgets/searchdialog.ui" line="184"/>
<source>Origin:</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="180"/>
<location filename="widgets/searchdialog.ui" line="190"/>
<source>From cursor</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="190"/>
<location filename="widgets/searchdialog.ui" line="200"/>
<source>Entire scope</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="218"/>
<location filename="widgets/searchdialog.ui" line="228"/>
<source>Direction:</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="224"/>
<location filename="widgets/searchdialog.ui" line="234"/>
<source>Forward</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="234"/>
<location filename="widgets/searchdialog.ui" line="244"/>
<source>Backward</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="257"/>
<location filename="widgets/searchdialog.ui" line="267"/>
<source>Where:</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="263"/>
<location filename="widgets/searchdialog.ui" line="273"/>
<source>Current File</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="273"/>
<location filename="widgets/searchdialog.ui" line="283"/>
<source>Files In Project</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="280"/>
<location filename="widgets/searchdialog.ui" line="290"/>
<source>Open Files</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="347"/>
<location filename="widgets/searchdialog.ui" line="357"/>
<location filename="widgets/searchdialog.cpp" line="37"/>
<location filename="widgets/searchdialog.cpp" line="150"/>
<location filename="widgets/searchdialog.cpp" line="151"/>
<source>Find</source>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.ui" line="354"/>
<location filename="widgets/searchdialog.ui" line="364"/>
<source>Cancel</source>
<translation></translation>
</message>
@ -6706,8 +6711,8 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="widgets/searchdialog.cpp" line="39"/>
<location filename="widgets/searchdialog.cpp" line="152"/>
<location filename="widgets/searchdialog.cpp" line="259"/>
<location filename="widgets/searchdialog.cpp" line="153"/>
<location filename="widgets/searchdialog.cpp" line="263"/>
<source>Replace</source>
<translation></translation>
</message>
@ -6717,7 +6722,7 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.cpp" line="260"/>
<location filename="widgets/searchdialog.cpp" line="264"/>
<source>Replace this occurrence of &apos;&apos;%1&apos;&apos;?</source>
<translation>&quot;%1&quot;</translation>
</message>

View File

@ -26,6 +26,7 @@ enum SynSearchOption {
ssoBackwards = 0x0004,
ssoEntireScope = 0x0008,
ssoSelectedOnly = 0x0010,
ssoWrapAround = 0x0020,
ssoRegExp = 0x0080
};

View File

@ -4907,6 +4907,7 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
else
ptCurrent = ptStart;
}
BufferCoord originCaretXY=caretXY();
// initialize the search engine
searchEngine->setOptions(sOptions);
searchEngine->setPattern(sSearch);
@ -5015,6 +5016,23 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
ptCurrent.Line--;
else
ptCurrent.Line++;
if (
((ptCurrent.Line < ptStart.Line) || (ptCurrent.Line > ptEnd.Line))
&& bFromCursor){
//search start from cursor, search has finished but no result founds
bFromCursor = false;
ptStart.Char = 1;
ptStart.Line = 1;
ptEnd.Line = mLines->count();
ptEnd.Char = mLines->getString(ptEnd.Line - 1).length();
if (bBackward) {
ptStart = originCaretXY;
ptCurrent = ptEnd;
} else {
ptEnd= originCaretXY;
ptCurrent = ptStart;
}
}
}
}
return result;

View File

@ -103,6 +103,7 @@ void SearchDialog::findInFiles(const QString &keyword, SearchFileScope scope, Sy
ui->chkRegExp->setChecked(options.testFlag(ssoRegExp));
ui->chkCaseSensetive->setChecked(options.testFlag(ssoMatchCase));
ui->chkWholeWord->setChecked(options.testFlag(ssoWholeWord));
ui->chkWrapAround->setChecked(options.testFlag(ssoWholeWord));
show();
}
@ -145,6 +146,7 @@ void SearchDialog::onTabChanged()
// Disable prompt when doing finds
ui->chkPrompt->setEnabled(isreplace);
ui->chkWrapAround->setEnabled(!isfindfiles);
if (isfind || isfindfiles) {
ui->btnExecute->setText(tr("Find"));
@ -212,6 +214,9 @@ void SearchDialog::on_btnExecute_clicked()
if (ui->chkWholeWord->isChecked()) {
mSearchOptions.setFlag(ssoWholeWord);
}
if (ui->chkWrapAround->isChecked()) {
mSearchOptions.setFlag(ssoWrapAround);
}
// Apply scope, when enabled
if (ui->grpScope->isEnabled()) {

View File

@ -132,6 +132,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkWrapAround">
<property name="text">
<string>Wrap Around</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkPrompt">
<property name="text">