[NEW_FEATURE] find/replace dialog settings are remembered. Add a hidden setting (dlgAlwaysVisible in config.xml) to not hide the dialog if any result found.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@435 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2009-03-08 02:06:30 +00:00
parent 849ebb417d
commit 22cae478e8
4 changed files with 252 additions and 102 deletions

View File

@ -1759,7 +1759,10 @@ bool Notepad_plus::findInFiles()
_pEditView = pOldView;
_findReplaceDlg.putFindResult(nbTotal);
if (nbTotal) _findReplaceDlg.display(false);
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory();
if (nbTotal && !findHistory._isDlgAlwaysVisible)
_findReplaceDlg.display(false);
return true;
}
@ -1805,7 +1808,10 @@ bool Notepad_plus::findInOpenedFiles()
_pEditView = pOldView;
_findReplaceDlg.putFindResult(nbTotal);
if (nbTotal) _findReplaceDlg.display(false);
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory();
if (nbTotal && !findHistory._isDlgAlwaysVisible)
_findReplaceDlg.display(false);
return true;
}
@ -1832,7 +1838,10 @@ bool Notepad_plus::findInCurrentFile()
_pEditView = pOldView;
_findReplaceDlg.putFindResult(nbTotal);
if (nbTotal) _findReplaceDlg.display(false);
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory();
if (nbTotal && !findHistory._isDlgAlwaysVisible)
_findReplaceDlg.display(false);
return true;
}

View File

