Mercurial > vim
comparison src/syntax.c @ 221:7fd4b5df33be
updated for version 7.0062
author | vimboss |
---|---|
date | Sun, 20 Mar 2005 22:37:15 +0000 |
parents | d292c40ca788 |
children | ef254e0f2365 |
comparison
equal
deleted
inserted
replaced
220:01e77186b20a | 221:7fd4b5df33be |
---|---|
202 #ifdef FEAT_EVAL | 202 #ifdef FEAT_EVAL |
203 static int current_id = 0; /* ID of current char for syn_get_id() */ | 203 static int current_id = 0; /* ID of current char for syn_get_id() */ |
204 static int current_trans_id = 0; /* idem, transparancy removed */ | 204 static int current_trans_id = 0; /* idem, transparancy removed */ |
205 #endif | 205 #endif |
206 | 206 |
207 struct syn_cluster | 207 typedef struct syn_cluster_S |
208 { | 208 { |
209 char_u *scl_name; /* syntax cluster name */ | 209 char_u *scl_name; /* syntax cluster name */ |
210 char_u *scl_name_u; /* uppercase of scl_name */ | 210 char_u *scl_name_u; /* uppercase of scl_name */ |
211 short *scl_list; /* IDs in this syntax cluster */ | 211 short *scl_list; /* IDs in this syntax cluster */ |
212 }; | 212 } syn_cluster_T; |
213 | 213 |
214 /* | 214 /* |
215 * Methods of combining two clusters | 215 * Methods of combining two clusters |
216 */ | 216 */ |
217 #define CLUSTER_REPLACE 1 /* replace first list with second */ | 217 #define CLUSTER_REPLACE 1 /* replace first list with second */ |
218 #define CLUSTER_ADD 2 /* add second list to first */ | 218 #define CLUSTER_ADD 2 /* add second list to first */ |
219 #define CLUSTER_SUBTRACT 3 /* subtract second list from first */ | 219 #define CLUSTER_SUBTRACT 3 /* subtract second list from first */ |
220 | 220 |
221 #define SYN_CLSTR(buf) ((struct syn_cluster *)((buf)->b_syn_clusters.ga_data)) | 221 #define SYN_CLSTR(buf) ((syn_cluster_T *)((buf)->b_syn_clusters.ga_data)) |
222 | 222 |
223 /* | 223 /* |
224 * Syntax group IDs have different types: | 224 * Syntax group IDs have different types: |
225 * 0 - 9999 normal syntax groups | 225 * 0 - 9999 normal syntax groups |
226 * 10000 - 14999 ALLBUT indicator (current_syn_inc_tag added) | 226 * 10000 - 14999 ALLBUT indicator (current_syn_inc_tag added) |
370 static void load_current_state __ARGS((synstate_T *from)); | 370 static void load_current_state __ARGS((synstate_T *from)); |
371 static void invalidate_current_state __ARGS((void)); | 371 static void invalidate_current_state __ARGS((void)); |
372 static int syn_stack_equal __ARGS((synstate_T *sp)); | 372 static int syn_stack_equal __ARGS((synstate_T *sp)); |
373 static void validate_current_state __ARGS((void)); | 373 static void validate_current_state __ARGS((void)); |
374 static int syn_finish_line __ARGS((int syncing)); | 374 static int syn_finish_line __ARGS((int syncing)); |
375 static int syn_current_attr __ARGS((int syncing, int displaying)); | 375 static int syn_current_attr __ARGS((int syncing, int displaying, int *can_spell)); |
376 static int did_match_already __ARGS((int idx, garray_T *gap)); | 376 static int did_match_already __ARGS((int idx, garray_T *gap)); |
377 static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si)); | 377 static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si)); |
378 static void check_state_ends __ARGS((void)); | 378 static void check_state_ends __ARGS((void)); |
379 static void update_si_attr __ARGS((int idx)); | 379 static void update_si_attr __ARGS((int idx)); |
380 static void check_keepend __ARGS((void)); | 380 static void check_keepend __ARGS((void)); |
1658 | 1658 |
1659 if (!current_finished) | 1659 if (!current_finished) |
1660 { | 1660 { |
1661 while (!current_finished) | 1661 while (!current_finished) |
1662 { | 1662 { |
1663 (void)syn_current_attr(syncing, FALSE); | 1663 (void)syn_current_attr(syncing, FALSE, NULL); |
1664 /* | 1664 /* |
1665 * When syncing, and found some item, need to check the item. | 1665 * When syncing, and found some item, need to check the item. |
1666 */ | 1666 */ |
1667 if (syncing && current_state.ga_len) | 1667 if (syncing && current_state.ga_len) |
1668 { | 1668 { |
1691 * Return highlight attributes for next character. | 1691 * Return highlight attributes for next character. |
1692 * Must first call syntax_start() once for the line. | 1692 * Must first call syntax_start() once for the line. |
1693 * "col" is normally 0 for the first use in a line, and increments by one each | 1693 * "col" is normally 0 for the first use in a line, and increments by one each |
1694 * time. It's allowed to skip characters and to stop before the end of the | 1694 * time. It's allowed to skip characters and to stop before the end of the |
1695 * line. But only a "col" after a previously used column is allowed. | 1695 * line. But only a "col" after a previously used column is allowed. |
1696 * When "can_spell" is not NULL set it to TRUE when spell-checking should be | |
1697 * done. | |
1696 */ | 1698 */ |
1697 int | 1699 int |
1698 get_syntax_attr(col) | 1700 get_syntax_attr(col, can_spell) |
1699 colnr_T col; | 1701 colnr_T col; |
1702 int *can_spell; | |
1700 { | 1703 { |
1701 int attr = 0; | 1704 int attr = 0; |
1702 | 1705 |
1703 /* check for out of memory situation */ | 1706 /* check for out of memory situation */ |
1704 if (syn_buf->b_sst_array == NULL) | 1707 if (syn_buf->b_sst_array == NULL) |
1713 /* | 1716 /* |
1714 * Skip from the current column to "col", get the attributes for "col". | 1717 * Skip from the current column to "col", get the attributes for "col". |
1715 */ | 1718 */ |
1716 while (current_col <= col) | 1719 while (current_col <= col) |
1717 { | 1720 { |
1718 attr = syn_current_attr(FALSE, TRUE); | 1721 attr = syn_current_attr(FALSE, TRUE, can_spell); |
1719 ++current_col; | 1722 ++current_col; |
1720 } | 1723 } |
1721 | 1724 |
1722 reg_syn = FALSE; | 1725 reg_syn = FALSE; |
1723 return attr; | 1726 return attr; |
1725 | 1728 |
1726 /* | 1729 /* |
1727 * Get syntax attributes for current_lnum, current_col. | 1730 * Get syntax attributes for current_lnum, current_col. |
1728 */ | 1731 */ |
1729 static int | 1732 static int |
1730 syn_current_attr(syncing, displaying) | 1733 syn_current_attr(syncing, displaying, can_spell) |
1731 int syncing; /* When 1: called for syncing */ | 1734 int syncing; /* When 1: called for syncing */ |
1732 int displaying; /* result will be displayed */ | 1735 int displaying; /* result will be displayed */ |
1736 int *can_spell; /* return: do spell checking */ | |
1733 { | 1737 { |
1734 int syn_id; | 1738 int syn_id; |
1735 lpos_T endpos; /* was: char_u *endp; */ | 1739 lpos_T endpos; /* was: char_u *endp; */ |
1736 lpos_T hl_startpos; /* was: int hl_startcol; */ | 1740 lpos_T hl_startpos; /* was: int hl_startcol; */ |
1737 lpos_T hl_endpos; | 1741 lpos_T hl_endpos; |
1738 lpos_T eos_pos; /* end-of-start match (start region) */ | 1742 lpos_T eos_pos; /* end-of-start match (start region) */ |
1739 lpos_T eoe_pos; /* end-of-end pattern */ | 1743 lpos_T eoe_pos; /* end-of-end pattern */ |
1740 int end_idx; /* group ID for end pattern */ | 1744 int end_idx; /* group ID for end pattern */ |
1741 int idx; | 1745 int idx; |
1742 synpat_T *spp; | 1746 synpat_T *spp; |
1743 stateitem_T *cur_si, *sip; | 1747 stateitem_T *cur_si, *sip = NULL; |
1744 int startcol; | 1748 int startcol; |
1745 int endcol; | 1749 int endcol; |
1746 long flags; | 1750 long flags; |
1747 short *next_list; | 1751 short *next_list; |
1748 int found_match; /* found usable match */ | 1752 int found_match; /* found usable match */ |
2164 current_id = 0; | 2168 current_id = 0; |
2165 current_trans_id = 0; | 2169 current_trans_id = 0; |
2166 #endif | 2170 #endif |
2167 if (cur_si != NULL) | 2171 if (cur_si != NULL) |
2168 { | 2172 { |
2173 #ifndef FEAT_EVAL | |
2174 int current_trans_id = 0; | |
2175 #endif | |
2169 for (idx = current_state.ga_len - 1; idx >= 0; --idx) | 2176 for (idx = current_state.ga_len - 1; idx >= 0; --idx) |
2170 { | 2177 { |
2171 sip = &CUR_STATE(idx); | 2178 sip = &CUR_STATE(idx); |
2172 if ((current_lnum > sip->si_h_startpos.lnum | 2179 if ((current_lnum > sip->si_h_startpos.lnum |
2173 || (current_lnum == sip->si_h_startpos.lnum | 2180 || (current_lnum == sip->si_h_startpos.lnum |
2178 && current_col < sip->si_h_endpos.col))) | 2185 && current_col < sip->si_h_endpos.col))) |
2179 { | 2186 { |
2180 current_attr = sip->si_attr; | 2187 current_attr = sip->si_attr; |
2181 #ifdef FEAT_EVAL | 2188 #ifdef FEAT_EVAL |
2182 current_id = sip->si_id; | 2189 current_id = sip->si_id; |
2190 #endif | |
2183 current_trans_id = sip->si_trans_id; | 2191 current_trans_id = sip->si_trans_id; |
2184 #endif | |
2185 break; | 2192 break; |
2186 } | 2193 } |
2187 } | 2194 } |
2195 | |
2196 if (can_spell != NULL) | |
2197 { | |
2198 struct sp_syn sps; | |
2199 | |
2200 /* | |
2201 * set "can_spell" to TRUE if spell checking is supposed to be | |
2202 * done in the current item. | |
2203 */ | |
2204 | |
2205 /* Always do spelling if there is no @Spell cluster. */ | |
2206 if (syn_buf->b_spell_cluster_id == 0) | |
2207 *can_spell = TRUE; | |
2208 else if (current_trans_id == 0) | |
2209 *can_spell = FALSE; | |
2210 else | |
2211 { | |
2212 sps.inc_tag = 0; | |
2213 sps.id = syn_buf->b_spell_cluster_id; | |
2214 sps.cont_in_list = NULL; | |
2215 *can_spell = in_id_list(sip, sip->si_cont_list, &sps, 0); | |
2216 } | |
2217 } | |
2218 | |
2188 | 2219 |
2189 /* | 2220 /* |
2190 * Check for end of current state (and the states before it) at the | 2221 * Check for end of current state (and the states before it) at the |
2191 * next column. Don't do this for syncing, because we would miss a | 2222 * next column. Don't do this for syncing, because we would miss a |
2192 * single character match. | 2223 * single character match. |
2203 check_state_ends(); | 2234 check_state_ends(); |
2204 --current_col; | 2235 --current_col; |
2205 } | 2236 } |
2206 } | 2237 } |
2207 } | 2238 } |
2239 else if (can_spell != NULL) | |
2240 /* Only do spelling when there is no @Spell cluster. */ | |
2241 *can_spell = (syn_buf->b_spell_cluster_id == 0); | |
2208 | 2242 |
2209 /* nextgroup ends at end of line, unless "skipnl" or "skipemtpy" present */ | 2243 /* nextgroup ends at end of line, unless "skipnl" or "skipemtpy" present */ |
2210 if (current_next_list != NULL | 2244 if (current_next_list != NULL |
2211 && syn_getcurline()[current_col + 1] == NUL | 2245 && syn_getcurline()[current_col + 1] == NUL |
2212 && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) | 2246 && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) |
5027 * "name" must be an allocated string, it will be consumed. | 5061 * "name" must be an allocated string, it will be consumed. |
5028 * Return 0 for failure. | 5062 * Return 0 for failure. |
5029 */ | 5063 */ |
5030 static int | 5064 static int |
5031 syn_add_cluster(name) | 5065 syn_add_cluster(name) |
5032 char_u *name; | 5066 char_u *name; |
5033 { | 5067 { |
5034 int len; | 5068 int len; |
5035 | 5069 |
5036 /* | 5070 /* |
5037 * First call for this growarray: init growing array. | 5071 * First call for this growarray: init growing array. |
5038 */ | 5072 */ |
5039 if (curbuf->b_syn_clusters.ga_data == NULL) | 5073 if (curbuf->b_syn_clusters.ga_data == NULL) |
5040 { | 5074 { |
5041 curbuf->b_syn_clusters.ga_itemsize = sizeof(struct syn_cluster); | 5075 curbuf->b_syn_clusters.ga_itemsize = sizeof(syn_cluster_T); |
5042 curbuf->b_syn_clusters.ga_growsize = 10; | 5076 curbuf->b_syn_clusters.ga_growsize = 10; |
5043 } | 5077 } |
5044 | 5078 |
5045 /* | 5079 /* |
5046 * Make room for at least one other cluster entry. | 5080 * Make room for at least one other cluster entry. |
5050 vim_free(name); | 5084 vim_free(name); |
5051 return 0; | 5085 return 0; |
5052 } | 5086 } |
5053 len = curbuf->b_syn_clusters.ga_len; | 5087 len = curbuf->b_syn_clusters.ga_len; |
5054 | 5088 |
5055 vim_memset(&(SYN_CLSTR(curbuf)[len]), 0, sizeof(struct syn_cluster)); | 5089 vim_memset(&(SYN_CLSTR(curbuf)[len]), 0, sizeof(syn_cluster_T)); |
5056 SYN_CLSTR(curbuf)[len].scl_name = name; | 5090 SYN_CLSTR(curbuf)[len].scl_name = name; |
5057 SYN_CLSTR(curbuf)[len].scl_name_u = vim_strsave_up(name); | 5091 SYN_CLSTR(curbuf)[len].scl_name_u = vim_strsave_up(name); |
5058 SYN_CLSTR(curbuf)[len].scl_list = NULL; | 5092 SYN_CLSTR(curbuf)[len].scl_list = NULL; |
5059 ++curbuf->b_syn_clusters.ga_len; | 5093 ++curbuf->b_syn_clusters.ga_len; |
5094 | |
5095 if (STRICMP(name, "Spell") == 0) | |
5096 curbuf->b_spell_cluster_id = len + SYNID_CLUSTER; | |
5060 | 5097 |
5061 return len + SYNID_CLUSTER; | 5098 return len + SYNID_CLUSTER; |
5062 } | 5099 } |
5063 | 5100 |
5064 /* | 5101 /* |
5087 rest = get_group_name(arg, &group_name_end); | 5124 rest = get_group_name(arg, &group_name_end); |
5088 | 5125 |
5089 if (rest != NULL) | 5126 if (rest != NULL) |
5090 { | 5127 { |
5091 scl_id = syn_check_cluster(arg, (int)(group_name_end - arg)) | 5128 scl_id = syn_check_cluster(arg, (int)(group_name_end - arg)) |
5092 - SYNID_CLUSTER; | 5129 - SYNID_CLUSTER; |
5093 | 5130 |
5094 for (;;) | 5131 for (;;) |
5095 { | 5132 { |
5096 if (STRNICMP(rest, "add", 3) == 0 | 5133 if (STRNICMP(rest, "add", 3) == 0 |
5097 && (vim_iswhite(rest[3]) || rest[3] == '=')) | 5134 && (vim_iswhite(rest[3]) || rest[3] == '=')) |
5894 if (curwin->w_buffer != syn_buf | 5931 if (curwin->w_buffer != syn_buf |
5895 || lnum != current_lnum | 5932 || lnum != current_lnum |
5896 || col < (long)current_col) | 5933 || col < (long)current_col) |
5897 syntax_start(curwin, lnum); | 5934 syntax_start(curwin, lnum); |
5898 | 5935 |
5899 (void)get_syntax_attr((colnr_T)col); | 5936 (void)get_syntax_attr((colnr_T)col, NULL); |
5900 | 5937 |
5901 return (trans ? current_trans_id : current_id); | 5938 return (trans ? current_trans_id : current_id); |
5902 } | 5939 } |
5903 #endif | 5940 #endif |
5904 | 5941 |
5966 "LineNr term=underline ctermfg=Brown guifg=Brown", | 6003 "LineNr term=underline ctermfg=Brown guifg=Brown", |
5967 "MoreMsg term=bold ctermfg=DarkGreen gui=bold guifg=SeaGreen", | 6004 "MoreMsg term=bold ctermfg=DarkGreen gui=bold guifg=SeaGreen", |
5968 "Normal gui=NONE", | 6005 "Normal gui=NONE", |
5969 "Question term=standout ctermfg=DarkGreen gui=bold guifg=SeaGreen", | 6006 "Question term=standout ctermfg=DarkGreen gui=bold guifg=SeaGreen", |
5970 "Search term=reverse ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE", | 6007 "Search term=reverse ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE", |
6008 "SpellBad term=reverse ctermbg=LightRed guisp=Red gui=undercurl", | |
6009 "SpellRare term=reverse ctermbg=LightMagenta guisp=Magenta gui=undercurl", | |
6010 "SpellLocal term=underline ctermbg=Cyan guisp=DarkCyan gui=undercurl", | |
5971 "SpecialKey term=bold ctermfg=DarkBlue guifg=Blue", | 6011 "SpecialKey term=bold ctermfg=DarkBlue guifg=Blue", |
5972 "Title term=bold ctermfg=DarkMagenta gui=bold guifg=Magenta", | 6012 "Title term=bold ctermfg=DarkMagenta gui=bold guifg=Magenta", |
5973 "WarningMsg term=standout ctermfg=DarkRed guifg=Red", | 6013 "WarningMsg term=standout ctermfg=DarkRed guifg=Red", |
5974 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", | 6014 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", |
5975 "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue", | 6015 "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue", |
5988 "MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen", | 6028 "MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen", |
5989 "Normal gui=NONE", | 6029 "Normal gui=NONE", |
5990 "Question term=standout ctermfg=LightGreen gui=bold guifg=Green", | 6030 "Question term=standout ctermfg=LightGreen gui=bold guifg=Green", |
5991 "Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", | 6031 "Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", |
5992 "SpecialKey term=bold ctermfg=LightBlue guifg=Cyan", | 6032 "SpecialKey term=bold ctermfg=LightBlue guifg=Cyan", |
6033 "SpellBad term=reverse ctermbg=Red guisp=Red gui=undercurl", | |
6034 "SpellRare term=reverse ctermbg=Magenta guisp=Magenta gui=undercurl", | |
6035 "SpellLocal term=underline ctermbg=Cyan guisp=Cyan gui=undercurl", | |
5993 "Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta", | 6036 "Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta", |
5994 "WarningMsg term=standout ctermfg=LightRed guifg=Red", | 6037 "WarningMsg term=standout ctermfg=LightRed guifg=Red", |
5995 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", | 6038 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", |
5996 "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan", | 6039 "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan", |
5997 "FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan", | 6040 "FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan", |
7517 } | 7560 } |
7518 ++table->ga_len; | 7561 ++table->ga_len; |
7519 return (table->ga_len - 1 + ATTR_OFF); | 7562 return (table->ga_len - 1 + ATTR_OFF); |
7520 } | 7563 } |
7521 | 7564 |
7565 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
7566 /* | |
7567 * Combine the spelling attributes with other attributes. "spell_attr" | |
7568 * overrules "char_attr". | |
7569 * This creates a new group when required. | |
7570 * Since we expect there to be few spelling mistakes we don't cache the | |
7571 * result. | |
7572 * Return the resulting attributes. | |
7573 */ | |
7574 int | |
7575 hl_combine_attr(char_attr, spell_attr) | |
7576 int char_attr; | |
7577 int spell_attr; | |
7578 { | |
7579 attrentry_T *char_aep = NULL; | |
7580 attrentry_T *spell_aep; | |
7581 attrentry_T new_en; | |
7582 | |
7583 if (char_attr == 0) | |
7584 return spell_attr; | |
7585 if (char_attr <= HL_ALL && spell_attr <= HL_ALL) | |
7586 return char_attr | spell_attr; | |
7587 #ifdef FEAT_GUI | |
7588 if (gui.in_use) | |
7589 { | |
7590 if (char_attr > HL_ALL) | |
7591 char_aep = syn_gui_attr2entry(char_attr); | |
7592 if (char_aep != NULL) | |
7593 new_en = *char_aep; | |
7594 else | |
7595 { | |
7596 vim_memset(&new_en, 0, sizeof(new_en)); | |
7597 if (char_attr <= HL_ALL) | |
7598 new_en.ae_attr = char_attr; | |
7599 } | |
7600 | |
7601 if (spell_attr <= HL_ALL) | |
7602 new_en.ae_attr |= spell_attr; | |
7603 else | |
7604 { | |
7605 spell_aep = syn_gui_attr2entry(spell_attr); | |
7606 if (spell_aep != NULL) | |
7607 { | |
7608 new_en.ae_attr |= spell_aep->ae_attr; | |
7609 if (spell_aep->ae_u.gui.fg_color != INVALCOLOR) | |
7610 new_en.ae_u.gui.fg_color = spell_aep->ae_u.gui.fg_color; | |
7611 if (spell_aep->ae_u.gui.bg_color != INVALCOLOR) | |
7612 new_en.ae_u.gui.bg_color = spell_aep->ae_u.gui.bg_color; | |
7613 if (spell_aep->ae_u.gui.sp_color != INVALCOLOR) | |
7614 new_en.ae_u.gui.sp_color = spell_aep->ae_u.gui.sp_color; | |
7615 if (spell_aep->ae_u.gui.font != NOFONT) | |
7616 new_en.ae_u.gui.font = spell_aep->ae_u.gui.font; | |
7617 # ifdef FEAT_XFONTSET | |
7618 if (spell_aep->ae_u.gui.fontset != NOFONTSET) | |
7619 new_en.ae_u.gui.fontset = spell_aep->ae_u.gui.fontset; | |
7620 # endif | |
7621 } | |
7622 } | |
7623 return get_attr_entry(&gui_attr_table, &new_en); | |
7624 } | |
7625 #endif | |
7626 | |
7627 if (t_colors > 1) | |
7628 { | |
7629 if (char_attr > HL_ALL) | |
7630 char_aep = syn_cterm_attr2entry(char_attr); | |
7631 if (char_aep != NULL) | |
7632 new_en = *char_aep; | |
7633 else | |
7634 { | |
7635 vim_memset(&new_en, 0, sizeof(new_en)); | |
7636 if (char_attr <= HL_ALL) | |
7637 new_en.ae_attr = char_attr; | |
7638 } | |
7639 | |
7640 if (spell_attr <= HL_ALL) | |
7641 new_en.ae_attr |= spell_attr; | |
7642 else | |
7643 { | |
7644 spell_aep = syn_cterm_attr2entry(spell_attr); | |
7645 if (spell_aep != NULL) | |
7646 { | |
7647 new_en.ae_attr |= spell_aep->ae_attr; | |
7648 if (spell_aep->ae_u.cterm.fg_color > 0) | |
7649 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color; | |
7650 if (spell_aep->ae_u.cterm.bg_color > 0) | |
7651 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; | |
7652 } | |
7653 } | |
7654 return get_attr_entry(&cterm_attr_table, &new_en); | |
7655 } | |
7656 | |
7657 if (char_attr > HL_ALL) | |
7658 char_aep = syn_term_attr2entry(char_attr); | |
7659 if (char_aep != NULL) | |
7660 new_en = *char_aep; | |
7661 else | |
7662 { | |
7663 vim_memset(&new_en, 0, sizeof(new_en)); | |
7664 if (char_attr <= HL_ALL) | |
7665 new_en.ae_attr = char_attr; | |
7666 } | |
7667 | |
7668 if (spell_attr <= HL_ALL) | |
7669 new_en.ae_attr |= spell_attr; | |
7670 else | |
7671 { | |
7672 spell_aep = syn_cterm_attr2entry(spell_attr); | |
7673 if (spell_aep != NULL) | |
7674 { | |
7675 new_en.ae_attr |= spell_aep->ae_attr; | |
7676 if (spell_aep->ae_u.term.start != NULL) | |
7677 { | |
7678 new_en.ae_u.term.start = spell_aep->ae_u.term.start; | |
7679 new_en.ae_u.term.stop = spell_aep->ae_u.term.stop; | |
7680 } | |
7681 } | |
7682 } | |
7683 return get_attr_entry(&term_attr_table, &new_en); | |
7684 } | |
7685 #endif | |
7686 | |
7522 #ifdef FEAT_GUI | 7687 #ifdef FEAT_GUI |
7523 | 7688 |
7524 attrentry_T * | 7689 attrentry_T * |
7525 syn_gui_attr2entry(attr) | 7690 syn_gui_attr2entry(attr) |
7526 int attr; | 7691 int attr; |