diff options
author | nyamatongwe <unknown> | 2011-06-24 10:23:09 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-06-24 10:23:09 +1000 |
commit | b8c03bfcdda07e63becf660244f977a0e10d8c5b (patch) | |
tree | 9979488f5d8b81b932fa4f0fd4f31656f6743437 /lexers/LexHTML.cxx | |
parent | ac04dd054380d2caea9106cae5083e4d41954594 (diff) | |
download | scintilla-mirror-b8c03bfcdda07e63becf660244f977a0e10d8c5b.tar.gz |
Support for new Mako block syntax. Feature #3325178.
From Stephan R.A. Deibel.
Diffstat (limited to 'lexers/LexHTML.cxx')
-rw-r--r-- | lexers/LexHTML.cxx | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx index 60146ed9b..b54401805 100644 --- a/lexers/LexHTML.cxx +++ b/lexers/LexHTML.cxx @@ -356,7 +356,7 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw return SCE_HB_DEFAULT; } -static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) { +static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType, bool isMako) { bool wordIsNumber = IsADigit(styler[start]); char s[30 + 1]; unsigned int i = 0; @@ -373,6 +373,8 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key chAttr = SCE_HP_NUMBER; else if (keywords.InList(s)) chAttr = SCE_HP_WORD; + else if (isMako && 0 == strcmp(s, "block")) + chAttr = SCE_HP_WORD; styler.ColourTo(end, statePrintForState(chAttr, inScriptType)); strcpy(prevWord, s); } @@ -494,7 +496,10 @@ static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType (0 == strcmp(blockType, "page"))) { return ((ch == '/') && (chNext == '>')); } else if (0 == strcmp(blockType, "%")) { - return isLineEnd(ch); + if (ch == '/' && isLineEnd(chNext)) + return 1; + else + return isLineEnd(ch); } else if (0 == strcmp(blockType, "{")) { return ch == '}'; } else { @@ -925,9 +930,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty // handle the start Mako template Python code else if (isMako && scriptLanguage == eScriptNone && ((ch == '<' && chNext == '%') || (lineStartVisibleChars == 1 && ch == '%') || + (lineStartVisibleChars == 1 && ch == '/' && chNext == '%') || (ch == '$' && chNext == '{') || (ch == '<' && chNext == '/' && chNext2 == '%'))) { - if (ch == '%') + if (ch == '%' || ch == '/') strcpy(makoBlockType, "%"); else if (ch == '$') strcpy(makoBlockType, "{"); @@ -953,7 +959,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty scriptLanguage = eScriptPython; styler.ColourTo(i, SCE_H_ASP); - if (ch != '%' && ch != '$') { + if (ch != '%' && ch != '$' && ch != '/') { i += strlen(makoBlockType); visibleChars += strlen(makoBlockType); if (keywords4.InList(makoBlockType)) @@ -1096,7 +1102,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.GetStartSegment(), i - 1, aspScript); } if (state == SCE_HP_WORD) { - classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); } else { styler.ColourTo(i - 1, StateToPrint); } @@ -1104,7 +1110,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty i++; visibleChars++; } - if (0 != strcmp(makoBlockType, "%")) { + else if (0 == strcmp(makoBlockType, "%") && ch == '/') { + i++; + visibleChars++; + } + if (0 != strcmp(makoBlockType, "%") || ch == '/') { styler.ColourTo(i, SCE_H_ASP); } state = beforePreProc; @@ -1126,7 +1136,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.GetStartSegment(), i - 1, aspScript); } if (state == SCE_HP_WORD) { - classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); } else { styler.ColourTo(i - 1, StateToPrint); } @@ -1160,7 +1170,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler, inScriptType); break; case SCE_HP_WORD: - classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); break; case SCE_HPHP_WORD: classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler); @@ -1822,7 +1832,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty break; case SCE_HP_WORD: if (!IsAWordChar(ch)) { - classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); state = SCE_HP_DEFAULT; if (ch == '#') { state = SCE_HP_COMMENTLINE; @@ -2111,7 +2121,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty classifyWordHTVB(styler.GetStartSegment(), lengthDoc - 1, keywords3, styler, inScriptType); break; case SCE_HP_WORD: - classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType, isMako); break; case SCE_HPHP_WORD: classifyWordHTPHP(styler.GetStartSegment(), lengthDoc - 1, keywords5, styler); |