- fix: search around option can't be disabled

- enhancement: show a confirm dialog when search/replace around
This commit is contained in:
Roy Qu 2022-01-24 18:03:35 +08:00
parent c100c5c3e8
commit 1135fcf7dd
10 changed files with 116 additions and 43 deletions

View File

@ -22,6 +22,8 @@ Red Panda C++ Version 0.13.3
- fix: indent lines displayed at wrong position, when there are folded lines - fix: indent lines displayed at wrong position, when there are folded lines
- fix: if editor's active line color is disabled, caret's position may not be correct redrawn - fix: if editor's active line color is disabled, caret's position may not be correct redrawn
- fix: insert code snippets will crash, if current compiler set's include dir list is not empty and lib dir list is empty - fix: insert code snippets will crash, if current compiler set's include dir list is not empty and lib dir list is empty
- fix: search around option can't be disabled
- enhancement: show a confirm dialog when search/replace around
Red Panda C++ Version 0.13.2 Red Panda C++ Version 0.13.2
- fix: "delete and exit" button in the environtment / folder option page doesn't work correctly - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly

Binary file not shown.

View File

@ -773,9 +773,8 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.ui" line="141"/>
<source>Add Charset arguments when calling the compiler</source> <source>Add Charset arguments when calling the compiler</source>
<translation></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.ui" line="35"/> <location filename="settingsdialog/compilersetoptionwidget.ui" line="35"/>
@ -807,6 +806,12 @@ p, li { white-space: pre-wrap; }
<source>Remove</source> <source>Remove</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<location filename="settingsdialog/compilersetoptionwidget.ui" line="141"/>
<source>Convert Executable&apos;s Charset as</source>
<oldsource>Convert Executable&apos;s Charset</oldsource>
<translation></translation>
</message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.ui" line="157"/> <location filename="settingsdialog/compilersetoptionwidget.ui" line="157"/>
<source>Statically link libraries</source> <source>Statically link libraries</source>
@ -902,12 +907,12 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="285"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="283"/>
<source>Confirm</source> <source>Confirm</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="277"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="275"/>
<source>Red Panda C++ will clear current compiler list and search for compilers in the following locations:&lt;br /&gt; &apos;%1&apos;&lt;br /&gt; &apos;%2&apos;&lt;br /&gt;Are you really want to continue?</source> <source>Red Panda C++ will clear current compiler list and search for compilers in the following locations:&lt;br /&gt; &apos;%1&apos;&lt;br /&gt; &apos;%2&apos;&lt;br /&gt;Are you really want to continue?</source>
<oldsource>Red Panda C++ will clear current compiler list and search for compilers in the following locations: <oldsource>Red Panda C++ will clear current compiler list and search for compilers in the following locations:
&apos;%1&apos; &apos;%1&apos;
@ -916,50 +921,50 @@ Are you really want to continue?</oldsource>
<translation>C++ :&lt;br/&gt; &apos;%1&apos;&lt;br/&gt; &apos;%2&apos;&lt;br /&gt;</translation> <translation>C++ :&lt;br/&gt; &apos;%1&apos;&lt;br/&gt; &apos;%2&apos;&lt;br /&gt;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="65"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="64"/>
<source>ANSI</source> <source>ANSI</source>
<translation>ANSI</translation> <translation>ANSI</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="66"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="65"/>
<source>UTF-8</source> <source>UTF-8</source>
<translation>UTF-8</translation> <translation>UTF-8</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="282"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="280"/>
<source>Red Panda C++ will clear current compiler list and search for compilers in the the PATH. &lt;br /&gt;Are you really want to continue?</source> <source>Red Panda C++ will clear current compiler list and search for compilers in the the PATH. &lt;br /&gt;Are you really want to continue?</source>
<translation>C++ PATH路径中搜索gcc编译器.&lt;br /&gt;</translation> <translation>C++ PATH路径中搜索gcc编译器.&lt;br /&gt;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="293"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="291"/>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="317"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="315"/>
<source>Failed</source> <source>Failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="293"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="291"/>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="317"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="315"/>
<source>Can&apos;t find any compiler.</source> <source>Can&apos;t find any compiler.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="299"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="297"/>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="323"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="321"/>
<source>Compiler Set Name</source> <source>Compiler Set Name</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="299"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="297"/>
<source>Name</source> <source>Name</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="308"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="306"/>
<source>Compiler Set Folder</source> <source>Compiler Set Folder</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="323"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="321"/>
<source>New name</source> <source>New name</source>
<translation></translation> <translation></translation>
</message> </message>
@ -6027,6 +6032,26 @@ Are you really want to continue?</oldsource>
<source>Cannot find the %1 &quot;%2&quot;</source> <source>Cannot find the %1 &quot;%2&quot;</source>
<translation>%1&quot;%2&quot;</translation> <translation>%1&quot;%2&quot;</translation>
</message> </message>
<message>
<location filename="settings.cpp" line="1594"/>
<source>C Compiler</source>
<translation>C编译器</translation>
</message>
<message>
<location filename="settings.cpp" line="1599"/>
<source>C++ Compiler</source>
<translation>C++</translation>
</message>
<message>
<location filename="settings.cpp" line="1604"/>
<source>Maker</source>
<translation>(Make)</translation>
</message>
<message>
<location filename="settings.cpp" line="1609"/>
<source>Debugger</source>
<translation></translation>
</message>
<message> <message>
<location filename="settings.cpp" line="2137"/> <location filename="settings.cpp" line="2137"/>
<source>C options</source> <source>C options</source>
@ -6093,7 +6118,7 @@ Are you really want to continue?</oldsource>
<translation>(-g3)</translation> <translation>(-g3)</translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2631"/> <location filename="settings.cpp" line="2636"/>
<source>Would you like Red Panda C++ to search for compilers in PATH?</source> <source>Would you like Red Panda C++ to search for compilers in PATH?</source>
<translation>C++PATH路径中寻找gcc编译器吗</translation> <translation>C++PATH路径中寻找gcc编译器吗</translation>
</message> </message>
@ -6192,34 +6217,34 @@ Are you really want to continue?</oldsource>
<translation>(-S)</translation> <translation>(-S)</translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2592"/> <location filename="settings.cpp" line="2597"/>
<location filename="settings.cpp" line="2633"/> <location filename="settings.cpp" line="2638"/>
<source>Confirm</source> <source>Confirm</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2593"/> <location filename="settings.cpp" line="2598"/>
<source>The following problems were found during validation of compiler set &quot;%1&quot;:</source> <source>The following problems were found during validation of compiler set &quot;%1&quot;:</source>
<translation>&quot;%1&quot;</translation> <translation>&quot;%1&quot;</translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2597"/> <location filename="settings.cpp" line="2602"/>
<source>Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths?</source> <source>Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths?</source>
<translation>C++</translation> <translation>C++</translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2599"/> <location filename="settings.cpp" line="2604"/>
<source>Leaving those directories will lead to problems during compilation.&lt;br /&gt;&lt;br /&gt;Unless you know exactly what you&apos;re doing, it is recommended that you click Yes.</source> <source>Leaving those directories will lead to problems during compilation.&lt;br /&gt;&lt;br /&gt;Unless you know exactly what you&apos;re doing, it is recommended that you click Yes.</source>
<translation>&lt;br /&gt;&lt;br /&gt;</translation> <translation>&lt;br /&gt;&lt;br /&gt;</translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2623"/> <location filename="settings.cpp" line="2628"/>
<location filename="settings.cpp" line="2629"/> <location filename="settings.cpp" line="2634"/>
<source>Compiler set not configuared.</source> <source>Compiler set not configuared.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settings.cpp" line="2625"/> <location filename="settings.cpp" line="2630"/>
<source>Would you like Red Panda C++ to search for compilers in the following locations: &lt;BR /&gt;&apos;%1&apos;&lt;BR /&gt;&apos;%2&apos;? </source> <source>Would you like Red Panda C++ to search for compilers in the following locations: &lt;BR /&gt;&apos;%1&apos;&lt;BR /&gt;&apos;%2&apos;? </source>
<translation>C++&lt;br /&gt;%1&lt;br /&gt;%2</translation> <translation>C++&lt;br /&gt;%1&lt;br /&gt;%2</translation>
</message> </message>
@ -6244,13 +6269,13 @@ Are you really want to continue?</oldsource>
<translation>C++</translation> <translation>C++</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="112"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="111"/>
<location filename="settingsdialog/projectcompilerwidget.cpp" line="80"/> <location filename="settingsdialog/projectcompilerwidget.cpp" line="80"/>
<source>No</source> <source>No</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/compilersetoptionwidget.cpp" line="113"/> <location filename="settingsdialog/compilersetoptionwidget.cpp" line="112"/>
<location filename="settingsdialog/projectcompilerwidget.cpp" line="81"/> <location filename="settingsdialog/projectcompilerwidget.cpp" line="81"/>
<source>Yes</source> <source>Yes</source>
<translation></translation> <translation></translation>
@ -6753,7 +6778,7 @@ Are you really want to continue?</oldsource>
<message> <message>
<location filename="widgets/searchdialog.cpp" line="39"/> <location filename="widgets/searchdialog.cpp" line="39"/>
<location filename="widgets/searchdialog.cpp" line="154"/> <location filename="widgets/searchdialog.cpp" line="154"/>
<location filename="widgets/searchdialog.cpp" line="264"/> <location filename="widgets/searchdialog.cpp" line="272"/>
<source>Replace</source> <source>Replace</source>
<translation></translation> <translation></translation>
</message> </message>
@ -6763,10 +6788,36 @@ Are you really want to continue?</oldsource>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="widgets/searchdialog.cpp" line="265"/> <location filename="widgets/searchdialog.cpp" line="256"/>
<source>Continue Search</source>
<oldsource>Search Around</oldsource>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.cpp" line="257"/>
<location filename="widgets/searchdialog.cpp" line="294"/>
<source>End of file has been reached. </source>
<oldsource>End of file has been reached.</oldsource>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.cpp" line="258"/>
<location filename="widgets/searchdialog.cpp" line="295"/>
<source>Do you want to continue from file&apos;s beginning?</source>
<oldsource>Do you want to start from beginning?</oldsource>
<translation></translation>
</message>
<message>
<location filename="widgets/searchdialog.cpp" line="273"/>
<source>Replace this occurrence of &apos;&apos;%1&apos;&apos;?</source> <source>Replace this occurrence of &apos;&apos;%1&apos;&apos;?</source>
<translation>&quot;%1&quot;</translation> <translation>&quot;%1&quot;</translation>
</message> </message>
<message>
<location filename="widgets/searchdialog.cpp" line="293"/>
<source>Continue Replace</source>
<oldsource>Replace Around</oldsource>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>SearchResultListModel</name> <name>SearchResultListModel</name>
@ -7368,7 +7419,7 @@ Are you really want to continue?</oldsource>
<translation>&apos;%1&apos;!</translation> <translation>&apos;%1&apos;!</translation>
</message> </message>
<message> <message>
<location filename="qsynedit/TextBuffer.cpp" line="615"/> <location filename="qsynedit/TextBuffer.cpp" line="629"/>
<source>Can&apos;t open file &apos;%1&apos; for save!</source> <source>Can&apos;t open file &apos;%1&apos; for save!</source>
<translation>&apos;%2&apos;!</translation> <translation>&apos;%2&apos;!</translation>
</message> </message>

