Add "Find in Projects" features

Close #8125, close #9534
This commit is contained in:
Udo Hoffmann 2021-02-18 02:54:59 +01:00 committed by Don HO
parent 10b091b54d
commit 5c884a80c6
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
16 changed files with 481 additions and 77 deletions

View File

@ -376,7 +376,7 @@ The comments are here for explanation, it's not necessary to translate them.
</Menu>
<Dialog>
<Find title="" titleFind="Find" titleReplace="Replace" titleFindInFiles="Find in Files" titleMark="Mark">
<Find title="" titleFind="Find" titleReplace="Replace" titleFindInFiles="Find in Files" titleFindInProjects="Find in Projects" titleMark="Mark">
<Item id="1" name="Find Next"/>
<Item id="1722" name="Backward direction"/>
<Item id="2" name="Close"/>
@ -407,7 +407,11 @@ The comments are here for explanation, it's not necessary to translate them.
<Item id="1625" name="&amp;Normal"/>
<Item id="1626" name="E&amp;xtended (\n, \r, \t, \0, \x...)"/>
<Item id="1660" name="Replace in Files"/>
<Item id="1665" name="Replace in Projects"/>
<Item id="1661" name="Follow current doc."/>
<Item id="1662" name="Project Panel 1"/>
<Item id="1663" name="Project Panel 2"/>
<Item id="1664" name="Project Panel 3"/>
<Item id="1641" name="Find All in Current Document"/>
<Item id="1686" name="Transparenc&amp;y"/>
<Item id="1703" name="&amp;. matches newline"/>
@ -1269,6 +1273,7 @@ Continue?"/>
<Item id="3126" name="Save As..."/>
<Item id="3127" name="Save a Copy As..."/>
<Item id="3121" name="Add New Project"/>
<Item id="3128" name="Find in Projects..."/>
</WorkspaceMenu>
<ProjectMenu>
<Item id="3111" name="Rename"/>
@ -1384,6 +1389,8 @@ Find in all files except exe, obj &amp;&amp; log:
<replace-in-files-confirm-directory value="Are you sure you want to replace all occurrences in :"/>
<replace-in-files-confirm-filetype value="For file type :"/>
<replace-in-files-progress-title value="Replace In Files progress..."/>
<replace-in-projects-confirm-title value="Are you sure?"/>
<replace-in-projects-confirm-message value="Do you want to replace all occurrences in all documents in the selected Project Panel(s)?"/>
<replace-in-open-docs-confirm-title value="Are you sure?"/>
<replace-in-open-docs-confirm-message value="Are you sure you want to replace all occurrences in all open documents?"/>
<find-result-caption value="Search results"/>

View File

