[NEW_FEATURE] Tag match highliting is finished.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@251 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-06-23 22:18:02 +00:00
parent f7f0c438b9
commit f154e6984d

View File

@ -2384,18 +2384,6 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
// determinate the nature of current word : tagOpen, tagClose or outOfTag // determinate the nature of current word : tagOpen, tagClose or outOfTag
TagCateg tagCateg = getTagCategory(tagsPos, caretPos); TagCateg tagCateg = getTagCategory(tagsPos, caretPos);
/*
string toto;
switch (tagCateg)
{
case tagOpen : toto = "tag open"; break;
case tagClose : toto = "tag close"; break;
case inSingleTag : toto = "tag single"; break;
case invalidTag : toto = "tag invalid"; break;
case unknownPb : toto = "unknown Pb"; break;
}
::SetWindowText(_hSelf, toto.c_str());
*/
switch (tagCateg) switch (tagCateg)
{ {
case tagOpen : // if tagOpen search right case tagOpen : // if tagOpen search right
@ -2417,19 +2405,25 @@ string toto;
delete [] tagName; delete [] tagName;
pair<int, int> foundPos; pair<int, int> foundPos;
while (true)
{
int ltPosOnR = getFirstTokenPosFrom(caretPos, DIR_RIGHT, closeTag.c_str(), foundPos); int ltPosOnR = getFirstTokenPosFrom(caretPos, DIR_RIGHT, closeTag.c_str(), foundPos);
if (ltPosOnR == -1) if (ltPosOnR == -1)
return false; return false;
pair<int, int> tmpPos; pair<int, int> tmpPos;
int openLtPosOnR = getFirstTokenPosFrom(caretPos, DIR_RIGHT, openTag.c_str(), tmpPos); int openLtPosOnR = getFirstTokenPosFrom(caretPos, DIR_RIGHT, openTag.c_str(), tmpPos);
if ((openLtPosOnR != -1) && (openLtPosOnR < ltPosOnR)) if ((openLtPosOnR == -1) || (openLtPosOnR > ltPosOnR))
return false; {
tagsPos.tagCloseStart = foundPos.first; tagsPos.tagCloseStart = foundPos.first;
tagsPos.tagCloseEnd = foundPos.second; tagsPos.tagCloseEnd = foundPos.second;
return true; return true;
} }
caretPos = foundPos.second;
}
return false;
}
case tagClose : // if tagClose search left case tagClose : // if tagClose search left
{ {
@ -2443,16 +2437,31 @@ string toto;
openTag += tagName; openTag += tagName;
openTag += "[ >]"; openTag += "[ >]";
string closeTag = "</";
closeTag += tagName;
closeTag += "[ ]*>";
delete [] tagName; delete [] tagName;
pair<int, int> foundPos; pair<int, int> foundPos;
while (true)
{
int ltPosOnL = getFirstTokenPosFrom(caretPos, DIR_LEFT, openTag.c_str(), foundPos); int ltPosOnL = getFirstTokenPosFrom(caretPos, DIR_LEFT, openTag.c_str(), foundPos);
if (ltPosOnL == -1) if (ltPosOnL == -1)
return false; return false;
if (getTagCategory(tagsPos, ltPosOnL+2) != tagOpen) if (getTagCategory(tagsPos, ltPosOnL+2) != tagOpen)
return false; return false;
pair<int, int> tmpPos;
int closeLtPosOnL = getFirstTokenPosFrom(caretPos, DIR_LEFT, closeTag.c_str(), tmpPos);
if ((closeLtPosOnL == -1) || (closeLtPosOnL < ltPosOnL))
return true; return true;
caretPos = foundPos.first;
}
return false;
} }
case inSingleTag : // if in single tag case inSingleTag : // if in single tag