qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs TODO.org parser.c qe.h qestyles.h util.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs TODO.org parser.c qe.h qestyles.h util.c
Date: Thu, 8 Oct 2020 20:00:55 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        20/10/08 20:00:55

Modified files:
        .              : TODO.org parser.c qe.h qestyles.h util.c 

Log message:
        style and color fixes:
        
        - document default styles
        - skip_blanks() returns the next character
        - simplify minimal parser
        - handle multiline comments in config files

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/TODO.org?cvsroot=qemacs&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/qemacs/parser.c?cvsroot=qemacs&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.275&r2=1.276
http://cvs.savannah.gnu.org/viewcvs/qemacs/qestyles.h?cvsroot=qemacs&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.86&r2=1.87

Patches:
Index: TODO.org
===================================================================
RCS file: /sources/qemacs/qemacs/TODO.org,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- TODO.org    2 Oct 2020 20:09:18 -0000       1.45
+++ TODO.org    9 Oct 2020 00:00:55 -0000       1.46
@@ -5,6 +5,10 @@
 
 * Recent bugs and ideas
 
+** style: add color themes
+** style: add style recent changes (highlight-recent-changes)
+** style: add style for trailing blanks
+** basic: use minor mode keymap to exit preview mode with KEY_RET
 ** basic: update default settings to indent_tabs_mode = 0, indent_width = 4, 
my-colors
 ** basic: add property lists in buffer and window for default directory and 
similar properties (override)
 ** basic: backspace delete hacking tabs

