[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs lisp.c markdown.c perl.c script.c qe.h o...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs lisp.c markdown.c perl.c script.c qe.h o... |
Date: |
Mon, 10 Mar 2014 22:11:25 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/03/10 22:11:25
Modified files:
. : lisp.c markdown.c perl.c script.c qe.h
orgmode.c makemode.c extra-modes.c
Log message:
use SET_COLOR macros in various colorizers
* use macro to prepare for coloring API change
* done for lisp-mode, markdown-mode, perl-mode, shell-script-mode,
org-mode, makefile-mode
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/lisp.c?cvsroot=qemacs&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/qemacs/markdown.c?cvsroot=qemacs&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/qemacs/perl.c?cvsroot=qemacs&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/qemacs/script.c?cvsroot=qemacs&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.148&r2=1.149
http://cvs.savannah.gnu.org/viewcvs/qemacs/orgmode.c?cvsroot=qemacs&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/qemacs/makemode.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/extra-modes.c?cvsroot=qemacs&r1=1.6&r2=1.7
Patches:
Index: lisp.c
===================================================================
RCS file: /sources/qemacs/qemacs/lisp.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- lisp.c 6 Feb 2014 00:22:18 -0000 1.6
+++ lisp.c 10 Mar 2014 22:11:24 -0000 1.7
@@ -47,7 +47,7 @@
break;
}
}
- set_color(str + i, str + j, LISP_STRING);
+ SET_COLOR(str, i, j, LISP_STRING);
i = j;
}
if (colstate & IN_COMMENT) {
@@ -58,13 +58,13 @@
break;
}
}
- set_color(str + i, str + j, LISP_COMMENT);
+ SET_COLOR(str, i, j, LISP_COMMENT);
i = j;
}
while (i < n) {
switch (str[i]) {
case ';':
- set_color(str + i, str + n, LISP_COMMENT);
+ SET_COLOR(str, i, n, LISP_COMMENT);
i = n;
continue;
case '#':
@@ -78,7 +78,7 @@
break;
}
}
- set_color(str + i, str + j, LISP_COMMENT);
+ SET_COLOR(str, i, j, LISP_COMMENT);
i = j;
continue;
}
@@ -92,7 +92,7 @@
break;
}
}
- set_color(str + i, str + j, LISP_STRING);
+ SET_COLOR(str, i, j, LISP_STRING);
i = j;
continue;
default:
Index: markdown.c
===================================================================
RCS file: /sources/qemacs/qemacs/markdown.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- markdown.c 10 Mar 2014 02:03:39 -0000 1.4
+++ markdown.c 10 Mar 2014 22:11:24 -0000 1.5
@@ -131,7 +131,7 @@
if (ustrstart(str + i, "~~~", NULL)
|| ustrstart(str + i, "```", NULL)) {
colstate &= ~(IN_BLOCK | IN_LANG);
- set_color(str + i, str + n, QE_STYLE_MKD_TILDE);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_TILDE);
i = n;
} else {
int lang = colstate & IN_LANG;
@@ -153,7 +153,7 @@
lua_colorize_line(str, n, &colstate, state_only);
break;
default:
- set_color(str + i, str + n, QE_STYLE_MKD_CODE);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_CODE);
break;
}
colstate &= ~(IN_BLOCK | IN_LANG);
@@ -170,18 +170,18 @@
if (qe_isblank(str[j])) {
base_style = MkdBulletStyles[(j - i - 1) % BULLET_STYLES];
- set_color(str + i, str + j + 1, base_style);
+ SET_COLOR(str, i, j + 1, base_style);
i = j + 1;
}
} else
if (str[i] == '%') {
/* pandoc extension: line comment */
- set_color(str + i, str + n, QE_STYLE_MKD_COMMENT);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_COMMENT);
i = n;
} else
if (str[i] == '>') {
/* block quoting */
- set_color(str + i, str + n, QE_STYLE_MKD_BLOCK_QUOTE);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_BLOCK_QUOTE);
i = n;
} else
if (ustrstart(str + i, "~~~", NULL)
@@ -204,7 +204,7 @@
if (ustrstr(str + i + 3, "ruby")) {
colstate |= IN_RUBY;
}
- set_color(str + i, str + n, QE_STYLE_MKD_TILDE);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_TILDE);
i = n;
} else
if (str[i] == '-') {
@@ -212,7 +212,7 @@
for (j = i + 1; str[j] == '-'; j++)
continue;
if (j == n) {
- set_color(str + i, str + n, QE_STYLE_MKD_HEADING2);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_HEADING2);
i = n;
}
} else
@@ -221,7 +221,7 @@
for (j = i + 1; str[j] == '='; j++)
continue;
if (j == n) {
- set_color(str + i, str + n, QE_STYLE_MKD_HEADING1);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_HEADING1);
i = n;
}
} else
@@ -265,7 +265,7 @@
if (indent >= 4) {
/* Should detect sequel lines in ordered/unordered lists */
- set_color(str + i, str + n, QE_STYLE_MKD_CODE);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_CODE);
i = n;
}
}
@@ -282,7 +282,7 @@
}
if (j == n && count >= 3) {
/* Horizontal rule */
- set_color(str + i, str + n, QE_STYLE_MKD_HBAR);
+ SET_COLOR(str, i, n, QE_STYLE_MKD_HBAR);
i = n;
}
}
@@ -374,17 +374,17 @@
break;
case '\\': /* escape */
if (strchr("\\`*_{}[]()#+-.!", str[i + 1])) {
- set_color(str + i, str + i + 2, base_style);
+ SET_COLOR(str, i, i + 2, base_style);
i += 2;
continue;
}
break;
}
if (chunk) {
- set_color(str + i, str + i + chunk, chunk_style);
+ SET_COLOR(str, i, i + chunk, chunk_style);
i += chunk;
} else {
- set_color1(str + i, base_style);
+ SET_COLOR1(str, i, base_style);
i++;
}
}
Index: perl.c
===================================================================
RCS file: /sources/qemacs/qemacs/perl.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- perl.c 1 Mar 2014 19:05:30 -0000 1.13
+++ perl.c 10 Mar 2014 22:11:24 -0000 1.14
@@ -113,21 +113,21 @@
i++;
colstate &= ~(IN_STRING1|IN_STRING2);
}
- set_color(str + j, str + i, PERL_STRING);
+ SET_COLOR(str, j, i, PERL_STRING);
} else
if (colstate & IN_FORMAT) {
i = n;
if (n == 1 && str[0] == '.')
colstate &= ~IN_FORMAT;
- set_color(str + j, str + i, PERL_STRING);
+ SET_COLOR(str, j, i, PERL_STRING);
}
if (colstate & IN_HEREDOC) {
i = n;
if (n == perl_eos_len && !umemcmp(perl_eos, str, n)) {
colstate &= ~IN_HEREDOC;
- set_color(str + j, str + i, PERL_KEYWORD);
+ SET_COLOR(str, j, i, PERL_KEYWORD);
} else {
- set_color(str + j, str + i, PERL_STRING);
+ SET_COLOR(str, j, i, PERL_STRING);
}
}
if (str[i] == '=' && qe_isalpha(str[i + 1])) {
@@ -139,10 +139,10 @@
}
if (str[i] == '=' && qe_isalpha(str[i + 1])) {
i = n;
- set_color(str + j, str + i, PERL_KEYWORD);
+ SET_COLOR(str, j, i, PERL_KEYWORD);
} else {
i = n;
- set_color(str + j, str + i, PERL_COMMENT);
+ SET_COLOR(str, j, i, PERL_COMMENT);
}
}
@@ -172,7 +172,7 @@
break;
s1 = perl_var(str, j, n);
if (s1 > j) {
- set_color(str + i, str + s1, PERL_VAR);
+ SET_COLOR(str, i, s1, PERL_VAR);
i = s1;
continue;
}
@@ -188,7 +188,7 @@
}
break;
case '#':
- set_color(str + i, str + n, PERL_COMMENT);
+ SET_COLOR(str, i, n, PERL_COMMENT);
i = n;
continue;
case '<':
@@ -221,12 +221,12 @@
s1 = perl_string(str, c, j, n);
if (s1 >= n)
break;
- set_color1(str + i, PERL_DELIM);
- set_color(str + i + 1, str + s1, PERL_REGEX);
+ SET_COLOR1(str, i, PERL_DELIM);
+ SET_COLOR(str, i + 1, s1, PERL_REGEX);
i = s1;
while (++i < n && qe_isalpha(str[i]))
continue;
- set_color(str + s1, str + i, PERL_DELIM);
+ SET_COLOR(str, s1, i, PERL_DELIM);
continue;
case '\'':
case '`':
@@ -237,13 +237,13 @@
s1 = perl_string(str, delim, j, n);
if (s1 >= n) {
if (c == '\'') {
- set_color(str + i, str + n, PERL_STRING);
+ SET_COLOR(str, i, n, PERL_STRING);
i = n;
colstate |= IN_STRING1;
continue;
}
if (c == '\"') {
- set_color(str + i, str + n, PERL_STRING);
+ SET_COLOR(str, i, n, PERL_STRING);
i = n;
colstate |= IN_STRING2;
continue;
@@ -254,7 +254,7 @@
break;
}
s1++;
- set_color(str + i, str + s1, PERL_STRING);
+ SET_COLOR(str, i, s1, PERL_STRING);
i = s1;
continue;
case '.':
@@ -266,7 +266,7 @@
if (qe_isdigit(c)) {
number:
j = perl_number(str, i, n);
- set_color(str + i, str + j, PERL_NUMBER);
+ SET_COLOR(str, i, j, PERL_NUMBER);
i = j;
continue;
}
@@ -286,12 +286,12 @@
s1 = perl_string(str, str[j], j + 1, n);
if (s1 >= n)
goto keyword;
- set_color(str + i, str + j + 1, PERL_DELIM);
- set_color(str + j + 1, str + s1, PERL_REGEX);
+ SET_COLOR(str, i, j + 1, PERL_DELIM);
+ SET_COLOR(str, j + 1, s1, PERL_REGEX);
i = s1;
while (++i < n && qe_isalpha(str[i]))
continue;
- set_color(str + s1, str + i, PERL_DELIM);
+ SET_COLOR(str, s1, i, PERL_DELIM);
continue;
}
/* Should check for context */
@@ -303,14 +303,14 @@
s2 = perl_string(str, str[j], s1 + 1, n);
if (s2 >= n)
goto keyword;
- set_color(str + i, str + j + 1, PERL_DELIM);
- set_color(str + j + 1, str + s1, PERL_REGEX);
- set_color1(str + s1, PERL_DELIM);
- set_color(str + s1 + 1, str + s2, PERL_REGEX);
+ SET_COLOR(str, i, j + 1, PERL_DELIM);
+ SET_COLOR(str, j + 1, s1, PERL_REGEX);
+ SET_COLOR1(str, s1, PERL_DELIM);
+ SET_COLOR(str, s1 + 1, s2, PERL_REGEX);
i = s2;
while (++i < n && qe_isalpha(str[i]))
continue;
- set_color(str + s2, str + i, PERL_DELIM);
+ SET_COLOR(str, s2, i, PERL_DELIM);
continue;
}
keyword:
@@ -324,7 +324,7 @@
colstate |= IN_FORMAT;
}
}
- set_color(str + i, str + j, PERL_KEYWORD);
+ SET_COLOR(str, i, j, PERL_KEYWORD);
i = j;
continue;
}
Index: script.c
===================================================================
RCS file: /sources/qemacs/qemacs/script.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- script.c 2 Mar 2014 10:45:11 -0000 1.5
+++ script.c 10 Mar 2014 22:11:24 -0000 1.6
@@ -20,7 +20,7 @@
#include "qe.h"
-/*---------------- Perl colors ----------------*/
+/*---------------- Shell script colors ----------------*/
enum {
SCRIPT_TEXT = QE_STYLE_DEFAULT,
@@ -57,7 +57,7 @@
style = SCRIPT_COMMENT;
if (str[i + 1] == '!')
style = SCRIPT_PREPROCESS;
- set_color(str + i, str + n, style);
+ SET_COLOR(str, i, n, style);
i = n;
continue;
case '`':
@@ -74,7 +74,7 @@
break;
}
}
- set_color(str + i, str + j, style);
+ SET_COLOR(str, i, j, style);
i = j;
continue;
case ' ':
@@ -87,7 +87,7 @@
j++;
if (str[j] == '=')
style = SCRIPT_VARIABLE;
- set_color(str + i, str + j, style);
+ SET_COLOR(str, i, j, style);
style = SCRIPT_TEXT;
i = j;
continue;
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -b -r1.148 -r1.149
--- qe.h 10 Mar 2014 01:59:06 -0000 1.148
+++ qe.h 10 Mar 2014 22:11:24 -0000 1.149
@@ -1554,12 +1554,16 @@
return display_char_bidir(s, offset1, offset2, 0, ch);
}
-static inline void set_color(unsigned int *p, const unsigned int *to, int
style) {
+#define SET_COLOR(str,a,b,style) set_color((str) + (a), (str) + (b), style)
+
+static inline void set_color(unsigned int *p, unsigned int *to, int style) {
style <<= STYLE_SHIFT;
while (p < to)
*p++ |= style;
}
+#define SET_COLOR1(str,a,style) set_color1((str) + (a), style)
+
static inline void set_color1(unsigned int *p, int style) {
*p |= style << STYLE_SHIFT;
}
Index: orgmode.c
===================================================================
RCS file: /sources/qemacs/qemacs/orgmode.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- orgmode.c 6 Feb 2014 00:22:18 -0000 1.13
+++ orgmode.c 10 Mar 2014 22:11:24 -0000 1.14
@@ -114,13 +114,13 @@
if (str[j] == ' ') {
base_style = OrgBulletStyles[(j - i - 1) % BULLET_STYLES];
- set_color(str + i, str + j + 1, base_style);
+ SET_COLOR(str, i, j + 1, base_style);
i = j + 1;
kw = org_todo_keyword(str + i);
if (kw > -1) {
j = i + strlen(OrgTodoKeywords[kw].keyword) + 1;
- set_color(str + i, str + j, OrgTodoKeywords[kw].style);
+ SET_COLOR(str, i, j, OrgTodoKeywords[kw].style);
i = j;
}
}
@@ -130,7 +130,7 @@
if (str[i] == '#') {
if (str[i + 1] == ' ') { /* [ \t]*[#][ ] -> comment */
- set_color(str + i, str + n, QE_STYLE_COMMENT);
+ SET_COLOR(str, i, n, QE_STYLE_COMMENT);
i = n;
} else
if (str[i + 1] == '+') { /* [ \t]*[#][+] -> metadata */
@@ -145,18 +145,18 @@
colstate |= IN_LISP;
}
}
- set_color(str + i, str + n, QE_STYLE_PREPROCESS);
+ SET_COLOR(str, i, n, QE_STYLE_PREPROCESS);
i = n;
}
} else
if (str[i] == ':') {
if (str[i + 1] == ' ') {
/* code snipplet, should use code colorizer */
- set_color(str + i, str + n, QE_STYLE_FUNCTION);
+ SET_COLOR(str, i, n, QE_STYLE_FUNCTION);
i = n;
} else {
/* property */
- set_color(str + i, str + n, QE_STYLE_KEYWORD);
+ SET_COLOR(str, i, n, QE_STYLE_KEYWORD);
i = n;
}
} else
@@ -214,7 +214,7 @@
break;
case '\\': /* TeX syntax: \keyword \- \[ \] \( \) */
if (str[i + 1] == '\\') { /* \\ escape */
- set_color(str + i, str + i + 2, base_style);
+ SET_COLOR(str, i, i + 2, base_style);
i += 2;
continue;
}
@@ -259,10 +259,10 @@
has_space = (str[i] == ' ');
}
if (chunk) {
- set_color(str + i, str + i + chunk, QE_STYLE_STRING);
+ SET_COLOR(str, i, i + chunk, QE_STYLE_STRING);
i += chunk;
} else {
- set_color1(str + i, base_style);
+ SET_COLOR1(str, i, base_style);
i++;
}
}
Index: makemode.c
===================================================================
RCS file: /sources/qemacs/qemacs/makemode.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- makemode.c 2 Mar 2014 10:45:10 -0000 1.11
+++ makemode.c 10 Mar 2014 22:11:24 -0000 1.12
@@ -73,7 +73,7 @@
}
}
if (i < j)
- set_color(str + i, str + j, MAKEFILE_MACRO);
+ SET_COLOR(str, i, j, MAKEFILE_MACRO);
i = j;
continue;
case ' ':
@@ -89,18 +89,18 @@
break;
if (str[i+1] == '=')
goto variable;
- set_color(str + j, str + i, MAKEFILE_TARGET);
+ SET_COLOR(str, j, i, MAKEFILE_TARGET);
break;
case '=':
if (j)
break;
variable:
- set_color(str + j, str + i, MAKEFILE_VARIABLE);
+ SET_COLOR(str, j, i, MAKEFILE_VARIABLE);
break;
case '#':
if (i > 0 && str[i - 1] == '\\')
break;
- set_color(str + i, str + n, MAKEFILE_COMMENT);
+ SET_COLOR(str, i, n, MAKEFILE_COMMENT);
i = n;
continue;
case '!':
@@ -113,7 +113,7 @@
if (str[j] == '#')
break;
}
- set_color(str + i, str + j, MAKEFILE_PREPROCESS);
+ SET_COLOR(str, i, j, MAKEFILE_PREPROCESS);
i = j;
continue;
case '\'':
@@ -126,7 +126,7 @@
break;
}
}
- set_color(str + i, str + j, MAKEFILE_STRING);
+ SET_COLOR(str, i, j, MAKEFILE_STRING);
i = j;
continue;
default:
Index: extra-modes.c
===================================================================
RCS file: /sources/qemacs/qemacs/extra-modes.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- extra-modes.c 10 Mar 2014 22:07:35 -0000 1.6
+++ extra-modes.c 10 Mar 2014 22:11:24 -0000 1.7
@@ -20,8 +20,6 @@
#include "qe.h"
-#define SET_COLOR(str,a,b,style) set_color((str) + (a), (str) + (b), style)
-
#define MAX_KEYWORD_SIZE 16
static int is_lc_keyword(unsigned int *str, int from, int to, const char *list)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs lisp.c markdown.c perl.c script.c qe.h o...,
Charlie Gordon <=