From 4e74b2dff492f9863f6bd7db08a03851ceef70a1 Mon Sep 17 00:00:00 2001 From: yniq Date: Wed, 11 Feb 2009 16:09:44 +0000 Subject: [PATCH] [BUG_FIXED] Changing global stylers now affects the Finder window. [BUG_FIXED] Changing current line background color of the search result styler now affects the Finder window. [UPDATE] Some other updates regarding the finder styles. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@427 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 7 +-- .../src/ScitillaComponent/FindReplaceDlg.cpp | 46 ++++++++----------- .../WinControls/ColourPicker/WordStyleDlg.cpp | 15 +----- .../WinControls/ColourPicker/WordStyleDlg.h | 1 - 4 files changed, 21 insertions(+), 48 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index de0cafd4..52db00a1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -8212,6 +8212,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _subEditView.defineDocType(_subEditView.getCurrentBuffer()->getLangType()); _mainEditView.performGlobalStyles(); _subEditView.performGlobalStyles(); + _findReplaceDlg.updateFinderScintilla(); drawTabbarColoursFromStylerArray(); @@ -8224,12 +8225,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case WM_UPDATEFINDERSCINTILLA : - { - _findReplaceDlg.updateFinderScintilla(); - return TRUE; - } - case WM_QUERYENDSESSION: case WM_CLOSE: { diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 1ece0aac..fff89561 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -461,7 +461,7 @@ void Finder::DeleteResult() int end = _scintView.execute(SCI_GETLINEENDPOSITION, lno); if (start + 2 >= end) return; // avoid empty lines - setFinderStyle(); // Restore searchResult lexer in case the lexer was changed to SCLEX_NULL in GotoFoundLine() + _scintView.setLexer(SCLEX_SEARCHRESULT, L_SEARCHRESULT, 0); // Restore searchResult lexer in case the lexer was changed to SCLEX_NULL in GotoFoundLine() if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) // delete a folder { @@ -1458,21 +1458,6 @@ void FindReplaceDlg::findAllIn(InWhat op) // Subclass the ScintillaEditView for the Finder (Scintilla doesn't notify all key presses) originalFinderProc = SetWindowLong( _pFinder->_scintView.getHSelf(), GWL_WNDPROC, (LONG) finderProc); - - //_pFinder->_scintView.performGlobalStyles(); // yniq - needed? - // Set current line background color for the finder - TCHAR* lang = TEXT("searchResult"); - NppParameters *_pParameter = NppParameters::getInstance(); - LexerStylerArray & stylers = _pParameter->getLStylerArray(); - LexerStyler *pStyler = stylers.getLexerStylerByName(lang); - int i = pStyler->getStylerIndexByID(SCE_SEARCHRESULT_CURRENT_LINE); - if (i != -1) - { - Style & style = pStyler->getStyler(i); - _pFinder->_scintView.execute(SCI_SETCARETLINEBACK, style._bgColor); - } - - _pFinder->setFinderReadOnly(true); _pFinder->_scintView.execute(SCI_SETCODEPAGE, SC_CP_DBCS); _pFinder->_scintView.execute(SCI_USEPOPUP, FALSE); @@ -1480,7 +1465,9 @@ void FindReplaceDlg::findAllIn(InWhat op) _pFinder->_scintView.execute(SCI_SETCARETLINEVISIBLE, 1); _pFinder->_scintView.execute(SCI_SETCARETWIDTH, 0); _pFinder->_scintView.showMargin(ScintillaEditView::_SC_MARGE_FOLDER, true); + //_pFinder->_scintView.execute(SCI_SETEOLMODE, SC_EOL_CRLF); // yniq - needed? + // Send the address of _MarkingsStruct to the lexer char ptrword[sizeof(void*)*2+1]; sprintf(ptrword, "%p", &_pFinder->_MarkingsStruct); _pFinder->_scintView.execute(SCI_SETKEYWORDS, 0, (LPARAM) ptrword); @@ -1613,19 +1600,24 @@ void FindReplaceDlg::getPatterns(vector & patternVect) void Finder::setFinderStyle() { - StyleArray & stylers = (_scintView.getParameter())->getMiscStylerArray(); - int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT); - if (iStyleDefault != -1) - { - Style & styleDefault = stylers.getStyler(iStyleDefault); - styleDefault._colorStyle = COLORSTYLE_ALL; //All colors set - _scintView.setStyle(styleDefault); - } - _scintView.execute(SCI_STYLECLEARALL); - _scintView.execute(SCI_SETSTYLEBITS, 5); + // Set global styles for the finder + _scintView.performGlobalStyles(); + + // Set current line background color for the finder + const TCHAR * lexerName = ScintillaEditView::langNames[L_SEARCHRESULT].lexerName; + LexerStyler *pStyler = (_scintView._pParameter->getLStylerArray()).getLexerStylerByName(lexerName); + if (pStyler) + { + int i = pStyler->getStylerIndexByID(SCE_SEARCHRESULT_CURRENT_LINE); + if (i != -1) + { + Style & style = pStyler->getStyler(i); + _scintView.execute(SCI_SETCARETLINEBACK, style._bgColor); + } + } + _scintView.setSearchResultLexer(); _scintView.execute(SCI_COLOURISE, 0, -1); - _scintView.execute(SCI_SETEOLMODE, SC_EOL_CRLF); } BOOL CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index fe60e927..cfef1d25 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -217,7 +217,6 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar _isDirty = false; setVisualFromStyleList(); ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); - ::SendMessage(_hParent, WM_UPDATEFINDERSCINTILLA, 0, 0); } ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), !_isSync); display(false); @@ -707,17 +706,5 @@ void WordStyleDlg::apply() ::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE); //_isDirty = false; _isSync = false; - - TCHAR str[256] = TEXT(""); - int i = ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETCURSEL, 0, 0); - if (i == LB_ERR) - return; - ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETTEXT, i, (LPARAM)str); - - int cmdid = 0; - if (lstrcmp(str, TEXT("Search result")) == 0) - cmdid = WM_UPDATEFINDERSCINTILLA; - else - cmdid = WM_UPDATESCINTILLAS; - ::SendMessage(_hParent, cmdid, 0, 0); + ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 6ff3de23..86237265 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -29,7 +29,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "resource.h" #define WM_UPDATESCINTILLAS (WORDSTYLE_USER + 1) //GlobalStyleDlg's msg 2 send 2 its parent -#define WM_UPDATEFINDERSCINTILLA (WORDSTYLE_USER + 2) //the msg 2 notify the finder's styles changed enum fontStyleType {BOLD_STATUS, ITALIC_STATUS, UNDERLINE_STATUS};