diff options
-rw-r--r-- | include/SciLexer.h | 2 | ||||
-rw-r--r-- | include/Scintilla.iface | 2 | ||||
-rw-r--r-- | src/LexCSS.cxx | 26 |
3 files changed, 21 insertions, 9 deletions
diff --git a/include/SciLexer.h b/include/SciLexer.h index 80b3ef22b..2115aae1a 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -444,6 +444,8 @@ #define SCE_CSS_ID 10 #define SCE_CSS_IMPORTANT 11 #define SCE_CSS_DIRECTIVE 12 +#define SCE_CSS_DOUBLESTRING 13 +#define SCE_CSS_SINGLESTRING 14 //--Autogenerated -- end of section automatically generated from Scintilla.iface #endif diff --git a/include/Scintilla.iface b/include/Scintilla.iface index a0c73053e..4ec3566a1 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2002,6 +2002,8 @@ val SCE_CSS_COMMENT=9 val SCE_CSS_ID=10 val SCE_CSS_IMPORTANT=11 val SCE_CSS_DIRECTIVE=12 +val SCE_CSS_DOUBLESTRING=13 +val SCE_CSS_SINGLESTRING=14 # Events diff --git a/src/LexCSS.cxx b/src/LexCSS.cxx index 7192ac949..b89f7ea8b 100644 --- a/src/LexCSS.cxx +++ b/src/LexCSS.cxx @@ -21,8 +21,6 @@ #include "Scintilla.h" #include "SciLexer.h" - - static inline bool IsAWordChar(const unsigned int ch) { return (isalnum(ch) || ch == '-' || ch == '_' || ch >= 161); // _ is not in fact correct CSS word-character } @@ -73,6 +71,17 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.state == SCE_CSS_COMMENT) continue; + if (sc.state == SCE_CSS_DOUBLESTRING || sc.state == SCE_CSS_SINGLESTRING) { + if (sc.ch != (sc.state == SCE_CSS_DOUBLESTRING ? '\"' : '\'')) + continue; + unsigned int i = sc.currentPos; + while (i && styler[i-1] == '\\') + i--; + if ((sc.currentPos - i) % 2 == 1) + continue; + sc.ForwardSetState(SCE_CSS_VALUE); + } + if (sc.state == SCE_CSS_OPERATOR) { if (op == ' ') { unsigned int i = startPos; @@ -169,19 +178,18 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo } } - if (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_ID)) + if (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_ID)) sc.SetState(SCE_CSS_TAG); if (sc.Match('/', '*')) { lastStateC = sc.state; sc.SetState(SCE_CSS_COMMENT); sc.Forward(); - continue; - } - - if (IsCssOperator(static_cast<char>(sc.ch)) - && (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!') - && (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{') + } else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\"' || sc.ch == '\'')) { + sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING)); + } else if (IsCssOperator(static_cast<char>(sc.ch)) + && (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!') + && (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{') ) { if (sc.state != SCE_CSS_OPERATOR) lastState = sc.state; |