mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-22 21:34:58 +02:00
[BUG_FIXED] fixed the tag attribute highlight memorizing bug.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@275 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
014af9eb40
commit
ce45ebe455
@ -2397,16 +2397,15 @@ void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite)
|
|||||||
braceOpposite = int(_pEditView->execute(SCI_BRACEMATCH, braceAtCaret, 0));
|
braceOpposite = int(_pEditView->execute(SCI_BRACEMATCH, braceAtCaret, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Notepad_plus::getFirstTokenPosFrom(int currentPos, bool direction, const char *token, pair<int, int> & foundPos)
|
int Notepad_plus::getFirstTokenPosFrom(int targetStart, int targetEnd, const char *token, pair<int, int> & foundPos)
|
||||||
{
|
{
|
||||||
int start = currentPos;
|
//int start = currentPos;
|
||||||
int end = (direction == DIR_LEFT)?0:_pEditView->getCurrentDocLen();
|
//int end = (direction == DIR_LEFT)?0:_pEditView->getCurrentDocLen();
|
||||||
|
|
||||||
_pEditView->execute(SCI_SETTARGETSTART, start);
|
_pEditView->execute(SCI_SETTARGETSTART, targetStart);
|
||||||
_pEditView->execute(SCI_SETTARGETEND, end);
|
_pEditView->execute(SCI_SETTARGETEND, targetEnd);
|
||||||
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
|
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
|
||||||
int posFind = _pEditView->execute(SCI_SEARCHINTARGET, (WPARAM)strlen(token), (LPARAM)token);
|
int posFind = _pEditView->execute(SCI_SEARCHINTARGET, (WPARAM)strlen(token), (LPARAM)token);
|
||||||
|
|
||||||
if (posFind != -1)
|
if (posFind != -1)
|
||||||
{
|
{
|
||||||
foundPos.first = _pEditView->execute(SCI_GETTARGETSTART);
|
foundPos.first = _pEditView->execute(SCI_GETTARGETSTART);
|
||||||
@ -2419,8 +2418,10 @@ TagCateg Notepad_plus::getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos)
|
|||||||
{
|
{
|
||||||
pair<int, int> foundPos;
|
pair<int, int> foundPos;
|
||||||
|
|
||||||
int gtPos = getFirstTokenPosFrom(curPos, DIR_LEFT, ">", foundPos);
|
int docLen = _pEditView->getCurrentDocLen();
|
||||||
int ltPos = getFirstTokenPosFrom(curPos, DIR_LEFT, "<", foundPos);
|
|
||||||
|
int gtPos = getFirstTokenPosFrom(curPos, 0, ">", foundPos);
|
||||||
|
int ltPos = getFirstTokenPosFrom(curPos, 0, "<", foundPos);
|
||||||
if (ltPos != -1)
|
if (ltPos != -1)
|
||||||
{
|
{
|
||||||
if ((gtPos != -1) && (ltPos < gtPos))
|
if ((gtPos != -1) && (ltPos < gtPos))
|
||||||
@ -2440,8 +2441,8 @@ TagCateg Notepad_plus::getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos)
|
|||||||
|
|
||||||
// so now we are sure we have tag sign '<'
|
// so now we are sure we have tag sign '<'
|
||||||
// We'll see on the right
|
// We'll see on the right
|
||||||
int gtPosOnR = getFirstTokenPosFrom(curPos, DIR_RIGHT, ">", foundPos);
|
int gtPosOnR = getFirstTokenPosFrom(curPos, docLen, ">", foundPos);
|
||||||
int ltPosOnR = getFirstTokenPosFrom(curPos, DIR_RIGHT, "<", foundPos);
|
int ltPosOnR = getFirstTokenPosFrom(curPos, docLen, "<", foundPos);
|
||||||
|
|
||||||
if (gtPosOnR == -1)
|
if (gtPosOnR == -1)
|
||||||
return invalidTag;
|
return invalidTag;
|
||||||
@ -2486,6 +2487,8 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
|
|||||||
// get word where caret is on
|
// get word where caret is on
|
||||||
int caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
int caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||||
|
|
||||||
|
int docLen = _pEditView->getCurrentDocLen();
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
@ -2515,22 +2518,31 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
|
|||||||
|
|
||||||
delete [] tagName;
|
delete [] tagName;
|
||||||
|
|
||||||
|
int startClose = tagsPos.tagOpenEnd;
|
||||||
|
int endClose = docLen;
|
||||||
|
bool isFirstTime = true;
|
||||||
|
int posBeginSearch;
|
||||||
|
|
||||||
pair<int, int> foundPos;
|
pair<int, int> foundPos;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int ltPosOnR = getFirstTokenPosFrom(caretPos, DIR_RIGHT, closeTag.c_str(), foundPos);
|
int ltPosOnR = getFirstTokenPosFrom(startClose, endClose, 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(isFirstTime?foundPos.first:posBeginSearch, tagsPos.tagOpenEnd, openTag.c_str(), tmpPos);
|
||||||
if ((openLtPosOnR == -1) || (openLtPosOnR > ltPosOnR))
|
int openLtPosOnR = getFirstTokenPosFrom(foundPos.first, tagsPos.tagOpenEnd, openTag.c_str(), tmpPos);
|
||||||
|
isFirstTime = false;
|
||||||
|
|
||||||
|
if (openLtPosOnR == -1)
|
||||||
{
|
{
|
||||||
tagsPos.tagCloseStart = foundPos.first;
|
tagsPos.tagCloseStart = foundPos.first;
|
||||||
tagsPos.tagCloseEnd = foundPos.second;
|
tagsPos.tagCloseEnd = foundPos.second;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
caretPos = foundPos.second;
|
startClose = foundPos.second;
|
||||||
|
//posBeginSearch = tmpPos.first;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2555,10 +2567,14 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
|
|||||||
|
|
||||||
delete [] tagName;
|
delete [] tagName;
|
||||||
|
|
||||||
|
int startOpen = tagsPos.tagCloseStart;
|
||||||
|
bool isFirstTime = true;
|
||||||
|
int posBeginSearch;
|
||||||
|
|
||||||
pair<int, int> foundPos;
|
pair<int, int> foundPos;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int ltPosOnL = getFirstTokenPosFrom(caretPos, DIR_LEFT, openTag.c_str(), foundPos);
|
int ltPosOnL = getFirstTokenPosFrom(startOpen, 0, openTag.c_str(), foundPos);
|
||||||
if (ltPosOnL == -1)
|
if (ltPosOnL == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2566,14 +2582,15 @@ bool Notepad_plus::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
pair<int, int> tmpPos;
|
pair<int, int> tmpPos;
|
||||||
int closeLtPosOnL = getFirstTokenPosFrom(caretPos, DIR_LEFT, closeTag.c_str(), tmpPos);
|
int closeLtPosOnL = getFirstTokenPosFrom(isFirstTime?foundPos.second:posBeginSearch, tagsPos.tagCloseStart, closeTag.c_str(), tmpPos);
|
||||||
|
isFirstTime = false;
|
||||||
if ((closeLtPosOnL == -1) || (closeLtPosOnL < ltPosOnL))
|
if (closeLtPosOnL == -1)
|
||||||
{
|
{
|
||||||
tagsPos.tagNameEnd = ltPosOnL + 1 + (endPos - startPos);
|
tagsPos.tagNameEnd = ltPosOnL + 1 + (endPos - startPos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
caretPos = foundPos.first;
|
startOpen = foundPos.first;
|
||||||
|
posBeginSearch = tmpPos.second;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -675,7 +675,7 @@ private:
|
|||||||
void findMatchingBracePos(int & braceAtCaret, int & braceOpposite);
|
void findMatchingBracePos(int & braceAtCaret, int & braceOpposite);
|
||||||
void braceMatch();
|
void braceMatch();
|
||||||
|
|
||||||
int getFirstTokenPosFrom(int currentPos, bool direction, 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 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);
|
||||||
|
@ -3369,7 +3369,7 @@ bool NppParameters::writeGUIParams()
|
|||||||
else
|
else
|
||||||
childNode->InsertEndChild(TiXmlText(pStr));
|
childNode->InsertEndChild(TiXmlText(pStr));
|
||||||
|
|
||||||
(childNode->ToElement())->SetAttribute("TagAttrHighLight", _nppGUI._enableTagsMatchHilite?"yes":"no");
|
(childNode->ToElement())->SetAttribute("TagAttrHighLight", _nppGUI._enableTagAttrsHilite?"yes":"no");
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(nm, "SaveOpenFileInSameDir"))
|
else if (!strcmp(nm, "SaveOpenFileInSameDir"))
|
||||||
@ -3569,7 +3569,7 @@ bool NppParameters::writeGUIParams()
|
|||||||
if (!tagsMatchHighLightExist)
|
if (!tagsMatchHighLightExist)
|
||||||
{
|
{
|
||||||
TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, "TagsMatchHighLight", _nppGUI._enableTagsMatchHilite);
|
TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, "TagsMatchHighLight", _nppGUI._enableTagsMatchHilite);
|
||||||
ele->SetAttribute("TagAttrHighLight", _nppGUI._enableTagsMatchHilite?"yes":"no");
|
ele->SetAttribute("TagAttrHighLight", _nppGUI._enableTagAttrsHilite?"yes":"no");
|
||||||
}
|
}
|
||||||
if (!rememberLastSessionExist)
|
if (!rememberLastSessionExist)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user