Enhancement: add search options output to FiF Search-results

Fix #14306, close #14373
pull/14481/head
Alan Kilborn 1 year ago committed by Don Ho
parent bf37d4714f
commit e497ae2c06

@ -1720,6 +1720,11 @@ Find in all files but exclude all folders log or logs recursively:
<find-result-title value="Search"/><!-- Must not begin with space or tab character --> <find-result-title value="Search"/><!-- Must not begin with space or tab character -->
<find-result-title-info value="($INT_REPLACE1$ hits in $INT_REPLACE2$ files of $INT_REPLACE3$ searched)"/> <find-result-title-info value="($INT_REPLACE1$ hits in $INT_REPLACE2$ files of $INT_REPLACE3$ searched)"/>
<find-result-title-info-selections value="($INT_REPLACE1$ hits in $INT_REPLACE2$ selections of $INT_REPLACE3$ searched)"/> <find-result-title-info-selections value="($INT_REPLACE1$ hits in $INT_REPLACE2$ selections of $INT_REPLACE3$ searched)"/>
<find-result-title-info-options-searchmode-normal value="Normal"/>
<find-result-title-info-options-searchmode-extended value="Extended"/>
<find-result-title-info-options-searchmode-regexp value="RegEx"/>
<find-result-title-info-options-case value="Case"/>
<find-result-title-info-options-word value="Word"/>
<find-result-title-info-extra value=" - Line Filter Mode: only display the filtered results"/> <find-result-title-info-extra value=" - Line Filter Mode: only display the filtered results"/>
<find-result-hits value="($INT_REPLACE$ hits)"/> <find-result-hits value="($INT_REPLACE$ hits)"/>
<find-result-line-prefix value="Line"/><!-- Must not begin with space or tab character --> <find-result-line-prefix value="Line"/><!-- Must not begin with space or tab character -->

@ -2123,7 +2123,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
progress.close(); progress.close();
const bool searchedInSelection = false; 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); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
_pEditView = pOldView; _pEditView = pOldView;

@ -4696,7 +4696,7 @@ void Finder::addFileHitCount(int count)
++_nbFoundFiles; ++_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 nbResStr = std::to_wstring(count);
generic_string nbFoundFilesStr = std::to_wstring(_nbFoundFiles); 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); 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")); generic_string lineFilterModeInfo = pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-extra", TEXT(" - Line Filter Mode: only display the filtered results"));
text += lineFilterModeInfo; text += lineFilterModeInfo;
@ -4976,7 +5006,7 @@ void Finder::beginNewFilesSearch()
_scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, fold_collapse); _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<FoundInfo>* _pOldFoundInfos; std::vector<FoundInfo>* _pOldFoundInfos;
std::vector<SearchResultMarkingLine>* _pOldMarkings; std::vector<SearchResultMarkingLine>* _pOldMarkings;
@ -4994,7 +5024,7 @@ void Finder::finishFilesSearch(int count, int searchedCount, bool isMatchLines,
if (_pMainMarkings->size() > 0) if (_pMainMarkings->size() > 0)
_markingsStruct._markings = &((*_pMainMarkings)[0]); _markingsStruct._markings = &((*_pMainMarkings)[0]);
addSearchHitCount(count, searchedCount, isMatchLines, searchedEntireNotSelection); addSearchResultInfo(count, searchedCount, searchedEntireNotSelection, pFindOpt);
_scintView.execute(SCI_SETSEL, 0, 0); _scintView.execute(SCI_SETSEL, 0, 0);
//SCI_SETILEXER resets the lexer property @MarkingsStruct and then no data could be exchanged with the searchResult lexer //SCI_SETILEXER resets the lexer property @MarkingsStruct and then no data could be exchanged with the searchResult lexer

@ -82,7 +82,7 @@ struct FindOption
bool _isProjectPanel_2 = false; bool _isProjectPanel_2 = false;
bool _isProjectPanel_3 = false; bool _isProjectPanel_3 = false;
bool _dotMatchesNewline = 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 //This class contains generic search functions as static functions for easy access
@ -124,7 +124,7 @@ public:
void addSearchLine(const TCHAR *searchName); void addSearchLine(const TCHAR *searchName);
void addFileNameTitle(const TCHAR * fileName); void addFileNameTitle(const TCHAR * fileName);
void addFileHitCount(int count); 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); const char* foundLine(FoundInfo fi, SearchResultMarkingLine mi, const TCHAR* foundline, size_t totalLineNumber);
void setFinderStyle(); void setFinderStyle();
void setFinderStyleForNpc(bool onlyColor = false); void setFinderStyleForNpc(bool onlyColor = false);
@ -135,7 +135,7 @@ public:
void copy(); void copy();
void copyPathnames(); void copyPathnames();
void beginNewFilesSearch(); 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); void gotoNextFoundResult(int direction);
std::pair<intptr_t, intptr_t> gotoFoundLine(size_t nOccurrence = 0); // value 0 means this argument is not used std::pair<intptr_t, intptr_t> gotoFoundLine(size_t nOccurrence = 0); // value 0 means this argument is not used
@ -232,6 +232,7 @@ public:
FindInFinderDlg() { FindInFinderDlg() {
_options._isMatchCase = false; _options._isMatchCase = false;
_options._isWholeWord = false; _options._isWholeWord = false;
_options._isMatchLineNumber = true;
}; };
private: private:
@ -340,8 +341,7 @@ public :
void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection) void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection)
{ {
const bool isMatchLines = false; _pFinder->finishFilesSearch(count, searchedCount, searchedEntireNotSelection, _env);
_pFinder->finishFilesSearch(count, searchedCount, isMatchLines, searchedEntireNotSelection);
} }
void focusOnFinder() { void focusOnFinder() {

Loading…
Cancel
Save