Add ability to avoid accumulating multiple search results

Fix #8777, close #9653
pull/9764/head
Scott Sumner 4 years ago committed by Don HO
parent da61b1d949
commit 874f0d0140

@ -1360,6 +1360,7 @@ Find in all files except exe, obj && log:
<finder-select-all value="Select all"/> <finder-select-all value="Select all"/>
<finder-clear-all value="Clear all"/> <finder-clear-all value="Clear all"/>
<finder-open-all value="Open all"/> <finder-open-all value="Open all"/>
<finder-purge-for-every-search value="Purge for every search"/>
<finder-wrap-long-lines value="Word wrap long lines"/> <finder-wrap-long-lines value="Word wrap long lines"/>
<common-ok value="OK"/> <common-ok value="OK"/>
<common-cancel value="Cancel"/> <common-cancel value="Cancel"/>

@ -4682,6 +4682,11 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
{ {
_nppGUI._finderLinesAreCurrentlyWrapped = (!lstrcmp(val, TEXT("yes"))); _nppGUI._finderLinesAreCurrentlyWrapped = (!lstrcmp(val, TEXT("yes")));
} }
val = element->Attribute(TEXT("purgeBeforeEverySearch"));
if (val)
{
_nppGUI._finderPurgeBeforeEverySearch = (!lstrcmp(val, TEXT("yes")));
}
} }
else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings"))) else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings")))
@ -5926,12 +5931,14 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("bottom"), _nppGUI._findWindowPos.bottom); GUIConfigElement->SetAttribute(TEXT("bottom"), _nppGUI._findWindowPos.bottom);
} }
// <GUIConfig name="FinderConfig" wrappedLines="no" /> // <GUIConfig name="FinderConfig" wrappedLines="no" purgeBeforeEverySearch="no"/>
{ {
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("FinderConfig")); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("FinderConfig"));
const TCHAR* pStr = _nppGUI._finderLinesAreCurrentlyWrapped ? TEXT("yes") : TEXT("no"); const TCHAR* pStr = _nppGUI._finderLinesAreCurrentlyWrapped ? TEXT("yes") : TEXT("no");
GUIConfigElement->SetAttribute(TEXT("wrappedLines"), pStr); GUIConfigElement->SetAttribute(TEXT("wrappedLines"), pStr);
pStr = _nppGUI._finderPurgeBeforeEverySearch ? TEXT("yes") : TEXT("no");
GUIConfigElement->SetAttribute(TEXT("purgeBeforeEverySearch"), pStr);
} }
// <GUIConfig name="noUpdate" intervalDays="15" nextUpdateDate="20161022">no</GUIConfig> // <GUIConfig name="noUpdate" intervalDays="15" nextUpdateDate="20161022">no</GUIConfig>

@ -801,6 +801,7 @@ struct NppGUI final
bool _tabReplacedBySpace = false; bool _tabReplacedBySpace = false;
bool _finderLinesAreCurrentlyWrapped = false; bool _finderLinesAreCurrentlyWrapped = false;
bool _finderPurgeBeforeEverySearch = false;
int _fileAutoDetection = cdEnabledNew; int _fileAutoDetection = cdEnabledNew;

