From 8fb47c3ba1be1939b66346a90f598ce2605d515d Mon Sep 17 00:00:00 2001 From: donho Date: Tue, 8 Jul 2008 10:11:04 +0000 Subject: [PATCH] git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@277 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 73 ++++++++++++++++++++------------ PowerEditor/src/Notepad_plus.h | 1 + 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index de485ab0a..f76efa9a6 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2482,6 +2482,51 @@ TagCateg Notepad_plus::getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos) 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 foundPos; + int ltPosOnR = getFirstTokenPosFrom(searchStart, searchEnd, tag2find, foundPos); + if (ltPosOnR == -1) + return false; + + pair 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) { // get word where caret is on @@ -2518,33 +2563,7 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos) delete [] tagName; - int startClose = tagsPos.tagOpenEnd; - int endClose = docLen; - bool isFirstTime = true; - int posBeginSearch; - - pair foundPos; - while (true) - { - int ltPosOnR = getFirstTokenPosFrom(startClose, endClose, closeTag.c_str(), foundPos); - if (ltPosOnR == -1) - return false; - - pair 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; + return getMatchedTagPos(tagsPos.tagOpenEnd, docLen, closeTag.c_str(), openTag.c_str(), tagsPos); } case tagClose : // if tagClose search left diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 241a931e3..bd75b5aa8 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -677,6 +677,7 @@ private: int getFirstTokenPosFrom(int targetStart, int targetEnd, const char *token, pair & foundPos); TagCateg getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos); + bool getMatchedTagPos(int searchStart, int searchEnd, const char *tag2find, const char *oppositeTag2find, XmlMatchedTagsPos & tagsPos); bool getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos); vector< pair > getAttributesPos(int start, int end); void tagMatch();