[NEW] Make search in hidden folder optional in find in file.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@192 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-04-29 22:05:32 +00:00
parent 017784de5b
commit 2951979ef5
6 changed files with 38 additions and 22 deletions

View File

@ -1238,7 +1238,7 @@ void Notepad_plus::loadLastSession()
loadSession(lastSession); loadSession(lastSession);
} }
void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & patterns, vector<string> & fileNames, bool isRecursive) void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & patterns, vector<string> & fileNames, bool isRecursive, bool isInHiddenDir)
{ {
string dirFilter(dir); string dirFilter(dir);
dirFilter += "*.*"; dirFilter += "*.*";
@ -1251,7 +1251,7 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & p
if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{ {
if (foundData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) if (!isInHiddenDir && (foundData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
{ {
// branles rien // branles rien
} }
@ -1262,7 +1262,7 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & p
string pathDir(dir); string pathDir(dir);
pathDir += foundData.cFileName; pathDir += foundData.cFileName;
pathDir += "\\"; pathDir += "\\";
getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive); getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive, isInHiddenDir);
} }
} }
} }
@ -1280,7 +1280,7 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & p
{ {
if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{ {
if (foundData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) if (!isInHiddenDir && (foundData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
{ {
// branles rien // branles rien
} }
@ -1291,7 +1291,7 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & p
string pathDir(dir); string pathDir(dir);
pathDir += foundData.cFileName; pathDir += foundData.cFileName;
pathDir += "\\"; pathDir += "\\";
getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive); getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive, isInHiddenDir);
} }
} }
} }
@ -1308,7 +1308,7 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & p
::FindClose(hFile); ::FindClose(hFile);
} }
bool Notepad_plus::findInFiles(bool isRecursive) bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
{ {
int nbTotal = 0; int nbTotal = 0;
ScintillaEditView *pOldView = _pEditView; ScintillaEditView *pOldView = _pEditView;
@ -1330,7 +1330,7 @@ bool Notepad_plus::findInFiles(bool isRecursive)
_findReplaceDlg.setFindInFilesDirFilter(NULL, "*.*"); _findReplaceDlg.setFindInFilesDirFilter(NULL, "*.*");
_findReplaceDlg.getPatterns(patterns2Match); _findReplaceDlg.getPatterns(patterns2Match);
vector<string> fileNames; vector<string> fileNames;
getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive); getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir);
for (size_t i = 0 ; i < fileNames.size() ; i++) for (size_t i = 0 ; i < fileNames.size() ; i++)
{ {
@ -2795,7 +2795,6 @@ void Notepad_plus::command(int id)
char dir[MAX_PATH]; char dir[MAX_PATH];
strcpy(dir, _pEditView->getCurrentTitle()); strcpy(dir, _pEditView->getCurrentTitle());
PathRemoveFileSpec((LPSTR)dir); PathRemoveFileSpec((LPSTR)dir);
str2Cliboard(dir); str2Cliboard(dir);
} }
break; break;
@ -6555,8 +6554,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_FINDINFILES : case WM_FINDINFILES :
{ {
bool isRecursive = lParam == TRUE; bool isRecursive = bool(lParam & FIND_RECURSIVE);
findInFiles(isRecursive); bool isInHiddenFolder = bool(lParam & FIND_INHIDDENDIR);
findInFiles(isRecursive, isInHiddenFolder);
return TRUE; return TRUE;
} }
@ -8257,7 +8257,6 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
return true; return true;
} }
void Notepad_plus::markSelectedText() void Notepad_plus::markSelectedText()
{ {
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI(); const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();

View File

@ -597,10 +597,10 @@ private:
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText); void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText);
bool replaceAllFiles(); bool replaceAllFiles();
bool findInOpenedFiles(); bool findInOpenedFiles();
bool findInFiles(bool isRecursive); bool findInFiles(bool isRecursive, bool isInHiddenDir);
bool matchInList(const char *fileName, const vector<string> & patterns); bool matchInList(const char *fileName, const vector<string> & patterns);
void getMatchedFileNames(const char *dir, const vector<string> & patterns, vector<string> & fileNames, bool isRecursive); void getMatchedFileNames(const char *dir, const vector<string> & patterns, vector<string> & fileNames, bool isRecursive, bool isInHiddenDir);
void doSynScorll(HWND hW); void doSynScorll(HWND hW);
void setWorkingDir(char *dir) { void setWorkingDir(char *dir) {
@ -622,6 +622,7 @@ private:
::SetCurrentDirectory(dir); ::SetCurrentDirectory(dir);
} }
bool str2Cliboard(const char *str2cpy); bool str2Cliboard(const char *str2cpy);
bool bin2Cliboard(const unsigned char *uchar2cpy, size_t length);
bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible); bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible);