@ -508,10 +508,10 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false)
{
_findHistory.nbFindHistoryPath = 0;
_findHistory.nbFindHistoryFilter = 0;
_findHistory.nbFindHistoryFind = 0;
_findHistory.nbFindHistoryReplace = 0;
_findHistory._nbFindHistoryPath = 0;
_findHistory._nbFindHistoryFilter = 0;
_findHistory._nbFindHistoryFind = 0;
_findHistory._nbFindHistoryReplace = 0;
//Get windows version
_winVersion = getWindowsVersion();
@ -1463,75 +1463,111 @@ void NppParameters::feedFileListParameters(TiXmlNode *node)
void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
{
_findHistory.nbMaxFindHistoryPath = 10;
_findHistory.nbMaxFindHistoryFilter = 10;
_findHistory.nbMaxFindHistoryFind = 10;
_findHistory.nbMaxFindHistoryReplace = 10;
TiXmlNode *findHistoryRoot = node->FirstChildElement(TEXT("FindHistory"));
if (!findHistoryRoot) return;
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryPath"), &_findHistory.nbMaxFindHistoryPath);
if ((_findHistory.nbMaxFindHistoryPath > 0) && (_findHistory.nbMaxFindHistoryPath <= NB_MAX_FINDHISTORY_PATH))
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryPath"), &_findHistory._nbMaxFindHistoryPath);
if ((_findHistory._nbMaxFindHistoryPath > 0) && (_findHistory._nbMaxFindHistoryPath <= NB_MAX_FINDHISTORY_PATH))
{
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Path"));
childNode && (_findHistory.nbFindHistoryPath < NB_MAX_FINDHISTORY_PATH);
childNode && (_findHistory._nbFindHistoryPath < NB_MAX_FINDHISTORY_PATH);
childNode = childNode->NextSibling(TEXT("Path")) )
{
const TCHAR *filePath = (childNode->ToElement())->Attribute(TEXT("name"));
if (filePath)
{
_findHistory.FindHistoryPath[_findHistory.nbFindHistoryPath++] = new generic_string(filePath);
_findHistory._pFindHistoryPath[_findHistory._nbFindHistoryPath++] = new generic_string(filePath);
}
}
}
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryFilter"), &_findHistory.nbMaxFindHistoryFilter);
if ((_findHistory.nbMaxFindHistoryFilter > 0) && (_findHistory.nbMaxFindHistoryFilter <= NB_MAX_FINDHISTORY_FILTER))
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryFilter"), &_findHistory._nbMaxFindHistoryFilter);
if ((_findHistory._nbMaxFindHistoryFilter > 0) && (_findHistory._nbMaxFindHistoryFilter <= NB_MAX_FINDHISTORY_FILTER))
{
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Filter"));
childNode && (_findHistory.nbFindHistoryFilter < NB_MAX_FINDHISTORY_FILTER);
childNode && (_findHistory._nbFindHistoryFilter < NB_MAX_FINDHISTORY_FILTER);
childNode = childNode->NextSibling(TEXT("Filter")))
{
const TCHAR *fileFilter = (childNode->ToElement())->Attribute(TEXT("name"));
if (fileFilter)
{
_findHistory.FindHistoryFilter[_findHistory.nbFindHistoryFilter++] = new generic_string(fileFilter);
_findHistory._pFindHistoryFilter[_findHistory._nbFindHistoryFilter++] = new generic_string(fileFilter);
}
}
}
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryFind"), &_findHistory.nbMaxFindHistoryFind);
if ((_findHistory.nbMaxFindHistoryFind > 0) && (_findHistory.nbMaxFindHistoryFind <= NB_MAX_FINDHISTORY_FIND))
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryFind"), &_findHistory._nbMaxFindHistoryFind);
if ((_findHistory._nbMaxFindHistoryFind > 0) && (_findHistory._nbMaxFindHistoryFind <= NB_MAX_FINDHISTORY_FIND))
{
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Find"));
childNode && (_findHistory.nbFindHistoryFind < NB_MAX_FINDHISTORY_FIND);
childNode && (_findHistory._nbFindHistoryFind < NB_MAX_FINDHISTORY_FIND);
childNode = childNode->NextSibling(TEXT("Find")))
{
const TCHAR *fileFind = (childNode->ToElement())->Attribute(TEXT("name"));
if (fileFind)
{
_findHistory.FindHistoryFind[_findHistory.nbFindHistoryFind++] = new generic_string(fileFind);
_findHistory._pFindHistoryFind[_findHistory._nbFindHistoryFind++] = new generic_string(fileFind);
}
}
}
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryReplace"), &_findHistory.nbMaxFindHistoryReplace);
if ((_findHistory.nbMaxFindHistoryReplace > 0) && (_findHistory.nbMaxFindHistoryReplace <= NB_MAX_FINDHISTORY_REPLACE))
(findHistoryRoot->ToElement())->Attribute(TEXT("nbMaxFindHistoryReplace"), &_findHistory._nbMaxFindHistoryReplace);
if ((_findHistory._nbMaxFindHistoryReplace > 0) && (_findHistory._nbMaxFindHistoryReplace <= NB_MAX_FINDHISTORY_REPLACE))
{
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Replace"));
childNode && (_findHistory.nbFindHistoryReplace < NB_MAX_FINDHISTORY_REPLACE);
childNode && (_findHistory._nbFindHistoryReplace < NB_MAX_FINDHISTORY_REPLACE);
childNode = childNode->NextSibling(TEXT("Replace")))
{
const TCHAR *fileReplace = (childNode->ToElement())->Attribute(TEXT("name"));
if (fileReplace)
{
_findHistory.FindHistoryReplace[_findHistory.nbFindHistoryReplace++] = new generic_string(fileReplace);
_findHistory._pFindHistoryReplace[_findHistory._nbFindHistoryReplace++] = new generic_string(fileReplace);
}
}
}
const TCHAR *boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("matchWord"));
if (boolStr)
_findHistory._isMatchWord = !lstrcmp(TEXT("yes"), boolStr);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("matchCase"));
if (boolStr)
_findHistory._isMatchCase = !lstrcmp(TEXT("yes"), boolStr);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("wrap"));
if (boolStr)
_findHistory._isWrap = !lstrcmp(TEXT("yes"), boolStr);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("directionDown"));
if (boolStr)
_findHistory._isDirectionDown = !lstrcmp(TEXT("yes"), boolStr);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifRecuisive"));
if (boolStr)
_findHistory._isFifRecuisive = !lstrcmp(TEXT("yes"), boolStr);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("fifInHiddenFolder"));
if (boolStr)
_findHistory._isFifInHiddenFolder = !lstrcmp(TEXT("yes"), boolStr);
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("dlgAlwaysVisible"));
if (boolStr)
_findHistory._isDlgAlwaysVisible = !lstrcmp(TEXT("yes"), boolStr);
int mode = 0;
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("searchMode"), &mode);
if (boolStr)
_findHistory._searchMode = (FindHistory::searchMode)mode;
boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("transparencyMode"), &mode);
if (boolStr)
_findHistory._transparencyMode = (FindHistory::transparencyMode)mode;
(findHistoryRoot->ToElement())->Attribute(TEXT("transparency"), &_findHistory._transparency);
if (_findHistory._transparency <= 0 || _findHistory._transparency > 200)
_findHistory._transparency = 150;
}
void NppParameters::feedShortcut(TiXmlNode *node)
{
TiXmlNode *shortcutsRoot = node->FirstChildElement(TEXT("InternalCommands"));
@ -4026,38 +4062,51 @@ bool NppParameters::writeFindHistory()
findHistoryRoot->Clear();
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryPath"), _findHistory.nbMaxFindHistoryPath);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryFilter"), _findHistory.nbMaxFindHistoryFilter);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryFind"), _findHistory.nbMaxFindHistoryFind);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryReplace"), _findHistory.nbMaxFindHistoryReplace);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryPath"), _findHistory._nbMaxFindHistoryPath);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryFilter"), _findHistory._nbMaxFindHistoryFilter);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryFind"), _findHistory._nbMaxFindHistoryFind);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryReplace"), _findHistory._nbMaxFindHistoryReplace);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("matchWord"), _findHistory._isMatchWord?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("matchCase"), _findHistory._isMatchCase?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("wrap"), _findHistory._isWrap?TEXT("yes"):TEXT("no"));
(findHistoryRoot->ToElement())->SetAttribute(TEXT("directionDown"), _findHistory._isDirectionDown?TEXT("yes"):TEXT("no"));
(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("searchMode"), _findHistory._searchMode);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("transparencyMode"), _findHistory._transparencyMode);
(findHistoryRoot->ToElement())->SetAttribute(TEXT("transparency"), _findHistory._transparency);
TiXmlElement hist_element(TEXT(""));
hist_element.SetValue(TEXT("Path"));
for (i = 0; i < _findHistory.nbFindHistoryPath; i++)
for (i = 0; i < _findHistory._nbFindHistoryPath; i++)
{
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory.FindHistoryPath[i]->c_str());
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryPath[i]->c_str());
findHistoryRoot->InsertEndChild(hist_element);
}
hist_element.SetValue(TEXT("Filter"));
for (i = 0; i < _findHistory.nbFindHistoryFilter; i++)
for (i = 0; i < _findHistory._nbFindHistoryFilter; i++)
{
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory.FindHistoryFilter[i]->c_str());
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryFilter[i]->c_str());
findHistoryRoot->InsertEndChild(hist_element);
}
hist_element.SetValue(TEXT("Find"));
for (i = 0; i < _findHistory.nbFindHistoryFind; i++)
for (i = 0; i < _findHistory._nbFindHistoryFind; i++)
{
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory.FindHistoryFind[i]->c_str());
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryFind[i]->c_str());
findHistoryRoot->InsertEndChild(hist_element);
}
hist_element.SetValue(TEXT("Replace"));
for (i = 0; i < _findHistory.nbFindHistoryReplace; i++)
for (i = 0; i < _findHistory._nbFindHistoryReplace; i++)
{
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory.FindHistoryReplace[i]->c_str());
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryReplace[i]->c_str());
findHistoryRoot->InsertEndChild(hist_element);
}

