comparison src/syntax.c @ 12068:e1b34958f118 v8.0.0914

patch 8.0.0914: highlight attributes are always combined commit https://github.com/vim/vim/commit/0cd2a94a4030f6bd12eaec44db92db108e33c913 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 12 15:12:30 2017 +0200 patch 8.0.0914: highlight attributes are always combined Problem: Highlight attributes are always combined. Solution: Add the 'nocombine' value to replace attributes instead of combining them. (scauligi, closes #1963)
author Christian Brabandt <cb@256bit.org>
date Sat, 12 Aug 2017 15:15:04 +0200
parents 35d7459251fd
children 504df4aa84c6
comparison
equal deleted inserted replaced
12067:8b7edea4be26 12068:e1b34958f118
84 * The "term", "cterm" and "gui" arguments can be any combination of the 84 * The "term", "cterm" and "gui" arguments can be any combination of the
85 * following names, separated by commas (but no spaces!). 85 * following names, separated by commas (but no spaces!).
86 */ 86 */
87 static char *(hl_name_table[]) = 87 static char *(hl_name_table[]) =
88 {"bold", "standout", "underline", "undercurl", 88 {"bold", "standout", "underline", "undercurl",
89 "italic", "reverse", "inverse", "NONE"}; 89 "italic", "reverse", "inverse", "nocombine", "NONE"};
90 static int hl_attr_table[] = 90 static int hl_attr_table[] =
91 {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, 0}; 91 {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, 0};
92 #define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? attr_b : (attr_a)) | (attr_b))
92 93
93 static int get_attr_entry(garray_T *table, attrentry_T *aep); 94 static int get_attr_entry(garray_T *table, attrentry_T *aep);
94 static void syn_unadd_group(void); 95 static void syn_unadd_group(void);
95 static void set_hl_attr(int idx); 96 static void set_hl_attr(int idx);
96 static void highlight_list_one(int id); 97 static void highlight_list_one(int id);
8910 attrentry_T new_en; 8911 attrentry_T new_en;
8911 8912
8912 if (char_attr == 0) 8913 if (char_attr == 0)
8913 return prim_attr; 8914 return prim_attr;
8914 if (char_attr <= HL_ALL && prim_attr <= HL_ALL) 8915 if (char_attr <= HL_ALL && prim_attr <= HL_ALL)
8915 return char_attr | prim_attr; 8916 return ATTR_COMBINE(char_attr, prim_attr);
8916 #ifdef FEAT_GUI 8917 #ifdef FEAT_GUI
8917 if (gui.in_use) 8918 if (gui.in_use)
8918 { 8919 {
8919 if (char_attr > HL_ALL) 8920 if (char_attr > HL_ALL)
8920 char_aep = syn_gui_attr2entry(char_attr); 8921 char_aep = syn_gui_attr2entry(char_attr);
8929 if (char_attr <= HL_ALL) 8930 if (char_attr <= HL_ALL)
8930 new_en.ae_attr = char_attr; 8931 new_en.ae_attr = char_attr;
8931 } 8932 }
8932 8933
8933 if (prim_attr <= HL_ALL) 8934 if (prim_attr <= HL_ALL)
8934 new_en.ae_attr |= prim_attr; 8935 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr);
8935 else 8936 else
8936 { 8937 {
8937 spell_aep = syn_gui_attr2entry(prim_attr); 8938 spell_aep = syn_gui_attr2entry(prim_attr);
8938 if (spell_aep != NULL) 8939 if (spell_aep != NULL)
8939 { 8940 {
8940 new_en.ae_attr |= spell_aep->ae_attr; 8941 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr,
8942 spell_aep->ae_attr);
8941 if (spell_aep->ae_u.gui.fg_color != INVALCOLOR) 8943 if (spell_aep->ae_u.gui.fg_color != INVALCOLOR)
8942 new_en.ae_u.gui.fg_color = spell_aep->ae_u.gui.fg_color; 8944 new_en.ae_u.gui.fg_color = spell_aep->ae_u.gui.fg_color;
8943 if (spell_aep->ae_u.gui.bg_color != INVALCOLOR) 8945 if (spell_aep->ae_u.gui.bg_color != INVALCOLOR)
8944 new_en.ae_u.gui.bg_color = spell_aep->ae_u.gui.bg_color; 8946 new_en.ae_u.gui.bg_color = spell_aep->ae_u.gui.bg_color;
8945 if (spell_aep->ae_u.gui.sp_color != INVALCOLOR) 8947 if (spell_aep->ae_u.gui.sp_color != INVALCOLOR)
8972 if (char_attr <= HL_ALL) 8974 if (char_attr <= HL_ALL)
8973 new_en.ae_attr = char_attr; 8975 new_en.ae_attr = char_attr;
8974 } 8976 }
8975 8977
8976 if (prim_attr <= HL_ALL) 8978 if (prim_attr <= HL_ALL)
8977 new_en.ae_attr |= prim_attr; 8979 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr);
8978 else 8980 else
8979 { 8981 {
8980 spell_aep = syn_cterm_attr2entry(prim_attr); 8982 spell_aep = syn_cterm_attr2entry(prim_attr);
8981 if (spell_aep != NULL) 8983 if (spell_aep != NULL)
8982 { 8984 {
8983 new_en.ae_attr |= spell_aep->ae_attr; 8985 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr,
8986 spell_aep->ae_attr);
8984 if (spell_aep->ae_u.cterm.fg_color > 0) 8987 if (spell_aep->ae_u.cterm.fg_color > 0)
8985 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color; 8988 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color;
8986 if (spell_aep->ae_u.cterm.bg_color > 0) 8989 if (spell_aep->ae_u.cterm.bg_color > 0)
8987 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; 8990 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color;
8988 #ifdef FEAT_TERMGUICOLORS 8991 #ifdef FEAT_TERMGUICOLORS
9006 if (char_attr <= HL_ALL) 9009 if (char_attr <= HL_ALL)
9007 new_en.ae_attr = char_attr; 9010 new_en.ae_attr = char_attr;
9008 } 9011 }
9009 9012
9010 if (prim_attr <= HL_ALL) 9013 if (prim_attr <= HL_ALL)
9011 new_en.ae_attr |= prim_attr; 9014 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr);
9012 else 9015 else
9013 { 9016 {
9014 spell_aep = syn_term_attr2entry(prim_attr); 9017 spell_aep = syn_term_attr2entry(prim_attr);
9015 if (spell_aep != NULL) 9018 if (spell_aep != NULL)
9016 { 9019 {
9017 new_en.ae_attr |= spell_aep->ae_attr; 9020 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, spell_aep->ae_attr);
9018 if (spell_aep->ae_u.term.start != NULL) 9021 if (spell_aep->ae_u.term.start != NULL)
9019 { 9022 {
9020 new_en.ae_u.term.start = spell_aep->ae_u.term.start; 9023 new_en.ae_u.term.start = spell_aep->ae_u.term.start;
9021 new_en.ae_u.term.stop = spell_aep->ae_u.term.stop; 9024 new_en.ae_u.term.stop = spell_aep->ae_u.term.stop;
9022 } 9025 }