Add "Copy Pathnames" command to Search results context menu

Fix #9821, close #9822
This commit is contained in:
Scott Sumner 2021-05-01 19:08:12 -04:00 committed by Don HO
parent 4b7e1ac794
commit b657f58580
4 changed files with 28 additions and 0 deletions

View File

@ -1378,6 +1378,7 @@ Find in all files except exe, obj && log:
<finder-uncollapse-all value="Uncollapse all"/>
<finder-copy value="Copy Selected Line(s)"/>
<finder-copy-verbatim value="Copy"/>
<finder-copy-paths value="Copy Pathname(s)"/>
<finder-select-all value="Select all"/>
<finder-clear-all value="Clear all"/>
<finder-open-all value="Open all"/>

View File

@ -3990,6 +3990,23 @@ void Finder::openAll()
}
}
void Finder::copyPathnames()
{
generic_string toClipboard;
for (auto&& path : getResultFilePaths())
{
toClipboard += path + TEXT("\r\n");
}
if (!toClipboard.empty())
{
if (!str2Clipboard(toClipboard, _hSelf))
{
assert(false);
::MessageBox(NULL, TEXT("Error placing pathnames into clipboard."), TEXT("Notepad++"), MB_ICONINFORMATION);
}
}
}
void Finder::wrapLongLinesToggle()
{
_longLinesAreWrapped = !_longLinesAreWrapped;
@ -4242,6 +4259,12 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
}
case NPPM_INTERNAL_SCINTILLAFINDERCOPYPATHS:
{
copyPathnames();
return TRUE;
}
case NPPM_INTERNAL_SCINTILLAFINDERSELECTALL :
{
_scintView.execute(SCI_SELECTALL);
@ -4296,6 +4319,7 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
generic_string uncollapseAll = pNativeSpeaker->getLocalizedStrFromID("finder-uncollapse-all", TEXT("Uncollapse all"));
generic_string copyLines = pNativeSpeaker->getLocalizedStrFromID("finder-copy", TEXT("Copy Selected Line(s)"));
generic_string copyVerbatim = pNativeSpeaker->getLocalizedStrFromID("finder-copy-verbatim", TEXT("Copy"));
generic_string copyPaths = pNativeSpeaker->getLocalizedStrFromID("finder-copy-paths", TEXT("Copy Pathname(s)"));
generic_string selectAll = pNativeSpeaker->getLocalizedStrFromID("finder-select-all", TEXT("Select 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"));
@ -4311,6 +4335,7 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
tmp.push_back(MenuItemUnit(0, TEXT("Separator")));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERCOPYVERBATIM, copyVerbatim));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERCOPY, copyLines));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERCOPYPATHS, copyPaths));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERSELECTALL, selectAll));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, clearAll));
tmp.push_back(MenuItemUnit(0, TEXT("Separator")));

View File

@ -126,6 +126,7 @@ public:
void wrapLongLinesToggle();
void purgeToggle();
void copy();
void copyPathnames();
void beginNewFilesSearch();
void finishFilesSearch(int count, int searchedCount, bool isMatchLines, bool searchedEntireNotSelection);
void gotoNextFoundResult(int direction);

View File

@ -463,6 +463,7 @@
#define NPPM_INTERNAL_SCINTILLAFINDERPURGE (NOTEPADPLUS_USER_INTERNAL + 57)
#define NPPM_INTERNAL_UPDATETEXTZONEPADDING (NOTEPADPLUS_USER_INTERNAL + 58)
#define NPPM_INTERNAL_REFRESHDARKMODE (NOTEPADPLUS_USER_INTERNAL + 59)
#define NPPM_INTERNAL_SCINTILLAFINDERCOPYPATHS (NOTEPADPLUS_USER_INTERNAL + 60)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)