From e310844ef398d81eb3a90791e01edfe633f61987 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Fri, 3 Jan 2020 16:24:45 -0800 Subject: [PATCH] Fixes rendering glitch for resuming normal foreground color --- config.h | 2 +- hermes.c | 6 +++--- syntaxhl.h | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.h b/config.h index 2e8cb06..d4fcda3 100644 --- a/config.h +++ b/config.h @@ -17,7 +17,7 @@ static const int use_alternate_screen = 1; // use as bool (0 or 1) * see: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit */ static const unsigned int EDITOR_BG_COLOR = 235; -static const unsigned int VISUAL_BG_COLOR = 69; +static const unsigned int VISUAL_BG_COLOR = 69; static const unsigned int HL_NUMBER_COLOR = 207; static const unsigned int HL_STRING_COLOR = 116; static const unsigned int HL_COMMENT_COLOR = 243; diff --git a/hermes.c b/hermes.c index 48310f4..8bdfa9e 100644 --- a/hermes.c +++ b/hermes.c @@ -735,12 +735,12 @@ void editorDrawRows(struct abuf *ab) { abAppend(ab, buf, clen); } } else if (hl[j] == HL_NORMAL) { + int color = editorSyntaxToColor(hl[j]); if (current_color != -1) { - int color = editorSyntaxToColor(hl[j]); + current_color = -1; char buf[16]; int clen = snprintf(buf, sizeof(buf), "\033[38;5;%dm", color); - abAppend(ab, "\033[39m", clen); - current_color = -1; + abAppend(ab, buf, clen); } editorDrawVisualBg(ab, 0, j, filerow, len); abAppend(ab, &c[j], 1); diff --git a/syntaxhl.h b/syntaxhl.h index eb0d913..1554483 100644 --- a/syntaxhl.h +++ b/syntaxhl.h @@ -69,7 +69,7 @@ char *SH_HL_keywords[] = { "export", "else", "while", "do|", "done|", "for", "until", "case", "esac", "break|", "continue|", "exit", "return", "trap|", "wait|", "eval|", "exec|", "ulimit|", "umask|", NULL -} +}; // HTML char *HTML_HL_keywords[] = { @@ -78,7 +78,7 @@ char *HTML_HL_keywords[] = { "form", "input", "class|", "id|", "href|", "img", "src|", "target|", "style|", "meta", "h1", "h2", "h3", "h4", "h5", "role|", "!DOCTYPE|", "script", "type|", "link", "rel|", NULL -} +}; // PHP char *PHP_HL_keywords[] = { @@ -91,14 +91,14 @@ char *PHP_HL_keywords[] = { "isset|", "list|", "namespace", "new|", "or|", "print|", "private|", "protected|", "public|", "require", "require_once", "return", "static|", "switch", "throw", "trait|", "try", "unset|", "use|", "var|", "while", "xor|", "yield", NULL -} +}; // Lua char *LUA_HL_keywords[] = { "function", "return", "for", "while", "do", "if", "else", "elseif", "and|", "or|", "false|", "true|", "nil|", "until", "then|", "repeat|", "local|", "not|", "in|", "break|", NULL -} +}; static struct editorSyntax HLDB[] = { // 3. Add an entry to the editorSyndax db (this var). @@ -136,19 +136,19 @@ static struct editorSyntax HLDB[] = { "shell", SH_HL_extensions, "#", - NULL, - NULL, + "", + "", SH_HL_keywords, HL_HIGHLIGHT_NUMBERS | HL_HIGHLIGHT_STRINGS }, { "html", HTML_HL_extensions, - NULL, + "", "", HTML_HL_keywords, - NULL + HL_HIGHLIGHT_NUMBERS }, { "php",