style and color fixes:
- document default styles - skip_blanks() returns the next character - simplify minimal parser - handle multiline comments in config files
This commit is contained in:
parent
aecdcf067c
commit
49a1c1275b
5 changed files with 105 additions and 120 deletions
4
TODO.org
4
TODO.org
|
|
@ -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
|
||||
|
|
|
|||
53
parser.c
53
parser.c
|
|
@ -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 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
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 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
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 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
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 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
continue;
|
||||
}
|
||||
|
||||
skip_spaces(&p);
|
||||
if (sep) {
|
||||
/* CG: Should test for arg list too short. */
|
||||
/* CG: Could supply default arguments. */
|
||||
|
|
@ -288,6 +295,7 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
goto fail;
|
||||
}
|
||||
sep = ',';
|
||||
skip_spaces(&p);
|
||||
|
||||
switch (args_type[i]) {
|
||||
case CMD_ARG_INT:
|
||||
|
|
@ -314,8 +322,7 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
break;
|
||||
}
|
||||
}
|
||||
skip_spaces(&p);
|
||||
if (*p != ')') {
|
||||
if (skip_spaces(&p) != ')') {
|
||||
put_status(s, "Too many arguments for %s", d->name);
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
2
qe.h
2
qe.h
|
|
@ -455,7 +455,7 @@ int ustr_get_word(char *buf, int buf_size, int c,
|
|||
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);
|
||||
|
|
|
|||
140
qestyles.h
140
qestyles.h
|
|
@ -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)
|
||||
|
|
|
|||
26
util.c
26
util.c
|
|
@ -493,14 +493,16 @@ void qe_strtolower(char *buf, int size, const char *str)
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ static int nb_qe_colors = nb_default_colors;
|
|||
|
||||
#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 @@ QEColor const xterm_colors[256] = {
|
|||
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 */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue