diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index e2f3f2d0..95a6406e 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2067,6 +2067,7 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_SETTARGETEND, endPos); vector > hotspotStylers; + int style_hotspot = 30; int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR); @@ -2079,69 +2080,69 @@ void Notepad_plus::addHotSpot(bool docIsModifing) if (end < posBegin2style - 1) { - if (style_hotspot > 1) + if (style_hotspot > 24) style_hotspot--; } else { - int fs = -1; - for (size_t i = 0 ; i < hotspotStylers.size() ; i++) + int fs = -1; + for (size_t i = 0 ; i < hotspotStylers.size() ; i++) + { + if (hotspotStylers[i].second == idStyle) { - if (hotspotStylers[i].second == idStyle) - { - fs = hotspotStylers[i].first; - break; - } + fs = hotspotStylers[i].first; + break; } + } - if (fs != -1) - { - _pEditView->execute(SCI_STARTSTYLING, start, 0xFF); - _pEditView->execute(SCI_SETSTYLING, foundTextLen, fs); + if (fs != -1) + { + _pEditView->execute(SCI_STARTSTYLING, start, 0xFF); + _pEditView->execute(SCI_SETSTYLING, foundTextLen, fs); - } - else - { - pair p(style_hotspot, idStyle); - hotspotStylers.push_back(p); - int activeFG = 0xFF0000; - char fontNameA[128]; + } + else + { + pair p(style_hotspot, idStyle); + hotspotStylers.push_back(p); + int activeFG = 0xFF0000; + char fontNameA[128]; - Style hotspotStyle; + Style hotspotStyle; - hotspotStyle._styleID = style_hotspot; - _pEditView->execute(SCI_STYLEGETFONT, idStyle, (LPARAM)fontNameA); - TCHAR *generic_fontname = new TCHAR[128]; + hotspotStyle._styleID = style_hotspot; + _pEditView->execute(SCI_STYLEGETFONT, idStyle, (LPARAM)fontNameA); + TCHAR *generic_fontname = new TCHAR[128]; #ifdef UNICODE - WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); - const wchar_t * fontNameW = wmc->char2wchar(fontNameA, _nativeLangSpeaker.getLangEncoding()); - lstrcpy(generic_fontname, fontNameW); + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const wchar_t * fontNameW = wmc->char2wchar(fontNameA, _nativeLangSpeaker.getLangEncoding()); + lstrcpy(generic_fontname, fontNameW); #else - lstrcpy(generic_fontname, fontNameA); + lstrcpy(generic_fontname, fontNameA); #endif - hotspotStyle._fontName = generic_fontname; + hotspotStyle._fontName = generic_fontname; - hotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle); - hotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle); - hotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle); + hotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle); + hotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle); + hotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle); - int isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyle); - int isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyle); - int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyle); - hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); + int isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyle); + int isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyle); + int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyle); + hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); - int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; - if (urlAction == 2) - hotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; + int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; + if (urlAction == 2) + hotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; - _pEditView->setHotspotStyle(hotspotStyle); + _pEditView->setHotspotStyle(hotspotStyle); - _pEditView->execute(SCI_STYLESETHOTSPOT, style_hotspot, TRUE); - _pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG); - _pEditView->execute(SCI_SETHOTSPOTSINGLELINE, style_hotspot, 0); - _pEditView->execute(SCI_STARTSTYLING, start, 0x1F); - _pEditView->execute(SCI_SETSTYLING, foundTextLen, style_hotspot); - if (style_hotspot > 1) + _pEditView->execute(SCI_STYLESETHOTSPOT, style_hotspot, TRUE); + _pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG); + _pEditView->execute(SCI_SETHOTSPOTSINGLELINE, style_hotspot, 0); + _pEditView->execute(SCI_STARTSTYLING, start, 0x1F); + _pEditView->execute(SCI_SETSTYLING, foundTextLen, style_hotspot); + if (style_hotspot > 24) style_hotspot--; } } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 24efa4b8..ce26ecc2 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -405,7 +405,7 @@ public: }; protected: - Style _styleArray[SCE_USER_STYLE_TOTAL_STYLES]; + Style _styleArray[SCE_STYLE_ARRAY_SIZE]; int _nbStyler; }; diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index d4a8bd74..06d80e14 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -259,6 +259,7 @@ #define SCE_USER_STYLE_IDENTIFIER 24 #define SCE_USER_STYLE_TOTAL_STYLES SCE_USER_STYLE_IDENTIFIER #define SCE_USER_STYLE_MAPPER_TOTAL 17 +#define SCE_STYLE_ARRAY_SIZE 30 // must cover sizes of NppParameters::_lexerStyler and NppParameters::_widgetStyle #define SCE_USER_MASK_NESTING_NONE 0 #define SCE_USER_MASK_NESTING_DELIMITER1 0x1 diff --git a/scintilla/lexers/LexUser.cxx b/scintilla/lexers/LexUser.cxx index a385d7a0..1d30e827 100644 --- a/scintilla/lexers/LexUser.cxx +++ b/scintilla/lexers/LexUser.cxx @@ -809,8 +809,8 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod // multi-part keyword is found, // but it must be followed by whitespace (or 'forward' keyword) // otherwise "else if" might wrongly match "else iff" - bNext = sc.GetRelative(indexb + offset + 1); - if (isWhiteSpace2(b, nlCountTemp, wsChar, bNext)) + bNext = sc.GetRelative(indexb + offset); + if (isWhiteSpace(bNext)) fwDelimiterFound = FORWARD_WHITESPACE_FOUND; if (fwDelimiterFound == NO_DELIMITER)