Index: parser.c
===================================================================
RCS file: /sources/qemacs/qemacs/parser.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- parser.c    19 Dec 2018 11:45:39 -0000      1.9
+++ parser.c    9 Oct 2020 00:00:55 -0000       1.10
@@ -30,10 +30,8 @@
 
 static int expect_token(const char **pp, int tok)
 {
-    skip_spaces(pp);
-    if (**pp == tok) {
+    if (skip_spaces(pp) == tok) {
         ++*pp;
-        skip_spaces(pp);
         return 1;
     } else {
         put_status(NULL, "'%c' expected", tok);
@@ -129,12 +127,12 @@
     const char *p, *r;
     int line_num;
     CmdDef *d;
-    int nb_args, sep, i, skip;
+    int nb_args, sep, i, skip, incomment;
     CmdArg args[MAX_CMD_ARGS];
     unsigned char args_type[MAX_CMD_ARGS];
 
     ec = qs->ec;
-    skip = 0;
+    incomment = skip = 0;
     line_num = ds->line_num;
     /* Should parse whole config file in a single read, or load it via
      * a buffer */
@@ -146,9 +144,31 @@
         qs->ec.function = NULL;
         qs->ec.lineno = line_num;
 
-        /* XXX: line based parser does not handle multiline comments */
         p = line;
-        skip_spaces(&p);
+    again:
+        if (incomment)
+            goto comment;
+        if (skip_spaces(&p) == '\0')
+            continue;
+        if (*p == '/') {
+            if (p[1] == '/')  /* line comment */
+                continue;
+            if (p[1] == '*') { /* multiline comment */
+                p += 2;
+                incomment = 1;
+            comment:
+                while (*p) {
+                    if (*p++ == '*' && *p == '/') {
+                        p++;
+                        incomment = 0;
+                        break;
+                    }
+                }
+                if (incomment)
+                    continue;
+                goto again;
+            }
+        }
         if (p[0] == '}') {
             /* simplistic 1 level if block skip feature */
             p++;
@@ -158,22 +178,10 @@
         if (skip)
             continue;
 
-        /* skip comments */
-        while (p[0] == '/' && p[1] == '*') {
-            for (p += 2; *p; p++) {
-                if (p[0] == '*' && p[1] == '/') {
-                    p += 2;
-                    break;
-                }
-            }
-            skip_spaces(&p);
-            /* XXX: unfinished comments silently unsupported */
-        }
-        if (p[0] == '/' && p[1] == '/')
-            continue;
         if (p[0] == '\0')
             continue;
 
+        /* XXX: should parse numbers, strings and symbols */
         get_str(&p, cmd, sizeof(cmd), "{}();=/");
         if (*cmd == '\0') {
             put_status(s, "Syntax error");
@@ -280,7 +288,6 @@
                 continue;
             }
 
-            skip_spaces(&p);
             if (sep) {
                 /* CG: Should test for arg list too short. */
                 /* CG: Could supply default arguments. */
@@ -288,6 +295,7 @@
                     goto fail;
             }
             sep = ',';
+            skip_spaces(&p);
 
             switch (args_type[i]) {
             case CMD_ARG_INT:
@@ -314,8 +322,7 @@
                 break;
             }
         }
-        skip_spaces(&p);
-        if (*p != ')') {
+        if (skip_spaces(&p) != ')') {
             put_status(s, "Too many arguments for %s", d->name);
             goto fail;
         }

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.275
retrieving revision 1.276
diff -u -b -r1.275 -r1.276
--- qe.h        4 Oct 2020 23:57:11 -0000       1.275
+++ qe.h        9 Oct 2020 00:00:55 -0000       1.276
@@ -455,7 +455,7 @@
 int qe_strcollate(const char *s1, const char *s2);
 int qe_strtobool(const char *s, int def);
 void qe_strtolower(char *buf, int buf_size, const char *str);
-void skip_spaces(const char **pp);
+int skip_spaces(const char **pp);
 
 static inline int strequal(const char *s1, const char *s2) {
     return !strcmp(s1, s2);

Index: qestyles.h
===================================================================
RCS file: /sources/qemacs/qemacs/qestyles.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- qestyles.h  10 May 2017 15:46:17 -0000      1.13
+++ qestyles.h  9 Oct 2020 00:00:55 -0000       1.14
@@ -1,97 +1,69 @@
     /* root style, must be complete */
-    STYLE_DEF(QE_STYLE_DEFAULT, "default",
-              QERGB(0xf8, 0xd8, 0xb0), QERGB(0x00, 0x00, 0x00),
-              QE_FONT_FAMILY_FIXED, 12)
+    STYLE_DEF(QE_STYLE_DEFAULT, "default", /* #f8d8b0 on black */
+              QERGB(0xf8, 0xd8, 0xb0), QERGB(0x00, 0x00, 0x00), 
QE_FONT_FAMILY_FIXED, 12)
 
     /* system styles */
-    STYLE_DEF(QE_STYLE_MODE_LINE, "mode-line",
-              QERGB(0x00, 0x00, 0x00), QERGB(0xe0, 0xe0, 0xe0),
-              0, 0)
-    STYLE_DEF(QE_STYLE_WINDOW_BORDER, "window-border",
-              QERGB(0x00, 0x00, 0x00), QERGB(0xe0, 0xe0, 0xe0),
-              0, 0)
-    STYLE_DEF(QE_STYLE_MINIBUF, "minibuf",
-              QERGB(0xff, 0xff, 0x00), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_STATUS, "status",
-              QERGB(0xff, 0xff, 0x00), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_GUTTER, "gutter",
-              QERGB(0xf8, 0x44, 0x00), QERGB(0x3f, 0x3f, 0x3f),
-              0, 0)
+    STYLE_DEF(QE_STYLE_MODE_LINE, "mode-line", /* black on grey88 */
+              QERGB(0x00, 0x00, 0x00), QERGB(0xe0, 0xe0, 0xe0), 0, 0)
+    STYLE_DEF(QE_STYLE_WINDOW_BORDER, "window-border", /* black on grey88 */
+              QERGB(0x00, 0x00, 0x00), QERGB(0xe0, 0xe0, 0xe0), 0, 0)
+    STYLE_DEF(QE_STYLE_MINIBUF, "minibuf", /* yellow */
+              QERGB(0xff, 0xff, 0x00), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_STATUS, "status", /* yellow */
+              QERGB(0xff, 0xff, 0x00), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_GUTTER, "gutter", /* #f84400 on grey25 */
+              QERGB(0xf8, 0x44, 0x00), QERGB(0x3f, 0x3f, 0x3f), 0, 0)
 
     /* default style for HTML/CSS2 pages */
-    STYLE_DEF(QE_STYLE_CSS_DEFAULT, "css-default",
-              QERGB(0x00, 0x00, 0x00), QERGB(0xbb, 0xbb, 0xbb),
-              QE_FONT_FAMILY_SERIF, 12)
+    STYLE_DEF(QE_STYLE_CSS_DEFAULT, "css-default", /* black on grey74 */
+              QERGB(0x00, 0x00, 0x00), QERGB(0xbb, 0xbb, 0xbb), 
QE_FONT_FAMILY_SERIF, 12)
 
     /* coloring styles */
-    STYLE_DEF(QE_STYLE_HIGHLIGHT, "highlight",
-              QERGB(0x00, 0x00, 0x00), QERGB(0xf8, 0xd8, 0xb0),
-              0, 0)
-    STYLE_DEF(QE_STYLE_SELECTION, "selection",
-              QERGB(0xff, 0xff, 0xff), QERGB(0x00, 0x00, 0xff),
-              0, 0)
+    STYLE_DEF(QE_STYLE_HIGHLIGHT, "highlight", /* black on #f8d8b0 */
+              QERGB(0x00, 0x00, 0x00), QERGB(0xf8, 0xd8, 0xb0), 0, 0)
+    STYLE_DEF(QE_STYLE_SELECTION, "selection", /* white on blue */
+              QERGB(0xff, 0xff, 0xff), QERGB(0x00, 0x00, 0xff), 0, 0)
 
     /* Generic syntax coloring styles */
-    STYLE_DEF(QE_STYLE_COMMENT, "comment",
-              QERGB(0xf8, 0x44, 0x00), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_PREPROCESS, "preprocess",
-              QERGB(0x00, 0xff, 0xff), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_STRING, "string",
-              QERGB(0xf8, 0xa0, 0x78), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_STRING_Q, "string-q",
-              QERGB(0xf8, 0xa0, 0x78), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_KEYWORD, "keyword",
-              QERGB(0x00, 0xff, 0xff), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_NUMBER, "number",
-              QERGB(0xf8, 0xd8, 0xb0), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_FUNCTION, "function",
-              QERGB(0x80, 0xcc, 0xf0), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_VARIABLE, "variable",
-              QERGB(0xe8, 0xdc, 0x80), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_TYPE, "type",
-              QERGB(0x98, 0xf8, 0x98), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_TAG, "tag",
-              QERGB(0x00, 0xff, 0xff), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_CSS, "css",
-              QERGB(0x98, 0xf8, 0x98), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_ERROR, "error",
-              QERGB(0xff, 0x00, 0x00), COLOR_TRANSPARENT,
-              0, 0)
+    STYLE_DEF(QE_STYLE_COMMENT, "comment", /* #f84400 */
+              QERGB(0xf8, 0x44, 0x00), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_PREPROCESS, "preprocess", /* cyan */
+              QERGB(0x00, 0xff, 0xff), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_STRING, "string", /* #f8a078 */
+              QERGB(0xf8, 0xa0, 0x78), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_STRING_Q, "string-q", /* #f8a078 */
+              QERGB(0xf8, 0xa0, 0x78), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_KEYWORD, "keyword", /* cyan */
+              QERGB(0x00, 0xff, 0xff), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_NUMBER, "number", /* #f8d8b0 */
+              QERGB(0xf8, 0xd8, 0xb0), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_FUNCTION, "function", /* #80ccf0 */
+              QERGB(0x80, 0xcc, 0xf0), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_VARIABLE, "variable", /* #e8dc80 */
+              QERGB(0xe8, 0xdc, 0x80), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_TYPE, "type", /* #98f898 */
+              QERGB(0x98, 0xf8, 0x98), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_TAG, "tag", /* cyan */
+              QERGB(0x00, 0xff, 0xff), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_CSS, "css", /* #98f898 */
+              QERGB(0x98, 0xf8, 0x98), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_ERROR, "error", /* red */
+              QERGB(0xff, 0x00, 0x00), COLOR_TRANSPARENT, 0, 0)
 
     /* popup / region styles */
-    STYLE_DEF(QE_STYLE_REGION_HILITE, "region-hilite",
-              QERGB(0x00, 0x00, 0x00), QERGB(0x80, 0xf0, 0xf0),
-              0, 0)
-    STYLE_DEF(QE_STYLE_SEARCH_HILITE, "search-hilite",
-              QERGB(0x00, 0x00, 0x00), QERGB(0x00, 0x80, 0x80),
-              0, 0)
-    STYLE_DEF(QE_STYLE_SEARCH_MATCH, "search-match",
-              QERGB(0xe0, 0xe0, 0xe0), QERGB(0xf0, 0x00, 0xf0),
-              0, 0)
+    STYLE_DEF(QE_STYLE_REGION_HILITE, "region-hilite", /* black on #80f0f0 */
+              QERGB(0x00, 0x00, 0x00), QERGB(0x80, 0xf0, 0xf0), 0, 0)
+    STYLE_DEF(QE_STYLE_SEARCH_HILITE, "search-hilite", /* black on teal */
+              QERGB(0x00, 0x00, 0x00), QERGB(0x00, 0x80, 0x80), 0, 0)
+    STYLE_DEF(QE_STYLE_SEARCH_MATCH, "search-match", /* grey88 on #f000f0 */
+              QERGB(0xe0, 0xe0, 0xe0), QERGB(0xf0, 0x00, 0xf0), 0, 0)
 
     /* HTML coloring styles */
-    STYLE_DEF(QE_STYLE_HTML_COMMENT, "html-comment",
-              QERGB(0xf8, 0x44, 0x00), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_HTML_STRING, "html-string",
-              QERGB(0xf8, 0xa0, 0x78), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_HTML_ENTITY, "html-entity",
-              QERGB(0xe8, 0xdc, 0x80), COLOR_TRANSPARENT,
-              0, 0)
-    STYLE_DEF(QE_STYLE_HTML_TAG, "html-tag",
-              QERGB(0x80, 0xcc, 0xf0), COLOR_TRANSPARENT,
-              0, 0)
+    STYLE_DEF(QE_STYLE_HTML_COMMENT, "html-comment", /* #f84400 */
+              QERGB(0xf8, 0x44, 0x00), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_HTML_STRING, "html-string", /* #f8a078 */
+              QERGB(0xf8, 0xa0, 0x78), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_HTML_ENTITY, "html-entity", /* #e8dc80 */
+              QERGB(0xe8, 0xdc, 0x80), COLOR_TRANSPARENT, 0, 0)
+    STYLE_DEF(QE_STYLE_HTML_TAG, "html-tag", /* #80ccf0 */
+              QERGB(0x80, 0xcc, 0xf0), COLOR_TRANSPARENT, 0, 0)

Index: util.c
===================================================================
RCS file: /sources/qemacs/qemacs/util.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- util.c      2 Oct 2020 20:06:02 -0000       1.86
+++ util.c      9 Oct 2020 00:00:55 -0000       1.87
@@ -493,14 +493,16 @@
     }
 }
 
-void skip_spaces(const char **pp)
+int skip_spaces(const char **pp)
 {
     const char *p;
+    int c;
 
     p = *pp;
-    while (qe_isspace(*p))
+    while (qe_isspace(c = *p))
         p++;
     *pp = p;
+    return c;
 }
 
 int memfind(const char *list, const char *s, int len)
@@ -1292,19 +1294,19 @@
 
 #if 0
 static QEColor const tty_full_colors[8] = {
-    QERGB(0x00, 0x00, 0x00),
-    QERGB(0xff, 0x00, 0x00),
-    QERGB(0x00, 0xff, 0x00),
-    QERGB(0xff, 0xff, 0x00),
-    QERGB(0x00, 0x00, 0xff),
-    QERGB(0xff, 0x00, 0xff),
-    QERGB(0x00, 0xff, 0xff),
-    QERGB(0xff, 0xff, 0xff),
+    QERGB(0x00, 0x00, 0x00),  /* black */
+    QERGB(0xff, 0x00, 0x00),  /* red */
+    QERGB(0x00, 0xff, 0x00),  /* lime */
+    QERGB(0xff, 0xff, 0x00),  /* yellow */
+    QERGB(0x00, 0x00, 0xff),  /* blue */
+    QERGB(0xff, 0x00, 0xff),  /* fuchsia */
+    QERGB(0x00, 0xff, 0xff),  /* aqua */
+    QERGB(0xff, 0xff, 0xff),  /* white */
 };
 #endif
 
 QEColor const xterm_colors[256] = {
-    QERGB(0x00, 0x00, 0x00),
+    QERGB(0x00, 0x00, 0x00), /*        black */
     QERGB(0xbb, 0x00, 0x00),
     QERGB(0x00, 0xbb, 0x00),
     QERGB(0xbb, 0xbb, 0x00),
@@ -1320,7 +1322,7 @@
     QERGB(0x55, 0x55, 0xff),
     QERGB(0xff, 0x55, 0xff),
     QERGB(0x55, 0xff, 0xff),
-    QERGB(0xff, 0xff, 0xff),
+    QERGB(0xff, 0xff, 0xff), /*        white */
 #if 1
     /* Extended color palette for xterm 256 color mode */
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]