diff options
author | nyamatongwe <unknown> | 2004-06-02 11:58:51 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2004-06-02 11:58:51 +0000 |
commit | 41aaf1a65a98fcfe37a67405213cc1a5d41a2b11 (patch) | |
tree | 5494a8ad9a4fb6dad3d59677c0218a01e2c496c3 /src | |
parent | 82db4d4cdd58a52e9462ca4f0e25f2d0f3028e02 (diff) | |
download | scintilla-mirror-41aaf1a65a98fcfe37a67405213cc1a5d41a2b11.tar.gz |
Update from Philippe with some support for CSS 2.
Diffstat (limited to 'src')
-rw-r--r-- | src/LexCSS.cxx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/LexCSS.cxx b/src/LexCSS.cxx index 11daa1423..73d5b07d9 100644 --- a/src/LexCSS.cxx +++ b/src/LexCSS.cxx @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file LexCSS.cxx - ** Lexer for Cascade Style Sheets + ** Lexer for Cascading Style Sheets ** Written by Jakub Vrána **/ // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org> @@ -21,19 +21,27 @@ #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 } inline bool IsCssOperator(const char ch) { - if (!isalnum(ch) && (ch == '{' || ch == '}' || ch == ':' || ch == ',' || ch == ';' || ch == '.' || ch == '#' || ch == '!' || ch == '@')) + if (!isalnum(ch) && + (ch == '{' || ch == '}' || ch == ':' || ch == ',' || ch == ';' || + ch == '.' || ch == '#' || ch == '!' || ch == '@' || + /* CSS2 */ + ch == '*' || ch == '>' || ch == '+' || ch == '=' || ch == '~' || ch == '|' || + ch == '[' || ch == ']' || ch == '(' || ch == ')')) { return true; + } return false; } static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &pseudoClasses = *keywordlists[1]; + WordList &keywords2 = *keywordlists[2]; StyleContext sc(startPos, length, initStyle, styler); @@ -44,7 +52,8 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo for (; sc.More(); sc.Forward()) { if (sc.state == SCE_CSS_COMMENT && sc.Match('*', '/')) { if (lastStateC == -1) { - // backtrack to get last state + // backtrack to get last state: + // comments are like whitespace, so we must return to the previous state unsigned int i = startPos; for (; i > 0; i--) { if ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) { @@ -157,7 +166,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo s2++; switch (sc.state) { case SCE_CSS_IDENTIFIER: - if (!keywords.InList(s2)) + if (!keywords.InList(s2) && !keywords2.InList(s2)) sc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER); break; case SCE_CSS_UNKNOWN_IDENTIFIER: |