[ENHANCE] Enhance Tag match highlighting.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@267 f5eea248-9336-0410-98b8-ebc06183d4e3pull/343/head^2
parent
9a2cebbd6e
commit
41be902ec8
|
@ -2547,7 +2547,7 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
|
|||
|
||||
string openTag = "<";
|
||||
openTag += tagName;
|
||||
openTag += "[ >]";
|
||||
//openTag += "[ >]";
|
||||
|
||||
string closeTag = "</";
|
||||
closeTag += tagName;
|
||||
|
@ -2581,7 +2581,6 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
|
|||
case inSingleTag : // if in single tag
|
||||
{
|
||||
_pEditView->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<pair<int, int>> Notepad_plus::getAttributesPos(int start, int end)
|
||||
{
|
||||
vector<pair<int, int>> 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<int, int>(start+startPos, start+i));
|
||||
startPos = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startPos == -1)
|
||||
{
|
||||
startPos = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startPos != -1)
|
||||
attributes.push_back(pair<int, int>(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<pair<int, int>> 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
|
||||
|
|
|
@ -678,6 +678,7 @@ private:
|
|||
int getFirstTokenPosFrom(int currentPos, bool direction, const char *token, pair<int, int> & foundPos);
|
||||
TagCateg getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos);
|
||||
bool getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos);
|
||||
vector<pair<int, int>> getAttributesPos(int start, int end);
|
||||
void tagMatch();
|
||||
|
||||
void activateNextDoc(bool direction);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -713,7 +713,8 @@
|
|||
<WidgetStyle name="Smart HighLighting" styleID="29" bgColor="00FF00" />
|
||||
<WidgetStyle name="Find Mark Style" styleID="31" bgColor="FF0000" />
|
||||
<WidgetStyle name="Incremental highlight all" styleID="28" bgColor="0080FF" />
|
||||
<WidgetStyle name="Tags match highlighting" styleID="27" bgColor="8000FF" />
|
||||
<WidgetStyle name="Tags match highlighting" styleID="27" bgColor="0080FF" />
|
||||
<WidgetStyle name="Tags attribute" styleID="26" bgColor="FFFF00" />
|
||||
<WidgetStyle name="Active tab focused indicator" styleID="0" fgColor="FAAA3C" />
|
||||
<WidgetStyle name="Active tab unfocused indicator" styleID="0" fgColor="FFCAB0" />
|
||||
<WidgetStyle name="Active tab text" styleID="0" fgColor="000000" />
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue