From c924a47560494ff7d7d4eb816748e2dd594faf25 Mon Sep 17 00:00:00 2001 From: yniq Date: Sat, 18 Apr 2009 18:54:54 +0000 Subject: [PATCH] [UPDATE] Added an (hidden) option to make the "Filters" and "Directory" fields follow the current opened document in "Find in files" dialog. The new parameters are located in config.xml and are called: "fifFilterFollowsDoc" and "fifFolderFollowsDoc" (set to "yes"/"no") git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@452 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 30 +++++++++---------- PowerEditor/src/Parameters.cpp | 12 +++++++- PowerEditor/src/Parameters.h | 4 ++- .../src/ScitillaComponent/FindReplaceDlg.h | 2 +- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index dcd9a3e7..96d54364 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1657,12 +1657,12 @@ bool Notepad_plus::replaceInFiles() HANDLE CancelThreadHandle = NULL; vector patterns2Match; - if (_findReplaceDlg.getFilters() == TEXT("")) - { - NppParameters *pNppParam = NppParameters::getInstance(); - _findReplaceDlg.setFindInFilesDirFilter(pNppParam->getWorkingDir(), TEXT("*.*")); - } _findReplaceDlg.getPatterns(patterns2Match); + if (patterns2Match.size() == 0) + { + _findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*")); + _findReplaceDlg.getPatterns(patterns2Match); + } vector fileNames; getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir); @@ -1738,14 +1738,13 @@ bool Notepad_plus::findInFiles() HANDLE CancelThreadHandle = NULL; vector patterns2Match; - if (_findReplaceDlg.getFilters() == TEXT("")) - { - NppParameters *pNppParam = NppParameters::getInstance(); - _findReplaceDlg.setFindInFilesDirFilter(pNppParam->getWorkingDir(), TEXT("*.*")); - } _findReplaceDlg.getPatterns(patterns2Match); + if (patterns2Match.size() == 0) + { + _findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*")); + _findReplaceDlg.getPatterns(patterns2Match); + } vector fileNames; - getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir); if (fileNames.size() > 1) @@ -9741,15 +9740,16 @@ void Notepad_plus::setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *fil { generic_string fltr; NppParameters *pNppParam = NppParameters::getInstance(); + FindHistory & findHistory = pNppParam->getFindHistory(); - // get current language file extensions in case they are not provided. - - if (!dir) + // get current directory in case it's not provided. + if (!dir && findHistory._isFolderFollowDoc) { dir = pNppParam->getWorkingDir(); } - if (!filter) + // get current language file extensions in case it's not provided. + if (!filter && findHistory._isFilterFollowDoc) { // Get current language file extensions const TCHAR *ext = NULL; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 3dc5b5b0..05ee1704 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1552,6 +1552,14 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node) if (boolStr) _findHistory._isDlgAlwaysVisible = !lstrcmp(TEXT("yes"), boolStr); + boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifFilterFollowsDoc")); + if (boolStr) + _findHistory._isFilterFollowDoc = !lstrcmp(TEXT("yes"), boolStr); + + boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifFolderFollowsDoc")); + if (boolStr) + _findHistory._isFolderFollowDoc = !lstrcmp(TEXT("yes"), boolStr); + int mode = 0; boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("searchMode"), &mode); if (boolStr) @@ -4072,7 +4080,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("dlgAlwaysVisible"), _findHistory._isDlgAlwaysVisible?TEXT("yes"):TEXT("no")); + (findHistoryRoot->ToElement())->SetAttribute(TEXT("dlgAlwaysVisible"), _findHistory._isDlgAlwaysVisible?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")); (findHistoryRoot->ToElement())->SetAttribute(TEXT("searchMode"), _findHistory._searchMode); (findHistoryRoot->ToElement())->SetAttribute(TEXT("transparencyMode"), _findHistory._transparencyMode); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 42307753..fd44cfe6 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -794,6 +794,7 @@ struct FindHistory { _nbFindHistoryPath(0), _nbFindHistoryFilter(0),_nbFindHistoryFind(0), _nbFindHistoryReplace(0),\ _isMatchWord(false), _isMatchCase(false),_isWrap(true),_isDirectionDown(true),\ _isFifRecuisive(true), _isFifInHiddenFolder(false), _isDlgAlwaysVisible(false),\ + _isFilterFollowDoc(false), _isFolderFollowDoc(false),\ _searchMode(normal), _transparencyMode(onLossingFocus), _transparency(150) {}; @@ -825,7 +826,8 @@ struct FindHistory { int _transparency; bool _isDlgAlwaysVisible; - + bool _isFilterFollowDoc; + bool _isFolderFollowDoc; }; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index 2d843bd6..36b377e4 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -350,7 +350,7 @@ public : if (dir) { _directory = dir; - //::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir); + ::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir); } if (filters) {