mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-28 08:14:18 +02:00
[ENHANCE] Enhance Find in files thread feature - add stop searching ability.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@335 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
ddd055e5a2
commit
2fd07e9a2d
@ -1550,20 +1550,25 @@ bool Notepad_plus::findInFiles()
|
|||||||
vector<generic_string> fileNames;
|
vector<generic_string> fileNames;
|
||||||
|
|
||||||
_findReplaceDlg.putFindResultStr(TEXT("Scanning files to search..."));
|
_findReplaceDlg.putFindResultStr(TEXT("Scanning files to search..."));
|
||||||
_findReplaceDlg.Refresh();
|
_findReplaceDlg.refresh();
|
||||||
|
|
||||||
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
|
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
|
||||||
|
|
||||||
TCHAR msg[128];
|
TCHAR msg[128];
|
||||||
wsprintf(msg, TEXT("Found %d matching files"), fileNames.size());
|
wsprintf(msg, TEXT("Found %d matching files"), fileNames.size());
|
||||||
_findReplaceDlg.putFindResultStr((const TCHAR*)msg);
|
_findReplaceDlg.putFindResultStr((const TCHAR*)msg);
|
||||||
_findReplaceDlg.Refresh();
|
_findReplaceDlg.refresh();
|
||||||
|
|
||||||
UINT_PTR pTimer = ::SetTimer(_hSelf, 12614, 500, NULL);
|
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++)
|
||||||
{
|
{
|
||||||
|
if (!_findReplaceDlg.isFindingInFiles())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -1597,7 +1602,8 @@ bool Notepad_plus::findInFiles()
|
|||||||
|
|
||||||
wsprintf(msg, TEXT("%d hits"), nbTotal);
|
wsprintf(msg, TEXT("%d hits"), nbTotal);
|
||||||
_findReplaceDlg.putFindResultStr((const TCHAR *)&msg);
|
_findReplaceDlg.putFindResultStr((const TCHAR *)&msg);
|
||||||
_findReplaceDlg.Refresh();
|
_findReplaceDlg.refresh();
|
||||||
|
_findReplaceDlg.reachEnd();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7863,7 +7869,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
{
|
{
|
||||||
_findReplaceDlg.Refresh();
|
_findReplaceDlg.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
case NPPM_DMMHIDE:
|
case NPPM_DMMHIDE:
|
||||||
|
@ -531,20 +531,14 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
//Single actions
|
//Single actions
|
||||||
case IDOK : // Find Next
|
case IDOK : // Find Next : only for FIND_DLG and REPLACE_DLG
|
||||||
{
|
{
|
||||||
bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit;
|
bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit;
|
||||||
if ((_currentStatus == FIND_DLG) || (_currentStatus == REPLACE_DLG))
|
|
||||||
{
|
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||||
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
generic_string str2Search = getTextFromCombo(hFindCombo, isUnicode);
|
||||||
generic_string str2Search = getTextFromCombo(hFindCombo, isUnicode);
|
updateCombo(IDFINDWHAT);
|
||||||
updateCombo(IDFINDWHAT);
|
processFindNext(str2Search.c_str());
|
||||||
processFindNext(str2Search.c_str());
|
|
||||||
}
|
|
||||||
else if (_currentStatus == FINDINFILES_DLG)
|
|
||||||
{
|
|
||||||
::SendMessage(_hSelf, WM_COMMAND, IDD_FINDINFILES_FIND_BUTTON, (LPARAM)_hSelf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -574,26 +568,31 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
|
|
||||||
case IDD_FINDINFILES_FIND_BUTTON :
|
case IDD_FINDINFILES_FIND_BUTTON :
|
||||||
{
|
{
|
||||||
if (_currentStatus == FINDINFILES_DLG)
|
_isFindingInFiles = true;
|
||||||
{
|
showFindInFilesButton();
|
||||||
const int filterSize = 256;
|
const int filterSize = 256;
|
||||||
TCHAR filters[filterSize];
|
TCHAR filters[filterSize];
|
||||||
TCHAR directory[MAX_PATH];
|
TCHAR directory[MAX_PATH];
|
||||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
|
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
|
||||||
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
|
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
|
||||||
_filters = filters;
|
_filters = filters;
|
||||||
|
|
||||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
||||||
addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
||||||
_directory = directory;
|
_directory = directory;
|
||||||
|
|
||||||
if ((lstrlen(directory) > 0) && (directory[lstrlen(directory)-1] != '\\'))
|
|
||||||
_directory += TEXT("\\");
|
|
||||||
|
|
||||||
updateCombo(IDFINDWHAT);
|
|
||||||
findAllIn(FILES_IN_DIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ((lstrlen(directory) > 0) && (directory[lstrlen(directory)-1] != '\\'))
|
||||||
|
_directory += TEXT("\\");
|
||||||
|
|
||||||
|
updateCombo(IDFINDWHAT);
|
||||||
|
findAllIn(FILES_IN_DIR);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case IDD_FINDINFILES_FINDSTOP_BUTTON :
|
||||||
|
{
|
||||||
|
_isFindingInFiles = false;
|
||||||
|
showFindInFilesButton();
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -1294,7 +1293,7 @@ void FindReplaceDlg::findAllIn(InWhat op)
|
|||||||
|
|
||||||
::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, 0);
|
::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, 0);
|
||||||
|
|
||||||
Refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::putFindResultStr(const TCHAR *text)
|
void FindReplaceDlg::putFindResultStr(const TCHAR *text)
|
||||||
@ -1302,7 +1301,7 @@ void FindReplaceDlg::putFindResultStr(const TCHAR *text)
|
|||||||
wsprintf(_findAllResultStr, TEXT("%s"), text);
|
wsprintf(_findAllResultStr, TEXT("%s"), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::Refresh()
|
void FindReplaceDlg::refresh()
|
||||||
{
|
{
|
||||||
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
|
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
|
||||||
}
|
}
|
||||||
@ -1313,8 +1312,6 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable)
|
|||||||
int hideOrShow = isEnable?SW_SHOW:SW_HIDE;
|
int hideOrShow = isEnable?SW_SHOW:SW_HIDE;
|
||||||
RECT *pClosePos = isEnable?&_replaceClosePos:&_findClosePos;
|
RECT *pClosePos = isEnable?&_replaceClosePos:&_findClosePos;
|
||||||
|
|
||||||
//::EnableWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FIND_BUTTON), FALSE);
|
|
||||||
//::EnableWindow(::GetDlgItem(_hSelf, IDOK), TRUE);
|
|
||||||
enableFindInFilesControls(false);
|
enableFindInFilesControls(false);
|
||||||
|
|
||||||
// replce controls
|
// replce controls
|
||||||
@ -1378,7 +1375,8 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable)
|
|||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_STATIC), isEnable?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_STATIC), isEnable?SW_SHOW:SW_HIDE);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO), isEnable?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO), isEnable?SW_SHOW:SW_HIDE);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_BROWSE_BUTTON), isEnable?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_BROWSE_BUTTON), isEnable?SW_SHOW:SW_HIDE);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FIND_BUTTON), isEnable?SW_SHOW:SW_HIDE);
|
//::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FIND_BUTTON), isEnable?SW_SHOW:SW_HIDE);
|
||||||
|
showFindInFilesButton(isEnable);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_GOBACK_BUTTON), isEnable?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_GOBACK_BUTTON), isEnable?SW_SHOW:SW_HIDE);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK), isEnable?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK), isEnable?SW_SHOW:SW_HIDE);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK), isEnable?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK), isEnable?SW_SHOW:SW_HIDE);
|
||||||
|
@ -192,7 +192,7 @@ class FindReplaceDlg : public StaticDialog
|
|||||||
friend class FindIncrementDlg;
|
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), _isFindingInFiles(false) {
|
||||||
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
|
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
|
||||||
_winVer = (NppParameters::getInstance())->getWinVersion();
|
_winVer = (NppParameters::getInstance())->getWinVersion();
|
||||||
};
|
};
|
||||||
@ -274,7 +274,7 @@ public :
|
|||||||
};
|
};
|
||||||
void putFindResultStr(const TCHAR *text);
|
void putFindResultStr(const TCHAR *text);
|
||||||
|
|
||||||
void Refresh();
|
void refresh();
|
||||||
|
|
||||||
void setSearchWord2Finder(){
|
void setSearchWord2Finder(){
|
||||||
generic_string str2Search = getText2search();
|
generic_string str2Search = getText2search();
|
||||||
@ -309,8 +309,27 @@ 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 isRecursive() const { return _isRecursive; };
|
||||||
bool isInHiddenDir() { return _isInHiddenDir; }
|
bool isInHiddenDir() const { return _isInHiddenDir; };
|
||||||
|
void showFindInFilesButton(bool shouldBeShown = true) {
|
||||||
|
bool fif, fifStop;
|
||||||
|
if (shouldBeShown)
|
||||||
|
{
|
||||||
|
fif = !_isFindingInFiles;
|
||||||
|
fifStop = _isFindingInFiles;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fif = fifStop = false;
|
||||||
|
}
|
||||||
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FIND_BUTTON), fif?SW_SHOW:SW_HIDE);
|
||||||
|
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FINDSTOP_BUTTON), fifStop?SW_SHOW:SW_HIDE);
|
||||||
|
};
|
||||||
|
bool isFindingInFiles() const {return _isFindingInFiles;};
|
||||||
|
void reachEnd() {
|
||||||
|
_isFindingInFiles = false;
|
||||||
|
showFindInFilesButton();
|
||||||
|
};
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
@ -325,6 +344,7 @@ private :
|
|||||||
bool _doMarkLine;
|
bool _doMarkLine;
|
||||||
bool _doStyleFoundToken;
|
bool _doStyleFoundToken;
|
||||||
bool _isInSelection;
|
bool _isInSelection;
|
||||||
|
bool _isFindingInFiles;
|
||||||
|
|
||||||
|
|
||||||
RECT _findClosePos, _replaceClosePos, _findInFilesClosePos;
|
RECT _findClosePos, _replaceClosePos, _findInFilesClosePos;
|
||||||
|
@ -71,6 +71,7 @@ BEGIN
|
|||||||
PUSHBUTTON "Replace &All",IDREPLACEALL,217,56,90,14, WS_TABSTOP
|
PUSHBUTTON "Replace &All",IDREPLACEALL,217,56,90,14, WS_TABSTOP
|
||||||
PUSHBUTTON "Replace all in all opened documents",IDC_REPLACE_OPENEDFILES,217,74,90,21,BS_MULTILINE | WS_TABSTOP
|
PUSHBUTTON "Replace all in all opened documents",IDC_REPLACE_OPENEDFILES,217,74,90,21,BS_MULTILINE | WS_TABSTOP
|
||||||
PUSHBUTTON "Find them all",IDD_FINDINFILES_FIND_BUTTON,217,20,90,14,WS_GROUP
|
PUSHBUTTON "Find them all",IDD_FINDINFILES_FIND_BUTTON,217,20,90,14,WS_GROUP
|
||||||
|
PUSHBUTTON "Stop searching",IDD_FINDINFILES_FINDSTOP_BUTTON,217,20,90,14,WS_GROUP
|
||||||
PUSHBUTTON "Close",IDCANCEL,217,99,90,14, WS_TABSTOP
|
PUSHBUTTON "Close",IDCANCEL,217,99,90,14, WS_TABSTOP
|
||||||
|
|
||||||
GROUPBOX "Transparency",IDC_TRANSPARENT_GRPBOX,227,123,83,49
|
GROUPBOX "Transparency",IDC_TRANSPARENT_GRPBOX,227,123,83,49
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#define IDD_FINDINFILES_GOBACK_BUTTON 1657
|
#define IDD_FINDINFILES_GOBACK_BUTTON 1657
|
||||||
#define IDD_FINDINFILES_RECURSIVE_CHECK 1658
|
#define IDD_FINDINFILES_RECURSIVE_CHECK 1658
|
||||||
#define IDD_FINDINFILES_INHIDDENDIR_CHECK 1659
|
#define IDD_FINDINFILES_INHIDDENDIR_CHECK 1659
|
||||||
|
#define IDD_FINDINFILES_FINDSTOP_BUTTON 1660
|
||||||
|
|
||||||
#define IDD_FINDRESULT 1670
|
#define IDD_FINDRESULT 1670
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user