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