View File

@ -787,20 +787,45 @@ public:
};
struct FindHistory {
int nbMaxFindHistoryPath;
int nbMaxFindHistoryFilter;
int nbMaxFindHistoryFind;
int nbMaxFindHistoryReplace;
enum searchMode{normal, extended, regExpr};
enum transparencyMode{none, onLossingFocus, persistant};
int nbFindHistoryPath;
int nbFindHistoryFilter;
int nbFindHistoryFind;
int nbFindHistoryReplace;
FindHistory() : _nbMaxFindHistoryPath(10), _nbMaxFindHistoryFilter(10), _nbMaxFindHistoryFind(10), _nbMaxFindHistoryReplace(10),\
_nbFindHistoryPath(0), _nbFindHistoryFilter(0),_nbFindHistoryFind(0), _nbFindHistoryReplace(0),\
_isMatchWord(false), _isMatchCase(false),_isWrap(true),_isDirectionDown(true),\
_isFifRecuisive(true), _isFifInHiddenFolder(false), _isDlgAlwaysVisible(false),\
_searchMode(normal), _transparencyMode(onLossingFocus), _transparency(150)
{};
int _nbMaxFindHistoryPath;
int _nbMaxFindHistoryFilter;
int _nbMaxFindHistoryFind;
int _nbMaxFindHistoryReplace;
int _nbFindHistoryPath;
int _nbFindHistoryFilter;
int _nbFindHistoryFind;
int _nbFindHistoryReplace;
generic_string *_pFindHistoryPath[NB_MAX_FINDHISTORY_PATH];
generic_string *_pFindHistoryFilter[NB_MAX_FINDHISTORY_FILTER];
generic_string *_pFindHistoryFind[NB_MAX_FINDHISTORY_FIND];
generic_string *_pFindHistoryReplace[NB_MAX_FINDHISTORY_REPLACE];
bool _isMatchWord;
bool _isMatchCase;
bool _isWrap;
bool _isDirectionDown;
bool _isFifRecuisive;
bool _isFifInHiddenFolder;
searchMode _searchMode;
transparencyMode _transparencyMode;
int _transparency;
bool _isDlgAlwaysVisible;
generic_string *FindHistoryPath[NB_MAX_FINDHISTORY_PATH];
generic_string *FindHistoryFilter[NB_MAX_FINDHISTORY_FILTER];
generic_string *FindHistoryFind[NB_MAX_FINDHISTORY_FIND];
generic_string *FindHistoryReplace[NB_MAX_FINDHISTORY_REPLACE];
};
@ -1048,15 +1073,13 @@ public:
};
void SetTransparent(HWND hwnd, int percent) {
//WNDPROC transparentFunc = (NppParameters::getInstance())->getTransparentFunc();
if (!_transparentFuncAddr) return;
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) | /*WS_EX_LAYERED*/0x00080000);
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) | 0x00080000);
_transparentFuncAddr(hwnd, 0, percent, 0x00000002);
};
void removeTransparent(HWND hwnd) {
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~/*WS_EX_LAYERED*/0x00080000);
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~0x00080000);
};
void setCmdlineParam(const CmdLineParams & cmdLineParams) {

View File

@ -260,28 +260,10 @@ const int STYLING_MASK = 255;
void FindReplaceDlg::create(int dialogID, bool isRTL)
{
StaticDialog::create(dialogID, isRTL);
fillFindHistory();
_currentStatus = REPLACE_DLG;
initOptionsFromDlg();
if ((NppParameters::getInstance())->isTransparentAvailable())
{
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_CHECK), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_GRPBOX), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_LOSSFOCUS_RADIO), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_ALWAYS_RADIO), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER), SW_SHOW);
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(20, 200));
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETPOS, TRUE, 150);
if (!isCheckedOrNot(IDC_TRANSPARENT_CHECK))
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_GRPBOX), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_LOSSFOCUS_RADIO), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_ALWAYS_RADIO), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER), FALSE);
}
}
RECT rect;
//::GetWindowRect(_hSelf, &rect);
getClientRect(rect);
@ -307,8 +289,6 @@ void FindReplaceDlg::create(int dialogID, bool isRTL)
_tab.reSizeTo(rect);
_tab.display();
fillFindHistory();
ETDTProc enableDlgTheme = (ETDTProc)::SendMessage(_hParent, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0);
if (enableDlgTheme)
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
@ -318,12 +298,76 @@ void FindReplaceDlg::create(int dialogID, bool isRTL)
void FindReplaceDlg::fillFindHistory()
{
FindHistory& findHistory = (NppParameters::getInstance())->getFindHistory();
NppParameters *nppParams = NppParameters::getInstance();
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory.nbFindHistoryPath, findHistory.FindHistoryPath);
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory.nbFindHistoryFilter, findHistory.FindHistoryFilter);
fillComboHistory(IDFINDWHAT, findHistory.nbFindHistoryFind, findHistory.FindHistoryFind);
fillComboHistory(IDREPLACEWITH, findHistory.nbFindHistoryReplace, findHistory.FindHistoryReplace);
FindHistory& findHistory = nppParams->getFindHistory();
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbFindHistoryPath, findHistory._pFindHistoryPath);
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbFindHistoryFilter, findHistory._pFindHistoryFilter);
fillComboHistory(IDFINDWHAT, findHistory._nbFindHistoryFind, findHistory._pFindHistoryFind);
fillComboHistory(IDREPLACEWITH, findHistory._nbFindHistoryReplace, findHistory._pFindHistoryReplace);
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0);
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0);
::SendDlgItemMessage(_hSelf, IDMATCHCASE, BM_SETCHECK, findHistory._isMatchCase, 0);
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, !findHistory._isDirectionDown, 0);
::SendDlgItemMessage(_hSelf, IDDIRECTIONDOWN, BM_SETCHECK, findHistory._isDirectionDown, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK, BM_SETCHECK, findHistory._isFifInHiddenFolder, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, findHistory._isFifRecuisive, 0);
::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, findHistory._searchMode == FindHistory::normal, 0);
::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, findHistory._searchMode == FindHistory::extended, 0);
::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, findHistory._searchMode == FindHistory::regExpr, 0);
if (findHistory._searchMode == FindHistory::regExpr)
{
//regex doesnt allow wholeword
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD), (BOOL)false);
//regex doesnt allow upward search
::SendDlgItemMessage(_hSelf, IDDIRECTIONDOWN, BM_SETCHECK, BST_CHECKED, 0);
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDDIRECTIONUP), (BOOL)false);
}
if (nppParams->isTransparentAvailable())
{
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_CHECK), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_GRPBOX), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_LOSSFOCUS_RADIO), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_ALWAYS_RADIO), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER), SW_SHOW);
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(20, 200));
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETPOS, TRUE, findHistory._transparency);
if (findHistory._transparencyMode == FindHistory::none)
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_GRPBOX), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_LOSSFOCUS_RADIO), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TRANSPARENT_ALWAYS_RADIO), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER), FALSE);
}
else
{
::SendDlgItemMessage(_hSelf, IDC_TRANSPARENT_CHECK, BM_SETCHECK, TRUE, 0);
int id;
if (findHistory._transparencyMode == FindHistory::onLossingFocus)
{
id = IDC_TRANSPARENT_LOSSFOCUS_RADIO;
}
else
{
id = IDC_TRANSPARENT_ALWAYS_RADIO;
(NppParameters::getInstance())->SetTransparent(_hSelf, findHistory._transparency);
}
::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, TRUE, 0);
}
}
}
void FindReplaceDlg::fillComboHistory(int id, int count, generic_string **pStrings)
@ -346,10 +390,10 @@ void FindReplaceDlg::saveFindHistory()
if (! isCreated()) return;
FindHistory& findHistory = (NppParameters::getInstance())->getFindHistory();
saveComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory.nbMaxFindHistoryPath, findHistory.nbFindHistoryPath, findHistory.FindHistoryPath);
saveComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory.nbMaxFindHistoryFilter, findHistory.nbFindHistoryFilter, findHistory.FindHistoryFilter);
saveComboHistory(IDFINDWHAT, findHistory.nbMaxFindHistoryFind, findHistory.nbFindHistoryFind, findHistory.FindHistoryFind);
saveComboHistory(IDREPLACEWITH, findHistory.nbMaxFindHistoryReplace, findHistory.nbFindHistoryReplace, findHistory.FindHistoryReplace);
saveComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbMaxFindHistoryPath, findHistory._nbFindHistoryPath, findHistory._pFindHistoryPath);
saveComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbMaxFindHistoryFilter, findHistory._nbFindHistoryFilter, findHistory._pFindHistoryFilter);
saveComboHistory(IDFINDWHAT, findHistory._nbMaxFindHistoryFind, findHistory._nbFindHistoryFind, findHistory._pFindHistoryFind);
saveComboHistory(IDREPLACEWITH, findHistory._nbMaxFindHistoryReplace, findHistory._nbFindHistoryReplace, findHistory._pFindHistoryReplace);
}
void FindReplaceDlg::saveComboHistory(int id, int maxcount, int & oldcount, generic_string **pStrings)
@ -552,6 +596,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{
case WM_INITDIALOG :
{
/*
// Wrap arround active by default
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, BST_CHECKED, 0);
// Normal search active by default
@ -559,7 +604,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
if (_isRecursive)
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, BST_CHECKED, 0);
*/
RECT arc;
::GetWindowRect(::GetDlgItem(_hSelf, IDCANCEL), &arc);
_findInFilesClosePos.bottom = _replaceClosePos.bottom = _findClosePos.bottom = arc.bottom - arc.top;
@ -588,9 +633,11 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER))
{
int percent = ::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0);
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory();
findHistory._transparency = percent;
if (isCheckedOrNot(IDC_TRANSPARENT_ALWAYS_RADIO))
{
int percent = ::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0);
(NppParameters::getInstance())->SetTransparent(_hSelf, percent);
}
}
@ -653,6 +700,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case WM_COMMAND :
{
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory();
switch (wParam)
{
case IDCANCEL : // Close
@ -827,40 +875,57 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
return TRUE;
//Option actions
case IDWHOLEWORD :
_options._isWholeWord = isCheckedOrNot(IDWHOLEWORD);
findHistory._isMatchWord = _options._isWholeWord = isCheckedOrNot(IDWHOLEWORD);
return TRUE;
case IDMATCHCASE :
_options._isMatchCase = isCheckedOrNot(IDMATCHCASE);
findHistory._isMatchCase = _options._isMatchCase = isCheckedOrNot(IDMATCHCASE);
return TRUE;
case IDNORMAL:
case IDEXTENDED:
case IDREGEXP : {
_options._searchType = isCheckedOrNot(IDREGEXP)?FindRegex:isCheckedOrNot(IDEXTENDED)?FindExtended:FindNormal;
if (isCheckedOrNot(IDREGEXP))
{
_options._searchType = FindRegex;
findHistory._searchMode = FindHistory::regExpr;
}
else if (isCheckedOrNot(IDEXTENDED))
{
_options._searchType = FindExtended;
findHistory._searchMode = FindHistory::extended;
}
else
{
_options._searchType = FindNormal;
findHistory._searchMode = FindHistory::normal;
}
bool isRegex = (_options._searchType == FindRegex);
if (isRegex) { //regex doesnt allow wholeword
if (isRegex)
{
//regex doesnt allow whole word
_options._isWholeWord = false;
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, _options._isWholeWord?BST_CHECKED:BST_UNCHECKED, 0);
}
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD), (BOOL)!isRegex);
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, _options._isWholeWord?BST_CHECKED:BST_UNCHECKED, 0);
if (isRegex) { //regex doesnt allow upward search
//regex doesnt allow upward search
::SendDlgItemMessage(_hSelf, IDDIRECTIONDOWN, BM_SETCHECK, BST_CHECKED, 0);
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
_options._whichDirection = DIR_DOWN;
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
_options._whichDirection = DIR_DOWN;
}
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD), (BOOL)!isRegex);
::EnableWindow(::GetDlgItem(_hSelf, IDDIRECTIONUP), (BOOL)!isRegex);
return TRUE; }
case IDWRAP :
_options._isWrapAround = isCheckedOrNot(IDWRAP);
findHistory._isWrap = _options._isWrapAround = isCheckedOrNot(IDWRAP);
return TRUE;
case IDDIRECTIONUP :
case IDDIRECTIONDOWN :
_options._whichDirection = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDDIRECTIONDOWN), BM_GETCHECK, BST_CHECKED, 0));
findHistory._isDirectionDown = _options._whichDirection == DIR_DOWN;
return TRUE;
case IDC_PURGE_CHECK :
@ -909,12 +974,14 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
if (isChecked)
{
::SendDlgItemMessage(_hSelf, IDC_TRANSPARENT_LOSSFOCUS_RADIO, BM_SETCHECK, BST_CHECKED, 0);
findHistory._transparencyMode = FindHistory::onLossingFocus;
}
else
{
::SendDlgItemMessage(_hSelf, IDC_TRANSPARENT_LOSSFOCUS_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_TRANSPARENT_ALWAYS_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
(NppParameters::getInstance())->removeTransparent(_hSelf);
findHistory._transparencyMode = FindHistory::none;
}
return TRUE;
@ -924,12 +991,14 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{
int percent = ::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0);
(NppParameters::getInstance())->SetTransparent(_hSelf, percent);
findHistory._transparencyMode = FindHistory::persistant;
}
return TRUE;
case IDC_TRANSPARENT_LOSSFOCUS_RADIO :
{
(NppParameters::getInstance())->removeTransparent(_hSelf);
findHistory._transparencyMode = FindHistory::onLossingFocus;
}
return TRUE;
@ -939,7 +1008,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDD_FINDINFILES_RECURSIVE_CHECK :
{
if (_currentStatus == FINDINFILES_DLG)
_isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
findHistory._isFifRecuisive = _isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
}
return TRUE;
@ -947,7 +1016,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDD_FINDINFILES_INHIDDENDIR_CHECK :
{
if (_currentStatus == FINDINFILES_DLG)
_isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
findHistory._isFifInHiddenFolder = _isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
}
return TRUE;