View File

@ -4755,7 +4755,7 @@ void SynEdit::doSetSelText(const QString &Value)
} }
int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynSearchOptions sOptions, PSynSearchBase searchEngine, int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynSearchOptions sOptions, PSynSearchBase searchEngine,
SynSearchMathedProc matchedCallback) SynSearchMathedProc matchedCallback, SynSearchConfirmAroundProc confirmAroundCallback)
{ {
if (!searchEngine) if (!searchEngine)
return 0; return 0;
@ -4917,9 +4917,10 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
ptCurrent.Line--; ptCurrent.Line--;
else else
ptCurrent.Line++; ptCurrent.Line++;
if ( if (((ptCurrent.Line < ptStart.Line) || (ptCurrent.Line > ptEnd.Line))
((ptCurrent.Line < ptStart.Line) || (ptCurrent.Line > ptEnd.Line)) && bFromCursor && sOptions.testFlag(ssoWrapAround)){
&& bFromCursor){ if (confirmAroundCallback && !confirmAroundCallback())
break;
//search start from cursor, search has finished but no result founds //search start from cursor, search has finished but no result founds
bFromCursor = false; bFromCursor = false;
ptStart.Char = 1; ptStart.Char = 1;

View File

@ -147,6 +147,7 @@ using SynPaintProc = std::function<void(const QPaintDevice& paintDevice )>;
// SynFontStyles& style, QColor& foreground, QColor& background)>; // SynFontStyles& style, QColor& foreground, QColor& background)>;
using SynSearchMathedProc = std::function<SynSearchAction(const QString& sSearch, using SynSearchMathedProc = std::function<SynSearchAction(const QString& sSearch,
const QString& sReplace, int Line, int ch, int wordLen)>; const QString& sReplace, int Line, int ch, int wordLen)>;
using SynSearchConfirmAroundProc = std::function<bool ()>;
class SynEdit; class SynEdit;
using PSynEdit = std::shared_ptr<SynEdit>; using PSynEdit = std::shared_ptr<SynEdit>;
@ -244,7 +245,8 @@ public:
void setSelText(const QString& text); void setSelText(const QString& text);
int searchReplace(const QString& sSearch, const QString& sReplace, SynSearchOptions options, int searchReplace(const QString& sSearch, const QString& sReplace, SynSearchOptions options,
PSynSearchBase searchEngine, SynSearchMathedProc matchedCallback = nullptr); PSynSearchBase searchEngine, SynSearchMathedProc matchedCallback = nullptr,
SynSearchConfirmAroundProc confirmAroundCallback = nullptr);
int maxScrollWidth() const; int maxScrollWidth() const;
int maxScrollHeight() const; int maxScrollHeight() const;

View File

@ -720,7 +720,6 @@ void SynEditTextPainter::PaintFoldAttributes()
// Now loop through all the lines. The indices are valid for Lines. // Now loop through all the lines. The indices are valid for Lines.
for (cRow = aFirstRow; cRow<=aLastRow;cRow++) { for (cRow = aFirstRow; cRow<=aLastRow;cRow++) {
vLine = edit->rowToLine(cRow); vLine = edit->rowToLine(cRow);
qDebug()<<cRow<<vLine;
if (vLine > edit->mLines->count() && edit->mLines->count() > 0) if (vLine > edit->mLines->count() && edit->mLines->count() > 0)
break; break;
// Set vertical coord // Set vertical coord

View File

@ -59,7 +59,6 @@ CompilerSetOptionWidget::~CompilerSetOptionWidget()
void CompilerSetOptionWidget::init() void CompilerSetOptionWidget::init()
{ {
ui->cbEncoding->setVisible(false);
ui->cbEncodingDetails->setVisible(false); ui->cbEncodingDetails->setVisible(false);
ui->cbEncoding->clear(); ui->cbEncoding->clear();
ui->cbEncoding->addItem(tr("ANSI"),ENCODING_SYSTEM_DEFAULT); ui->cbEncoding->addItem(tr("ANSI"),ENCODING_SYSTEM_DEFAULT);
@ -144,7 +143,6 @@ static void loadCompilerSetSettings(Settings::PCompilerSet pSet, Ui::CompilerSet
ui->txtResourceCompiler->setText(pSet->resourceCompiler()); ui->txtResourceCompiler->setText(pSet->resourceCompiler());
ui->txtProfiler->setText(pSet->profiler()); ui->txtProfiler->setText(pSet->profiler());
ui->cbEncoding->setVisible(pSet->autoAddCharsetParams());
if (pSet->execCharset() == ENCODING_AUTO_DETECT if (pSet->execCharset() == ENCODING_AUTO_DETECT
|| pSet->execCharset() == ENCODING_SYSTEM_DEFAULT || pSet->execCharset() == ENCODING_SYSTEM_DEFAULT
|| pSet->execCharset() == ENCODING_UTF8) { || pSet->execCharset() == ENCODING_UTF8) {

View File

@ -138,7 +138,7 @@
<item> <item>
<widget class="QCheckBox" name="chkAutoAddCharset"> <widget class="QCheckBox" name="chkAutoAddCharset">
<property name="text"> <property name="text">
<string>Convert Executable's Charset</string> <string>Convert Executable's Charset as</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -250,7 +250,15 @@ void SearchDialog::on_btnExecute_clicked()
if (actionType == SearchAction::Find) { if (actionType == SearchAction::Find) {
Editor *e = pMainWindow->editorList()->getEditor(); Editor *e = pMainWindow->editorList()->getEditor();
if (e!=nullptr) { if (e!=nullptr) {
findCount+=execute(e,ui->cbFind->currentText(),""); findCount+=execute(e,ui->cbFind->currentText(),"",nullptr,
[](){
return QMessageBox::question(pMainWindow,
tr("Continue Search"),
tr("End of file has been reached. ")
+tr("Do you want to continue from file's beginning?"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes) == QMessageBox::Yes;
});
} }
} else if (actionType == SearchAction::Replace) { } else if (actionType == SearchAction::Replace) {
Editor *e = pMainWindow->editorList()->getEditor(); Editor *e = pMainWindow->editorList()->getEditor();
@ -279,6 +287,14 @@ void SearchDialog::on_btnExecute_clicked()
} else { } else {
return SynSearchAction::ReplaceAll; return SynSearchAction::ReplaceAll;
} }
},
[](){
return QMessageBox::question(pMainWindow,
tr("Continue Replace"),
tr("End of file has been reached. ")
+tr("Do you want to continue from file's beginning?"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes) == QMessageBox::Yes;
}); });
} }
@ -376,7 +392,9 @@ void SearchDialog::on_btnExecute_clicked()
} }
} }
int SearchDialog::execute(SynEdit *editor, const QString &sSearch, const QString &sReplace, SynSearchMathedProc matchCallback) int SearchDialog::execute(SynEdit *editor, const QString &sSearch, const QString &sReplace,
SynSearchMathedProc matchCallback,
SynSearchConfirmAroundProc confirmAroundCallback)
{ {
if (editor==nullptr) if (editor==nullptr)
return 0; return 0;
@ -398,7 +416,7 @@ int SearchDialog::execute(SynEdit *editor, const QString &sSearch, const QString
} }
return editor->searchReplace(sSearch, sReplace, mSearchOptions, return editor->searchReplace(sSearch, sReplace, mSearchOptions,
mSearchEngine, matchCallback); mSearchEngine, matchCallback, confirmAroundCallback);
} }
std::shared_ptr<SearchResultTreeItem> SearchDialog::batchFindInEditor(SynEdit *e, const QString& filename,const QString &keyword) std::shared_ptr<SearchResultTreeItem> SearchDialog::batchFindInEditor(SynEdit *e, const QString& filename,const QString &keyword)

View File

@ -61,7 +61,9 @@ private slots:
void on_btnExecute_clicked(); void on_btnExecute_clicked();
private: private:
int execute(SynEdit* editor, const QString& sSearch, int execute(SynEdit* editor, const QString& sSearch,
const QString& sReplace, SynSearchMathedProc matchCallback = nullptr); const QString& sReplace,
SynSearchMathedProc matchCallback = nullptr,
SynSearchConfirmAroundProc confirmAroundCallback = nullptr);
std::shared_ptr<SearchResultTreeItem> batchFindInEditor(SynEdit * editor,const QString& filename, const QString& keyword); std::shared_ptr<SearchResultTreeItem> batchFindInEditor(SynEdit * editor,const QString& filename, const QString& keyword);
private: private:
Ui::SearchDialog *ui; Ui::SearchDialog *ui;