@ -1513,20 +1513,73 @@ void Notepad_plus::getMatchedFileNames(const TCHAR *dir, const vector<generic_st
::FindClose(hFile);
}
std::mutex replaceInFiles_mutex;
bool Notepad_plus::replaceInFiles()
bool Notepad_plus::createFilelistForFiles(vector<generic_string> & fileNames)
{
std::lock_guard<std::mutex> lock(replaceInFiles_mutex);
const TCHAR *dir2Search = _findReplaceDlg.getDir2Search();
if (!dir2Search[0] || !::PathFileExists(dir2Search))
{
return false;
}
vector<generic_string> patterns2Match;
_findReplaceDlg.getAndValidatePatterns(patterns2Match);
bool isRecursive = _findReplaceDlg.isRecursive();
bool isInHiddenDir = _findReplaceDlg.isInHiddenDir();
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
return true;
}
bool Notepad_plus::createFilelistForProjects(vector<generic_string> & fileNames)
{
vector<generic_string> patterns2Match;
_findReplaceDlg.getAndValidatePatterns(patterns2Match);
bool somethingIsSelected = false; // at least one Project Panel is open and checked
if (_findReplaceDlg.isProjectPanel_1() && _pProjectPanel_1 && !_pProjectPanel_1->isClosed())
{
_pProjectPanel_1->enumWorkSpaceFiles (NULL, patterns2Match, fileNames);
somethingIsSelected = true;
}
if (_findReplaceDlg.isProjectPanel_2() && _pProjectPanel_2 && !_pProjectPanel_2->isClosed())
{
_pProjectPanel_2->enumWorkSpaceFiles (NULL, patterns2Match, fileNames);
somethingIsSelected = true;
}
if (_findReplaceDlg.isProjectPanel_3() && _pProjectPanel_3 && !_pProjectPanel_3->isClosed())
{
_pProjectPanel_3->enumWorkSpaceFiles (NULL, patterns2Match, fileNames);
somethingIsSelected = true;
}
return somethingIsSelected;
}
std::mutex replaceInFiles_mutex;
bool Notepad_plus::replaceInFiles()
{
std::lock_guard<std::mutex> lock(replaceInFiles_mutex);
std::vector<generic_string> fileNames;
if (!createFilelistForFiles(fileNames))
return false;
return replaceInFilelist(fileNames);
}
bool Notepad_plus::replaceInProjects()
{
std::lock_guard<std::mutex> lock(replaceInFiles_mutex);
std::vector<generic_string> fileNames;
if (!createFilelistForProjects(fileNames))
return false;
return replaceInFilelist(fileNames);
}
bool Notepad_plus::replaceInFilelist(std::vector<generic_string> & fileNames)
{
int nbTotal = 0;
ScintillaEditView *pOldView = _pEditView;
@ -1534,22 +1587,6 @@ bool Notepad_plus::replaceInFiles()
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
Buffer * oldBuf = _invisibleEditView.getCurrentBuffer(); //for manually setting the buffer, so notifications can be handled properly
vector<generic_string> patterns2Match;
_findReplaceDlg.getPatterns(patterns2Match);
if (patterns2Match.size() == 0)
{
_findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*"));
_findReplaceDlg.getPatterns(patterns2Match);
}
else if (allPatternsAreExclusion(patterns2Match))
{
patterns2Match.insert(patterns2Match.begin(), TEXT("*.*"));
}
vector<generic_string> fileNames;
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
Progress progress(_pPublicInterface->getHinst());
size_t filesCount = fileNames.size();
size_t filesPerPercent = 1;
@ -1706,35 +1743,29 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
bool Notepad_plus::findInFiles()
{
const TCHAR *dir2Search = _findReplaceDlg.getDir2Search();
if (!dir2Search[0] || !::PathFileExists(dir2Search))
{
std::vector<generic_string> fileNames;
if (! createFilelistForFiles(fileNames))
return false;
}
bool isRecursive = _findReplaceDlg.isRecursive();
bool isInHiddenDir = _findReplaceDlg.isInHiddenDir();
return findInFilelist(fileNames);
}
bool Notepad_plus::findInProjects()
{
vector<generic_string> fileNames;
if (! createFilelistForProjects(fileNames))
return false;
return findInFilelist(fileNames);
}
bool Notepad_plus::findInFilelist(std::vector<generic_string> & fileNames)
{
int nbTotal = 0;
ScintillaEditView *pOldView = _pEditView;
_pEditView = &_invisibleEditView;
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
vector<generic_string> patterns2Match;
_findReplaceDlg.getPatterns(patterns2Match);
if (patterns2Match.size() == 0)
{
_findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*"));
_findReplaceDlg.getPatterns(patterns2Match);
}
else if (allPatternsAreExclusion(patterns2Match))
{
patterns2Match.insert(patterns2Match.begin(), TEXT("*.*"));
}
vector<generic_string> fileNames;
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
_findReplaceDlg.beginNewFilesSearch();
Progress progress(_pPublicInterface->getHinst());

View File

@ -222,8 +222,16 @@ public:
void prepareBufferChangedDialog(Buffer * buffer);
void notifyBufferChanged(Buffer * buffer, int mask);
bool findInFinderFiles(FindersInfo *findInFolderInfo);
bool createFilelistForFiles(std::vector<generic_string> & fileNames);
bool createFilelistForProjects(std::vector<generic_string> & fileNames);
bool findInFiles();
bool findInProjects();
bool findInFilelist(std::vector<generic_string> & fileList);
bool replaceInFiles();
bool replaceInProjects();
bool replaceInFilelist(std::vector<generic_string> & fileList);
void setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filters);
std::vector<generic_string> addNppComponents(const TCHAR *destDir, const TCHAR *extFilterName, const TCHAR *extFilter);
std::vector<generic_string> addNppPlugins(const TCHAR *extFilterName, const TCHAR *extFilter);

View File

@ -217,6 +217,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return findInFiles();
}
case WM_FINDINPROJECTS:
{
return findInProjects();
}
case WM_FINDALL_INCURRENTFINDER:
{
FindersInfo *findInFolderInfo = reinterpret_cast<FindersInfo *>(wParam);
@ -233,6 +238,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case WM_REPLACEINPROJECTS:
{
replaceInProjects();
return TRUE;
}
case NPPM_LAUNCHFINDINFILESDLG:
{
// Find in files function code should be here due to the number of parameters (2) cannot be passed via WM_COMMAND
@ -257,6 +268,23 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_INTERNAL_FINDINPROJECTS:
{
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize];
bool isFirstTime = not _findReplaceDlg.isCreated();
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
_pEditView->getGenericSelectedText(str, strSize);
_findReplaceDlg.setSearchText(str);
if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
_findReplaceDlg.launchFindInProjectsDlg();
_findReplaceDlg.setProjectCheckmarks(NULL, (int) wParam);
return TRUE;
}
case NPPM_INTERNAL_FINDINFINDERDLG:
{
const int strSize = FINDREPLACE_MAXLENGTH;

View File

@ -2386,6 +2386,18 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
if (boolStr)
_findHistory._isFifInHiddenFolder = (lstrcmp(TEXT("yes"), boolStr) == 0);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifProjectPanel1"));
if (boolStr)
_findHistory._isFifProjectPanel_1 = (lstrcmp(TEXT("yes"), boolStr) == 0);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifProjectPanel2"));
if (boolStr)
_findHistory._isFifProjectPanel_2 = (lstrcmp(TEXT("yes"), boolStr) == 0);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifProjectPanel3"));
if (boolStr)
_findHistory._isFifProjectPanel_3 = (lstrcmp(TEXT("yes"), boolStr) == 0);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifFilterFollowsDoc"));
if (boolStr)
_findHistory._isFilterFollowDoc = (lstrcmp(TEXT("yes"), boolStr) == 0);
@ -6302,6 +6314,9 @@ bool NppParameters::writeFindHistory()
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifRecuisive"), _findHistory._isFifRecuisive?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifInHiddenFolder"), _findHistory._isFifInHiddenFolder?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifProjectPanel1"), _findHistory._isFifProjectPanel_1?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifProjectPanel2"), _findHistory._isFifProjectPanel_2?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifProjectPanel3"), _findHistory._isFifProjectPanel_3?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifFilterFollowsDoc"), _findHistory._isFilterFollowDoc?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("fifFolderFollowsDoc"), _findHistory._isFolderFollowDoc?TEXT("yes"):TEXT("no"));

View File