View File

@ -744,6 +744,13 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
} }
return TRUE; return TRUE;
case IDD_FINDINFILES_INHIDDENDIR_CHECK :
{
if (_currentStatus == FINDINFILES_DLG)
_isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
}
return TRUE;
case IDD_FINDINFILES_BROWSE_BUTTON : case IDD_FINDINFILES_BROWSE_BUTTON :
{ {
if (_currentStatus == FINDINFILES_DLG) if (_currentStatus == FINDINFILES_DLG)
@ -1285,7 +1292,12 @@ void FindReplaceDlg::findAllIn(InWhat op)
_pFinder->setMode(op); _pFinder->setMode(op);
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0); ::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, (op!=ALL_OPEN_DOCS)?_isRecursive: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);
//char *pDataToWrite = _findAllResultStr + strlen(FIND_RESULT_DEFAULT_TITLE); //char *pDataToWrite = _findAllResultStr + strlen(FIND_RESULT_DEFAULT_TITLE);
sprintf(_findAllResultStr, "%d hits", _findAllResult); sprintf(_findAllResultStr, "%d hits", _findAllResult);
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf()); ::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
@ -1365,6 +1377,7 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable)
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FIND_BUTTON), isEnable?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_FIND_BUTTON), isEnable?SW_SHOW:SW_HIDE);
::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);
char label[MAX_PATH]; char label[MAX_PATH];
_tab.getCurrentTitle(label, sizeof(label)); _tab.getCurrentTitle(label, sizeof(label));

View File

@ -25,11 +25,10 @@
#include "StatusBar.h" #include "StatusBar.h"
#include "DockingDlgInterface.h" #include "DockingDlgInterface.h"
/*
typedef bool DIALOG_TYPE; #define FIND_RECURSIVE 1
#define REPLACE true #define FIND_INHIDDENDIR 2
#define FIND false
*/
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG}; enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG};
#define DIR_DOWN true #define DIR_DOWN true
@ -173,7 +172,8 @@ class FindReplaceDlg : public StaticDialog
{ {
friend class FindIncrementDlg; friend class FindIncrementDlg;
public : public :
FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false), _isRecursive(true), _maxNbCharAllocated(1024), _fileNameLenMax(1024) { FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false), _isRecursive(true),_isInHiddenDir(false),\
_maxNbCharAllocated(1024), _fileNameLenMax(1024) {
_line = new char[_maxNbCharAllocated + 3]; _line = new char[_maxNbCharAllocated + 3];
_uniCharLine = new char[(_maxNbCharAllocated + 3) * 2]; _uniCharLine = new char[(_maxNbCharAllocated + 3) * 2];
_uniFileName = new char[(_fileNameLenMax + 3) * 2]; _uniFileName = new char[(_fileNameLenMax + 3) * 2];
@ -333,6 +333,7 @@ private :
string _filters; string _filters;
string _directory; string _directory;
bool _isRecursive; bool _isRecursive;
bool _isInHiddenDir;
int _maxNbCharAllocated; int _maxNbCharAllocated;
int _fileNameLenMax; int _fileNameLenMax;

View File

@ -48,7 +48,8 @@ BEGIN
RTEXT "Directory :",IDD_FINDINFILES_DIR_STATIC,7,58,40,8 RTEXT "Directory :",IDD_FINDINFILES_DIR_STATIC,7,58,40,8
COMBOBOX IDD_FINDINFILES_DIR_COMBO,49,57,141,150, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP COMBOBOX IDD_FINDINFILES_DIR_COMBO,49,57,141,150, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,193,56,16,14 PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,193,56,16,14
CONTROL "In all sub-folders",IDD_FINDINFILES_RECURSIVE_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,49,70,110,15 CONTROL "In all sub-folders",IDD_FINDINFILES_RECURSIVE_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,49,70,80,15
CONTROL "In hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,129,70,80,15
CONTROL "Match &whole word only",IDWHOLEWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,6,88,110,15 CONTROL "Match &whole word only",IDWHOLEWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,6,88,110,15
CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,100,110,15 CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,100,110,15

View File

@ -53,7 +53,8 @@
#define IDD_FINDINFILES_DIR_STATIC 1655 #define IDD_FINDINFILES_DIR_STATIC 1655
#define IDD_FINDINFILES_FIND_BUTTON 1656 #define IDD_FINDINFILES_FIND_BUTTON 1656
#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_FINDRESULT 1670 #define IDD_FINDRESULT 1670