diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index fa5962da2..1d7f5fc17 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -38,6 +38,9 @@ const bool dirDown = false; #define LINKTRIGGERED WM_USER+555 +#define BCKGRD_COLOR (RGB(255,102,102)) +#define TXT_COLOR (RGB(255,255,255)) + #ifdef UNICODE #define NppMainEntry wWinMain #define generic_strtol wcstol diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index ead679e35..5588384e1 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -36,8 +36,7 @@ FindOption * FindReplaceDlg::_env; FindOption FindReplaceDlg::_options; #define SHIFTED 0x8000 -#define BCKGRD_COLOR (RGB(255,102,102)) -#define TXT_COLOR (RGB(255,255,255)) + int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length) { //query may equal to result, since it always gets smaller int i = 0, j = 0; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index ba51f7b8f..52ce955e9 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -378,31 +378,10 @@ public : void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false); virtual void destroy(); virtual void display(bool toShow = true) const; -#ifdef UNICODE + void setSearchText(const TCHAR * txt2find, bool) { ::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find); }; -#else - void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) { - if (!isUTF8) - { - ::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find); - return; - } - const int wideBufferSize = 256; - WCHAR wchars[wideBufferSize]; - ::MultiByteToWideChar(CP_UTF8, 0, txt2find, -1, wchars, wideBufferSize); - winVer winVersion = NppParameters::getInstance()->getWinVersion(); - if (winVersion <= WV_ME) { - //Cannot simply take txt2find since its UTF8 - char ansiBuffer[wideBufferSize]; //Assuming no more than 2 bytes for each wchar (SBCS or DBCS, no UTF8 and sorts) - ::WideCharToMultiByte(CP_ACP, 0, wchars, -1, ansiBuffer, wideBufferSize, NULL, NULL); - ::SendDlgItemMessageA(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)ansiBuffer); - } else { - ::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars); - } - }; -#endif void setFindStatus(FindStatus iStatus); diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 8368c8756..721e0b00d 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -156,13 +156,14 @@ generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::v } } -void FunctionListPanel::addInTreeStateArray(TreeStateNode tree2Update) +void FunctionListPanel::addInStateArray(TreeStateNode tree2Update, const TCHAR *searchText) { bool found = false; for (size_t i = 0, len = _treeParams.size(); i < len; ++i) { if (_treeParams[i]._treeState._extraData == tree2Update._extraData) { + _treeParams[i]._searchParameters._text2Find = searchText; _treeParams[i]._treeState = tree2Update; found = true; } @@ -171,16 +172,17 @@ void FunctionListPanel::addInTreeStateArray(TreeStateNode tree2Update) { TreeParams params; params._treeState = tree2Update; + params._searchParameters._text2Find = searchText; _treeParams.push_back(params); } } -TreeStateNode* FunctionListPanel::getFromTreeStateArray(generic_string fullFilePath) +TreeParams* FunctionListPanel::getFromStateArray(generic_string fullFilePath) { for (size_t i = 0, len = _treeParams.size(); i < len; ++i) { if (_treeParams[i]._treeState._extraData == fullFilePath) - return &_treeParams[i]._treeState; + return &_treeParams[i]; } return NULL; } @@ -191,8 +193,13 @@ void FunctionListPanel::reload() TreeStateNode currentTree; bool isOK = _treeView.retrieveFoldingStateTo(currentTree, _treeView.getRoot()); if (isOK) - addInTreeStateArray(currentTree); + { + TCHAR text2Search[MAX_PATH]; + ::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, (LPARAM)text2Search); + addInStateArray(currentTree, text2Search); + } removeAllEntries(); + ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, (LPARAM)TEXT("")); vector fi; @@ -236,16 +243,21 @@ void FunctionListPanel::reload() if (root) { _treeView.setItemParam(root, fullFilePath); - TreeStateNode *previousTree = getFromTreeStateArray(fullFilePath); - if (!previousTree) + TreeParams *previousParams = getFromStateArray(fullFilePath); + if (!previousParams) { + ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, (LPARAM)TEXT("")); _treeView.expand(root); } else { - _treeView.restoreFoldingStateFrom(*previousTree, root); + ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, (LPARAM)(previousParams->_searchParameters)._text2Find.c_str()); + _treeView.restoreFoldingStateFrom(previousParams->_treeState, root); + } } + // invalidate the editor rect + ::InvalidateRect(_hSearchEdit, NULL, TRUE); } @@ -402,6 +414,9 @@ void FunctionListPanel::searchFuncAndSwitchView() } else { + if (_treeView.getRoot() == NULL) + return; + _treeViewSearchResult.removeAllItems(); const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); _treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, TEXT("-1")); @@ -409,13 +424,48 @@ void FunctionListPanel::searchFuncAndSwitchView() _treeViewSearchResult.display(true); _treeViewSearchResult.expand(_treeViewSearchResult.getRoot()); _treeView.display(false); + + // invalidate the editor rect + ::InvalidateRect(_hSearchEdit, NULL, TRUE); } } +static WNDPROC oldFunclstToolbarProc = NULL; +static BOOL CALLBACK funclstToolbarProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_CTLCOLOREDIT : + { + return ::SendMessage(::GetParent(hwnd), WM_CTLCOLOREDIT, wParam, lParam); + } + } + return oldFunclstToolbarProc(hwnd, message, wParam, lParam); +} + BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { + // Make edit field red if not found + case WM_CTLCOLOREDIT : + { + // if the text not found modify the background color of the editor + static HBRUSH hBrushBackground = CreateSolidBrush(BCKGRD_COLOR); + HTREEITEM searchViewRoot = _treeViewSearchResult.getRoot(); + if (searchViewRoot) + { + if (_treeViewSearchResult.getChildFrom(searchViewRoot)) + return FALSE; // children found, use the default color + } + else + return FALSE; // no root (no parser), use the default color + // text not found + SetTextColor((HDC)wParam, TXT_COLOR); + SetBkColor((HDC)wParam, BCKGRD_COLOR); + return (LRESULT)hBrushBackground; + } + case WM_INITDIALOG : { int editWidth = 100; @@ -424,6 +474,9 @@ BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST; _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style, 0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL); + + //::GetWindowLongPtr(_hToolbarMenu, GWL_WNDPROC); + oldFunclstToolbarProc = (WNDPROC)::SetWindowLongPtr(_hToolbarMenu, GWLP_WNDPROC, (LONG_PTR)funclstToolbarProc); TBBUTTON tbButtons[2]; tbButtons[0].idCommand = 0; @@ -482,26 +535,6 @@ BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM switch (LOWORD(wParam)) { -/* - case IDC_LIST_FUNCLIST_AUX: - case IDC_LIST_FUNCLIST: - { - if (HIWORD(wParam) == LBN_DBLCLK) - { - int ctrlID = LOWORD(wParam); - int i = ::SendDlgItemMessage(_hSelf, ctrlID, LB_GETCURSEL, 0, 0); - if (i != LB_ERR) - { - int pos = ::SendDlgItemMessage(_hSelf, ctrlID, LB_GETITEMDATA, i, (LPARAM)0); - //printInt(pos); - int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos); - (*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line); - (*_ppEditView)->execute(SCI_GOTOPOS, pos); - } - } - } - return TRUE; -*/ case IDC_RELOADBUTTON_FUNCLIST: { reload(); diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h index d5603fafa..5c463e11a 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h @@ -115,22 +115,19 @@ private: TreeView *_pTreeView; TreeView _treeView; - TreeView _treeViewSearchResult; - //SearchParameters _searchParams; ScintillaEditView **_ppEditView; FunctionParsersManager _funcParserMgr; std::vector _funcInfos; std::vector< std::pair > _skipZones; - //std::vector _treeStates; std::vector _treeParams; HIMAGELIST _hImaLst; generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos); size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol); void notified(LPNMHDR notification); - void addInTreeStateArray(TreeStateNode tree2Update); - TreeStateNode* getFromTreeStateArray(generic_string fullFilePath); + void addInStateArray(TreeStateNode tree2Update, const TCHAR *searchText); + TreeParams* getFromStateArray(generic_string fullFilePath); BOOL setImageList(int root_id, int node_id, int leaf_id); bool openSelection(const TreeView &treeView); }; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 467f0792f..569d74de7 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -275,7 +275,8 @@ static WNDPROC oldProc = NULL; static generic_string currentExt = TEXT(""); -static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { +static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ switch (message) { case WM_COMMAND :