@ -1165,6 +1165,9 @@ struct FindHistory final
bool _isFifRecuisive = true;
bool _isFifInHiddenFolder = false;
bool _isFifProjectPanel_1 = false;
bool _isFifProjectPanel_2 = false;
bool _isFifProjectPanel_3 = false;
searchMode _searchMode = normal;
transparencyMode _transparencyMode = onLossingFocus;
@ -1575,6 +1578,7 @@ public:
generic_string _find;
generic_string _replace;
generic_string _findInFiles;
generic_string _findInProjects;
generic_string _mark;
};

View File

@ -279,11 +279,13 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent)
const TCHAR *find = TEXT("Find");
const TCHAR *replace = TEXT("Replace");
const TCHAR *findInFiles = TEXT("Find in Files");
const TCHAR *findInProjects = TEXT("Find in Projects");
const TCHAR *mark = TEXT("Mark");
_tab.insertAtEnd(find);
_tab.insertAtEnd(replace);
_tab.insertAtEnd(findInFiles);
_tab.insertAtEnd(findInProjects);
_tab.insertAtEnd(mark);
_tab.reSizeTo(rect);
@ -334,6 +336,10 @@ void FindReplaceDlg::fillFindHistory()
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, findHistory._isFifRecuisive, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, BM_SETCHECK, findHistory._isFolderFollowDoc, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT1_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_1, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT2_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_2, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT3_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_3, 0);
::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, findHistory._searchMode == FindHistory::normal, 0);
::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, findHistory._searchMode == FindHistory::extended, 0);
::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, findHistory._searchMode == FindHistory::regExpr, 0);
@ -772,12 +778,13 @@ void FindReplaceDlg::resizeDialogElements(LONG newWidth)
//elements that need to be moved
const auto moveWindowIDs = {
IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK,IDD_FINDINFILES_RECURSIVE_CHECK, IDD_FINDINFILES_INHIDDENDIR_CHECK,
IDD_FINDINFILES_PROJECT1_CHECK, IDD_FINDINFILES_PROJECT2_CHECK, IDD_FINDINFILES_PROJECT3_CHECK,
IDC_TRANSPARENT_GRPBOX, IDC_TRANSPARENT_CHECK, IDC_TRANSPARENT_LOSSFOCUS_RADIO, IDC_TRANSPARENT_ALWAYS_RADIO,
IDC_PERCENTAGE_SLIDER , IDC_REPLACEINSELECTION , IDC_IN_SELECTION_CHECK,
IDD_FINDINFILES_BROWSE_BUTTON, IDCMARKALL, IDC_CLEAR_ALL, IDCCOUNTALL, IDC_FINDALL_OPENEDFILES, IDC_FINDALL_CURRENTFILE,
IDREPLACE, IDREPLACEALL,IDC_REPLACE_OPENEDFILES, IDD_FINDINFILES_FIND_BUTTON, IDD_FINDINFILES_REPLACEINFILES, IDOK, IDCANCEL,
IDC_FINDPREV, IDC_FINDNEXT, IDC_2_BUTTONS_MODE, IDC_COPY_MARKED_TEXT
IDC_FINDPREV, IDC_FINDNEXT, IDC_2_BUTTONS_MODE, IDC_COPY_MARKED_TEXT, IDD_FINDINFILES_REPLACEINPROJECTS
};
const UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS;
@ -1054,6 +1061,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
enableFindDlgItem(IDREDOTMATCHNL, false);
}
enableProjectCheckmarks();
return TRUE;
}
@ -1221,26 +1229,38 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
_options._filters = filters;
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
_options._directory = directory;
trim(_options._directory);
if (!_options._directory.empty())
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
combo2ExtendedMode(IDFINDWHAT);
_options._str2Search = getTextFromCombo(hFindCombo);
updateCombo(IDFINDWHAT);
if (_currentStatus == FINDINFILES_DLG)
{
addText2Combo(_options._directory.c_str(), ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
if (_options._directory.back() != L'\\')
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
_options._directory = directory;
trim(_options._directory);
if (!_options._directory.empty())
{
_options._directory += TEXT("\\");
addText2Combo(_options._directory.c_str(), ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
if (_options._directory.back() != L'\\')
{
_options._directory += TEXT("\\");
}
nppParamInst._isFindReplacing = true;
if (isMacroRecording) saveInMacro(wParam, FR_OP_FIND + FR_OP_FIF);
findAllIn(FILES_IN_DIR);
nppParamInst._isFindReplacing = false;
}
}
else if (_currentStatus == FINDINPROJECTS_DLG)
{
if (_options._isProjectPanel_1 || _options._isProjectPanel_2 || _options._isProjectPanel_3)
{
nppParamInst._isFindReplacing = true;
if (isMacroRecording) saveInMacro(IDD_FINDINFILES_FINDINPROJECTS, FR_OP_FIND + FR_OP_FIP);
findAllIn(FILES_IN_PROJECTS);
nppParamInst._isFindReplacing = false;
}
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
combo2ExtendedMode(IDFINDWHAT);
_options._str2Search = getTextFromCombo(hFindCombo);
updateCombo(IDFINDWHAT);
nppParamInst._isFindReplacing = true;
if (isMacroRecording) saveInMacro(wParam, FR_OP_FIND + FR_OP_FIF);
findAllIn(FILES_IN_DIR);
nppParamInst._isFindReplacing = false;
}
}
return TRUE;
@ -1286,6 +1306,33 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
}
return TRUE;
case IDD_FINDINFILES_REPLACEINPROJECTS:
{
std::lock_guard<std::mutex> lock(findOps_mutex);
setStatusbarMessage(TEXT(""), FSNoMessage);
const int filterSize = 256;
TCHAR filters[filterSize];
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
_options._filters = filters;
if (replaceInProjectsConfirmCheck())
{
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
_options._str2Search = getTextFromCombo(hFindCombo);
HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH);
_options._str4Replace = getTextFromCombo(hReplaceCombo);
updateCombo(IDFINDWHAT);
updateCombo(IDREPLACEWITH);
nppParamInst._isFindReplacing = true;
if (isMacroRecording) saveInMacro(wParam, FR_OP_REPLACE + FR_OP_FIP);
::SendMessage(_hParent, WM_REPLACEINPROJECTS, 0, 0);
nppParamInst._isFindReplacing = false;
}
}
case IDC_REPLACE_OPENEDFILES :
{
std::lock_guard<std::mutex> lock(findOps_mutex);
@ -1611,7 +1658,31 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
if (_currentStatus == FINDINFILES_DLG)
findHistory._isFifInHiddenFolder = _options._isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
}
return TRUE;
case IDD_FINDINFILES_PROJECT1_CHECK:
case IDD_FINDINFILES_PROJECT2_CHECK:
case IDD_FINDINFILES_PROJECT3_CHECK:
{
if (_currentStatus == FINDINPROJECTS_DLG)
{
switch (LOWORD(wParam))
{
case IDD_FINDINFILES_PROJECT1_CHECK:
findHistory._isFifProjectPanel_1 = _options._isProjectPanel_1 = isCheckedOrNot(IDD_FINDINFILES_PROJECT1_CHECK);
break;
case IDD_FINDINFILES_PROJECT2_CHECK:
findHistory._isFifProjectPanel_2 = _options._isProjectPanel_2 = isCheckedOrNot(IDD_FINDINFILES_PROJECT2_CHECK);
break;
case IDD_FINDINFILES_PROJECT3_CHECK:
findHistory._isFifProjectPanel_3 = _options._isProjectPanel_3 = isCheckedOrNot(IDD_FINDINFILES_PROJECT3_CHECK);
break;
}
bool enable = _options._isProjectPanel_1 || _options._isProjectPanel_2 || _options._isProjectPanel_3;
enableFindDlgItem(IDD_FINDINFILES_FIND_BUTTON, enable);
enableFindDlgItem(IDD_FINDINFILES_REPLACEINPROJECTS, enable);
}
}
return TRUE;
@ -2450,6 +2521,8 @@ void FindReplaceDlg::findAllIn(InWhat op)
cmdid = WM_FINDALL_INOPENEDDOC;
else if (op == FILES_IN_DIR)
cmdid = WM_FINDINFILES;
else if (op == FILES_IN_PROJECTS)
cmdid = WM_FINDINPROJECTS;
else if ((op == CURRENT_DOC) || (op == CURR_DOC_SELECTION))
cmdid = WM_FINDALL_INCURRENTDOC;
@ -2652,7 +2725,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable)
RECT *pInSelectionFramePos = isEnable ? &_replaceInSelFramePos : &_countInSelFramePos;
RECT *pInSectionCheckPos = isEnable ? &_replaceInSelCheckPos : &_countInSelCheckPos;
enableFindInFilesControls(false);
enableFindInFilesControls(false, false);
enableMarkAllControls(false);
// replace controls
showFindDlgItem(ID_STATICTEXT_REPLACE, isEnable);
@ -2697,7 +2770,7 @@ void FindReplaceDlg::enableMarkAllControls(bool isEnable)
showFindDlgItem(IDC_COPY_MARKED_TEXT, isEnable);
}
void FindReplaceDlg::enableFindInFilesControls(bool isEnable)
void FindReplaceDlg::enableFindInFilesControls(bool isEnable, bool projectPanels)
{
// Hide Items
showFindDlgItem(IDC_BACKWARDDIRECTION, !isEnable);
@ -2740,16 +2813,20 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable)
showFindDlgItem(ID_STATICTEXT_REPLACE);
showFindDlgItem(IDREPLACEWITH);
}
showFindDlgItem(IDD_FINDINFILES_REPLACEINFILES, isEnable);
showFindDlgItem(IDD_FINDINFILES_REPLACEINFILES, isEnable && (!projectPanels));
showFindDlgItem(IDD_FINDINFILES_REPLACEINPROJECTS, isEnable && projectPanels);
showFindDlgItem(IDD_FINDINFILES_FILTERS_STATIC, isEnable);
showFindDlgItem(IDD_FINDINFILES_FILTERS_COMBO, isEnable);
showFindDlgItem(IDD_FINDINFILES_DIR_STATIC, isEnable);
showFindDlgItem(IDD_FINDINFILES_DIR_COMBO, isEnable);
showFindDlgItem(IDD_FINDINFILES_BROWSE_BUTTON, isEnable);
showFindDlgItem(IDD_FINDINFILES_DIR_STATIC, isEnable && (!projectPanels));
showFindDlgItem(IDD_FINDINFILES_DIR_COMBO, isEnable && (!projectPanels));
showFindDlgItem(IDD_FINDINFILES_BROWSE_BUTTON, isEnable && (!projectPanels));
showFindDlgItem(IDD_FINDINFILES_FIND_BUTTON, isEnable);
showFindDlgItem(IDD_FINDINFILES_RECURSIVE_CHECK, isEnable);
showFindDlgItem(IDD_FINDINFILES_INHIDDENDIR_CHECK, isEnable);
showFindDlgItem(IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, isEnable);
showFindDlgItem(IDD_FINDINFILES_RECURSIVE_CHECK, isEnable && (!projectPanels));
showFindDlgItem(IDD_FINDINFILES_INHIDDENDIR_CHECK, isEnable && (!projectPanels));
showFindDlgItem(IDD_FINDINFILES_PROJECT1_CHECK, isEnable && projectPanels);
showFindDlgItem(IDD_FINDINFILES_PROJECT2_CHECK, isEnable && projectPanels);
showFindDlgItem(IDD_FINDINFILES_PROJECT3_CHECK, isEnable && projectPanels);
showFindDlgItem(IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, isEnable && (!projectPanels));
}
void FindReplaceDlg::getPatterns(vector<generic_string> & patternVect)
@ -2757,6 +2834,20 @@ void FindReplaceDlg::getPatterns(vector<generic_string> & patternVect)
cutString(_env->_filters.c_str(), patternVect);
}
void FindReplaceDlg::getAndValidatePatterns(vector<generic_string> & patternVect)
{
getPatterns(patternVect);
if (patternVect.size() == 0)
{
setFindInFilesDirFilter(NULL, TEXT("*.*"));
getPatterns(patternVect);
}
else if (allPatternsAreExclusion(patternVect))
{
patternVect.insert(patternVect.begin(), TEXT("*.*"));
}
}
void FindReplaceDlg::saveInMacro(size_t cmd, int cmdType)
{
int booleans = 0;
@ -2781,6 +2872,13 @@ void FindReplaceDlg::saveInMacro(size_t cmd, int cmdType)
booleans |= _options._isRecursive?IDF_FINDINFILES_RECURSIVE_CHECK:0;
booleans |= _options._isInHiddenDir?IDF_FINDINFILES_INHIDDENDIR_CHECK:0;
}
if (cmdType & FR_OP_FIP)
{
::SendMessage(_hParent, WM_FRSAVE_STR, IDD_FINDINFILES_FILTERS_COMBO, reinterpret_cast<LPARAM>(_options._filters.c_str()));
booleans |= _options._isProjectPanel_1?IDF_FINDINFILES_PROJECT1_CHECK:0;
booleans |= _options._isProjectPanel_2?IDF_FINDINFILES_PROJECT2_CHECK:0;
booleans |= _options._isProjectPanel_3?IDF_FINDINFILES_PROJECT3_CHECK:0;
}
else if (!(cmdType & FR_OP_GLOBAL))
{
booleans |= _options._isInSelection?IDF_IN_SELECTION_CHECK:0;
@ -2880,6 +2978,9 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
_env->_isMatchCase = ((intValue & IDF_MATCHCASE) > 0);
_env->_isRecursive = ((intValue & IDF_FINDINFILES_RECURSIVE_CHECK) > 0);
_env->_isInHiddenDir = ((intValue & IDF_FINDINFILES_INHIDDENDIR_CHECK) > 0);
_env->_isProjectPanel_1 = ((intValue & IDF_FINDINFILES_PROJECT1_CHECK) > 0);
_env->_isProjectPanel_2 = ((intValue & IDF_FINDINFILES_PROJECT2_CHECK) > 0);
_env->_isProjectPanel_3 = ((intValue & IDF_FINDINFILES_PROJECT3_CHECK) > 0);
_env->_doPurge = ((intValue & IDF_PURGE_CHECK) > 0);
_env->_doMarkLine = ((intValue & IDF_MARKLINE_CHECK) > 0);
_env->_isInSelection = ((intValue & IDF_IN_SELECTION_CHECK) > 0);
@ -2987,6 +3088,11 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
findAllIn(FILES_IN_DIR);
nppParamInst._isFindReplacing = false;
break;
case IDD_FINDINFILES_FINDINPROJECTS:
nppParamInst._isFindReplacing = true;
findAllIn(FILES_IN_PROJECTS);
nppParamInst._isFindReplacing = false;
break;
case IDD_FINDINFILES_REPLACEINFILES:
{
@ -2998,6 +3104,18 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
}
break;
}
case IDD_FINDINFILES_REPLACEINPROJECTS:
{
if (replaceInProjectsConfirmCheck())
{
nppParamInst._isFindReplacing = true;
::SendMessage(_hParent, WM_REPLACEINPROJECTS, 0, 0);
nppParamInst._isFindReplacing = false;
}
break;
}
case IDREPLACEALL:
{
nppParamInst._isFindReplacing = true;
@ -3165,6 +3283,72 @@ void FindReplaceDlg::setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filt
}
}
void FindReplaceDlg::enableProjectCheckmarks()
{
NppParameters& nppParams = NppParameters::getInstance();
FindHistory & findHistory = nppParams.getFindHistory();
HMENU hMenu = (HMENU) ::SendMessage (_hParent, NPPM_INTERNAL_GETMENU, 0, 0);
if (hMenu)
{
int idm [3] = {IDM_VIEW_PROJECT_PANEL_1, IDM_VIEW_PROJECT_PANEL_2, IDM_VIEW_PROJECT_PANEL_3};
int idd [3] = {IDD_FINDINFILES_PROJECT1_CHECK, IDD_FINDINFILES_PROJECT2_CHECK, IDD_FINDINFILES_PROJECT3_CHECK};
bool *opt [3] = {&_options._isProjectPanel_1, &_options._isProjectPanel_2, &_options._isProjectPanel_3};
bool *hst [3] = {&findHistory._isFifProjectPanel_1, &findHistory._isFifProjectPanel_2, &findHistory._isFifProjectPanel_3};
bool enable = false;
for (int i = 0; i < 3; i++)
{
UINT s = GetMenuState (hMenu, idm [i], MF_BYCOMMAND);
if (s != -1)
{
if (s & MF_CHECKED)
{
enableFindDlgItem (idd [i], true);
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, idd [i], BM_GETCHECK, 0, 0))
enable = true;
}
else
{
*opt [i] = 0;
*hst [i] = 0;
::SendDlgItemMessage(_hSelf, idd [i], BM_SETCHECK, 0, 0);
enableFindDlgItem (idd [i], false);
}
}
}
enableFindDlgItem (IDD_FINDINFILES_FIND_BUTTON, enable);
enableFindDlgItem (IDD_FINDINFILES_REPLACEINPROJECTS, enable);
}
}
void FindReplaceDlg::setProjectCheckmarks(FindHistory *findHistory, int msk)
{
_options._isProjectPanel_1 = (msk & 1) ? true : false;
_options._isProjectPanel_2 = (msk & 2) ? true : false;
_options._isProjectPanel_3 = (msk & 4) ? true : false;
FindHistory *fh = findHistory;
if (! fh)
{
NppParameters& nppParams = NppParameters::getInstance();
fh = & nppParams.getFindHistory();
}
if (fh)
{
fh->_isFifProjectPanel_1 = _options._isProjectPanel_1;
fh->_isFifProjectPanel_2 = _options._isProjectPanel_2;
fh->_isFifProjectPanel_3 = _options._isProjectPanel_3;
}
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT1_CHECK, BM_SETCHECK, _options._isProjectPanel_1, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT2_CHECK, BM_SETCHECK, _options._isProjectPanel_2, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT3_CHECK, BM_SETCHECK, _options._isProjectPanel_3, 0);
if (_currentStatus == FINDINPROJECTS_DLG)
{
enableFindDlgItem (IDD_FINDINFILES_FIND_BUTTON, msk != 0);
enableFindDlgItem (IDD_FINDINFILES_REPLACEINPROJECTS, msk != 0);
}
}
void FindReplaceDlg::initOptionsFromDlg()
{
_options._isWholeWord = isCheckedOrNot(IDWHOLEWORD);
@ -3181,6 +3365,9 @@ void FindReplaceDlg::initOptionsFromDlg()
_options._isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
_options._isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
_options._isProjectPanel_1 = isCheckedOrNot(IDD_FINDINFILES_PROJECT1_CHECK);
_options._isProjectPanel_2 = isCheckedOrNot(IDD_FINDINFILES_PROJECT2_CHECK);
_options._isProjectPanel_3 = isCheckedOrNot(IDD_FINDINFILES_PROJECT3_CHECK);
}
void FindInFinderDlg::doDialog(Finder *launcher, bool isRTL)
@ -3208,6 +3395,8 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
if (whichType == FINDINFILES_DLG)
enableFindInFilesFunc();
else if (whichType == FINDINPROJECTS_DLG)
enableFindInProjectsFunc();
else if (whichType == MARK_DLG)
enableMarkFunc();
else
@ -3272,7 +3461,7 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM
void FindReplaceDlg::enableFindInFilesFunc()
{
enableFindInFilesControls();
enableFindInFilesControls(true, false);
_currentStatus = FINDINFILES_DLG;
gotoCorrectTab();
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left + _deltaWidth, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
@ -3280,11 +3469,27 @@ void FindReplaceDlg::enableFindInFilesFunc()
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
setDefaultButton(IDD_FINDINFILES_FIND_BUTTON);
enableFindDlgItem (IDD_FINDINFILES_FIND_BUTTON, true);
}
void FindReplaceDlg::enableFindInProjectsFunc()
{
enableFindInFilesControls(true, true);
_currentStatus = FINDINPROJECTS_DLG;
gotoCorrectTab();
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left + _deltaWidth, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
TCHAR label[MAX_PATH];
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
setDefaultButton(IDD_FINDINFILES_FIND_BUTTON);
bool enable = _options._isProjectPanel_1 || _options._isProjectPanel_2 || _options._isProjectPanel_3;
enableFindDlgItem (IDD_FINDINFILES_FIND_BUTTON, enable);
enableFindDlgItem (IDD_FINDINFILES_REPLACEINPROJECTS, enable);
}
void FindReplaceDlg::enableMarkFunc()
{
enableFindInFilesControls(false);
enableFindInFilesControls(false, false);
enableMarkAllControls(true);
// Replace controls to hide
@ -3426,6 +3631,25 @@ bool FindReplaceDlg::replaceInFilesConfirmCheck(generic_string directory, generi
return confirmed;
}
bool FindReplaceDlg::replaceInProjectsConfirmCheck()
{
bool confirmed = false;
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string title = pNativeSpeaker->getLocalizedStrFromID("replace-in-projects-confirm-title", TEXT("Are you sure?"));
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("replace-in-files-confirm-message", TEXT("Do you want to replace all occurrences in all documents in the selected Project Panel(s)?"));
int res = ::MessageBox(NULL, msg.c_str(), title.c_str(), MB_OKCANCEL | MB_DEFBUTTON2 | MB_TASKMODAL);
if (res == IDOK)
{
confirmed = true;
}
return confirmed;
}
bool FindReplaceDlg::replaceInOpenDocsConfirmCheck(void)
{
bool confirmed = false;

View File

@ -29,14 +29,14 @@
#define FINDREPLACE_MAXLENGTH 2048
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG, MARK_DLG};
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG, FINDINPROJECTS_DLG, MARK_DLG};
#define DIR_DOWN true
#define DIR_UP false
//#define FIND_REPLACE_STR_MAX 256
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR, CURRENT_DOC, CURR_DOC_SELECTION};
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR, CURRENT_DOC, CURR_DOC_SELECTION, FILES_IN_PROJECTS};
struct FoundInfo {
FoundInfo(int start, int end, size_t lineNumber, const TCHAR *fullPath)
@ -73,6 +73,9 @@ struct FindOption
generic_string _directory;
bool _isRecursive = true;
bool _isInHiddenDir = false;
bool _isProjectPanel_1 = false;
bool _isProjectPanel_2 = false;
bool _isProjectPanel_3 = false;
bool _dotMatchesNewline = false;
bool _isMatchLineNumber = true; // only for Find in Folder
};
@ -263,12 +266,19 @@ public :
const TCHAR * getDir2Search() const {return _env->_directory.c_str();};
void getPatterns(std::vector<generic_string> & patternVect);
void getAndValidatePatterns(std::vector<generic_string> & patternVect);
void launchFindInFilesDlg() {
doDialog(FINDINFILES_DLG);
};
void launchFindInProjectsDlg() {
doDialog(FINDINPROJECTS_DLG);
};
void setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filters);
void setProjectCheckmarks(FindHistory *findHistory, int Msk);
void enableProjectCheckmarks();
generic_string getText2search() const {
return _env->_str2Search;
@ -279,6 +289,9 @@ public :
const FindOption & getCurrentOptions() const {return *_env;};
bool isRecursive() const { return _env->_isRecursive; };
bool isInHiddenDir() const { return _env->_isInHiddenDir; };
bool isProjectPanel_1() const { return _env->_isProjectPanel_1; };
bool isProjectPanel_2() const { return _env->_isProjectPanel_2; };
bool isProjectPanel_3() const { return _env->_isProjectPanel_3; };
void saveFindHistory();
void changeTabName(DIALOG_TYPE index, const TCHAR *name2change) {
TCITEM tie;
@ -330,6 +343,7 @@ public :
generic_string getScopeInfoForStatusBar(FindOption const *pFindOpt) const;
Finder * createFinder();
bool removeFinder(Finder *finder2remove);
DIALOG_TYPE getCurrentStatus() {return _currentStatus;};
protected :
void resizeDialogElements(LONG newWidth);
@ -385,8 +399,9 @@ private :
void showFindDlgItem(int dlgItemID, bool isShow = true);
void enableReplaceFunc(bool isEnable);
void enableFindInFilesControls(bool isEnable = true);
void enableFindInFilesControls(bool isEnable, bool projectPanels);
void enableFindInFilesFunc();
void enableFindInProjectsFunc();
void enableMarkAllControls(bool isEnable);
void enableMarkFunc();
@ -413,9 +428,11 @@ private :
static const int FR_OP_REPLACE = 2;
static const int FR_OP_FIF = 4;
static const int FR_OP_GLOBAL = 8;
static const int FR_OP_FIP = 16;
void saveInMacro(size_t cmd, int cmdType);
void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
bool replaceInFilesConfirmCheck(generic_string directory, generic_string fileTypes);
bool replaceInProjectsConfirmCheck();
bool replaceInOpenDocsConfirmCheck(void);
};

View File

@ -41,6 +41,12 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,87,94,15
CONTROL "In &hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,101,94,15
CONTROL "Project Panel 1",IDD_FINDINFILES_PROJECT1_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,73,94,15
CONTROL "Project Panel 2",IDD_FINDINFILES_PROJECT2_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,87,94,15
CONTROL "Project Panel 3",IDD_FINDINFILES_PROJECT3_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,101,94,15
CONTROL "Book&mark line",IDC_MARKLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,140,15
CONTROL "Purge for each search",IDC_PURGE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,64,140,15
PUSHBUTTON "Mark All",IDCMARKALL,268,20,91,14
@ -69,6 +75,7 @@ BEGIN
PUSHBUTTON "Replace All in All Opened Doc&uments",IDC_REPLACE_OPENEDFILES,268,74,91,21,BS_MULTILINE
PUSHBUTTON "Find All",IDD_FINDINFILES_FIND_BUTTON,268,20,91,14,WS_GROUP
PUSHBUTTON "Replace in Files",IDD_FINDINFILES_REPLACEINFILES,268,38,91,14
PUSHBUTTON "Replace in Projects",IDD_FINDINFILES_REPLACEINPROJECTS,268,38,91,14
PUSHBUTTON "Copy Marked Text",IDC_COPY_MARKED_TEXT,268,56,91,14
PUSHBUTTON "Close",IDCANCEL,268,98,91,14
GROUPBOX "",IDC_TRANSPARENT_GRPBOX,258,131,99,48

View File

@ -85,6 +85,14 @@
#define IDF_FINDINFILES_INHIDDENDIR_CHECK 64
#define IDD_FINDINFILES_REPLACEINFILES 1660
#define IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK 1661
#define IDD_FINDINFILES_PROJECT1_CHECK 1662
#define IDF_FINDINFILES_PROJECT1_CHECK 128
#define IDD_FINDINFILES_PROJECT2_CHECK 1663
#define IDF_FINDINFILES_PROJECT2_CHECK 256
#define IDD_FINDINFILES_PROJECT3_CHECK 1664
#define IDF_FINDINFILES_PROJECT3_CHECK 512
#define IDD_FINDINFILES_REPLACEINPROJECTS 1665
#define IDD_FINDINFILES_FINDINPROJECTS 1666
#define IDD_FINDRESULT 1670

View File

@ -65,6 +65,8 @@ typedef void * SCINTILLA_PTR;
#define WM_FRSAVE_INT (SCINTILLA_USER + 12)
#define WM_FRSAVE_STR (SCINTILLA_USER + 13)
#define WM_FINDALL_INCURRENTFINDER (SCINTILLA_USER + 14)
#define WM_FINDINPROJECTS (SCINTILLA_USER + 15)
#define WM_REPLACEINPROJECTS (SCINTILLA_USER + 16)
const int NB_FOLDER_STATE = 7;

View File

@ -225,6 +225,7 @@ void ProjectPanel::initMenus()
generic_string saveas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEASWS, PM_SAVEASWORKSPACE);
generic_string saveacopyas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEACOPYASWS, PM_SAVEACOPYASWORKSPACE);
generic_string newproject_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWPROJECT, PM_NEWPROJECTWORKSPACE);
generic_string findinprojects_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_FINDINPROJECTSWS, PM_FINDINFILESWORKSPACE);
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWWS, new_workspace.c_str());
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_OPENWS, open_workspace.c_str());
@ -234,6 +235,8 @@ void ProjectPanel::initMenus()
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_SAVEACOPYASWS, saveacopyas_workspace.c_str());
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, static_cast<UINT>(-1), 0);
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWPROJECT, newproject_workspace.c_str());
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, static_cast<UINT>(-1), 0);
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_FINDINPROJECTSWS, findinprojects_workspace.c_str());
generic_string edit_moveup = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEUP, PM_MOVEUPENTRY);
generic_string edit_movedown = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEDOWN, PM_MOVEDOWNENTRY);
@ -506,6 +509,39 @@ void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR
}
}
bool ProjectPanel::enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector<generic_string> & patterns, std::vector<generic_string> & fileNames)
{
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
tvItem.mask = TVIF_TEXT | TVIF_PARAM;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
HTREEITEM tvRoot = tvFrom ? tvFrom : _treeView.getRoot();
if (!tvRoot) return false;
for (HTREEITEM tvProj = _treeView.getChildFrom(tvRoot);
tvProj != NULL;
tvProj = _treeView.getNextSibling(tvProj))
{
tvItem.hItem = tvProj;
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
if (tvItem.lParam)
{
if (matchInList(tvItem.pszText, patterns))
{
generic_string *fn = (generic_string *)tvItem.lParam;
fileNames.push_back (*fn);
}
}
else
{
if (!enumWorkSpaceFiles (tvProj, patterns, fileNames)) return false;
}
}
return true;
}
generic_string ProjectPanel::getRelativePath(const generic_string & filePath, const TCHAR *workSpaceFileName)
{
TCHAR wsfn[MAX_PATH];
@ -1098,6 +1134,12 @@ void ProjectPanel::popupMenuCmd(int cmdID)
}
break;
case IDM_PROJECT_FINDINPROJECTSWS:
{
::SendMessage(_hParent, NPPM_INTERNAL_FINDINPROJECTS, (WPARAM) 1 << _panelID, 0);
}
break;
case IDM_PROJECT_DELETEFOLDER :
{
HTREEITEM parent = _treeView.getParent(hTreeItem);

View File

@ -33,6 +33,7 @@
#define PM_SAVEASWORKSPACE TEXT("Save As...")
#define PM_SAVEACOPYASWORKSPACE TEXT("Save a Copy As...")
#define PM_NEWPROJECTWORKSPACE TEXT("Add New Project")
#define PM_FINDINFILESWORKSPACE TEXT("Find in Projects...")
#define PM_EDITRENAME TEXT("Rename")
#define PM_EDITNEWFOLDER TEXT("Add Folder")
@ -101,6 +102,7 @@ public:
virtual void setForegroundColor(COLORREF fgColour) {
TreeView_SetTextColor(_treeView.getHSelf(), fgColour);
};
bool enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector<generic_string> & patterns, std::vector<generic_string> & fileNames);
protected:
TreeView _treeView;