@ -2498,6 +2498,8 @@ void FindReplaceDlg::findAllIn(InWhat op)
_pFinder->_scintView.setWrapMode(LINEWRAP_INDENT); _pFinder->_scintView.setWrapMode(LINEWRAP_INDENT);
_pFinder->_scintView.showWrapSymbol(true); _pFinder->_scintView.showWrapSymbol(true);
_pFinder->_purgeBeforeEverySearch = nppGUI._finderPurgeBeforeEverySearch;
// allow user to start selecting as a stream block, then switch to a column block by adding Alt keypress // allow user to start selecting as a stream block, then switch to a column block by adding Alt keypress
_pFinder->_scintView.execute(SCI_SETMOUSESELECTIONRECTANGULARSWITCH, true); _pFinder->_scintView.execute(SCI_SETMOUSESELECTIONRECTANGULARSWITCH, true);
@ -2516,6 +2518,11 @@ void FindReplaceDlg::findAllIn(InWhat op)
} }
_pFinder->setFinderStyle(); _pFinder->setFinderStyle();
if (_pFinder->_purgeBeforeEverySearch)
{
_pFinder->removeAll();
}
if (justCreated) if (justCreated)
{ {
// Send the address of _MarkingsStruct to the lexer // Send the address of _MarkingsStruct to the lexer
@ -3910,6 +3917,19 @@ void Finder::wrapLongLinesToggle()
} }
} }
void Finder::purgeToggle()
{
_purgeBeforeEverySearch = !_purgeBeforeEverySearch;
if (!_canBeVolatiled)
{
// only remember this setting from the original finder
NppParameters& nppParam = NppParameters::getInstance();
NppGUI& nppGUI = const_cast<NppGUI&>(nppParam.getNppGUI());
nppGUI._finderPurgeBeforeEverySearch = _purgeBeforeEverySearch;
}
}
bool Finder::isLineActualSearchResult(const generic_string & s) const bool Finder::isLineActualSearchResult(const generic_string & s) const
{ {
// actual-search-result lines are the only type that start with a tab character // actual-search-result lines are the only type that start with a tab character
@ -4159,6 +4179,12 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
} }
case NPPM_INTERNAL_SCINTILLAFINDERPURGE:
{
purgeToggle();
return TRUE;
}
default : default :
{ {
return FALSE; return FALSE;
@ -4185,6 +4211,7 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
generic_string copyVerbatim = pNativeSpeaker->getLocalizedStrFromID("finder-copy-verbatim", TEXT("Copy")); generic_string copyVerbatim = pNativeSpeaker->getLocalizedStrFromID("finder-copy-verbatim", TEXT("Copy"));
generic_string selectAll = pNativeSpeaker->getLocalizedStrFromID("finder-select-all", TEXT("Select all")); generic_string selectAll = pNativeSpeaker->getLocalizedStrFromID("finder-select-all", TEXT("Select all"));
generic_string clearAll = pNativeSpeaker->getLocalizedStrFromID("finder-clear-all", TEXT("Clear all")); generic_string clearAll = pNativeSpeaker->getLocalizedStrFromID("finder-clear-all", TEXT("Clear all"));
generic_string purgeForEverySearch = pNativeSpeaker->getLocalizedStrFromID("finder-purge-for-every-search", TEXT("Purge for every search"));
generic_string openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-all", TEXT("Open all")); generic_string openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-all", TEXT("Open all"));
generic_string wrapLongLines = pNativeSpeaker->getLocalizedStrFromID("finder-wrap-long-lines", TEXT("Word wrap long lines")); generic_string wrapLongLines = pNativeSpeaker->getLocalizedStrFromID("finder-wrap-long-lines", TEXT("Word wrap long lines"));
@ -4201,12 +4228,17 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, clearAll)); tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, clearAll));
tmp.push_back(MenuItemUnit(0, TEXT("Separator"))); tmp.push_back(MenuItemUnit(0, TEXT("Separator")));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDEROPENALL, openAll)); tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDEROPENALL, openAll));
// configuration items go at the bottom:
tmp.push_back(MenuItemUnit(0, TEXT("Separator"))); tmp.push_back(MenuItemUnit(0, TEXT("Separator")));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERWRAP, wrapLongLines)); tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERWRAP, wrapLongLines));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERPURGE, purgeForEverySearch));
scintillaContextmenu.create(_hSelf, tmp); scintillaContextmenu.create(_hSelf, tmp);
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, !_canBeVolatiled); scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, !_canBeVolatiled);
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERPURGE, !_canBeVolatiled);
scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERPURGE, _purgeBeforeEverySearch && !_canBeVolatiled);
scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERWRAP, _longLinesAreWrapped); scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERWRAP, _longLinesAreWrapped);

@ -124,6 +124,7 @@ public:
void removeAll(); void removeAll();
void openAll(); void openAll();
void wrapLongLinesToggle(); void wrapLongLinesToggle();
void purgeToggle();
void copy(); void copy();
void beginNewFilesSearch(); void beginNewFilesSearch();
void finishFilesSearch(int count, int searchedCount, bool isMatchLines, bool searchedEntireNotSelection); void finishFilesSearch(int count, int searchedCount, bool isMatchLines, bool searchedEntireNotSelection);
@ -160,6 +161,7 @@ private:
bool _canBeVolatiled = true; bool _canBeVolatiled = true;
bool _longLinesAreWrapped = false; bool _longLinesAreWrapped = false;
bool _purgeBeforeEverySearch = false;
generic_string _prefixLineStr; generic_string _prefixLineStr;

@ -444,6 +444,7 @@
#define NPPM_INTERNAL_MINIMIZED_TRAY (NOTEPADPLUS_USER_INTERNAL + 54) #define NPPM_INTERNAL_MINIMIZED_TRAY (NOTEPADPLUS_USER_INTERNAL + 54)
#define NPPM_INTERNAL_SCINTILLAFINDERCOPYVERBATIM (NOTEPADPLUS_USER_INTERNAL + 55) #define NPPM_INTERNAL_SCINTILLAFINDERCOPYVERBATIM (NOTEPADPLUS_USER_INTERNAL + 55)
#define NPPM_INTERNAL_FINDINPROJECTS (NOTEPADPLUS_USER_INTERNAL + 56) #define NPPM_INTERNAL_FINDINPROJECTS (NOTEPADPLUS_USER_INTERNAL + 56)
#define NPPM_INTERNAL_SCINTILLAFINDERPURGE (NOTEPADPLUS_USER_INTERNAL + 57)
// See Notepad_plus_msgs.h // See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000) //#define NOTEPADPLUS_USER (WM_USER + 1000)

Loading…
Cancel
Save