diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 3959dc40f..05fd0ab7e 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2547,7 +2547,7 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos) string openTag = "<"; openTag += tagName; - openTag += "[ >]"; + //openTag += "[ >]"; string closeTag = "execute(SCI_SETWORDCHARS, 0, (LPARAM)tagNameChars); - //int startPos = _pEditView->execute(SCI_WORDSTARTPOSITION, tagsPos.tagOpenStart+1, true); int endPos = _pEditView->execute(SCI_WORDENDPOSITION, tagsPos.tagOpenStart+1, true); tagsPos.tagNameEnd = endPos; _pEditView->execute(SCI_SETCHARSDEFAULT); @@ -2597,10 +2596,46 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos) return false; } +vector> Notepad_plus::getAttributesPos(int start, int end) +{ + vector> attributes; + + int bufLen = end - start + 1; + char *buf = new char[bufLen+1]; + _pEditView->getText(buf, start, end); + + int i = 0; + int startPos = -1; + for (; i < bufLen ; i++) + { + if (buf[i] == ' ' || buf[i] == '\t') + { + if (startPos != -1) + { + attributes.push_back(pair(start+startPos, start+i)); + startPos = -1; + } + } + else + { + if (startPos == -1) + { + startPos = i; + } + } + } + if (startPos != -1) + attributes.push_back(pair(start+startPos, start+i-1)); + + delete [] buf; + return attributes; +} + void Notepad_plus::tagMatch() { // Clean up all marks of previous action _pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH); + _pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR); // Detect the current lang type. It works only with html and xml LangType lang = (_pEditView->getCurrentBuffer())->getLangType(); @@ -2629,6 +2664,13 @@ void Notepad_plus::tagMatch() // Now the open tag and its attributs _pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagOpenStart, xmlTags.tagNameEnd - xmlTags.tagOpenStart); _pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagOpenEnd - openTagTailLen, openTagTailLen); + + vector> attributes = getAttributesPos(xmlTags.tagNameEnd, xmlTags.tagOpenEnd - openTagTailLen); + _pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_TAGATTR); + for (size_t i = 0 ; i < attributes.size() ; i++) + { + _pEditView->execute(SCI_INDICATORFILLRANGE, attributes[i].first, attributes[i].second - attributes[i].first); + } } // restore the original targets to avoid the conflit with search/replace function diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index f12b044af..b3d54edfe 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -678,6 +678,7 @@ private: int getFirstTokenPosFrom(int currentPos, bool direction, const char *token, pair & foundPos); TagCateg getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos); bool getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos); + vector> getAttributesPos(int start, int end); void tagMatch(); void activateNextDoc(bool direction); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 8dbcfac74..a971d4fa0 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -172,11 +172,14 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE, INDIC_ROUNDBOX); execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE_INC, INDIC_ROUNDBOX); execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_TAGMATCH, INDIC_ROUNDBOX); + execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_TAGATTR, INDIC_ROUNDBOX); + execute(SCI_INDICSETALPHA, SCE_UNIVERSAL_FOUND_STYLE_2, 100); execute(SCI_INDICSETALPHA, SCE_UNIVERSAL_FOUND_STYLE, 100); execute(SCI_INDICSETALPHA, SCE_UNIVERSAL_FOUND_STYLE_INC, 100); execute(SCI_INDICSETALPHA, SCE_UNIVERSAL_TAGMATCH, 100); + execute(SCI_INDICSETALPHA, SCE_UNIVERSAL_TAGATTR, 100); _pParameter = NppParameters::getInstance(); @@ -736,7 +739,15 @@ void ScintillaEditView::defineDocType(LangType typeDoc) //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } - + + iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_TAGATTR); + if (iFind != -1) + { + Style & styleFind = stylers.getStyler(iFind); + //setSpecialStyle(styleFind); + setSpecialIndicator(styleFind); + } + iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_SELECT_STYLE); if (iFind != -1) { diff --git a/PowerEditor/src/stylers.model.xml b/PowerEditor/src/stylers.model.xml index 6d6b0853c..11dfad452 100644 --- a/PowerEditor/src/stylers.model.xml +++ b/PowerEditor/src/stylers.model.xml @@ -713,7 +713,8 @@ - + + diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index d9a910031..87b899edb 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -112,6 +112,7 @@ #define SCE_UNIVERSAL_FOUND_STYLE_2 29 #define SCE_UNIVERSAL_FOUND_STYLE_INC 28 #define SCE_UNIVERSAL_TAGMATCH 27 +#define SCE_UNIVERSAL_TAGATTR 26 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1