View File

@ -38,6 +38,7 @@
#define IDM_PROJECT_SAVEWS (IDD_PROJECTPANEL_MENUWS + 5)
#define IDM_PROJECT_SAVEASWS (IDD_PROJECTPANEL_MENUWS + 6)
#define IDM_PROJECT_SAVEACOPYASWS (IDD_PROJECTPANEL_MENUWS + 7)
#define IDM_PROJECT_FINDINPROJECTSWS (IDD_PROJECTPANEL_MENUWS + 8)
#define IDD_PROJECTPANEL_CTRL (IDD_PROJECTPANEL + 30)
#define ID_PROJECTTREEVIEW (IDD_PROJECTPANEL_CTRL + 1)

View File

@ -751,7 +751,8 @@ void NativeLangSpeaker::changeFindReplaceDlgLang(FindReplaceDlg & findReplaceDlg
const char *titre1 = (dlgNode->ToElement())->Attribute("titleFind");
const char *titre2 = (dlgNode->ToElement())->Attribute("titleReplace");
const char *titre3 = (dlgNode->ToElement())->Attribute("titleFindInFiles");
const char *titre4 = (dlgNode->ToElement())->Attribute("titleMark");
const char *titre4 = (dlgNode->ToElement())->Attribute("titleFindInProjects");
const char *titre5 = (dlgNode->ToElement())->Attribute("titleMark");
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
@ -776,6 +777,12 @@ void NativeLangSpeaker::changeFindReplaceDlgLang(FindReplaceDlg & findReplaceDlg
if (titre4 && titre4[0])
{
basic_string<wchar_t> nameW = wmc.char2wchar(titre4, _nativeLangEncoding);
nppParam.getFindDlgTabTitiles()._findInProjects = nameW;
findReplaceDlg.changeTabName(FINDINPROJECTS_DLG, nppParam.getFindDlgTabTitiles()._findInProjects.c_str());
}
if (titre5 && titre5[0])
{
basic_string<wchar_t> nameW = wmc.char2wchar(titre5, _nativeLangEncoding);
nppParam.getFindDlgTabTitiles()._mark = nameW;
findReplaceDlg.changeTabName(MARK_DLG, nppParam.getFindDlgTabTitiles()._mark.c_str());
}

View File

@ -441,6 +441,7 @@
#define NPPM_INTERNAL_SCINTILLAFINDERWRAP (NOTEPADPLUS_USER_INTERNAL + 53)
#define NPPM_INTERNAL_MINIMIZED_TRAY (NOTEPADPLUS_USER_INTERNAL + 54)
#define NPPM_INTERNAL_SCINTILLAFINFERCOPYVERBATIM (NOTEPADPLUS_USER_INTERNAL + 55)
#define NPPM_INTERNAL_FINDINPROJECTS (NOTEPADPLUS_USER_INTERNAL + 56)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)