mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-23 09:58:34 +02:00
[NEW] The file filters and the directory are set while find/replace/findInFiles dialog is launched.
[BUG_FIXED] Texts in combo box of Find dialog are restored in order now on the launch time. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@404 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
ab4ae49c8a
commit
6eda888b6e
@ -1725,6 +1725,7 @@ bool Notepad_plus::findInFiles()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Notepad_plus::findInOpenedFiles()
|
bool Notepad_plus::findInOpenedFiles()
|
||||||
{
|
{
|
||||||
int nbTotal = 0;
|
int nbTotal = 0;
|
||||||
@ -2981,6 +2982,7 @@ void Notepad_plus::command(int id)
|
|||||||
|
|
||||||
_pEditView->getGenericSelectedText(str, strSize);
|
_pEditView->getGenericSelectedText(str, strSize);
|
||||||
_findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
|
_findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
|
||||||
|
setFindReplaceFolderFilter(NULL, NULL);
|
||||||
|
|
||||||
if (isFirstTime)
|
if (isFirstTime)
|
||||||
changeFindReplaceDlgLang();
|
changeFindReplaceDlgLang();
|
||||||
@ -7099,54 +7101,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
if (isFirstTime)
|
if (isFirstTime)
|
||||||
changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
|
changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
|
||||||
_findReplaceDlg.launchFindInFilesDlg();
|
_findReplaceDlg.launchFindInFilesDlg();
|
||||||
|
setFindReplaceFolderFilter((const TCHAR*) wParam, (const TCHAR*) lParam);
|
||||||
const TCHAR *dir = NULL;
|
|
||||||
generic_string fltr;
|
|
||||||
|
|
||||||
if (wParam)
|
|
||||||
dir = (const TCHAR *)wParam;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dir = pNppParam->getWorkingDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lParam)
|
|
||||||
{
|
|
||||||
fltr = (const TCHAR *)lParam;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const TCHAR *ext = NULL;
|
|
||||||
LangType lt = _pEditView->getCurrentBuffer()->getLangType();
|
|
||||||
if (lt == L_USER)
|
|
||||||
{
|
|
||||||
Buffer * buf = _pEditView->getCurrentBuffer();
|
|
||||||
UserLangContainer * userLangContainer = pNppParam->getULCFromName(buf->getUserDefineLangName());
|
|
||||||
if (userLangContainer)
|
|
||||||
ext = userLangContainer->getExtention();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ext = NppParameters::getInstance()->getLangExtFromLangType(lt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ext && ext[0])
|
|
||||||
{
|
|
||||||
generic_string filtres = TEXT("");
|
|
||||||
vector<generic_string> vStr;
|
|
||||||
cutString(ext, vStr);
|
|
||||||
for (size_t i = 0 ; i < vStr.size() ; i++)
|
|
||||||
{
|
|
||||||
filtres += TEXT("*.");
|
|
||||||
filtres += vStr[i] + TEXT(" ");
|
|
||||||
}
|
|
||||||
fltr = filtres;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fltr = TEXT("*.*");
|
|
||||||
}
|
|
||||||
_findReplaceDlg.setFindInFilesDirFilter(dir, fltr.c_str());
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9476,3 +9431,53 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam
|
|||||||
switchToFile(lastOpened);
|
switchToFile(lastOpened);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notepad_plus::setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filter)
|
||||||
|
{
|
||||||
|
generic_string fltr;
|
||||||
|
NppParameters *pNppParam = NppParameters::getInstance();
|
||||||
|
|
||||||
|
// get current direcroty and current language file extensions in case they are not provided.
|
||||||
|
|
||||||
|
if (!dir)
|
||||||
|
{
|
||||||
|
dir = pNppParam->getWorkingDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filter)
|
||||||
|
{
|
||||||
|
// Get current language file extensions
|
||||||
|
const TCHAR *ext = NULL;
|
||||||
|
LangType lt = _pEditView->getCurrentBuffer()->getLangType();
|
||||||
|
|
||||||
|
if (lt == L_USER)
|
||||||
|
{
|
||||||
|
Buffer * buf = _pEditView->getCurrentBuffer();
|
||||||
|
UserLangContainer * userLangContainer = pNppParam->getULCFromName(buf->getUserDefineLangName());
|
||||||
|
if (userLangContainer)
|
||||||
|
ext = userLangContainer->getExtention();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ext = NppParameters::getInstance()->getLangExtFromLangType(lt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ext && ext[0])
|
||||||
|
{
|
||||||
|
fltr = TEXT("");
|
||||||
|
vector<generic_string> vStr;
|
||||||
|
cutString(ext, vStr);
|
||||||
|
for (size_t i = 0; i < vStr.size(); i++)
|
||||||
|
{
|
||||||
|
fltr += TEXT("*.");
|
||||||
|
fltr += vStr[i] + TEXT(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fltr = TEXT("*.*");
|
||||||
|
}
|
||||||
|
filter = fltr.c_str();
|
||||||
|
}
|
||||||
|
_findReplaceDlg.setFindInFilesDirFilter(dir, filter);
|
||||||
|
}
|
||||||
|
@ -218,6 +218,7 @@ public:
|
|||||||
void notifyBufferChanged(Buffer * buffer, int mask);
|
void notifyBufferChanged(Buffer * buffer, int mask);
|
||||||
bool findInFiles();
|
bool findInFiles();
|
||||||
bool replaceInFiles();
|
bool replaceInFiles();
|
||||||
|
void setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filters);
|
||||||
|
|
||||||
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
||||||
private:
|
private:
|
||||||
|
@ -151,28 +151,24 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
|||||||
{
|
{
|
||||||
if (!hCombo) return;
|
if (!hCombo) return;
|
||||||
if (!lstrcmp(txt2add, TEXT(""))) return;
|
if (!lstrcmp(txt2add, TEXT(""))) return;
|
||||||
|
|
||||||
TCHAR text[MAX_PATH];
|
|
||||||
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
for ( ; i < count ; i++)
|
i = ::SendMessage(hCombo, CB_FINDSTRINGEXACT, -1, (LPARAM)txt2add);
|
||||||
|
if (i != CB_ERR) // found
|
||||||
{
|
{
|
||||||
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
||||||
if (!lstrcmp(txt2add, text))
|
|
||||||
{
|
|
||||||
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
TCHAR text[MAX_PATH];
|
||||||
bool isWin9x = _winVer <= WV_ME;
|
bool isWin9x = _winVer <= WV_ME;
|
||||||
wchar_t wchars2Add[MAX_PATH];
|
wchar_t wchars2Add[MAX_PATH];
|
||||||
wchar_t textW[MAX_PATH];
|
wchar_t textW[MAX_PATH];
|
||||||
|
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||||
|
|
||||||
if (isUTF8)
|
if (isUTF8)
|
||||||
::MultiByteToWideChar(CP_UTF8, 0, txt2add, -1, wchars2Add, MAX_PATH - 1);
|
::MultiByteToWideChar(CP_UTF8, 0, txt2add, -1, wchars2Add, MAX_PATH - 1);
|
||||||
@ -183,6 +179,7 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
|||||||
{
|
{
|
||||||
if (!isWin9x)
|
if (!isWin9x)
|
||||||
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
|
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
||||||
@ -205,8 +202,10 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUTF8)
|
if (!isUTF8)
|
||||||
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!isWin9x)
|
if (!isWin9x)
|
||||||
@ -332,7 +331,7 @@ void FindReplaceDlg::fillComboHistory(int id, int count, generic_string **pStrin
|
|||||||
HWND hCombo;
|
HWND hCombo;
|
||||||
|
|
||||||
hCombo = ::GetDlgItem(_hSelf, id);
|
hCombo = ::GetDlgItem(_hSelf, id);
|
||||||
for (i = 0; i < count; i++)
|
for (i = count -1 ; i >= 0 ; i--)
|
||||||
{
|
{
|
||||||
addText2Combo(pStrings[i]->c_str(), hCombo, isUnicode);
|
addText2Combo(pStrings[i]->c_str(), hCombo, isUnicode);
|
||||||
}
|
}
|
||||||
@ -351,7 +350,7 @@ void FindReplaceDlg::saveFindHistory()
|
|||||||
saveComboHistory(IDREPLACEWITH, findHistory.nbMaxFindHistoryReplace, findHistory.nbFindHistoryReplace, findHistory.FindHistoryReplace);
|
saveComboHistory(IDREPLACEWITH, findHistory.nbMaxFindHistoryReplace, findHistory.nbFindHistoryReplace, findHistory.FindHistoryReplace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::saveComboHistory(int id, int maxcount, int& oldcount, generic_string **pStrings)
|
void FindReplaceDlg::saveComboHistory(int id, int maxcount, int & oldcount, generic_string **pStrings)
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
bool isUnicode = false;
|
bool isUnicode = false;
|
||||||
@ -523,13 +522,6 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
{
|
{
|
||||||
int indexClicked = int(::SendMessage(tabHandle, TCM_GETCURSEL, 0, 0));
|
int indexClicked = int(::SendMessage(tabHandle, TCM_GETCURSEL, 0, 0));
|
||||||
doDialog((DIALOG_TYPE)indexClicked);
|
doDialog((DIALOG_TYPE)indexClicked);
|
||||||
if ((DIALOG_TYPE)indexClicked == FINDINFILES_DLG)
|
|
||||||
{
|
|
||||||
//TCHAR currentDir[MAX_PATH];
|
|
||||||
//::GetCurrentDirectory(MAX_PATH, currentDir);
|
|
||||||
//setFindInFilesDirFilter(currentDir, NULL);
|
|
||||||
setFindInFilesDirFilter(NppParameters::getInstance()->getWorkingDir(), NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user