From f602782337540d27810792eca5e137e80e0fae2e Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 27 Aug 2010 01:01:10 +0000 Subject: [PATCH] [BUG_FIXED] Fix Lexer SearchResult syntax highlighting bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@656 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../src/ScitillaComponent/FindReplaceDlg.cpp | 21 ++++++++++++------- scintilla/include/SciLexer.h | 10 ++++----- scintilla/lexers/LexSearchResult.cxx | 7 ++++++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 850e851d..6bcc0c78 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -512,7 +512,7 @@ void Finder::GotoFoundLine() // Then we colourise the double clicked line setFinderStyle(); - _scintView.execute(SCI_SETLEXER, SCLEX_NULL); // yniq - this line causes a bug!!! (last line suddenly belongs to file header level (?) instead of having level=0x400) + //_scintView.execute(SCI_SETLEXER, SCLEX_NULL); // yniq - this line causes a bug!!! (last line suddenly belongs to file header level (?) instead of having level=0x400) // later it affects DeleteResult and gotoNextFoundResult (assertions) // fixed by calling setFinderStyle() in DeleteResult() _scintView.execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_HIGHLIGHT_LINE, true); @@ -1676,7 +1676,7 @@ void FindReplaceDlg::replaceAllInOpenedDocs() void FindReplaceDlg::findAllIn(InWhat op) { - //HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("findInFilesEvent")); + bool doSetMarkingStruct = false; if (!_pFinder) { _pFinder = new Finder(); @@ -1711,11 +1711,6 @@ void FindReplaceDlg::findAllIn(InWhat op) _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); - // get the width of FindDlg RECT findRect; ::GetWindowRect(_pFinder->getHSelf(), &findRect); @@ -1726,8 +1721,18 @@ void FindReplaceDlg::findAllIn(InWhat op) _pFinder->_scintView.display(); _pFinder->display(); + doSetMarkingStruct = true; } _pFinder->setFinderStyle(); + + if (doSetMarkingStruct) + { + // 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); + _pFinder->_scintView.execute(SCI_SETPROPERTY, (WPARAM)"@MarkingsStruct", (LPARAM)ptrword); + } ::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0); @@ -2266,7 +2271,7 @@ void Finder::openAll() void Finder::beginNewFilesSearch() { - _scintView.execute(SCI_SETLEXER, SCLEX_NULL); + //_scintView.execute(SCI_SETLEXER, SCLEX_NULL); _scintView.execute(SCI_SETCURRENTPOS, 0); _pMainFoundInfos = _pMainFoundInfos == &_foundInfos1 ? &_foundInfos2 : &_foundInfos1; diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index 19be0914..2f171e91 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -110,12 +110,12 @@ #define SCLEX_POWERPRO 95 #define SCLEX_NIMROD 96 #define SCLEX_SML 97 -#define SCLEX_MARKDOWN 198 -#define SCLEX_TXT2TAGS 199 +#define SCLEX_MARKDOWN 98 +#define SCLEX_TXT2TAGS 99 -#define SCLEX_SEARCHRESULT 98 -#define SCLEX_OBJC 99 -#define SCLEX_USER 100 +#define SCLEX_SEARCHRESULT 150 +#define SCLEX_OBJC 151 +#define SCLEX_USER 152 #define SCLEX_AUTOMATIC 1000 diff --git a/scintilla/lexers/LexSearchResult.cxx b/scintilla/lexers/LexSearchResult.cxx index 595702be..6742f626 100644 --- a/scintilla/lexers/LexSearchResult.cxx +++ b/scintilla/lexers/LexSearchResult.cxx @@ -31,6 +31,7 @@ #include "ILexer.h" #include "LexAccessor.h" +#include "PropSetSimple.h" #include "Accessor.h" #include "WordList.h" #include "Scintilla.h" @@ -103,8 +104,12 @@ static void ColouriseSearchResultDoc(unsigned int startPos, int length, int, Wor unsigned int linePos = 0; unsigned int startLine = startPos; + const char *addrMarkingsStruct = (styler.pprops)->Get("@MarkingsStruct"); + if (!addrMarkingsStruct || !addrMarkingsStruct[0]) + return; + SearchResultMarkings* pMarkings = NULL; - sscanf(keywordlists[0]->words[0], "%p", &pMarkings); + sscanf(addrMarkingsStruct, "%p", &pMarkings); PLATFORM_ASSERT(pMarkings); for (unsigned int i = startPos; i < startPos + length; i++) {