diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2018-04-08 09:51:22 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2018-07-21 13:20:37 +0200 |
commit | 989b585e105b4f343f639abf5daf820de19d4a26 (patch) | |
tree | 6ec6611413f4d996a5294dc06f9942d92ae6e194 /src/nvim/syntax.c | |
parent | 696e24f311acbb0ccfa1818fb016f19f0497d950 (diff) | |
download | rneovim-989b585e105b4f343f639abf5daf820de19d4a26.tar.gz rneovim-989b585e105b4f343f639abf5daf820de19d4a26.tar.bz2 rneovim-989b585e105b4f343f639abf5daf820de19d4a26.zip |
highlight: refactor to use stateful representation
This allows us to keep track of the source higlight groups,
and not only the final combined highlights.
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 44cd3cdeac..ff9619574b 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7249,15 +7249,7 @@ static void set_hl_attr(int idx) at_en.rgb_bg_color = sgp->sg_rgb_bg_name ? sgp->sg_rgb_bg : -1; at_en.rgb_sp_color = sgp->sg_rgb_sp_name ? sgp->sg_rgb_sp : -1; - if (at_en.cterm_fg_color != 0 || at_en.cterm_bg_color != 0 - || at_en.rgb_fg_color != -1 || at_en.rgb_bg_color != -1 - || at_en.rgb_sp_color != -1 || at_en.cterm_ae_attr != 0 - || at_en.rgb_ae_attr != 0) { - sgp->sg_attr = get_attr_entry(&at_en); - } else { - // If all the fields are cleared, clear the attr field back to default value - sgp->sg_attr = 0; - } + sgp->sg_attr = hl_get_syn_attr(idx+1, at_en); } /// Lookup a highlight group name and return its ID. @@ -7392,7 +7384,7 @@ static void syn_unadd_group(void) /// Translate a group ID to highlight attributes. -/// @see syn_cterm_attr2entry +/// @see syn_attr2entry int syn_id2attr(int hl_id) { struct hl_group *sgp; @@ -7452,7 +7444,6 @@ void highlight_attr_set_all(void) /// screen redraw after any :highlight command. void highlight_changed(void) { - int attr; int id; char_u userhl[10]; int id_SNC = -1; @@ -7467,13 +7458,15 @@ void highlight_changed(void) if (id == 0) { abort(); } - attr = syn_id2attr(id); + int final_id = syn_get_final_id(id); if (hlf == (int)HLF_SNC) { - id_SNC = syn_get_final_id(id); + id_SNC = final_id; } else if (hlf == (int)HLF_S) { - id_S = syn_get_final_id(id); + id_S = final_id; } - highlight_attr[hlf] = attr; + + highlight_attr[hlf] = hl_get_ui_attr(hlf, final_id, + hlf == (int)HLF_INACTIVE); } /* Setup the user highlights |