aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKerem Cakirer <keremc@users.noreply.github.com>2016-09-10 13:17:06 +0300
committerJustin M. Keyes <justinkz@gmail.com>2016-09-16 00:45:57 +0200
commit0c536b5d8afee9f8d06e1d0dc875af61f7d04707 (patch)
tree734736661a8c78cd88eb506286ec43e7fd7a1df9 /src
parentc4199d1866f4159fc14aff85d5e896d240c5ca3d (diff)
downloadrneovim-0c536b5d8afee9f8d06e1d0dc875af61f7d04707.tar.gz
rneovim-0c536b5d8afee9f8d06e1d0dc875af61f7d04707.tar.bz2
rneovim-0c536b5d8afee9f8d06e1d0dc875af61f7d04707.zip
syntax.c: Support bg/fg special color-names. #5319
Refresh colors if changing Normal group
Diffstat (limited to 'src')
-rw-r--r--src/nvim/syntax.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index bec2b5c5b0..c753c6fabd 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -6597,6 +6597,9 @@ do_highlight (
else {
if (is_normal_group) {
HL_TABLE()[idx].sg_attr = 0;
+ // Need to update all groups, because they might be using "bg" and/or
+ // "fg", which have been changed now.
+ highlight_attr_set_all();
// If the normal group has changed, it is simpler to refresh every UI
ui_refresh();
} else
@@ -7261,6 +7264,23 @@ int syn_get_final_id(int hl_id)
return hl_id;
}
+/// Refresh the color attributes of all highlight groups.
+static void highlight_attr_set_all(void)
+{
+ for (int idx = 0; idx < highlight_ga.ga_len; idx++) {
+ struct hl_group *sgp = &HL_TABLE()[idx];
+ if (sgp->sg_rgb_bg_name != NULL) {
+ sgp->sg_rgb_bg = name_to_color(sgp->sg_rgb_bg_name);
+ }
+ if (sgp->sg_rgb_fg_name != NULL) {
+ sgp->sg_rgb_fg = name_to_color(sgp->sg_rgb_fg_name);
+ }
+ if (sgp->sg_rgb_sp_name != NULL) {
+ sgp->sg_rgb_sp = name_to_color(sgp->sg_rgb_sp_name);
+ }
+ set_hl_attr(idx);
+ }
+}
/*
* Translate the 'highlight' option into attributes in highlight_attr[] and
@@ -7702,6 +7722,10 @@ RgbValue name_to_color(uint8_t *name)
&& isxdigit(name[6]) && name[7] == NUL) {
// rgb hex string
return strtol((char *)(name + 1), NULL, 16);
+ } else if (!STRICMP(name, "bg") || !STRICMP(name, "background")) {
+ return normal_bg;
+ } else if (!STRICMP(name, "fg") || !STRICMP(name, "foreground")) {
+ return normal_fg;
}
for (int i = 0; color_name_table[i].name != NULL; i++) {