[NEW_FEATURE] Add indent guide line highlighting for html/xml tags.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@571 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-11-24 00:32:54 +00:00
parent a6bffa9666
commit 215b5c0049
3 changed files with 36 additions and 5 deletions

View File

@ -2688,7 +2688,36 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (nppGui._enableTagsMatchHilite)
{
XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView);
xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite);
pair<int, int> tagPos = xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite);
int braceAtCaret = tagPos.first;
int braceOpposite = tagPos.second;
if ((braceAtCaret != -1) && (braceOpposite == -1))
{
_pEditView->execute(SCI_SETHIGHLIGHTGUIDE, 0);
}
else if (_pEditView->isShownIndentGuide())
{
int columnAtCaret = int(_pEditView->execute(SCI_GETCOLUMN, braceAtCaret));
int columnOpposite = int(_pEditView->execute(SCI_GETCOLUMN, braceOpposite));
int lineAtCaret = int(_pEditView->execute(SCI_LINEFROMPOSITION, braceAtCaret));
int lineOpposite = int(_pEditView->execute(SCI_LINEFROMPOSITION, braceOpposite));
if (lineAtCaret != lineOpposite)
{
StyleArray & stylers = nppParam->getMiscStylerArray();
int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_TAGMATCH);
if (iFind)
{
Style *pStyle = &(stylers.getStyler(iFind));
_pEditView->execute(SCI_STYLESETFORE, STYLE_BRACELIGHT, pStyle->_bgColor);
}
// braceAtCaret - 1, braceOpposite-1 : walk around to not highlight the '<'
_pEditView->execute(SCI_BRACEHIGHLIGHT, braceAtCaret-1, braceOpposite-1);
_pEditView->execute(SCI_SETHIGHLIGHTGUIDE, (columnAtCaret < columnOpposite)?columnAtCaret:columnOpposite);
}
}
}
if (nppGui._enableSmartHilite)
@ -3090,7 +3119,7 @@ void Notepad_plus::braceMatch()
if ((braceAtCaret != -1) && (braceOpposite == -1))
{
_pEditView->execute(SCI_BRACEBADLIGHT, braceAtCaret);
_pEditView->execute(SCI_SETHIGHLIGHTGUIDE);
_pEditView->execute(SCI_SETHIGHLIGHTGUIDE, 0);
}
else
{

View File

@ -439,7 +439,7 @@ vector< pair<int, int> > XmlMatchedTagsHighlighter::getAttributesPos(int start,
void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
pair<int, int> XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
{
// Clean up all marks of previous action
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH);
@ -449,7 +449,7 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
LangType lang = (_pEditView->getCurrentBuffer())->getLangType();
if (lang != L_XML && lang != L_HTML && lang != L_PHP && lang != L_ASP)
return;
return pair<int, int>(-1, -1);
// Get the original targets and search options to restore after tag matching operation
int originalStartPos = _pEditView->execute(SCI_GETTARGETSTART);
@ -490,4 +490,6 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
_pEditView->execute(SCI_SETTARGETSTART, originalStartPos);
_pEditView->execute(SCI_SETTARGETEND, originalEndPos);
_pEditView->execute(SCI_SETSEARCHFLAGS, originalSearchFlags);
return pair<int, int>(xmlTags.tagOpenStart, xmlTags.tagCloseStart);
}

View File

@ -27,7 +27,7 @@ enum TagCateg {tagOpen, tagClose, inSingleTag, outOfTag, invalidTag, unknownPb};
class XmlMatchedTagsHighlighter {
public:
XmlMatchedTagsHighlighter(ScintillaEditView *pEditView):_pEditView(pEditView){};
void tagMatch(bool doHiliteAttr);
pair<int, int> tagMatch(bool doHiliteAttr);
private:
struct XmlMatchedTagsPos {