[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.h clang.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.h clang.c |
Date: |
Sun, 18 May 2014 22:40:05 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/05/18 22:40:05
Modified files:
. : qe.h clang.c
Log message:
add colorizer for css files and portions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.171&r2=1.172
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.64&r2=1.65
Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -b -r1.171 -r1.172
--- qe.h 18 May 2014 11:01:55 -0000 1.171
+++ qe.h 18 May 2014 22:40:04 -0000 1.172
@@ -1968,6 +1968,7 @@
CLANG_CPP,
CLANG_OBJC,
CLANG_CSHARP,
+ CLANG_CSS,
CLANG_JS,
CLANG_AS,
CLANG_JAVA,
@@ -2014,8 +2015,7 @@
static inline void css_colorize_line(QEColorizeContext *cp,
unsigned int *str, int n, int mode_flags)
{
- /* XXX: should have real colorizer for CSS syntax */
- c_colorize_line(cp, str, n, mode_flags);
+ c_colorize_line(cp, str, n, mode_flags | CLANG_CSS);
}
/* xml.c */
Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- clang.c 18 May 2014 10:47:13 -0000 1.64
+++ clang.c 18 May 2014 22:40:05 -0000 1.65
@@ -89,6 +89,14 @@
"boolean|byte|char|double|float|int|long|short|void|String|"
};
+static const char css_keywords[] = {
+ "|"
+};
+
+static const char css_types[] = {
+ "|"
+};
+
static const char js_keywords[] = {
"break|case|catch|continue|debugger|default|delete|do|"
"else|finally|for|function|if|in|instanceof|new|"
@@ -286,6 +294,7 @@
{ cpp_keywords, cpp_types }, /* CLANG_CPP */
{ objc_keywords, objc_types }, /* CLANG_OBJC */
{ csharp_keywords, csharp_types }, /* CLANG_CSHARP */
+ { css_keywords, css_types }, /* CLANG_CSS */
{ js_keywords, js_types }, /* CLANG_JS */
{ as_keywords, as_types }, /* CLANG_AS */
{ java_keywords, java_types }, /* CLANG_JAVA */
@@ -307,9 +316,10 @@
"cc|hh|cpp|hpp|cxx|hxx|CPP|CC|c++|" /* C++ */
"m|mm|" /* Objective-C, Limbo */
"cs|" /* C Sharp */
- "jav|java|" /* Java */
+ "css|" /* Cascaded Style Sheet, CSS */
"js|json|" /* Javascript, JSon */
"as|" /* Actionscript */
+ "jav|java|" /* Java */
"jsx|" /* JSX (extended Javascript) */
"hx|" /* Haxe (extended Javascript) */
"go|" /* Go language */
@@ -331,20 +341,24 @@
/* grab a C identifier from a uint buf, stripping color.
* return char count.
*/
-static int get_c_identifier(char *buf, int buf_size, unsigned int *p)
+static int get_c_identifier(char *buf, int buf_size, unsigned int *p, int
flavor)
{
unsigned int c;
int i, j;
i = j = 0;
- c = p[i];
- if (qe_isalpha_(c & CHAR_MASK) || c == '$' || c == '@') {
- do {
+ c = p[i] & CHAR_MASK;
+ if (qe_isalpha_(c) || c == '$' || c == '@') {
+ for (;;) {
if (j < buf_size - 1)
buf[j++] = c;
i++;
- c = p[i];
- } while (qe_isalnum_(c & CHAR_MASK));
+ c = p[i] & CHAR_MASK;
+ if (c == '-' && flavor == CLANG_CSS)
+ continue;
+ if (!qe_isalnum_(c))
+ break;
+ }
}
buf[j] = '\0';
return i;
@@ -549,7 +563,7 @@
goto parse_regex;
}
if (flavor == CLANG_HAXE) {
- i += get_c_identifier(kbuf, countof(kbuf), str + i);
+ i += get_c_identifier(kbuf, countof(kbuf), str + i, flavor);
// XXX: check for proper preprocessor directive?
SET_COLOR(str, start, i, C_STYLE_PREPROCESS);
continue;
@@ -683,11 +697,13 @@
}
if (qe_isalpha_(c) || c == '$' || c == '@') {
/* XXX: should support :: */
- klen = get_c_identifier(kbuf, countof(kbuf), str + start);
+ klen = get_c_identifier(kbuf, countof(kbuf), str + start,
flavor);
i = start + klen;
if ((keywords && strfind(keywords, kbuf))
- || ((mode_flags & CLANG_CC) && strfind(c_keywords, kbuf))) {
+ || ((mode_flags & CLANG_CC) && strfind(c_keywords, kbuf))
+ || ((flavor == CLANG_CSS) && str[i] == ':')
+ ) {
SET_COLOR(str, start, i, C_STYLE_KEYWORD);
continue;
}
@@ -1037,7 +1053,7 @@
break;
}
if (qe_isalpha_(c & CHAR_MASK)) {
- j = get_c_identifier(buf1, countof(buf1), buf + i);
+ j = get_c_identifier(buf1, countof(buf1), buf + i, CLANG_C);
if (style == C_STYLE_KEYWORD) {
if (strfind("case|default", buf1))
@@ -1314,6 +1330,10 @@
s->mode_name = "Java";
s->mode_flags = CLANG_JAVA;
} else
+ if (match_extension(base, "css")) {
+ s->mode_name = "CSS";
+ s->mode_flags = CLANG_CSS;
+ } else
if (match_extension(base, "js|json")) {
s->mode_name = "Javascript";
s->mode_flags = CLANG_JS | CLANG_REGEX;