mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-26 23:34:44 +02:00
[NEW_FEATURE] Find in Files in thread.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@334 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
3169124d8d
commit
ddd055e5a2
@ -1525,8 +1525,10 @@ void Notepad_plus::getMatchedFileNames(const TCHAR *dir, const vector<generic_st
|
|||||||
::FindClose(hFile);
|
::FindClose(hFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
|
bool Notepad_plus::findInFiles()
|
||||||
{
|
{
|
||||||
|
bool isRecursive = _findReplaceDlg.isRecursive();
|
||||||
|
bool isInHiddenDir = _findReplaceDlg.isInHiddenDir();
|
||||||
int nbTotal = 0;
|
int nbTotal = 0;
|
||||||
ScintillaEditView *pOldView = _pEditView;
|
ScintillaEditView *pOldView = _pEditView;
|
||||||
_pEditView = &_invisibleEditView;
|
_pEditView = &_invisibleEditView;
|
||||||
@ -1546,21 +1548,42 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
|
|||||||
_findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*"));
|
_findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*"));
|
||||||
_findReplaceDlg.getPatterns(patterns2Match);
|
_findReplaceDlg.getPatterns(patterns2Match);
|
||||||
vector<generic_string> fileNames;
|
vector<generic_string> fileNames;
|
||||||
|
|
||||||
|
_findReplaceDlg.putFindResultStr(TEXT("Scanning files to search..."));
|
||||||
|
_findReplaceDlg.Refresh();
|
||||||
|
|
||||||
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
|
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
|
||||||
|
|
||||||
|
TCHAR msg[128];
|
||||||
|
wsprintf(msg, TEXT("Found %d matching files"), fileNames.size());
|
||||||
|
_findReplaceDlg.putFindResultStr((const TCHAR*)msg);
|
||||||
|
_findReplaceDlg.Refresh();
|
||||||
|
|
||||||
|
UINT_PTR pTimer = ::SetTimer(_hSelf, 12614, 500, NULL);
|
||||||
|
|
||||||
bool dontClose = false;
|
bool dontClose = false;
|
||||||
for (size_t i = 0 ; i < fileNames.size() ; i++)
|
for (size_t i = 0 ; i < fileNames.size() ; i++)
|
||||||
{
|
{
|
||||||
BufferID id = MainFileManager->getBufferFromName(fileNames.at(i).c_str());
|
BufferID id = MainFileManager->getBufferFromName(fileNames.at(i).c_str());
|
||||||
if (id != BUFFER_INVALID) {
|
if (id != BUFFER_INVALID)
|
||||||
|
{
|
||||||
dontClose = true;
|
dontClose = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
id = MainFileManager->loadFile(fileNames.at(i).c_str());
|
id = MainFileManager->loadFile(fileNames.at(i).c_str());
|
||||||
dontClose = false;
|
dontClose = false;
|
||||||
}
|
}
|
||||||
if (id != BUFFER_INVALID) {
|
|
||||||
|
if (id != BUFFER_INVALID)
|
||||||
|
{
|
||||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
|
|
||||||
|
generic_string str = TEXT("File: ");
|
||||||
|
str += fileNames.at(i);
|
||||||
|
_findReplaceDlg.putFindResultStr(str.c_str());
|
||||||
|
|
||||||
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, true, fileNames.at(i).c_str());
|
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, true, fileNames.at(i).c_str());
|
||||||
if (!dontClose)
|
if (!dontClose)
|
||||||
MainFileManager->closeBuffer(id, _pEditView);
|
MainFileManager->closeBuffer(id, _pEditView);
|
||||||
@ -1570,10 +1593,21 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
|
|||||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
||||||
_pEditView = pOldView;
|
_pEditView = pOldView;
|
||||||
|
|
||||||
_findReplaceDlg.putFindResult(nbTotal);
|
::KillTimer(_hSelf, pTimer);
|
||||||
|
|
||||||
|
wsprintf(msg, TEXT("%d hits"), nbTotal);
|
||||||
|
_findReplaceDlg.putFindResultStr((const TCHAR *)&msg);
|
||||||
|
_findReplaceDlg.Refresh();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI AsyncFindInFiles(LPVOID iValue)
|
||||||
|
{
|
||||||
|
Notepad_plus* npp = (Notepad_plus*)iValue;
|
||||||
|
npp->findInFiles();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool Notepad_plus::findInOpenedFiles() {
|
bool Notepad_plus::findInOpenedFiles() {
|
||||||
int nbTotal = 0;
|
int nbTotal = 0;
|
||||||
ScintillaEditView *pOldView = _pEditView;
|
ScintillaEditView *pOldView = _pEditView;
|
||||||
@ -6685,9 +6719,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case WM_FINDINFILES :
|
case WM_FINDINFILES :
|
||||||
{
|
{
|
||||||
bool isRecursive = (lParam & FIND_RECURSIVE) != FALSE;
|
DWORD dwTnum;
|
||||||
bool isInHiddenFolder = (lParam & FIND_INHIDDENDIR) != FALSE;
|
::CreateThread(NULL,0,AsyncFindInFiles, this, 0, &dwTnum);
|
||||||
findInFiles(isRecursive, isInHiddenFolder);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7828,6 +7861,11 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_TIMER:
|
||||||
|
{
|
||||||
|
_findReplaceDlg.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
case NPPM_DMMHIDE:
|
case NPPM_DMMHIDE:
|
||||||
{
|
{
|
||||||
_dockingManager.showDockableDlg((HWND)lParam, SW_HIDE);
|
_dockingManager.showDockableDlg((HWND)lParam, SW_HIDE);
|
||||||
|
@ -185,8 +185,8 @@ public:
|
|||||||
winVer getWinVersion() const {return _winVersion;};
|
winVer getWinVersion() const {return _winVersion;};
|
||||||
|
|
||||||
bool emergency();
|
bool emergency();
|
||||||
|
|
||||||
void notifyBufferChanged(Buffer * buffer, int mask);
|
void notifyBufferChanged(Buffer * buffer, int mask);
|
||||||
|
bool findInFiles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const TCHAR _className[32];
|
static const TCHAR _className[32];
|
||||||
@ -675,7 +675,6 @@ private:
|
|||||||
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const TCHAR **translatedText);
|
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const TCHAR **translatedText);
|
||||||
bool replaceAllFiles();
|
bool replaceAllFiles();
|
||||||
bool findInOpenedFiles();
|
bool findInOpenedFiles();
|
||||||
bool findInFiles(bool isRecursive, bool isInHiddenDir);
|
|
||||||
|
|
||||||
bool matchInList(const TCHAR *fileName, const vector<generic_string> & patterns);
|
bool matchInList(const TCHAR *fileName, const vector<generic_string> & patterns);
|
||||||
void getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir);
|
void getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir);
|
||||||
|
@ -746,8 +746,6 @@ public :
|
|||||||
const TCHAR * getName() {return _name.c_str();};
|
const TCHAR * getName() {return _name.c_str();};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//TCHAR _name[langNameLenMax];
|
|
||||||
//TCHAR _ext[extsLenMax];
|
|
||||||
generic_string _name;
|
generic_string _name;
|
||||||
generic_string _ext;
|
generic_string _ext;
|
||||||
|
|
||||||
|
@ -1292,13 +1292,18 @@ void FindReplaceDlg::findAllIn(InWhat op)
|
|||||||
|
|
||||||
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
||||||
|
|
||||||
int finInFileOpt = _isRecursive?FIND_RECURSIVE:0;
|
::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, 0);
|
||||||
if (_isRecursive)
|
|
||||||
finInFileOpt |= _isInHiddenDir?FIND_INHIDDENDIR:0;
|
|
||||||
|
|
||||||
::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, (op!=ALL_OPEN_DOCS)?finInFileOpt:0);
|
Refresh();
|
||||||
//TCHAR *pDataToWrite = _findAllResultStr + lstrlen(FIND_RESULT_DEFAULT_TITLE);
|
}
|
||||||
wsprintf(_findAllResultStr, TEXT("%d hits"), _findAllResult);
|
|
||||||
|
void FindReplaceDlg::putFindResultStr(const TCHAR *text)
|
||||||
|
{
|
||||||
|
wsprintf(_findAllResultStr, TEXT("%s"), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindReplaceDlg::Refresh()
|
||||||
|
{
|
||||||
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
|
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,11 +193,8 @@ friend class FindIncrementDlg;
|
|||||||
public :
|
public :
|
||||||
FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false), _isRecursive(true),_isInHiddenDir(false),\
|
FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false), _isRecursive(true),_isInHiddenDir(false),\
|
||||||
_fileNameLenMax(1024) {
|
_fileNameLenMax(1024) {
|
||||||
//_line = new TCHAR[_maxNbCharAllocated + 3];
|
|
||||||
//_uniCharLine = new char[(_maxNbCharAllocated + 3) * 2];
|
|
||||||
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
|
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
|
||||||
_winVer = (NppParameters::getInstance())->getWinVersion();
|
_winVer = (NppParameters::getInstance())->getWinVersion();
|
||||||
//lstrcpy(_findAllResultStr, FIND_RESULT_DEFAULT_TITLE);
|
|
||||||
};
|
};
|
||||||
~FindReplaceDlg() {
|
~FindReplaceDlg() {
|
||||||
_tab.destroy();
|
_tab.destroy();
|
||||||
@ -275,6 +272,9 @@ public :
|
|||||||
void putFindResult(int result) {
|
void putFindResult(int result) {
|
||||||
_findAllResult = result;
|
_findAllResult = result;
|
||||||
};
|
};
|
||||||
|
void putFindResultStr(const TCHAR *text);
|
||||||
|
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
void setSearchWord2Finder(){
|
void setSearchWord2Finder(){
|
||||||
generic_string str2Search = getText2search();
|
generic_string str2Search = getText2search();
|
||||||
@ -309,6 +309,8 @@ public :
|
|||||||
const generic_string & getFilters() const {return _filters;};
|
const generic_string & getFilters() const {return _filters;};
|
||||||
const generic_string & getDirectory() const {return _directory;};
|
const generic_string & getDirectory() const {return _directory;};
|
||||||
const FindOption & getCurrentOptions() const {return _options;};
|
const FindOption & getCurrentOptions() const {return _options;};
|
||||||
|
bool isRecursive() { return _isRecursive; }
|
||||||
|
bool isInHiddenDir() { return _isInHiddenDir; }
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
@ -329,22 +331,17 @@ private :
|
|||||||
|
|
||||||
ScintillaEditView **_ppEditView;
|
ScintillaEditView **_ppEditView;
|
||||||
Finder *_pFinder;
|
Finder *_pFinder;
|
||||||
//StatusBar _statusBar;
|
|
||||||
bool _isRTL;
|
bool _isRTL;
|
||||||
//FindInFilesDlg _findInFilesDlg;
|
|
||||||
|
|
||||||
int _findAllResult;
|
int _findAllResult;
|
||||||
TCHAR _findAllResultStr[128];
|
TCHAR _findAllResultStr[1024];
|
||||||
|
|
||||||
generic_string _filters;
|
generic_string _filters;
|
||||||
generic_string _directory;
|
generic_string _directory;
|
||||||
bool _isRecursive;
|
bool _isRecursive;
|
||||||
bool _isInHiddenDir;
|
bool _isInHiddenDir;
|
||||||
|
|
||||||
//int _maxNbCharAllocated;
|
|
||||||
int _fileNameLenMax;
|
int _fileNameLenMax;
|
||||||
//TCHAR *_line;
|
|
||||||
//char *_uniCharLine;
|
|
||||||
char *_uniFileName;
|
char *_uniFileName;
|
||||||
|
|
||||||
TabBar _tab;
|
TabBar _tab;
|
||||||
@ -355,8 +352,6 @@ private :
|
|||||||
void enableFindInFilesFunc() {
|
void enableFindInFilesFunc() {
|
||||||
enableFindInFilesControls();
|
enableFindInFilesControls();
|
||||||
|
|
||||||
//::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE);
|
|
||||||
|
|
||||||
_currentStatus = FINDINFILES_DLG;
|
_currentStatus = FINDINFILES_DLG;
|
||||||
gotoCorrectTab();
|
gotoCorrectTab();
|
||||||
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
|
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user