git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@277 f5eea248-9336-0410-98b8-ebc06183d4e3

pull/343/head^2
donho 2008-07-08 10:11:04 +00:00
parent a9ad2f7a22
commit 8fb47c3ba1
2 changed files with 47 additions and 27 deletions

View File

@ -2482,6 +2482,51 @@ TagCateg Notepad_plus::getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos)
return outOfTag; return outOfTag;
} }
bool Notepad_plus::getMatchedTagPos(int searchStart, int searchEnd, const char *tag2find, const char *oppositeTag2find, XmlMatchedTagsPos & tagsPos)
{
const bool search2Left = false;
const bool search2Right = true;
bool direction = searchEnd > searchStart;
pair<int, int> foundPos;
int ltPosOnR = getFirstTokenPosFrom(searchStart, searchEnd, tag2find, foundPos);
if (ltPosOnR == -1)
return false;
pair<int, int> oppositeTagPos;
int s = foundPos.first;
int e = tagsPos.tagOpenEnd;
if (direction == search2Left)
{
}
int openLtPosOnR = getFirstTokenPosFrom(s, e, oppositeTag2find, oppositeTagPos);
if (openLtPosOnR == -1)
{
tagsPos.tagCloseStart = foundPos.first;
tagsPos.tagCloseEnd = foundPos.second;
if (direction == search2Left)
{
}
return true;
}
int start = foundPos.second;
int end = searchEnd;
if (direction == search2Left)
{
}
return getMatchedTagPos(start, end, tag2find, oppositeTag2find, tagsPos);
}
bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos) bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
{ {
// get word where caret is on // get word where caret is on
@ -2518,33 +2563,7 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
delete [] tagName; delete [] tagName;
int startClose = tagsPos.tagOpenEnd; return getMatchedTagPos(tagsPos.tagOpenEnd, docLen, closeTag.c_str(), openTag.c_str(), tagsPos);
int endClose = docLen;
bool isFirstTime = true;
int posBeginSearch;
pair<int, int> foundPos;
while (true)
{
int ltPosOnR = getFirstTokenPosFrom(startClose, endClose, closeTag.c_str(), foundPos);
if (ltPosOnR == -1)
return false;
pair<int, int> tmpPos;
//int openLtPosOnR = getFirstTokenPosFrom(isFirstTime?foundPos.first:posBeginSearch, tagsPos.tagOpenEnd, openTag.c_str(), tmpPos);
int openLtPosOnR = getFirstTokenPosFrom(foundPos.first, tagsPos.tagOpenEnd, openTag.c_str(), tmpPos);
isFirstTime = false;
if (openLtPosOnR == -1)
{
tagsPos.tagCloseStart = foundPos.first;
tagsPos.tagCloseEnd = foundPos.second;
return true;
}
startClose = foundPos.second;
//posBeginSearch = tmpPos.first;
}
return false;
} }
case tagClose : // if tagClose search left case tagClose : // if tagClose search left

View File

@ -677,6 +677,7 @@ private:
int getFirstTokenPosFrom(int targetStart, int targetEnd, const char *token, pair<int, int> & foundPos); int getFirstTokenPosFrom(int targetStart, int targetEnd, const char *token, pair<int, int> & foundPos);
TagCateg getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos); TagCateg getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos);
bool getMatchedTagPos(int searchStart, int searchEnd, const char *tag2find, const char *oppositeTag2find, XmlMatchedTagsPos & tagsPos);
bool getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos); bool getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos);
vector< pair<int, int> > getAttributesPos(int start, int end); vector< pair<int, int> > getAttributesPos(int start, int end);
void tagMatch(); void tagMatch();