From e497ae2c069ab7a82a3cd7b0da52e48233060c57 Mon Sep 17 00:00:00 2001 From: Alan Kilborn Date: Sun, 19 Nov 2023 12:27:21 -0500 Subject: [PATCH] Enhancement: add search options output to FiF Search-results Fix #14306, close #14373 --- PowerEditor/installer/nativeLang/english.xml | 5 +++ PowerEditor/src/Notepad_plus.cpp | 2 +- .../src/ScintillaComponent/FindReplaceDlg.cpp | 38 +++++++++++++++++-- .../src/ScintillaComponent/FindReplaceDlg.h | 10 ++--- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 17641599a7c..180d27f7fc4 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1720,6 +1720,11 @@ Find in all files but exclude all folders log or logs recursively: + + + + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index fd56ac18b7f..74554b522a3 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2123,7 +2123,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo) progress.close(); const bool searchedInSelection = false; - findInFolderInfo->_pDestFinder->finishFilesSearch(nbTotal, int(filesCount), findInFolderInfo->_findOption._isMatchLineNumber, !searchedInSelection); + findInFolderInfo->_pDestFinder->finishFilesSearch(nbTotal, int(filesCount), !searchedInSelection, &(findInFolderInfo->_findOption)); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); _pEditView = pOldView; diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index c6424f3d064..fddc26e1704 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -4696,7 +4696,7 @@ void Finder::addFileHitCount(int count) ++_nbFoundFiles; } -void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines, bool searchedEntireNotSelection) +void Finder::addSearchResultInfo(int count, int countSearched, bool searchedEntireNotSelection, const FindOption* pFindOpt) { generic_string nbResStr = std::to_wstring(count); generic_string nbFoundFilesStr = std::to_wstring(_nbFoundFiles); @@ -4735,7 +4735,37 @@ void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines, text = stringReplace(text, TEXT("$INT_REPLACE3$"), nbSearchedFilesStr); } - if (isMatchLines) + generic_string searchModeText; + if (pFindOpt->_searchType == FindExtended) + { + searchModeText += pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-options-searchmode-extended", TEXT("Extended")); + } + else if (pFindOpt->_searchType == FindRegex) + { + searchModeText += pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-options-searchmode-regexp", TEXT("RegEx")); + if (pFindOpt->_dotMatchesNewline) searchModeText += TEXT("."); + } + else + { + searchModeText += pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-options-searchmode-normal", TEXT("Normal")); + } + + generic_string searchOptionsText; + if (pFindOpt->_isMatchCase) + { + searchOptionsText += pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-options-case", TEXT("Case")); + } + if (pFindOpt->_isWholeWord) + { + if (!searchOptionsText.empty()) searchOptionsText += TEXT("/"); + searchOptionsText += pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-options-word", TEXT("Word")); + } + + if (!searchOptionsText.empty()) searchModeText += TEXT(": "); + + text += TEXT(" [") + searchModeText + searchOptionsText + TEXT("]"); + + if (pFindOpt->_isMatchLineNumber) { generic_string lineFilterModeInfo = pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-extra", TEXT(" - Line Filter Mode: only display the filtered results")); text += lineFilterModeInfo; @@ -4976,7 +5006,7 @@ void Finder::beginNewFilesSearch() _scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, fold_collapse); } -void Finder::finishFilesSearch(int count, int searchedCount, bool isMatchLines, bool searchedEntireNotSelection) +void Finder::finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection, const FindOption* pFindOpt) { std::vector* _pOldFoundInfos; std::vector* _pOldMarkings; @@ -4994,7 +5024,7 @@ void Finder::finishFilesSearch(int count, int searchedCount, bool isMatchLines, if (_pMainMarkings->size() > 0) _markingsStruct._markings = &((*_pMainMarkings)[0]); - addSearchHitCount(count, searchedCount, isMatchLines, searchedEntireNotSelection); + addSearchResultInfo(count, searchedCount, searchedEntireNotSelection, pFindOpt); _scintView.execute(SCI_SETSEL, 0, 0); //SCI_SETILEXER resets the lexer property @MarkingsStruct and then no data could be exchanged with the searchResult lexer diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 61fe824c4aa..3279907f3f9 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -82,7 +82,7 @@ struct FindOption bool _isProjectPanel_2 = false; bool _isProjectPanel_3 = false; bool _dotMatchesNewline = false; - bool _isMatchLineNumber = true; // only for Find in Folder + bool _isMatchLineNumber = false; // always false for main search }; //This class contains generic search functions as static functions for easy access @@ -124,7 +124,7 @@ friend class FindReplaceDlg; void addSearchLine(const TCHAR *searchName); void addFileNameTitle(const TCHAR * fileName); void addFileHitCount(int count); - void addSearchHitCount(int count, int countSearched, bool isMatchLines, bool searchedEntireNotSelection); + void addSearchResultInfo(int count, int countSearched, bool searchedEntireNotSelection, const FindOption *pFindOpt); const char* foundLine(FoundInfo fi, SearchResultMarkingLine mi, const TCHAR* foundline, size_t totalLineNumber); void setFinderStyle(); void setFinderStyleForNpc(bool onlyColor = false); @@ -135,7 +135,7 @@ friend class FindReplaceDlg; void copy(); void copyPathnames(); void beginNewFilesSearch(); - void finishFilesSearch(int count, int searchedCount, bool isMatchLines, bool searchedEntireNotSelection); + void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection, const FindOption *pFindOpt); void gotoNextFoundResult(int direction); std::pair gotoFoundLine(size_t nOccurrence = 0); // value 0 means this argument is not used @@ -232,6 +232,7 @@ class FindInFinderDlg : public StaticDialog FindInFinderDlg() { _options._isMatchCase = false; _options._isWholeWord = false; + _options._isMatchLineNumber = true; }; private: @@ -340,8 +341,7 @@ public : void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection) { - const bool isMatchLines = false; - _pFinder->finishFilesSearch(count, searchedCount, isMatchLines, searchedEntireNotSelection); + _pFinder->finishFilesSearch(count, searchedCount, searchedEntireNotSelection, _env); } void focusOnFinder() {