[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-ebc06183d4e3pull/343/head^2
parent
ab4ae49c8a
commit
6eda888b6e
|
@ -1725,6 +1725,7 @@ bool Notepad_plus::findInFiles()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Notepad_plus::findInOpenedFiles()
|
||||
{
|
||||
int nbTotal = 0;
|
||||
|
@ -2981,6 +2982,7 @@ void Notepad_plus::command(int id)
|
|||
|
||||
_pEditView->getGenericSelectedText(str, strSize);
|
||||
_findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
|
||||
setFindReplaceFolderFilter(NULL, NULL);
|
||||
|
||||
if (isFirstTime)
|
||||
changeFindReplaceDlgLang();
|
||||
|
@ -7099,54 +7101,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
if (isFirstTime)
|
||||
changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
|
||||
_findReplaceDlg.launchFindInFilesDlg();
|
||||
|
||||
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());
|
||||
setFindReplaceFolderFilter((const TCHAR*) wParam, (const TCHAR*) lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -9476,3 +9431,53 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam
|
|||
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);
|
||||
bool findInFiles();
|
||||
bool replaceInFiles();
|
||||
void setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filters);
|
||||
|
||||
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
||||
private:
|
||||
|
|
|
@ -151,28 +151,24 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
|||
{
|
||||
if (!hCombo) return;
|
||||
if (!lstrcmp(txt2add, TEXT(""))) return;
|
||||
|
||||
TCHAR text[MAX_PATH];
|
||||
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||
|
||||
int i = 0;
|
||||
|
||||
#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);
|
||||
if (!lstrcmp(txt2add, text))
|
||||
{
|
||||
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
||||
break;
|
||||
}
|
||||
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
||||
}
|
||||
|
||||
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
||||
|
||||
#else
|
||||
TCHAR text[MAX_PATH];
|
||||
bool isWin9x = _winVer <= WV_ME;
|
||||
wchar_t wchars2Add[MAX_PATH];
|
||||
wchar_t textW[MAX_PATH];
|
||||
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||
|
||||
if (isUTF8)
|
||||
::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)
|
||||
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
|
||||
|
||||
else
|
||||
{
|
||||
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
||||
|
@ -205,8 +202,10 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isUTF8)
|
||||
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
||||
|
||||
else
|
||||
{
|
||||
if (!isWin9x)
|
||||
|
@ -332,7 +331,7 @@ void FindReplaceDlg::fillComboHistory(int id, int count, generic_string **pStrin
|
|||
HWND hCombo;
|
||||
|
||||
hCombo = ::GetDlgItem(_hSelf, id);
|
||||
for (i = 0; i < count; i++)
|
||||
for (i = count -1 ; i >= 0 ; i--)
|
||||
{
|
||||
addText2Combo(pStrings[i]->c_str(), hCombo, isUnicode);
|
||||
}
|
||||
|
@ -351,7 +350,7 @@ void FindReplaceDlg::saveFindHistory()
|
|||
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;
|
||||
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));
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue