From bab728e79204dbdc7b43debddd8366fe79ca301d Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 13 Jan 2022 12:55:55 +0800 Subject: [PATCH] - enhancement: add "wrap around" option to find/replace --- NEWS.md | 1 + RedPandaIDE/RedPandaIDE_zh_CN.qm | Bin 110777 -> 110837 bytes RedPandaIDE/RedPandaIDE_zh_CN.ts | 65 ++++++++++++++------------- RedPandaIDE/qsynedit/SearchBase.h | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 18 ++++++++ RedPandaIDE/widgets/searchdialog.cpp | 5 +++ RedPandaIDE/widgets/searchdialog.ui | 10 +++++ 7 files changed, 70 insertions(+), 30 deletions(-) diff --git a/NEWS.md b/NEWS.md index 33850b33..a1fbb23a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 1961990820c1eb7881ed69bdc16eb584d01cd4df..6fb3940ae753c06678367dfad36d17b34f455858 100644 GIT binary patch delta 1223 zcmXApeQZ-@6voeU`*Cl(wY3}T-DfWp*xf`ZM4%Fg7g1I)gc^b=^05mYYhlQW8>5J@ zqQi}tz#Ipupg1JcDPbuvNx^_iAZ&glE=Hsf{{Z61Aebx!5MxN@%{a+>e(#&Sf1Ete zIp_Rs>*L$jkG*x&P*N)*V8hZPnz*a}*Yx@Yh z@9?k?be|*3^o4}Acb{?V3D!(rA!=pa6vrAKG{xM_^g_o)qVMO^)MFb7El)XU4&e<> znH9|9j5&w_9yQCTV%bt9)OuLAWGC#RRnZp-=9*`$^U&&+vxK+iKI5)E9JXqBz$t4A z-?3jz;T8{w8cwk&DfpaKDTKwGk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;HV)_SF>@cz?-jP*;EqXQ_y&e1$ta&G&C8ujboQY1!oxAbGs~n! z?QaoQ*GjMSuOiZ}N;ONu1miZl3UqIg)Oc($A$y;+wtq3vj)DoIIm*oiqp-5!3!80E z_%!cxj+|fXiH;OHa<5s4p00PuSJDV8lk8H0W`lG^!A_1S)k5ukjw_Wy-A%ru7|39~ zuu^Eb%hAFZ_7BKKDzJq$zk*^m{H0RlkBnXW4-sk}a<{)iSbdq3{s3G&>hHkI94Xe3 z&++0orm|6@xeGIE(?QgkoFJO6alAx^lP{HYqlLp$B535~lv1J7JU(T+u;m+$l 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 - - + + Symbol '%1' not found! 未找到符号'%1'! - + astyle not found 找不到astyle程序 - + Can't find astyle in "%1". 找不到astyle程序"%1". - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -6614,88 +6614,93 @@ Are you really want to continue? + Wrap Around + 循环查找 + + + Regular Expression 正则表达式 - + Prompt on replace 替换时提示 - + Scope: 范围: - + Global 全局 - + Selection 选中文字 - + Origin: 起点: - + From cursor 从光标处 - + Entire scope 整个范围 - + Direction: 方向 - + Forward 向后 - + Backward 向前 - + Where: 在哪些文件中查找: - + Current File 当前文件 - + Files In Project 项目中的文件 - + Open Files 已打开的文件 - + - + Find 查找 - + Cancel 取消 @@ -6706,8 +6711,8 @@ Are you really want to continue? - - + + Replace 替换 @@ -6717,7 +6722,7 @@ Are you really want to continue? 在文件中替换 - + Replace this occurrence of ''%1''? 替换这里的"%1"? diff --git a/RedPandaIDE/qsynedit/SearchBase.h b/RedPandaIDE/qsynedit/SearchBase.h index cf66f8f3..e8d5e140 100644 --- a/RedPandaIDE/qsynedit/SearchBase.h +++ b/RedPandaIDE/qsynedit/SearchBase.h @@ -26,6 +26,7 @@ enum SynSearchOption { ssoBackwards = 0x0004, ssoEntireScope = 0x0008, ssoSelectedOnly = 0x0010, + ssoWrapAround = 0x0020, ssoRegExp = 0x0080 }; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index e6355598..b5cd9f41 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -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; diff --git a/RedPandaIDE/widgets/searchdialog.cpp b/RedPandaIDE/widgets/searchdialog.cpp index 3585dd5b..fb42d035 100644 --- a/RedPandaIDE/widgets/searchdialog.cpp +++ b/RedPandaIDE/widgets/searchdialog.cpp @@ -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()) { diff --git a/RedPandaIDE/widgets/searchdialog.ui b/RedPandaIDE/widgets/searchdialog.ui index b6880e60..27b46a66 100644 --- a/RedPandaIDE/widgets/searchdialog.ui +++ b/RedPandaIDE/widgets/searchdialog.ui @@ -132,6 +132,16 @@ + + + + Wrap Around + + + true + + +