[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs clang.c htmlsrc.c qe.h
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs clang.c htmlsrc.c qe.h |
Date: |
Sat, 17 May 2014 10:15:22 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/05/17 10:15:22
Modified files:
. : clang.c htmlsrc.c qe.h
Log message:
extend html-src-mode
* add support for ASP scripts with <% %. syntax
* add support for embedded C Sharp scripts
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/qemacs/htmlsrc.c?cvsroot=qemacs&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.169&r2=1.170
Patches:
Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- clang.c 16 May 2014 07:37:40 -0000 1.62
+++ clang.c 17 May 2014 10:15:21 -0000 1.63
@@ -57,16 +57,16 @@
};
static const char csharp_keywords[] = {
- "abstract|add|as|base|break|case|catch|checked|class|const|continue|"
+ "abstract|as|base|break|case|catch|checked|class|const|continue|"
"default|delegate|do|else|enum|event|explicit|extern|false|finally|"
"fixed|for|foreach|goto|if|implicit|in|interface|internal|is|lock|"
"namespace|new|null|operator|out|override|params|private|protected|"
- "public|readonly|ref|remove|return|sealed|sizeof|stackalloc|static|"
+ "public|readonly|ref|return|sealed|sizeof|stackalloc|static|"
"struct|switch|template|this|throw|true|try|typeof|unchecked|unsafe|"
"using|virtual|volatile|while|"
/* contextual keywords */
- "yield|partial|get|set|where|"
+ "add|remove|yield|partial|get|set|where|"
};
static const char csharp_types[] = {
Index: htmlsrc.c
===================================================================
RCS file: /sources/qemacs/qemacs/htmlsrc.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- htmlsrc.c 15 Apr 2014 08:08:01 -0000 1.15
+++ htmlsrc.c 17 May 2014 10:15:22 -0000 1.16
@@ -68,6 +68,8 @@
IN_HTML_STYLE = 0x200, /* <style> [...] </style> */
IN_HTML_PHP_TAG = 0x400, /* <?php ... ?> */
IN_HTML_PHP_STRING = 0x800, /* "<?php ... ?>" */
+ IN_HTML_ASP_TAG = 0x1000, /* <% ... %> */
+ IN_HTML_ASP_STRING = 0x2000, /* "<% ... %>" */
};
enum {
@@ -118,10 +120,10 @@
}
c = str[i]; /* save char to set '\0' delimiter */
str[i] = '\0';
- cp->colorize_state = state & ~(IN_HTML_PHP_TAG|IN_HTML_PHP_STRING);
+ cp->colorize_state = state & ~(IN_HTML_PHP_TAG |
IN_HTML_PHP_STRING);
php_colorize_line(cp, str + start, i - start, 0);
state = cp->colorize_state |
- (state & (IN_HTML_PHP_TAG|IN_HTML_PHP_STRING));
+ (state & (IN_HTML_PHP_TAG | IN_HTML_PHP_STRING));
str[i] = c;
if (c) {
start = i;
@@ -136,6 +138,31 @@
}
continue;
}
+ if (state & (IN_HTML_ASP_TAG | IN_HTML_ASP_STRING)) {
+ for (; i < n; i++) {
+ if (str[i] == '%' && str[i + 1] == '>')
+ break;
+ }
+ c = str[i]; /* save char to set '\0' delimiter */
+ str[i] = '\0';
+ cp->colorize_state = state & ~(IN_HTML_ASP_TAG |
IN_HTML_ASP_STRING);
+ csharp_colorize_line(cp, str + start, i - start, 0);
+ state = cp->colorize_state |
+ (state & (IN_HTML_ASP_TAG | IN_HTML_ASP_STRING));
+ str[i] = c;
+ if (c) {
+ start = i;
+ i += 2;
+ SET_COLOR(str, start, i, HTML_STYLE_PREPROCESS);
+ if (state & IN_HTML_ASP_TAG) {
+ state = 0;
+ } else {
+ /* XXX: should set these bits higher */
+ state = IN_HTML_STRING | IN_HTML_TAG;
+ }
+ }
+ continue;
+ }
if (state & IN_HTML_SCRIPT) {
for (; i < n; i++) {
if (str[i] == '<'
@@ -229,8 +256,20 @@
state = IN_HTML_PHP_STRING;
break;
} else
+ if (str[i] == '<' && str[i + 1] == '%') {
+ SET_COLOR(str, start, i, HTML_STYLE_STRING);
+ SET_COLOR(str, i, i + 2, HTML_STYLE_PREPROCESS);
+ i += 2;
+ start = i;
+ state = IN_HTML_ASP_STRING;
+ break;
+ } else
if (str[i] == '?' && str[i + 1] == '>') {
- /* special case embedded script tags */
+ /* special case embedded php script tags */
+ i += 1;
+ } else
+ if (str[i] == '%' && str[i + 1] == '>') {
+ /* special case embedded asp script tags */
i += 1;
} else
if (str[i] == '>') {
@@ -289,6 +328,12 @@
state = IN_HTML_PHP_TAG;
break;
}
+ if (str[i] == '<' && str[i + 1] == '%') {
+ i += 2;
+ SET_COLOR(str, start, i, HTML_STYLE_PREPROCESS);
+ state = IN_HTML_ASP_TAG;
+ break;
+ }
if (str[i] == '<'
&& (qe_isalpha(str[i + 1]) || str[i + 1] == '!'
|| str[i + 1] == '/' || str[i + 1] == '?')) {
@@ -377,7 +422,7 @@
/* html-src mode is almost like the text mode, so we copy and patch it */
memcpy(&htmlsrc_mode, &text_mode, sizeof(ModeDef));
htmlsrc_mode.name = "html-src";
- htmlsrc_mode.extensions = "html|htm|asp|shtml|hta|htp|phtml|php";
+ htmlsrc_mode.extensions = "html|htm|asp|aspx|shtml|hta|htp|phtml|php";
htmlsrc_mode.mode_probe = htmlsrc_mode_probe;
htmlsrc_mode.colorize_func = htmlsrc_colorize_line;
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -b -r1.169 -r1.170
--- qe.h 16 May 2014 07:37:40 -0000 1.169
+++ qe.h 17 May 2014 10:15:22 -0000 1.170
@@ -2001,6 +2001,12 @@
c_colorize_line(cp, str, n, mode_flags | CLANG_PHP | CLANG_REGEX);
}
+static inline void csharp_colorize_line(QEColorizeContext *cp,
+ unsigned int *str, int n, int
mode_flags)
+{
+ c_colorize_line(cp, str, n, mode_flags | CLANG_CSHARP);
+}
+
static inline void css_colorize_line(QEColorizeContext *cp,
unsigned int *str, int n, int mode_flags)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs clang.c htmlsrc.c qe.h,
Charlie Gordon <=