Mercurial > vim
annotate src/syntax.c @ 13314:65c3e8259124 v8.0.1531
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
commit https://github.com/vim/vim/commit/cafafb381a04e33f3ce9cd15dd9f94b73226831f
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 22 21:07:09 2018 +0100
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Problem: Cannot use 24 bit colors in MS-Windows console.
Solution: Add support for vcon. (Nobuhiro Takasaki, Ken Takasaki,
fixes #1270, fixes #2060)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 22 Feb 2018 21:15:05 +0100 |
parents | ae312df8d0ab |
children | b4e7082de11d |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * syntax.c: code for syntax highlighting | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 /* | |
17 * Structure that stores information about a highlight group. | |
18 * The ID of a highlight group is also called group ID. It is the index in | |
19 * the highlight_ga array PLUS ONE. | |
20 */ | |
21 struct hl_group | |
22 { | |
23 char_u *sg_name; /* highlight group name */ | |
24 char_u *sg_name_u; /* uppercase of sg_name */ | |
10624
5ac9d7920f11
patch 8.0.0201: completion of highlight groups includes cleared names
Christian Brabandt <cb@256bit.org>
parents:
10618
diff
changeset
|
25 int sg_cleared; /* "hi clear" was used */ |
7 | 26 /* for normal terminals */ |
27 int sg_term; /* "term=" highlighting attributes */ | |
28 char_u *sg_start; /* terminal string for start highl */ | |
29 char_u *sg_stop; /* terminal string for stop highl */ | |
30 int sg_term_attr; /* Screen attr for term mode */ | |
31 /* for color terminals */ | |
32 int sg_cterm; /* "cterm=" highlighting attr */ | |
33 int sg_cterm_bold; /* bold attr was set for light color */ | |
34 int sg_cterm_fg; /* terminal fg color number + 1 */ | |
35 int sg_cterm_bg; /* terminal bg color number + 1 */ | |
36 int sg_cterm_attr; /* Screen attr for color term mode */ | |
37 /* for when using the GUI */ | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
38 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
7 | 39 guicolor_T sg_gui_fg; /* GUI foreground color handle */ |
40 guicolor_T sg_gui_bg; /* GUI background color handle */ | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
41 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
42 #ifdef FEAT_GUI |
205 | 43 guicolor_T sg_gui_sp; /* GUI special color handle */ |
7 | 44 GuiFont sg_font; /* GUI font handle */ |
45 #ifdef FEAT_XFONTSET | |
46 GuiFontset sg_fontset; /* GUI fontset handle */ | |
47 #endif | |
48 char_u *sg_font_name; /* GUI font or fontset name */ | |
49 int sg_gui_attr; /* Screen attr for GUI mode */ | |
50 #endif | |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
51 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
52 /* Store the sp color name for the GUI or synIDattr() */ |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
53 int sg_gui; /* "gui=" highlighting attributes */ |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
54 char_u *sg_gui_fg_name;/* GUI foreground color name */ |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
55 char_u *sg_gui_bg_name;/* GUI background color name */ |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
56 char_u *sg_gui_sp_name;/* GUI special color name */ |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
57 #endif |
7 | 58 int sg_link; /* link to this highlight group ID */ |
59 int sg_set; /* combination of SG_* flags */ | |
448 | 60 #ifdef FEAT_EVAL |
61 scid_T sg_scriptID; /* script in which the group was last set */ | |
62 #endif | |
7 | 63 }; |
64 | |
65 #define SG_TERM 1 /* term has been set */ | |
66 #define SG_CTERM 2 /* cterm has been set */ | |
67 #define SG_GUI 4 /* gui has been set */ | |
68 #define SG_LINK 8 /* link has been set */ | |
69 | |
70 static garray_T highlight_ga; /* highlight groups for 'highlight' option */ | |
71 | |
72 #define HL_TABLE() ((struct hl_group *)((highlight_ga.ga_data))) | |
73 | |
2756 | 74 #define MAX_HL_ID 20000 /* maximum value for a highlight ID. */ |
75 | |
7 | 76 #ifdef FEAT_CMDL_COMPL |
1322 | 77 /* Flags to indicate an additional string for highlight name completion. */ |
78 static int include_none = 0; /* when 1 include "None" */ | |
79 static int include_default = 0; /* when 1 include "default" */ | |
80 static int include_link = 0; /* when 2 include "link" and "clear" */ | |
7 | 81 #endif |
82 | |
83 /* | |
84 * The "term", "cterm" and "gui" arguments can be any combination of the | |
85 * following names, separated by commas (but no spaces!). | |
86 */ | |
87 static char *(hl_name_table[]) = | |
205 | 88 {"bold", "standout", "underline", "undercurl", |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12180
diff
changeset
|
89 "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"}; |
7 | 90 static int hl_attr_table[] = |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12180
diff
changeset
|
91 {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0}; |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
92 #define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? attr_b : (attr_a)) | (attr_b)) |
7 | 93 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
94 static int get_attr_entry(garray_T *table, attrentry_T *aep); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
95 static void syn_unadd_group(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
96 static void set_hl_attr(int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
97 static void highlight_list_one(int id); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
98 static int highlight_list_arg(int id, int didh, int type, int iarg, char_u *sarg, char *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
99 static int syn_add_group(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
100 static int syn_list_header(int did_header, int outlen, int id); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
101 static int hl_has_settings(int idx, int check_link); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
102 static void highlight_clear(int idx); |
7 | 103 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
104 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
105 static void gui_do_one_color(int idx, int do_menu, int do_tooltip); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
106 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
107 #ifdef FEAT_GUI |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
108 static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
109 static GuiFont font_name2handle(char_u *name); |
7 | 110 # ifdef FEAT_XFONTSET |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
111 static GuiFontset fontset_name2handle(char_u *name, int fixed_width); |
7 | 112 # endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
113 static void hl_do_font(int idx, char_u *arg, int do_normal, int do_menu, int do_tooltip, int free_font); |
7 | 114 #endif |
115 | |
116 /* | |
117 * An attribute number is the index in attr_table plus ATTR_OFF. | |
118 */ | |
119 #define ATTR_OFF (HL_ALL + 1) | |
120 | |
121 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
122 | |
123 #define SYN_NAMELEN 50 /* maximum length of a syntax name */ | |
124 | |
125 /* different types of offsets that are possible */ | |
126 #define SPO_MS_OFF 0 /* match start offset */ | |
127 #define SPO_ME_OFF 1 /* match end offset */ | |
128 #define SPO_HS_OFF 2 /* highl. start offset */ | |
129 #define SPO_HE_OFF 3 /* highl. end offset */ | |
130 #define SPO_RS_OFF 4 /* region start offset */ | |
131 #define SPO_RE_OFF 5 /* region end offset */ | |
132 #define SPO_LC_OFF 6 /* leading context offset */ | |
133 #define SPO_COUNT 7 | |
134 | |
135 static char *(spo_name_tab[SPO_COUNT]) = | |
136 {"ms=", "me=", "hs=", "he=", "rs=", "re=", "lc="}; | |
137 | |
138 /* | |
139 * The patterns that are being searched for are stored in a syn_pattern. | |
140 * A match item consists of one pattern. | |
141 * A start/end item consists of n start patterns and m end patterns. | |
142 * A start/skip/end item consists of n start patterns, one skip pattern and m | |
143 * end patterns. | |
144 * For the latter two, the patterns are always consecutive: start-skip-end. | |
145 * | |
146 * A character offset can be given for the matched text (_m_start and _m_end) | |
147 * and for the actually highlighted text (_h_start and _h_end). | |
148 */ | |
149 typedef struct syn_pattern | |
150 { | |
151 char sp_type; /* see SPTYPE_ defines below */ | |
152 char sp_syncing; /* this item used for syncing */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
153 int sp_flags; /* see HL_ defines below */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
154 #ifdef FEAT_CONCEAL |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
155 int sp_cchar; /* conceal substitute character */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
156 #endif |
7 | 157 struct sp_syn sp_syn; /* struct passed to in_id_list() */ |
158 short sp_syn_match_id; /* highlight group ID of pattern */ | |
159 char_u *sp_pattern; /* regexp to match, pattern */ | |
160 regprog_T *sp_prog; /* regexp to match, program */ | |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
161 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
162 syn_time_T sp_time; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
163 #endif |
7 | 164 int sp_ic; /* ignore-case flag for sp_prog */ |
165 short sp_off_flags; /* see below */ | |
166 int sp_offsets[SPO_COUNT]; /* offsets */ | |
167 short *sp_cont_list; /* cont. group IDs, if non-zero */ | |
168 short *sp_next_list; /* next group IDs, if non-zero */ | |
169 int sp_sync_idx; /* sync item index (syncing only) */ | |
170 int sp_line_id; /* ID of last line where tried */ | |
171 int sp_startcol; /* next match in sp_line_id line */ | |
172 } synpat_T; | |
173 | |
174 /* The sp_off_flags are computed like this: | |
175 * offset from the start of the matched text: (1 << SPO_XX_OFF) | |
176 * offset from the end of the matched text: (1 << (SPO_XX_OFF + SPO_COUNT)) | |
177 * When both are present, only one is used. | |
178 */ | |
179 | |
180 #define SPTYPE_MATCH 1 /* match keyword with this group ID */ | |
181 #define SPTYPE_START 2 /* match a regexp, start of item */ | |
182 #define SPTYPE_END 3 /* match a regexp, end of item */ | |
183 #define SPTYPE_SKIP 4 /* match a regexp, skip within item */ | |
184 | |
185 | |
186 #define SYN_ITEMS(buf) ((synpat_T *)((buf)->b_syn_patterns.ga_data)) | |
187 | |
188 #define NONE_IDX -2 /* value of sp_sync_idx for "NONE" */ | |
189 | |
190 /* | |
191 * Flags for b_syn_sync_flags: | |
192 */ | |
193 #define SF_CCOMMENT 0x01 /* sync on a C-style comment */ | |
194 #define SF_MATCH 0x02 /* sync by matching a pattern */ | |
195 | |
196 #define SYN_STATE_P(ssp) ((bufstate_T *)((ssp)->ga_data)) | |
197 | |
198 #define MAXKEYWLEN 80 /* maximum length of a keyword */ | |
199 | |
200 /* | |
201 * The attributes of the syntax item that has been recognized. | |
202 */ | |
203 static int current_attr = 0; /* attr of current syntax word */ | |
204 #ifdef FEAT_EVAL | |
205 static int current_id = 0; /* ID of current char for syn_get_id() */ | |
2020 | 206 static int current_trans_id = 0; /* idem, transparency removed */ |
7 | 207 #endif |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
208 #ifdef FEAT_CONCEAL |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
209 static int current_flags = 0; |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
210 static int current_seqnr = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
211 static int current_sub_char = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
212 #endif |
7 | 213 |
221 | 214 typedef struct syn_cluster_S |
7 | 215 { |
216 char_u *scl_name; /* syntax cluster name */ | |
217 char_u *scl_name_u; /* uppercase of scl_name */ | |
218 short *scl_list; /* IDs in this syntax cluster */ | |
221 | 219 } syn_cluster_T; |
7 | 220 |
221 /* | |
222 * Methods of combining two clusters | |
223 */ | |
224 #define CLUSTER_REPLACE 1 /* replace first list with second */ | |
225 #define CLUSTER_ADD 2 /* add second list to first */ | |
226 #define CLUSTER_SUBTRACT 3 /* subtract second list from first */ | |
227 | |
221 | 228 #define SYN_CLSTR(buf) ((syn_cluster_T *)((buf)->b_syn_clusters.ga_data)) |
7 | 229 |
230 /* | |
231 * Syntax group IDs have different types: | |
2743 | 232 * 0 - 19999 normal syntax groups |
233 * 20000 - 20999 ALLBUT indicator (current_syn_inc_tag added) | |
234 * 21000 - 21999 TOP indicator (current_syn_inc_tag added) | |
235 * 22000 - 22999 CONTAINED indicator (current_syn_inc_tag added) | |
236 * 23000 - 32767 cluster IDs (subtract SYNID_CLUSTER for the cluster ID) | |
237 */ | |
2756 | 238 #define SYNID_ALLBUT MAX_HL_ID /* syntax group ID for contains=ALLBUT */ |
2743 | 239 #define SYNID_TOP 21000 /* syntax group ID for contains=TOP */ |
240 #define SYNID_CONTAINED 22000 /* syntax group ID for contains=CONTAINED */ | |
241 #define SYNID_CLUSTER 23000 /* first syntax group ID for clusters */ | |
242 | |
243 #define MAX_SYN_INC_TAG 999 /* maximum before the above overflow */ | |
244 #define MAX_CLUSTER_ID (32767 - SYNID_CLUSTER) | |
7 | 245 |
246 /* | |
247 * Annoying Hack(TM): ":syn include" needs this pointer to pass to | |
248 * expand_filename(). Most of the other syntax commands don't need it, so | |
249 * instead of passing it to them, we stow it here. | |
250 */ | |
251 static char_u **syn_cmdlinep; | |
252 | |
253 /* | |
254 * Another Annoying Hack(TM): To prevent rules from other ":syn include"'d | |
2251
646d34788036
Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
255 * files from leaking into ALLBUT lists, we assign a unique ID to the |
7 | 256 * rules in each ":syn include"'d file. |
257 */ | |
258 static int current_syn_inc_tag = 0; | |
259 static int running_syn_inc_tag = 0; | |
260 | |
261 /* | |
134 | 262 * In a hashtable item "hi_key" points to "keyword" in a keyentry. |
263 * This avoids adding a pointer to the hashtable item. | |
264 * KE2HIKEY() converts a var pointer to a hashitem key pointer. | |
265 * HIKEY2KE() converts a hashitem key pointer to a var pointer. | |
266 * HI2KE() converts a hashitem pointer to a var pointer. | |
267 */ | |
268 static keyentry_T dumkey; | |
269 #define KE2HIKEY(kp) ((kp)->keyword) | |
270 #define HIKEY2KE(p) ((keyentry_T *)((p) - (dumkey.keyword - (char_u *)&dumkey))) | |
271 #define HI2KE(hi) HIKEY2KE((hi)->hi_key) | |
272 | |
273 /* | |
7 | 274 * To reduce the time spent in keepend(), remember at which level in the state |
275 * stack the first item with "keepend" is present. When "-1", there is no | |
276 * "keepend" on the stack. | |
277 */ | |
278 static int keepend_level = -1; | |
279 | |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
280 static char msg_no_items[] = N_("No Syntax items defined for this buffer"); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
281 |
7 | 282 /* |
283 * For the current state we need to remember more than just the idx. | |
284 * When si_m_endpos.lnum is 0, the items other than si_idx are unknown. | |
285 * (The end positions have the column number of the next char) | |
286 */ | |
287 typedef struct state_item | |
288 { | |
1371 | 289 int si_idx; /* index of syntax pattern or |
290 KEYWORD_IDX */ | |
7 | 291 int si_id; /* highlight group ID for keywords */ |
2020 | 292 int si_trans_id; /* idem, transparency removed */ |
7 | 293 int si_m_lnum; /* lnum of the match */ |
294 int si_m_startcol; /* starting column of the match */ | |
295 lpos_T si_m_endpos; /* just after end posn of the match */ | |
296 lpos_T si_h_startpos; /* start position of the highlighting */ | |
297 lpos_T si_h_endpos; /* end position of the highlighting */ | |
298 lpos_T si_eoe_pos; /* end position of end pattern */ | |
299 int si_end_idx; /* group ID for end pattern or zero */ | |
300 int si_ends; /* if match ends before si_m_endpos */ | |
301 int si_attr; /* attributes in this state */ | |
302 long si_flags; /* HL_HAS_EOL flag in this state, and | |
303 * HL_SKIP* for si_next_list */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
304 #ifdef FEAT_CONCEAL |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
305 int si_seqnr; /* sequence number */ |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
306 int si_cchar; /* substitution character for conceal */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
307 #endif |
7 | 308 short *si_cont_list; /* list of contained groups */ |
309 short *si_next_list; /* nextgroup IDs after this item ends */ | |
310 reg_extmatch_T *si_extmatch; /* \z(...\) matches from start | |
311 * pattern */ | |
312 } stateitem_T; | |
313 | |
314 #define KEYWORD_IDX -1 /* value of si_idx for keywords */ | |
315 #define ID_LIST_ALL (short *)-1 /* valid of si_cont_list for containing all | |
316 but contained groups */ | |
317 | |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
318 #ifdef FEAT_CONCEAL |
6698 | 319 static int next_seqnr = 1; /* value to use for si_seqnr */ |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
320 #endif |
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
321 |
7 | 322 /* |
154 | 323 * Struct to reduce the number of arguments to get_syn_options(), it's used |
324 * very often. | |
325 */ | |
326 typedef struct | |
327 { | |
1222 | 328 int flags; /* flags for contained and transparent */ |
154 | 329 int keyword; /* TRUE for ":syn keyword" */ |
330 int *sync_idx; /* syntax item for "grouphere" argument, NULL | |
331 if not allowed */ | |
332 char has_cont_list; /* TRUE if "cont_list" can be used */ | |
333 short *cont_list; /* group IDs for "contains" argument */ | |
334 short *cont_in_list; /* group IDs for "containedin" argument */ | |
335 short *next_list; /* group IDs for "nextgroup" argument */ | |
336 } syn_opt_arg_T; | |
337 | |
338 /* | |
7 | 339 * The next possible match in the current line for any pattern is remembered, |
340 * to avoid having to try for a match in each column. | |
341 * If next_match_idx == -1, not tried (in this line) yet. | |
342 * If next_match_col == MAXCOL, no match found in this line. | |
343 * (All end positions have the column of the char after the end) | |
344 */ | |
345 static int next_match_col; /* column for start of next match */ | |
346 static lpos_T next_match_m_endpos; /* position for end of next match */ | |
347 static lpos_T next_match_h_startpos; /* pos. for highl. start of next match */ | |
348 static lpos_T next_match_h_endpos; /* pos. for highl. end of next match */ | |
349 static int next_match_idx; /* index of matched item */ | |
350 static long next_match_flags; /* flags for next match */ | |
351 static lpos_T next_match_eos_pos; /* end of start pattn (start region) */ | |
352 static lpos_T next_match_eoe_pos; /* pos. for end of end pattern */ | |
353 static int next_match_end_idx; /* ID of group for end pattn or zero */ | |
354 static reg_extmatch_T *next_match_extmatch = NULL; | |
355 | |
356 /* | |
357 * A state stack is an array of integers or stateitem_T, stored in a | |
358 * garray_T. A state stack is invalid if it's itemsize entry is zero. | |
359 */ | |
360 #define INVALID_STATE(ssp) ((ssp)->ga_itemsize == 0) | |
361 #define VALID_STATE(ssp) ((ssp)->ga_itemsize != 0) | |
362 | |
363 /* | |
364 * The current state (within the line) of the recognition engine. | |
365 * When current_state.ga_itemsize is 0 the current state is invalid. | |
366 */ | |
367 static win_T *syn_win; /* current window for highlighting */ | |
368 static buf_T *syn_buf; /* current buffer for highlighting */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
369 static synblock_T *syn_block; /* current buffer for highlighting */ |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
370 #ifdef FEAT_RELTIME |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
371 static proftime_T *syn_tm; /* timeout limit */ |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
372 #endif |
7 | 373 static linenr_T current_lnum = 0; /* lnum of current state */ |
374 static colnr_T current_col = 0; /* column of current state */ | |
375 static int current_state_stored = 0; /* TRUE if stored current state | |
376 * after setting current_finished */ | |
377 static int current_finished = 0; /* current line has been finished */ | |
378 static garray_T current_state /* current stack of state_items */ | |
379 = {0, 0, 0, 0, NULL}; | |
380 static short *current_next_list = NULL; /* when non-zero, nextgroup list */ | |
381 static int current_next_flags = 0; /* flags for current_next_list */ | |
382 static int current_line_id = 0; /* unique number for current line */ | |
383 | |
384 #define CUR_STATE(idx) ((stateitem_T *)(current_state.ga_data))[idx] | |
385 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
386 static void syn_sync(win_T *wp, linenr_T lnum, synstate_T *last_valid); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
387 static void save_chartab(char_u *chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
388 static void restore_chartab(char_u *chartab); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
389 static int syn_match_linecont(linenr_T lnum); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
390 static void syn_start_line(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
391 static void syn_update_ends(int startofline); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
392 static void syn_stack_alloc(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
393 static int syn_stack_cleanup(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
394 static void syn_stack_free_entry(synblock_T *block, synstate_T *p); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
395 static synstate_T *syn_stack_find_entry(linenr_T lnum); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
396 static synstate_T *store_current_state(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
397 static void load_current_state(synstate_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
398 static void invalidate_current_state(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
399 static int syn_stack_equal(synstate_T *sp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
400 static void validate_current_state(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
401 static int syn_finish_line(int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
402 static int syn_current_attr(int syncing, int displaying, int *can_spell, int keep_state); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
403 static int did_match_already(int idx, garray_T *gap); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
404 static stateitem_T *push_next_match(stateitem_T *cur_si); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
405 static void check_state_ends(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
406 static void update_si_attr(int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
407 static void check_keepend(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
408 static void update_si_end(stateitem_T *sip, int startcol, int force); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
409 static short *copy_id_list(short *list); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
410 static int in_id_list(stateitem_T *item, short *cont_list, struct sp_syn *ssp, int contained); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
411 static int push_current_state(int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
412 static void pop_current_state(void); |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
413 #ifdef FEAT_PROFILE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
414 static void syn_clear_time(syn_time_T *tt); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
415 static void syntime_clear(void); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
416 #ifdef __BORLANDC__ |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
417 static int _RTLENTRYF syn_compare_syntime(const void *v1, const void *v2); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
418 #else |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
419 static int syn_compare_syntime(const void *v1, const void *v2); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
420 #endif |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
421 static void syntime_report(void); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
422 static int syn_time_on = FALSE; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
423 # define IF_SYN_TIME(p) (p) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
424 #else |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
425 # define IF_SYN_TIME(p) NULL |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
426 typedef int syn_time_T; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
427 #endif |
7 | 428 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
429 static void syn_stack_apply_changes_block(synblock_T *block, buf_T *buf); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
430 static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_endpos, long *flagsp, lpos_T *end_endpos, int *end_idx, reg_extmatch_T *start_ext); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
431 static void clear_syn_state(synstate_T *p); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
432 static void clear_current_state(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
433 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
434 static void limit_pos(lpos_T *pos, lpos_T *limit); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
435 static void limit_pos_zero(lpos_T *pos, lpos_T *limit); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
436 static void syn_add_end_off(lpos_T *result, regmmatch_T *regmatch, synpat_T *spp, int idx, int extra); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
437 static void syn_add_start_off(lpos_T *result, regmmatch_T *regmatch, synpat_T *spp, int idx, int extra); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
438 static char_u *syn_getcurline(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
439 static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T *st); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
440 static int check_keyword_id(char_u *line, int startcol, int *endcol, long *flags, short **next_list, stateitem_T *cur_si, int *ccharp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
441 static void syn_cmd_case(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
442 static void syn_cmd_spell(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
443 static void syntax_sync_clear(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
444 static void syn_remove_pattern(synblock_T *block, int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
445 static void syn_clear_pattern(synblock_T *block, int i); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
446 static void syn_clear_cluster(synblock_T *block, int i); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
447 static void syn_cmd_clear(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
448 static void syn_cmd_conceal(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
449 static void syn_clear_one(int id, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
450 static void syn_cmd_on(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
451 static void syn_cmd_enable(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
452 static void syn_cmd_reset(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
453 static void syn_cmd_manual(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
454 static void syn_cmd_off(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
455 static void syn_cmd_onoff(exarg_T *eap, char *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
456 static void syn_cmd_list(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
457 static void syn_lines_msg(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
458 static void syn_match_msg(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
459 static void syn_stack_free_block(synblock_T *block); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
460 static void syn_list_one(int id, int syncing, int link_only); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
461 static void syn_list_cluster(int id); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
462 static void put_id_list(char_u *name, short *list, int attr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
463 static void put_pattern(char *s, int c, synpat_T *spp, int attr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
464 static int syn_list_keywords(int id, hashtab_T *ht, int did_header, int attr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
465 static void syn_clear_keyword(int id, hashtab_T *ht); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
466 static void clear_keywtab(hashtab_T *ht); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
467 static void add_keyword(char_u *name, int id, int flags, short *cont_in_list, short *next_list, int conceal_char); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
468 static char_u *get_group_name(char_u *arg, char_u **name_end); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
469 static char_u *get_syn_options(char_u *arg, syn_opt_arg_T *opt, int *conceal_char, int skip); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
470 static void syn_cmd_include(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
471 static void syn_cmd_iskeyword(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
472 static void syn_cmd_keyword(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
473 static void syn_cmd_match(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
474 static void syn_cmd_region(exarg_T *eap, int syncing); |
7 | 475 #ifdef __BORLANDC__ |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
476 static int _RTLENTRYF syn_compare_stub(const void *v1, const void *v2); |
7 | 477 #else |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
478 static int syn_compare_stub(const void *v1, const void *v2); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
479 #endif |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
480 static void syn_cmd_cluster(exarg_T *eap, int syncing); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
481 static int syn_scl_name2id(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
482 static int syn_scl_namen2id(char_u *linep, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
483 static int syn_check_cluster(char_u *pp, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
484 static int syn_add_cluster(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
485 static void init_syn_patterns(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
486 static char_u *get_syn_pattern(char_u *arg, synpat_T *ci); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
487 static void syn_cmd_sync(exarg_T *eap, int syncing); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
488 static int get_id_list(char_u **arg, int keylen, short **list, int skip); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
489 static void syn_combine_list(short **clstr1, short **clstr2, int list_op); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
490 static void syn_incl_toplevel(int id, int *flagsp); |
7 | 491 |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
492 #if defined(FEAT_RELTIME) || defined(PROTO) |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
493 /* |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
494 * Set the timeout used for syntax highlighting. |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
495 * Use NULL to reset, no timeout. |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
496 */ |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
497 void |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
498 syn_set_timeout(proftime_T *tm) |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
499 { |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
500 syn_tm = tm; |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
501 } |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
502 #endif |
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
503 |
7 | 504 /* |
505 * Start the syntax recognition for a line. This function is normally called | |
506 * from the screen updating, once for each displayed line. | |
507 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get | |
508 * it. Careful: curbuf and curwin are likely to point to another buffer and | |
509 * window. | |
510 */ | |
511 void | |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
512 syntax_start(win_T *wp, linenr_T lnum) |
7 | 513 { |
514 synstate_T *p; | |
515 synstate_T *last_valid = NULL; | |
516 synstate_T *last_min_valid = NULL; | |
1512 | 517 synstate_T *sp, *prev = NULL; |
7 | 518 linenr_T parsed_lnum; |
519 linenr_T first_stored; | |
520 int dist; | |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10660
diff
changeset
|
521 static varnumber_T changedtick = 0; /* remember the last change ID */ |
7 | 522 |
2401
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
523 #ifdef FEAT_CONCEAL |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
524 current_sub_char = NUL; |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
525 #endif |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
526 |
7 | 527 /* |
528 * After switching buffers, invalidate current_state. | |
26 | 529 * Also do this when a change was made, the current state may be invalid |
530 * then. | |
7 | 531 */ |
8806
8fff73f17ff1
commit https://github.com/vim/vim/commit/b681be175b6991cdc2b8ddd49b0e97e3fe2b201e
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
532 if (syn_block != wp->w_s |
8fff73f17ff1
commit https://github.com/vim/vim/commit/b681be175b6991cdc2b8ddd49b0e97e3fe2b201e
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
533 || syn_buf != wp->w_buffer |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
534 || changedtick != CHANGEDTICK(syn_buf)) |
7 | 535 { |
536 invalidate_current_state(); | |
537 syn_buf = wp->w_buffer; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
538 syn_block = wp->w_s; |
7 | 539 } |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
540 changedtick = CHANGEDTICK(syn_buf); |
7 | 541 syn_win = wp; |
542 | |
543 /* | |
544 * Allocate syntax stack when needed. | |
545 */ | |
546 syn_stack_alloc(); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
547 if (syn_block->b_sst_array == NULL) |
410 | 548 return; /* out of memory */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
549 syn_block->b_sst_lasttick = display_tick; |
7 | 550 |
551 /* | |
552 * If the state of the end of the previous line is useful, store it. | |
553 */ | |
554 if (VALID_STATE(¤t_state) | |
555 && current_lnum < lnum | |
556 && current_lnum < syn_buf->b_ml.ml_line_count) | |
557 { | |
558 (void)syn_finish_line(FALSE); | |
559 if (!current_state_stored) | |
560 { | |
561 ++current_lnum; | |
1512 | 562 (void)store_current_state(); |
7 | 563 } |
564 | |
565 /* | |
566 * If the current_lnum is now the same as "lnum", keep the current | |
567 * state (this happens very often!). Otherwise invalidate | |
568 * current_state and figure it out below. | |
569 */ | |
570 if (current_lnum != lnum) | |
571 invalidate_current_state(); | |
572 } | |
573 else | |
574 invalidate_current_state(); | |
575 | |
576 /* | |
577 * Try to synchronize from a saved state in b_sst_array[]. | |
578 * Only do this if lnum is not before and not to far beyond a saved state. | |
579 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
580 if (INVALID_STATE(¤t_state) && syn_block->b_sst_array != NULL) |
7 | 581 { |
582 /* Find last valid saved state before start_lnum. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
583 for (p = syn_block->b_sst_first; p != NULL; p = p->sst_next) |
7 | 584 { |
585 if (p->sst_lnum > lnum) | |
586 break; | |
587 if (p->sst_lnum <= lnum && p->sst_change_lnum == 0) | |
588 { | |
589 last_valid = p; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
590 if (p->sst_lnum >= lnum - syn_block->b_syn_sync_minlines) |
7 | 591 last_min_valid = p; |
592 } | |
593 } | |
594 if (last_min_valid != NULL) | |
595 load_current_state(last_min_valid); | |
596 } | |
597 | |
598 /* | |
599 * If "lnum" is before or far beyond a line with a saved state, need to | |
600 * re-synchronize. | |
601 */ | |
602 if (INVALID_STATE(¤t_state)) | |
603 { | |
604 syn_sync(wp, lnum, last_valid); | |
2906 | 605 if (current_lnum == 1) |
606 /* First line is always valid, no matter "minlines". */ | |
607 first_stored = 1; | |
608 else | |
609 /* Need to parse "minlines" lines before state can be considered | |
610 * valid to store. */ | |
611 first_stored = current_lnum + syn_block->b_syn_sync_minlines; | |
7 | 612 } |
613 else | |
614 first_stored = current_lnum; | |
615 | |
616 /* | |
617 * Advance from the sync point or saved state until the current line. | |
618 * Save some entries for syncing with later on. | |
619 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
620 if (syn_block->b_sst_len <= Rows) |
819 | 621 dist = 999999; |
622 else | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
623 dist = syn_buf->b_ml.ml_line_count / (syn_block->b_sst_len - Rows) + 1; |
7 | 624 while (current_lnum < lnum) |
625 { | |
626 syn_start_line(); | |
627 (void)syn_finish_line(FALSE); | |
628 ++current_lnum; | |
629 | |
630 /* If we parsed at least "minlines" lines or started at a valid | |
631 * state, the current state is considered valid. */ | |
632 if (current_lnum >= first_stored) | |
633 { | |
634 /* Check if the saved state entry is for the current line and is | |
635 * equal to the current state. If so, then validate all saved | |
636 * states that depended on a change before the parsed line. */ | |
637 if (prev == NULL) | |
1512 | 638 prev = syn_stack_find_entry(current_lnum - 1); |
639 if (prev == NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
640 sp = syn_block->b_sst_first; |
7 | 641 else |
1512 | 642 sp = prev; |
643 while (sp != NULL && sp->sst_lnum < current_lnum) | |
644 sp = sp->sst_next; | |
7 | 645 if (sp != NULL |
646 && sp->sst_lnum == current_lnum | |
647 && syn_stack_equal(sp)) | |
648 { | |
649 parsed_lnum = current_lnum; | |
650 prev = sp; | |
651 while (sp != NULL && sp->sst_change_lnum <= parsed_lnum) | |
652 { | |
653 if (sp->sst_lnum <= lnum) | |
654 /* valid state before desired line, use this one */ | |
655 prev = sp; | |
656 else if (sp->sst_change_lnum == 0) | |
657 /* past saved states depending on change, break here. */ | |
658 break; | |
659 sp->sst_change_lnum = 0; | |
660 sp = sp->sst_next; | |
661 } | |
662 load_current_state(prev); | |
663 } | |
664 /* Store the state at this line when it's the first one, the line | |
665 * where we start parsing, or some distance from the previously | |
666 * saved state. But only when parsed at least 'minlines'. */ | |
667 else if (prev == NULL | |
668 || current_lnum == lnum | |
669 || current_lnum >= prev->sst_lnum + dist) | |
1512 | 670 prev = store_current_state(); |
7 | 671 } |
672 | |
673 /* This can take a long time: break when CTRL-C pressed. The current | |
674 * state will be wrong then. */ | |
675 line_breakcheck(); | |
676 if (got_int) | |
677 { | |
678 current_lnum = lnum; | |
679 break; | |
680 } | |
681 } | |
682 | |
683 syn_start_line(); | |
684 } | |
685 | |
686 /* | |
687 * We cannot simply discard growarrays full of state_items or buf_states; we | |
688 * have to manually release their extmatch pointers first. | |
689 */ | |
690 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
691 clear_syn_state(synstate_T *p) |
7 | 692 { |
693 int i; | |
694 garray_T *gap; | |
695 | |
696 if (p->sst_stacksize > SST_FIX_STATES) | |
697 { | |
698 gap = &(p->sst_union.sst_ga); | |
699 for (i = 0; i < gap->ga_len; i++) | |
700 unref_extmatch(SYN_STATE_P(gap)[i].bs_extmatch); | |
701 ga_clear(gap); | |
702 } | |
703 else | |
704 { | |
705 for (i = 0; i < p->sst_stacksize; i++) | |
706 unref_extmatch(p->sst_union.sst_stack[i].bs_extmatch); | |
707 } | |
708 } | |
709 | |
710 /* | |
711 * Cleanup the current_state stack. | |
712 */ | |
713 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
714 clear_current_state(void) |
7 | 715 { |
716 int i; | |
717 stateitem_T *sip; | |
718 | |
719 sip = (stateitem_T *)(current_state.ga_data); | |
720 for (i = 0; i < current_state.ga_len; i++) | |
721 unref_extmatch(sip[i].si_extmatch); | |
722 ga_clear(¤t_state); | |
723 } | |
724 | |
725 /* | |
726 * Try to find a synchronisation point for line "lnum". | |
727 * | |
728 * This sets current_lnum and the current state. One of three methods is | |
729 * used: | |
730 * 1. Search backwards for the end of a C-comment. | |
731 * 2. Search backwards for given sync patterns. | |
732 * 3. Simply start on a given number of lines above "lnum". | |
733 */ | |
734 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
735 syn_sync( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
736 win_T *wp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
737 linenr_T start_lnum, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
738 synstate_T *last_valid) |
7 | 739 { |
740 buf_T *curbuf_save; | |
741 win_T *curwin_save; | |
742 pos_T cursor_save; | |
743 int idx; | |
744 linenr_T lnum; | |
745 linenr_T end_lnum; | |
746 linenr_T break_lnum; | |
747 int had_sync_point; | |
748 stateitem_T *cur_si; | |
749 synpat_T *spp; | |
750 char_u *line; | |
751 int found_flags = 0; | |
752 int found_match_idx = 0; | |
753 linenr_T found_current_lnum = 0; | |
754 int found_current_col= 0; | |
755 lpos_T found_m_endpos; | |
442 | 756 colnr_T prev_current_col; |
7 | 757 |
758 /* | |
759 * Clear any current state that might be hanging around. | |
760 */ | |
761 invalidate_current_state(); | |
762 | |
763 /* | |
764 * Start at least "minlines" back. Default starting point for parsing is | |
765 * there. | |
766 * Start further back, to avoid that scrolling backwards will result in | |
767 * resyncing for every line. Now it resyncs only one out of N lines, | |
768 * where N is minlines * 1.5, or minlines * 2 if minlines is small. | |
769 * Watch out for overflow when minlines is MAXLNUM. | |
770 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
771 if (syn_block->b_syn_sync_minlines > start_lnum) |
7 | 772 start_lnum = 1; |
773 else | |
774 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
775 if (syn_block->b_syn_sync_minlines == 1) |
7 | 776 lnum = 1; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
777 else if (syn_block->b_syn_sync_minlines < 10) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
778 lnum = syn_block->b_syn_sync_minlines * 2; |
7 | 779 else |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
780 lnum = syn_block->b_syn_sync_minlines * 3 / 2; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
781 if (syn_block->b_syn_sync_maxlines != 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
782 && lnum > syn_block->b_syn_sync_maxlines) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
783 lnum = syn_block->b_syn_sync_maxlines; |
7 | 784 if (lnum >= start_lnum) |
785 start_lnum = 1; | |
786 else | |
787 start_lnum -= lnum; | |
788 } | |
789 current_lnum = start_lnum; | |
790 | |
791 /* | |
792 * 1. Search backwards for the end of a C-style comment. | |
793 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
794 if (syn_block->b_syn_sync_flags & SF_CCOMMENT) |
7 | 795 { |
796 /* Need to make syn_buf the current buffer for a moment, to be able to | |
797 * use find_start_comment(). */ | |
798 curwin_save = curwin; | |
799 curwin = wp; | |
800 curbuf_save = curbuf; | |
801 curbuf = syn_buf; | |
802 | |
803 /* | |
804 * Skip lines that end in a backslash. | |
805 */ | |
806 for ( ; start_lnum > 1; --start_lnum) | |
807 { | |
808 line = ml_get(start_lnum - 1); | |
809 if (*line == NUL || *(line + STRLEN(line) - 1) != '\\') | |
810 break; | |
811 } | |
812 current_lnum = start_lnum; | |
813 | |
814 /* set cursor to start of search */ | |
815 cursor_save = wp->w_cursor; | |
816 wp->w_cursor.lnum = start_lnum; | |
817 wp->w_cursor.col = 0; | |
818 | |
819 /* | |
820 * If the line is inside a comment, need to find the syntax item that | |
821 * defines the comment. | |
822 * Restrict the search for the end of a comment to b_syn_sync_maxlines. | |
823 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
824 if (find_start_comment((int)syn_block->b_syn_sync_maxlines) != NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
825 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
826 for (idx = syn_block->b_syn_patterns.ga_len; --idx >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
827 if (SYN_ITEMS(syn_block)[idx].sp_syn.id |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
828 == syn_block->b_syn_sync_id |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
829 && SYN_ITEMS(syn_block)[idx].sp_type == SPTYPE_START) |
7 | 830 { |
831 validate_current_state(); | |
832 if (push_current_state(idx) == OK) | |
833 update_si_attr(current_state.ga_len - 1); | |
834 break; | |
835 } | |
836 } | |
837 | |
838 /* restore cursor and buffer */ | |
839 wp->w_cursor = cursor_save; | |
840 curwin = curwin_save; | |
841 curbuf = curbuf_save; | |
842 } | |
843 | |
844 /* | |
845 * 2. Search backwards for given sync patterns. | |
846 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
847 else if (syn_block->b_syn_sync_flags & SF_MATCH) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
848 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
849 if (syn_block->b_syn_sync_maxlines != 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
850 && start_lnum > syn_block->b_syn_sync_maxlines) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
851 break_lnum = start_lnum - syn_block->b_syn_sync_maxlines; |
7 | 852 else |
853 break_lnum = 0; | |
854 | |
699 | 855 found_m_endpos.lnum = 0; |
856 found_m_endpos.col = 0; | |
7 | 857 end_lnum = start_lnum; |
858 lnum = start_lnum; | |
859 while (--lnum > break_lnum) | |
860 { | |
861 /* This can take a long time: break when CTRL-C pressed. */ | |
862 line_breakcheck(); | |
863 if (got_int) | |
864 { | |
865 invalidate_current_state(); | |
866 current_lnum = start_lnum; | |
867 break; | |
868 } | |
869 | |
870 /* Check if we have run into a valid saved state stack now. */ | |
871 if (last_valid != NULL && lnum == last_valid->sst_lnum) | |
872 { | |
873 load_current_state(last_valid); | |
874 break; | |
875 } | |
876 | |
877 /* | |
878 * Check if the previous line has the line-continuation pattern. | |
879 */ | |
880 if (lnum > 1 && syn_match_linecont(lnum - 1)) | |
881 continue; | |
882 | |
883 /* | |
884 * Start with nothing on the state stack | |
885 */ | |
886 validate_current_state(); | |
887 | |
888 for (current_lnum = lnum; current_lnum < end_lnum; ++current_lnum) | |
889 { | |
890 syn_start_line(); | |
891 for (;;) | |
892 { | |
893 had_sync_point = syn_finish_line(TRUE); | |
894 /* | |
895 * When a sync point has been found, remember where, and | |
896 * continue to look for another one, further on in the line. | |
897 */ | |
898 if (had_sync_point && current_state.ga_len) | |
899 { | |
900 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
901 if (cur_si->si_m_endpos.lnum > start_lnum) | |
902 { | |
903 /* ignore match that goes to after where started */ | |
904 current_lnum = end_lnum; | |
905 break; | |
906 } | |
1371 | 907 if (cur_si->si_idx < 0) |
908 { | |
909 /* Cannot happen? */ | |
910 found_flags = 0; | |
911 found_match_idx = KEYWORD_IDX; | |
912 } | |
913 else | |
914 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
915 spp = &(SYN_ITEMS(syn_block)[cur_si->si_idx]); |
1371 | 916 found_flags = spp->sp_flags; |
917 found_match_idx = spp->sp_sync_idx; | |
918 } | |
7 | 919 found_current_lnum = current_lnum; |
920 found_current_col = current_col; | |
921 found_m_endpos = cur_si->si_m_endpos; | |
922 /* | |
923 * Continue after the match (be aware of a zero-length | |
924 * match). | |
925 */ | |
926 if (found_m_endpos.lnum > current_lnum) | |
927 { | |
928 current_lnum = found_m_endpos.lnum; | |
929 current_col = found_m_endpos.col; | |
930 if (current_lnum >= end_lnum) | |
931 break; | |
932 } | |
933 else if (found_m_endpos.col > current_col) | |
934 current_col = found_m_endpos.col; | |
935 else | |
936 ++current_col; | |
937 | |
938 /* syn_current_attr() will have skipped the check for | |
442 | 939 * an item that ends here, need to do that now. Be |
940 * careful not to go past the NUL. */ | |
941 prev_current_col = current_col; | |
942 if (syn_getcurline()[current_col] != NUL) | |
943 ++current_col; | |
7 | 944 check_state_ends(); |
442 | 945 current_col = prev_current_col; |
7 | 946 } |
947 else | |
948 break; | |
949 } | |
950 } | |
951 | |
952 /* | |
953 * If a sync point was encountered, break here. | |
954 */ | |
955 if (found_flags) | |
956 { | |
957 /* | |
958 * Put the item that was specified by the sync point on the | |
959 * state stack. If there was no item specified, make the | |
960 * state stack empty. | |
961 */ | |
962 clear_current_state(); | |
963 if (found_match_idx >= 0 | |
964 && push_current_state(found_match_idx) == OK) | |
965 update_si_attr(current_state.ga_len - 1); | |
966 | |
967 /* | |
968 * When using "grouphere", continue from the sync point | |
969 * match, until the end of the line. Parsing starts at | |
970 * the next line. | |
971 * For "groupthere" the parsing starts at start_lnum. | |
972 */ | |
973 if (found_flags & HL_SYNC_HERE) | |
974 { | |
975 if (current_state.ga_len) | |
976 { | |
977 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
978 cur_si->si_h_startpos.lnum = found_current_lnum; | |
979 cur_si->si_h_startpos.col = found_current_col; | |
980 update_si_end(cur_si, (int)current_col, TRUE); | |
981 check_keepend(); | |
982 } | |
983 current_col = found_m_endpos.col; | |
984 current_lnum = found_m_endpos.lnum; | |
985 (void)syn_finish_line(FALSE); | |
986 ++current_lnum; | |
987 } | |
988 else | |
989 current_lnum = start_lnum; | |
990 | |
991 break; | |
992 } | |
993 | |
994 end_lnum = lnum; | |
995 invalidate_current_state(); | |
996 } | |
997 | |
998 /* Ran into start of the file or exceeded maximum number of lines */ | |
999 if (lnum <= break_lnum) | |
1000 { | |
1001 invalidate_current_state(); | |
1002 current_lnum = break_lnum + 1; | |
1003 } | |
1004 } | |
1005 | |
1006 validate_current_state(); | |
1007 } | |
1008 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1009 static void |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1010 save_chartab(char_u *chartab) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1011 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1012 if (syn_block->b_syn_isk != empty_option) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1013 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1014 mch_memmove(chartab, syn_buf->b_chartab, (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1015 mch_memmove(syn_buf->b_chartab, syn_win->w_s->b_syn_chartab, |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1016 (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1017 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1018 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1019 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1020 static void |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1021 restore_chartab(char_u *chartab) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1022 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1023 if (syn_win->w_s->b_syn_isk != empty_option) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1024 mch_memmove(syn_buf->b_chartab, chartab, (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1025 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1026 |
7 | 1027 /* |
1028 * Return TRUE if the line-continuation pattern matches in line "lnum". | |
1029 */ | |
1030 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1031 syn_match_linecont(linenr_T lnum) |
7 | 1032 { |
1033 regmmatch_T regmatch; | |
6375 | 1034 int r; |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1035 char_u buf_chartab[32]; /* chartab array for syn iskyeyword */ |
7 | 1036 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1037 if (syn_block->b_syn_linecont_prog != NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1038 { |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1039 /* use syntax iskeyword option */ |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1040 save_chartab(buf_chartab); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1041 regmatch.rmm_ic = syn_block->b_syn_linecont_ic; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1042 regmatch.regprog = syn_block->b_syn_linecont_prog; |
6375 | 1043 r = syn_regexec(®match, lnum, (colnr_T)0, |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
1044 IF_SYN_TIME(&syn_block->b_syn_linecont_time)); |
6375 | 1045 syn_block->b_syn_linecont_prog = regmatch.regprog; |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1046 restore_chartab(buf_chartab); |
6375 | 1047 return r; |
7 | 1048 } |
1049 return FALSE; | |
1050 } | |
1051 | |
1052 /* | |
1053 * Prepare the current state for the start of a line. | |
1054 */ | |
1055 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1056 syn_start_line(void) |
7 | 1057 { |
1058 current_finished = FALSE; | |
1059 current_col = 0; | |
1060 | |
1061 /* | |
1062 * Need to update the end of a start/skip/end that continues from the | |
1063 * previous line and regions that have "keepend". | |
1064 */ | |
1065 if (current_state.ga_len > 0) | |
2863 | 1066 { |
7 | 1067 syn_update_ends(TRUE); |
2863 | 1068 check_state_ends(); |
1069 } | |
7 | 1070 |
1071 next_match_idx = -1; | |
1072 ++current_line_id; | |
11581
2298fda621d3
patch 8.0.0673: build failure without conceal feature
Christian Brabandt <cb@256bit.org>
parents:
11579
diff
changeset
|
1073 #ifdef FEAT_CONCEAL |
11579
52e3a77c097b
patch 8.0.0672: third item of synconcealed() changes too often
Christian Brabandt <cb@256bit.org>
parents:
11541
diff
changeset
|
1074 next_seqnr = 1; |
11581
2298fda621d3
patch 8.0.0673: build failure without conceal feature
Christian Brabandt <cb@256bit.org>
parents:
11579
diff
changeset
|
1075 #endif |
7 | 1076 } |
1077 | |
1078 /* | |
1079 * Check for items in the stack that need their end updated. | |
1080 * When "startofline" is TRUE the last item is always updated. | |
1081 * When "startofline" is FALSE the item with "keepend" is forcefully updated. | |
1082 */ | |
1083 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1084 syn_update_ends(int startofline) |
7 | 1085 { |
1086 stateitem_T *cur_si; | |
1087 int i; | |
991 | 1088 int seen_keepend; |
7 | 1089 |
1090 if (startofline) | |
1091 { | |
1092 /* Check for a match carried over from a previous line with a | |
1093 * contained region. The match ends as soon as the region ends. */ | |
1094 for (i = 0; i < current_state.ga_len; ++i) | |
1095 { | |
1096 cur_si = &CUR_STATE(i); | |
1097 if (cur_si->si_idx >= 0 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1098 && (SYN_ITEMS(syn_block)[cur_si->si_idx]).sp_type |
7 | 1099 == SPTYPE_MATCH |
1100 && cur_si->si_m_endpos.lnum < current_lnum) | |
1101 { | |
1102 cur_si->si_flags |= HL_MATCHCONT; | |
1103 cur_si->si_m_endpos.lnum = 0; | |
1104 cur_si->si_m_endpos.col = 0; | |
1105 cur_si->si_h_endpos = cur_si->si_m_endpos; | |
1106 cur_si->si_ends = TRUE; | |
1107 } | |
1108 } | |
1109 } | |
1110 | |
1111 /* | |
1112 * Need to update the end of a start/skip/end that continues from the | |
1113 * previous line. And regions that have "keepend", because they may | |
991 | 1114 * influence contained items. If we've just removed "extend" |
1115 * (startofline == 0) then we should update ends of normal regions | |
1116 * contained inside "keepend" because "extend" could have extended | |
1117 * these "keepend" regions as well as contained normal regions. | |
7 | 1118 * Then check for items ending in column 0. |
1119 */ | |
1120 i = current_state.ga_len - 1; | |
1121 if (keepend_level >= 0) | |
1122 for ( ; i > keepend_level; --i) | |
1123 if (CUR_STATE(i).si_flags & HL_EXTEND) | |
1124 break; | |
991 | 1125 |
1126 seen_keepend = FALSE; | |
7 | 1127 for ( ; i < current_state.ga_len; ++i) |
1128 { | |
1129 cur_si = &CUR_STATE(i); | |
1130 if ((cur_si->si_flags & HL_KEEPEND) | |
991 | 1131 || (seen_keepend && !startofline) |
7 | 1132 || (i == current_state.ga_len - 1 && startofline)) |
1133 { | |
1134 cur_si->si_h_startpos.col = 0; /* start highl. in col 0 */ | |
1135 cur_si->si_h_startpos.lnum = current_lnum; | |
1136 | |
1137 if (!(cur_si->si_flags & HL_MATCHCONT)) | |
1138 update_si_end(cur_si, (int)current_col, !startofline); | |
991 | 1139 |
1140 if (!startofline && (cur_si->si_flags & HL_KEEPEND)) | |
1141 seen_keepend = TRUE; | |
7 | 1142 } |
1143 } | |
1144 check_keepend(); | |
1145 } | |
1146 | |
1147 /**************************************** | |
1148 * Handling of the state stack cache. | |
1149 */ | |
1150 | |
1151 /* | |
1152 * EXPLANATION OF THE SYNTAX STATE STACK CACHE | |
1153 * | |
1154 * To speed up syntax highlighting, the state stack for the start of some | |
1155 * lines is cached. These entries can be used to start parsing at that point. | |
1156 * | |
1157 * The stack is kept in b_sst_array[] for each buffer. There is a list of | |
1158 * valid entries. b_sst_first points to the first one, then follow sst_next. | |
1159 * The entries are sorted on line number. The first entry is often for line 2 | |
1160 * (line 1 always starts with an empty stack). | |
1161 * There is also a list for free entries. This construction is used to avoid | |
1162 * having to allocate and free memory blocks too often. | |
1163 * | |
1164 * When making changes to the buffer, this is logged in b_mod_*. When calling | |
1165 * update_screen() to update the display, it will call | |
1166 * syn_stack_apply_changes() for each displayed buffer to adjust the cached | |
1167 * entries. The entries which are inside the changed area are removed, | |
1168 * because they must be recomputed. Entries below the changed have their line | |
1169 * number adjusted for deleted/inserted lines, and have their sst_change_lnum | |
1170 * set to indicate that a check must be made if the changed lines would change | |
1171 * the cached entry. | |
1172 * | |
1173 * When later displaying lines, an entry is stored for each line. Displayed | |
1174 * lines are likely to be displayed again, in which case the state at the | |
1175 * start of the line is needed. | |
1176 * For not displayed lines, an entry is stored for every so many lines. These | |
1177 * entries will be used e.g., when scrolling backwards. The distance between | |
1178 * entries depends on the number of lines in the buffer. For small buffers | |
1179 * the distance is fixed at SST_DIST, for large buffers there is a fixed | |
1180 * number of entries SST_MAX_ENTRIES, and the distance is computed. | |
1181 */ | |
1182 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1183 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1184 syn_stack_free_block(synblock_T *block) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1185 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1186 synstate_T *p; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1187 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1188 if (block->b_sst_array != NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1189 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1190 for (p = block->b_sst_first; p != NULL; p = p->sst_next) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1191 clear_syn_state(p); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
1192 VIM_CLEAR(block->b_sst_array); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1193 block->b_sst_len = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1194 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1195 } |
7 | 1196 /* |
1197 * Free b_sst_array[] for buffer "buf". | |
1198 * Used when syntax items changed to force resyncing everywhere. | |
1199 */ | |
1200 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1201 syn_stack_free_all(synblock_T *block) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1202 { |
11073
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
1203 #ifdef FEAT_FOLDING |
7 | 1204 win_T *wp; |
11073
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
1205 #endif |
7 | 1206 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1207 syn_stack_free_block(block); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1208 |
7 | 1209 #ifdef FEAT_FOLDING |
1210 /* When using "syntax" fold method, must update all folds. */ | |
1211 FOR_ALL_WINDOWS(wp) | |
1212 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1213 if (wp->w_s == block && foldmethodIsSyntax(wp)) |
7 | 1214 foldUpdateAll(wp); |
1215 } | |
1216 #endif | |
1217 } | |
1218 | |
1219 /* | |
1220 * Allocate the syntax state stack for syn_buf when needed. | |
1221 * If the number of entries in b_sst_array[] is much too big or a bit too | |
1222 * small, reallocate it. | |
1223 * Also used to allocate b_sst_array[] for the first time. | |
1224 */ | |
1225 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1226 syn_stack_alloc(void) |
7 | 1227 { |
1228 long len; | |
1229 synstate_T *to, *from; | |
1230 synstate_T *sstp; | |
1231 | |
1232 len = syn_buf->b_ml.ml_line_count / SST_DIST + Rows * 2; | |
1233 if (len < SST_MIN_ENTRIES) | |
1234 len = SST_MIN_ENTRIES; | |
1235 else if (len > SST_MAX_ENTRIES) | |
1236 len = SST_MAX_ENTRIES; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1237 if (syn_block->b_sst_len > len * 2 || syn_block->b_sst_len < len) |
7 | 1238 { |
1239 /* Allocate 50% too much, to avoid reallocating too often. */ | |
1240 len = syn_buf->b_ml.ml_line_count; | |
1241 len = (len + len / 2) / SST_DIST + Rows * 2; | |
1242 if (len < SST_MIN_ENTRIES) | |
1243 len = SST_MIN_ENTRIES; | |
1244 else if (len > SST_MAX_ENTRIES) | |
1245 len = SST_MAX_ENTRIES; | |
1246 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1247 if (syn_block->b_sst_array != NULL) |
7 | 1248 { |
1249 /* When shrinking the array, cleanup the existing stack. | |
1250 * Make sure that all valid entries fit in the new array. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1251 while (syn_block->b_sst_len - syn_block->b_sst_freecount + 2 > len |
7 | 1252 && syn_stack_cleanup()) |
1253 ; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1254 if (len < syn_block->b_sst_len - syn_block->b_sst_freecount + 2) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1255 len = syn_block->b_sst_len - syn_block->b_sst_freecount + 2; |
7 | 1256 } |
1257 | |
1258 sstp = (synstate_T *)alloc_clear((unsigned)(len * sizeof(synstate_T))); | |
1259 if (sstp == NULL) /* out of memory! */ | |
1260 return; | |
1261 | |
1262 to = sstp - 1; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1263 if (syn_block->b_sst_array != NULL) |
7 | 1264 { |
1265 /* Move the states from the old array to the new one. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1266 for (from = syn_block->b_sst_first; from != NULL; |
7 | 1267 from = from->sst_next) |
1268 { | |
1269 ++to; | |
1270 *to = *from; | |
1271 to->sst_next = to + 1; | |
1272 } | |
1273 } | |
1274 if (to != sstp - 1) | |
1275 { | |
1276 to->sst_next = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1277 syn_block->b_sst_first = sstp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1278 syn_block->b_sst_freecount = len - (int)(to - sstp) - 1; |
7 | 1279 } |
1280 else | |
1281 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1282 syn_block->b_sst_first = NULL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1283 syn_block->b_sst_freecount = len; |
7 | 1284 } |
1285 | |
1286 /* Create the list of free entries. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1287 syn_block->b_sst_firstfree = to + 1; |
7 | 1288 while (++to < sstp + len) |
1289 to->sst_next = to + 1; | |
1290 (sstp + len - 1)->sst_next = NULL; | |
1291 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1292 vim_free(syn_block->b_sst_array); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1293 syn_block->b_sst_array = sstp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1294 syn_block->b_sst_len = len; |
7 | 1295 } |
1296 } | |
1297 | |
1298 /* | |
1299 * Check for changes in a buffer to affect stored syntax states. Uses the | |
1300 * b_mod_* fields. | |
1301 * Called from update_screen(), before screen is being updated, once for each | |
1302 * displayed buffer. | |
1303 */ | |
1304 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1305 syn_stack_apply_changes(buf_T *buf) |
7 | 1306 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1307 win_T *wp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1308 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1309 syn_stack_apply_changes_block(&buf->b_s, buf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1310 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1311 FOR_ALL_WINDOWS(wp) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1312 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1313 if ((wp->w_buffer == buf) && (wp->w_s != &buf->b_s)) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1314 syn_stack_apply_changes_block(wp->w_s, buf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1315 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1316 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1317 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1318 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1319 syn_stack_apply_changes_block(synblock_T *block, buf_T *buf) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1320 { |
7 | 1321 synstate_T *p, *prev, *np; |
1322 linenr_T n; | |
1323 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1324 if (block->b_sst_array == NULL) /* nothing to do */ |
7 | 1325 return; |
1326 | |
1327 prev = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1328 for (p = block->b_sst_first; p != NULL; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1329 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1330 if (p->sst_lnum + block->b_syn_sync_linebreaks > buf->b_mod_top) |
7 | 1331 { |
1332 n = p->sst_lnum + buf->b_mod_xlines; | |
1333 if (n <= buf->b_mod_bot) | |
1334 { | |
1335 /* this state is inside the changed area, remove it */ | |
1336 np = p->sst_next; | |
1337 if (prev == NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1338 block->b_sst_first = np; |
7 | 1339 else |
1340 prev->sst_next = np; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1341 syn_stack_free_entry(block, p); |
7 | 1342 p = np; |
1343 continue; | |
1344 } | |
1345 /* This state is below the changed area. Remember the line | |
1346 * that needs to be parsed before this entry can be made valid | |
1347 * again. */ | |
1348 if (p->sst_change_lnum != 0 && p->sst_change_lnum > buf->b_mod_top) | |
1349 { | |
1350 if (p->sst_change_lnum + buf->b_mod_xlines > buf->b_mod_top) | |
1351 p->sst_change_lnum += buf->b_mod_xlines; | |
1352 else | |
1353 p->sst_change_lnum = buf->b_mod_top; | |
1354 } | |
1355 if (p->sst_change_lnum == 0 | |
1356 || p->sst_change_lnum < buf->b_mod_bot) | |
1357 p->sst_change_lnum = buf->b_mod_bot; | |
1358 | |
1359 p->sst_lnum = n; | |
1360 } | |
1361 prev = p; | |
1362 p = p->sst_next; | |
1363 } | |
1364 } | |
1365 | |
1366 /* | |
1367 * Reduce the number of entries in the state stack for syn_buf. | |
1368 * Returns TRUE if at least one entry was freed. | |
1369 */ | |
1370 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1371 syn_stack_cleanup(void) |
7 | 1372 { |
1373 synstate_T *p, *prev; | |
1374 disptick_T tick; | |
1375 int above; | |
1376 int dist; | |
1377 int retval = FALSE; | |
1378 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1379 if (syn_block->b_sst_array == NULL || syn_block->b_sst_first == NULL) |
7 | 1380 return retval; |
1381 | |
1382 /* Compute normal distance between non-displayed entries. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1383 if (syn_block->b_sst_len <= Rows) |
819 | 1384 dist = 999999; |
1385 else | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1386 dist = syn_buf->b_ml.ml_line_count / (syn_block->b_sst_len - Rows) + 1; |
7 | 1387 |
1388 /* | |
2020 | 1389 * Go through the list to find the "tick" for the oldest entry that can |
7 | 1390 * be removed. Set "above" when the "tick" for the oldest entry is above |
1391 * "b_sst_lasttick" (the display tick wraps around). | |
1392 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1393 tick = syn_block->b_sst_lasttick; |
7 | 1394 above = FALSE; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1395 prev = syn_block->b_sst_first; |
7 | 1396 for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) |
1397 { | |
1398 if (prev->sst_lnum + dist > p->sst_lnum) | |
1399 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1400 if (p->sst_tick > syn_block->b_sst_lasttick) |
7 | 1401 { |
1402 if (!above || p->sst_tick < tick) | |
1403 tick = p->sst_tick; | |
1404 above = TRUE; | |
1405 } | |
1406 else if (!above && p->sst_tick < tick) | |
1407 tick = p->sst_tick; | |
1408 } | |
1409 } | |
1410 | |
1411 /* | |
1412 * Go through the list to make the entries for the oldest tick at an | |
1413 * interval of several lines. | |
1414 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1415 prev = syn_block->b_sst_first; |
7 | 1416 for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) |
1417 { | |
1418 if (p->sst_tick == tick && prev->sst_lnum + dist > p->sst_lnum) | |
1419 { | |
1420 /* Move this entry from used list to free list */ | |
1421 prev->sst_next = p->sst_next; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1422 syn_stack_free_entry(syn_block, p); |
7 | 1423 p = prev; |
1424 retval = TRUE; | |
1425 } | |
1426 } | |
1427 return retval; | |
1428 } | |
1429 | |
1430 /* | |
1431 * Free the allocated memory for a syn_state item. | |
1432 * Move the entry into the free list. | |
1433 */ | |
1434 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1435 syn_stack_free_entry(synblock_T *block, synstate_T *p) |
7 | 1436 { |
1437 clear_syn_state(p); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1438 p->sst_next = block->b_sst_firstfree; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1439 block->b_sst_firstfree = p; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1440 ++block->b_sst_freecount; |
7 | 1441 } |
1442 | |
1443 /* | |
1444 * Find an entry in the list of state stacks at or before "lnum". | |
1445 * Returns NULL when there is no entry or the first entry is after "lnum". | |
1446 */ | |
1447 static synstate_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1448 syn_stack_find_entry(linenr_T lnum) |
7 | 1449 { |
1450 synstate_T *p, *prev; | |
1451 | |
1452 prev = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1453 for (p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next) |
7 | 1454 { |
1455 if (p->sst_lnum == lnum) | |
1456 return p; | |
1457 if (p->sst_lnum > lnum) | |
1458 break; | |
1459 } | |
1460 return prev; | |
1461 } | |
1462 | |
1463 /* | |
1464 * Try saving the current state in b_sst_array[]. | |
1465 * The current state must be valid for the start of the current_lnum line! | |
1466 */ | |
1467 static synstate_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1468 store_current_state(void) |
7 | 1469 { |
1470 int i; | |
1471 synstate_T *p; | |
1472 bufstate_T *bp; | |
1473 stateitem_T *cur_si; | |
1512 | 1474 synstate_T *sp = syn_stack_find_entry(current_lnum); |
7 | 1475 |
1476 /* | |
1477 * If the current state contains a start or end pattern that continues | |
1478 * from the previous line, we can't use it. Don't store it then. | |
1479 */ | |
1480 for (i = current_state.ga_len - 1; i >= 0; --i) | |
1481 { | |
1482 cur_si = &CUR_STATE(i); | |
1483 if (cur_si->si_h_startpos.lnum >= current_lnum | |
1484 || cur_si->si_m_endpos.lnum >= current_lnum | |
1485 || cur_si->si_h_endpos.lnum >= current_lnum | |
1486 || (cur_si->si_end_idx | |
1487 && cur_si->si_eoe_pos.lnum >= current_lnum)) | |
1488 break; | |
1489 } | |
1490 if (i >= 0) | |
1491 { | |
1492 if (sp != NULL) | |
1493 { | |
1494 /* find "sp" in the list and remove it */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1495 if (syn_block->b_sst_first == sp) |
7 | 1496 /* it's the first entry */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1497 syn_block->b_sst_first = sp->sst_next; |
7 | 1498 else |
1499 { | |
1500 /* find the entry just before this one to adjust sst_next */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1501 for (p = syn_block->b_sst_first; p != NULL; p = p->sst_next) |
7 | 1502 if (p->sst_next == sp) |
1503 break; | |
840 | 1504 if (p != NULL) /* just in case */ |
1505 p->sst_next = sp->sst_next; | |
7 | 1506 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1507 syn_stack_free_entry(syn_block, sp); |
7 | 1508 sp = NULL; |
1509 } | |
1510 } | |
1511 else if (sp == NULL || sp->sst_lnum != current_lnum) | |
1512 { | |
1513 /* | |
1514 * Add a new entry | |
1515 */ | |
1516 /* If no free items, cleanup the array first. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1517 if (syn_block->b_sst_freecount == 0) |
7 | 1518 { |
1519 (void)syn_stack_cleanup(); | |
1520 /* "sp" may have been moved to the freelist now */ | |
1521 sp = syn_stack_find_entry(current_lnum); | |
1522 } | |
1523 /* Still no free items? Must be a strange problem... */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1524 if (syn_block->b_sst_freecount == 0) |
7 | 1525 sp = NULL; |
1526 else | |
1527 { | |
1528 /* Take the first item from the free list and put it in the used | |
1529 * list, after *sp */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1530 p = syn_block->b_sst_firstfree; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1531 syn_block->b_sst_firstfree = p->sst_next; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1532 --syn_block->b_sst_freecount; |
7 | 1533 if (sp == NULL) |
1534 { | |
1535 /* Insert in front of the list */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1536 p->sst_next = syn_block->b_sst_first; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1537 syn_block->b_sst_first = p; |
7 | 1538 } |
1539 else | |
1540 { | |
1541 /* insert in list after *sp */ | |
1542 p->sst_next = sp->sst_next; | |
1543 sp->sst_next = p; | |
1544 } | |
1545 sp = p; | |
1546 sp->sst_stacksize = 0; | |
1547 sp->sst_lnum = current_lnum; | |
1548 } | |
1549 } | |
1550 if (sp != NULL) | |
1551 { | |
1552 /* When overwriting an existing state stack, clear it first */ | |
1553 clear_syn_state(sp); | |
1554 sp->sst_stacksize = current_state.ga_len; | |
1555 if (current_state.ga_len > SST_FIX_STATES) | |
1556 { | |
1557 /* Need to clear it, might be something remaining from when the | |
1558 * length was less than SST_FIX_STATES. */ | |
1559 ga_init2(&sp->sst_union.sst_ga, (int)sizeof(bufstate_T), 1); | |
1560 if (ga_grow(&sp->sst_union.sst_ga, current_state.ga_len) == FAIL) | |
1561 sp->sst_stacksize = 0; | |
1562 else | |
1563 sp->sst_union.sst_ga.ga_len = current_state.ga_len; | |
1564 bp = SYN_STATE_P(&(sp->sst_union.sst_ga)); | |
1565 } | |
1566 else | |
1567 bp = sp->sst_union.sst_stack; | |
1568 for (i = 0; i < sp->sst_stacksize; ++i) | |
1569 { | |
1570 bp[i].bs_idx = CUR_STATE(i).si_idx; | |
1571 bp[i].bs_flags = CUR_STATE(i).si_flags; | |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1572 #ifdef FEAT_CONCEAL |
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1573 bp[i].bs_seqnr = CUR_STATE(i).si_seqnr; |
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1574 bp[i].bs_cchar = CUR_STATE(i).si_cchar; |
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1575 #endif |
7 | 1576 bp[i].bs_extmatch = ref_extmatch(CUR_STATE(i).si_extmatch); |
1577 } | |
1578 sp->sst_next_flags = current_next_flags; | |
1579 sp->sst_next_list = current_next_list; | |
1580 sp->sst_tick = display_tick; | |
1581 sp->sst_change_lnum = 0; | |
1582 } | |
1583 current_state_stored = TRUE; | |
1584 return sp; | |
1585 } | |
1586 | |
1587 /* | |
1588 * Copy a state stack from "from" in b_sst_array[] to current_state; | |
1589 */ | |
1590 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1591 load_current_state(synstate_T *from) |
7 | 1592 { |
1593 int i; | |
1594 bufstate_T *bp; | |
1595 | |
1596 clear_current_state(); | |
1597 validate_current_state(); | |
1598 keepend_level = -1; | |
1599 if (from->sst_stacksize | |
1600 && ga_grow(¤t_state, from->sst_stacksize) != FAIL) | |
1601 { | |
1602 if (from->sst_stacksize > SST_FIX_STATES) | |
1603 bp = SYN_STATE_P(&(from->sst_union.sst_ga)); | |
1604 else | |
1605 bp = from->sst_union.sst_stack; | |
1606 for (i = 0; i < from->sst_stacksize; ++i) | |
1607 { | |
1608 CUR_STATE(i).si_idx = bp[i].bs_idx; | |
1609 CUR_STATE(i).si_flags = bp[i].bs_flags; | |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1610 #ifdef FEAT_CONCEAL |
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1611 CUR_STATE(i).si_seqnr = bp[i].bs_seqnr; |
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1612 CUR_STATE(i).si_cchar = bp[i].bs_cchar; |
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
1613 #endif |
7 | 1614 CUR_STATE(i).si_extmatch = ref_extmatch(bp[i].bs_extmatch); |
1615 if (keepend_level < 0 && (CUR_STATE(i).si_flags & HL_KEEPEND)) | |
1616 keepend_level = i; | |
1617 CUR_STATE(i).si_ends = FALSE; | |
1618 CUR_STATE(i).si_m_lnum = 0; | |
1619 if (CUR_STATE(i).si_idx >= 0) | |
1620 CUR_STATE(i).si_next_list = | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1621 (SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_next_list; |
7 | 1622 else |
1623 CUR_STATE(i).si_next_list = NULL; | |
1624 update_si_attr(i); | |
1625 } | |
1626 current_state.ga_len = from->sst_stacksize; | |
1627 } | |
1628 current_next_list = from->sst_next_list; | |
1629 current_next_flags = from->sst_next_flags; | |
1630 current_lnum = from->sst_lnum; | |
1631 } | |
1632 | |
1633 /* | |
1634 * Compare saved state stack "*sp" with the current state. | |
1635 * Return TRUE when they are equal. | |
1636 */ | |
1637 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1638 syn_stack_equal(synstate_T *sp) |
7 | 1639 { |
1640 int i, j; | |
1641 bufstate_T *bp; | |
1642 reg_extmatch_T *six, *bsx; | |
1643 | |
1644 /* First a quick check if the stacks have the same size end nextlist. */ | |
1645 if (sp->sst_stacksize == current_state.ga_len | |
1646 && sp->sst_next_list == current_next_list) | |
1647 { | |
1648 /* Need to compare all states on both stacks. */ | |
1649 if (sp->sst_stacksize > SST_FIX_STATES) | |
1650 bp = SYN_STATE_P(&(sp->sst_union.sst_ga)); | |
1651 else | |
1652 bp = sp->sst_union.sst_stack; | |
1653 | |
1654 for (i = current_state.ga_len; --i >= 0; ) | |
1655 { | |
1656 /* If the item has another index the state is different. */ | |
1657 if (bp[i].bs_idx != CUR_STATE(i).si_idx) | |
1658 break; | |
1659 if (bp[i].bs_extmatch != CUR_STATE(i).si_extmatch) | |
1660 { | |
1661 /* When the extmatch pointers are different, the strings in | |
1662 * them can still be the same. Check if the extmatch | |
1663 * references are equal. */ | |
1664 bsx = bp[i].bs_extmatch; | |
1665 six = CUR_STATE(i).si_extmatch; | |
1666 /* If one of the extmatch pointers is NULL the states are | |
1667 * different. */ | |
1668 if (bsx == NULL || six == NULL) | |
1669 break; | |
1670 for (j = 0; j < NSUBEXP; ++j) | |
1671 { | |
1672 /* Check each referenced match string. They must all be | |
1673 * equal. */ | |
1674 if (bsx->matches[j] != six->matches[j]) | |
1675 { | |
1676 /* If the pointer is different it can still be the | |
1677 * same text. Compare the strings, ignore case when | |
1678 * the start item has the sp_ic flag set. */ | |
1679 if (bsx->matches[j] == NULL | |
1680 || six->matches[j] == NULL) | |
1681 break; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1682 if ((SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_ic |
7 | 1683 ? MB_STRICMP(bsx->matches[j], |
1684 six->matches[j]) != 0 | |
1685 : STRCMP(bsx->matches[j], six->matches[j]) != 0) | |
1686 break; | |
1687 } | |
1688 } | |
1689 if (j != NSUBEXP) | |
1690 break; | |
1691 } | |
1692 } | |
1693 if (i < 0) | |
1694 return TRUE; | |
1695 } | |
1696 return FALSE; | |
1697 } | |
1698 | |
1699 /* | |
1700 * We stop parsing syntax above line "lnum". If the stored state at or below | |
1701 * this line depended on a change before it, it now depends on the line below | |
1702 * the last parsed line. | |
1703 * The window looks like this: | |
1704 * line which changed | |
1705 * displayed line | |
1706 * displayed line | |
1707 * lnum -> line below window | |
1708 */ | |
1709 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1710 syntax_end_parsing(linenr_T lnum) |
7 | 1711 { |
1712 synstate_T *sp; | |
1713 | |
1714 sp = syn_stack_find_entry(lnum); | |
1715 if (sp != NULL && sp->sst_lnum < lnum) | |
1716 sp = sp->sst_next; | |
1717 | |
1718 if (sp != NULL && sp->sst_change_lnum != 0) | |
1719 sp->sst_change_lnum = lnum; | |
1720 } | |
1721 | |
1722 /* | |
1723 * End of handling of the state stack. | |
1724 ****************************************/ | |
1725 | |
1726 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1727 invalidate_current_state(void) |
7 | 1728 { |
1729 clear_current_state(); | |
1730 current_state.ga_itemsize = 0; /* mark current_state invalid */ | |
1731 current_next_list = NULL; | |
1732 keepend_level = -1; | |
1733 } | |
1734 | |
1735 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1736 validate_current_state(void) |
7 | 1737 { |
1738 current_state.ga_itemsize = sizeof(stateitem_T); | |
1739 current_state.ga_growsize = 3; | |
1740 } | |
1741 | |
1742 /* | |
1743 * Return TRUE if the syntax at start of lnum changed since last time. | |
1744 * This will only be called just after get_syntax_attr() for the previous | |
1745 * line, to check if the next line needs to be redrawn too. | |
1746 */ | |
1747 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1748 syntax_check_changed(linenr_T lnum) |
7 | 1749 { |
1750 int retval = TRUE; | |
1751 synstate_T *sp; | |
1752 | |
1753 /* | |
1754 * Check the state stack when: | |
1755 * - lnum is just below the previously syntaxed line. | |
1756 * - lnum is not before the lines with saved states. | |
1757 * - lnum is not past the lines with saved states. | |
1758 * - lnum is at or before the last changed line. | |
1759 */ | |
1760 if (VALID_STATE(¤t_state) && lnum == current_lnum + 1) | |
1761 { | |
1762 sp = syn_stack_find_entry(lnum); | |
1763 if (sp != NULL && sp->sst_lnum == lnum) | |
1764 { | |
1765 /* | |
1766 * finish the previous line (needed when not all of the line was | |
1767 * drawn) | |
1768 */ | |
1769 (void)syn_finish_line(FALSE); | |
1770 | |
1771 /* | |
1772 * Compare the current state with the previously saved state of | |
1773 * the line. | |
1774 */ | |
1775 if (syn_stack_equal(sp)) | |
1776 retval = FALSE; | |
1777 | |
1778 /* | |
1779 * Store the current state in b_sst_array[] for later use. | |
1780 */ | |
1781 ++current_lnum; | |
1512 | 1782 (void)store_current_state(); |
7 | 1783 } |
1784 } | |
1785 | |
1786 return retval; | |
1787 } | |
1788 | |
1789 /* | |
1790 * Finish the current line. | |
1791 * This doesn't return any attributes, it only gets the state at the end of | |
1792 * the line. It can start anywhere in the line, as long as the current state | |
1793 * is valid. | |
1794 */ | |
1795 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1796 syn_finish_line( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1797 int syncing) /* called for syncing */ |
7 | 1798 { |
1799 stateitem_T *cur_si; | |
442 | 1800 colnr_T prev_current_col; |
7 | 1801 |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1802 while (!current_finished) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1803 { |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1804 (void)syn_current_attr(syncing, FALSE, NULL, FALSE); |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1805 /* |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1806 * When syncing, and found some item, need to check the item. |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1807 */ |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1808 if (syncing && current_state.ga_len) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1809 { |
7 | 1810 /* |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1811 * Check for match with sync item. |
7 | 1812 */ |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1813 cur_si = &CUR_STATE(current_state.ga_len - 1); |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1814 if (cur_si->si_idx >= 0 |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1815 && (SYN_ITEMS(syn_block)[cur_si->si_idx].sp_flags |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1816 & (HL_SYNC_HERE|HL_SYNC_THERE))) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1817 return TRUE; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1818 |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1819 /* syn_current_attr() will have skipped the check for an item |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1820 * that ends here, need to do that now. Be careful not to go |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1821 * past the NUL. */ |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1822 prev_current_col = current_col; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1823 if (syn_getcurline()[current_col] != NUL) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1824 ++current_col; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1825 check_state_ends(); |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1826 current_col = prev_current_col; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1827 } |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1828 ++current_col; |
7 | 1829 } |
1830 return FALSE; | |
1831 } | |
1832 | |
1833 /* | |
1834 * Return highlight attributes for next character. | |
1835 * Must first call syntax_start() once for the line. | |
1836 * "col" is normally 0 for the first use in a line, and increments by one each | |
1837 * time. It's allowed to skip characters and to stop before the end of the | |
1838 * line. But only a "col" after a previously used column is allowed. | |
221 | 1839 * When "can_spell" is not NULL set it to TRUE when spell-checking should be |
1840 * done. | |
7 | 1841 */ |
1842 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1843 get_syntax_attr( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1844 colnr_T col, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1845 int *can_spell, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1846 int keep_state) /* keep state of char at "col" */ |
7 | 1847 { |
1848 int attr = 0; | |
1849 | |
1363 | 1850 if (can_spell != NULL) |
1851 /* Default: Only do spelling when there is no @Spell cluster or when | |
1852 * ":syn spell toplevel" was used. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1853 *can_spell = syn_block->b_syn_spell == SYNSPL_DEFAULT |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1854 ? (syn_block->b_spell_cluster_id == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1855 : (syn_block->b_syn_spell == SYNSPL_TOP); |
1363 | 1856 |
7 | 1857 /* check for out of memory situation */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1858 if (syn_block->b_sst_array == NULL) |
7 | 1859 return 0; |
1860 | |
419 | 1861 /* After 'synmaxcol' the attribute is always zero. */ |
431 | 1862 if (syn_buf->b_p_smc > 0 && col >= (colnr_T)syn_buf->b_p_smc) |
419 | 1863 { |
1864 clear_current_state(); | |
1865 #ifdef FEAT_EVAL | |
1866 current_id = 0; | |
1867 current_trans_id = 0; | |
1868 #endif | |
2401
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
1869 #ifdef FEAT_CONCEAL |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
1870 current_flags = 0; |
11579
52e3a77c097b
patch 8.0.0672: third item of synconcealed() changes too often
Christian Brabandt <cb@256bit.org>
parents:
11541
diff
changeset
|
1871 current_seqnr = 0; |
2401
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
1872 #endif |
419 | 1873 return 0; |
1874 } | |
1875 | |
7 | 1876 /* Make sure current_state is valid */ |
1877 if (INVALID_STATE(¤t_state)) | |
1878 validate_current_state(); | |
1879 | |
1880 /* | |
1881 * Skip from the current column to "col", get the attributes for "col". | |
1882 */ | |
1883 while (current_col <= col) | |
1884 { | |
1504 | 1885 attr = syn_current_attr(FALSE, TRUE, can_spell, |
1886 current_col == col ? keep_state : FALSE); | |
7 | 1887 ++current_col; |
1888 } | |
1889 | |
1890 return attr; | |
1891 } | |
1892 | |
1893 /* | |
1894 * Get syntax attributes for current_lnum, current_col. | |
1895 */ | |
1896 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1897 syn_current_attr( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1898 int syncing, /* When 1: called for syncing */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1899 int displaying, /* result will be displayed */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1900 int *can_spell, /* return: do spell checking */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1901 int keep_state) /* keep syntax stack afterwards */ |
7 | 1902 { |
1903 int syn_id; | |
1904 lpos_T endpos; /* was: char_u *endp; */ | |
1905 lpos_T hl_startpos; /* was: int hl_startcol; */ | |
1906 lpos_T hl_endpos; | |
1907 lpos_T eos_pos; /* end-of-start match (start region) */ | |
1908 lpos_T eoe_pos; /* end-of-end pattern */ | |
1909 int end_idx; /* group ID for end pattern */ | |
1910 int idx; | |
1911 synpat_T *spp; | |
221 | 1912 stateitem_T *cur_si, *sip = NULL; |
7 | 1913 int startcol; |
1914 int endcol; | |
1915 long flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1916 int cchar; |
7 | 1917 short *next_list; |
1918 int found_match; /* found usable match */ | |
1919 static int try_next_column = FALSE; /* must try in next col */ | |
1920 int do_keywords; | |
1921 regmmatch_T regmatch; | |
1922 lpos_T pos; | |
1923 int lc_col; | |
1924 reg_extmatch_T *cur_extmatch = NULL; | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1925 char_u buf_chartab[32]; /* chartab array for syn iskyeyword */ |
7 | 1926 char_u *line; /* current line. NOTE: becomes invalid after |
1927 looking for a pattern match! */ | |
1928 | |
1929 /* variables for zero-width matches that have a "nextgroup" argument */ | |
1930 int keep_next_list; | |
1931 int zero_width_next_list = FALSE; | |
1932 garray_T zero_width_next_ga; | |
1933 | |
1934 /* | |
1935 * No character, no attributes! Past end of line? | |
1936 * Do try matching with an empty line (could be the start of a region). | |
1937 */ | |
1938 line = syn_getcurline(); | |
1939 if (line[current_col] == NUL && current_col != 0) | |
1940 { | |
1941 /* | |
1942 * If we found a match after the last column, use it. | |
1943 */ | |
1944 if (next_match_idx >= 0 && next_match_col >= (int)current_col | |
1945 && next_match_col != MAXCOL) | |
1946 (void)push_next_match(NULL); | |
1947 | |
1948 current_finished = TRUE; | |
1949 current_state_stored = FALSE; | |
1950 return 0; | |
1951 } | |
1952 | |
1953 /* if the current or next character is NUL, we will finish the line now */ | |
1954 if (line[current_col] == NUL || line[current_col + 1] == NUL) | |
1955 { | |
1956 current_finished = TRUE; | |
1957 current_state_stored = FALSE; | |
1958 } | |
1959 | |
1960 /* | |
1961 * When in the previous column there was a match but it could not be used | |
1962 * (empty match or already matched in this column) need to try again in | |
1963 * the next column. | |
1964 */ | |
1965 if (try_next_column) | |
1966 { | |
1967 next_match_idx = -1; | |
1968 try_next_column = FALSE; | |
1969 } | |
1970 | |
1971 /* Only check for keywords when not syncing and there are some. */ | |
1972 do_keywords = !syncing | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1973 && (syn_block->b_keywtab.ht_used > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1974 || syn_block->b_keywtab_ic.ht_used > 0); |
7 | 1975 |
1976 /* Init the list of zero-width matches with a nextlist. This is used to | |
1977 * avoid matching the same item in the same position twice. */ | |
1978 ga_init2(&zero_width_next_ga, (int)sizeof(int), 10); | |
1979 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1980 /* use syntax iskeyword option */ |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1981 save_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1982 |
7 | 1983 /* |
1984 * Repeat matching keywords and patterns, to find contained items at the | |
1985 * same column. This stops when there are no extra matches at the current | |
1986 * column. | |
1987 */ | |
1988 do | |
1989 { | |
1990 found_match = FALSE; | |
1991 keep_next_list = FALSE; | |
1992 syn_id = 0; | |
1993 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1994 |
7 | 1995 /* |
1996 * 1. Check for a current state. | |
1997 * Only when there is no current state, or if the current state may | |
1998 * contain other things, we need to check for keywords and patterns. | |
1999 * Always need to check for contained items if some item has the | |
2000 * "containedin" argument (takes extra time!). | |
2001 */ | |
2002 if (current_state.ga_len) | |
2003 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2004 else | |
2005 cur_si = NULL; | |
2006 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2007 if (syn_block->b_syn_containedin || cur_si == NULL |
7 | 2008 || cur_si->si_cont_list != NULL) |
2009 { | |
2010 /* | |
2011 * 2. Check for keywords, if on a keyword char after a non-keyword | |
2012 * char. Don't do this when syncing. | |
2013 */ | |
2014 if (do_keywords) | |
2015 { | |
2016 line = syn_getcurline(); | |
4043 | 2017 if (vim_iswordp_buf(line + current_col, syn_buf) |
7 | 2018 && (current_col == 0 |
4043 | 2019 || !vim_iswordp_buf(line + current_col - 1 |
7 | 2020 #ifdef FEAT_MBYTE |
2021 - (has_mbyte | |
2022 ? (*mb_head_off)(line, line + current_col - 1) | |
2023 : 0) | |
2024 #endif | |
2025 , syn_buf))) | |
2026 { | |
2027 syn_id = check_keyword_id(line, (int)current_col, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2028 &endcol, &flags, &next_list, cur_si, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2029 &cchar); |
205 | 2030 if (syn_id != 0) |
7 | 2031 { |
2032 if (push_current_state(KEYWORD_IDX) == OK) | |
2033 { | |
2034 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2035 cur_si->si_m_startcol = current_col; | |
2036 cur_si->si_h_startpos.lnum = current_lnum; | |
2037 cur_si->si_h_startpos.col = 0; /* starts right away */ | |
2038 cur_si->si_m_endpos.lnum = current_lnum; | |
2039 cur_si->si_m_endpos.col = endcol; | |
2040 cur_si->si_h_endpos.lnum = current_lnum; | |
2041 cur_si->si_h_endpos.col = endcol; | |
2042 cur_si->si_ends = TRUE; | |
2043 cur_si->si_end_idx = 0; | |
2044 cur_si->si_flags = flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2045 #ifdef FEAT_CONCEAL |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
2046 cur_si->si_seqnr = next_seqnr++; |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
2047 cur_si->si_cchar = cchar; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2048 if (current_state.ga_len > 1) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2049 cur_si->si_flags |= |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2050 CUR_STATE(current_state.ga_len - 2).si_flags |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2051 & HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2052 #endif |
7 | 2053 cur_si->si_id = syn_id; |
2054 cur_si->si_trans_id = syn_id; | |
2055 if (flags & HL_TRANSP) | |
2056 { | |
2057 if (current_state.ga_len < 2) | |
2058 { | |
2059 cur_si->si_attr = 0; | |
2060 cur_si->si_trans_id = 0; | |
2061 } | |
2062 else | |
2063 { | |
2064 cur_si->si_attr = CUR_STATE( | |
2065 current_state.ga_len - 2).si_attr; | |
2066 cur_si->si_trans_id = CUR_STATE( | |
2067 current_state.ga_len - 2).si_trans_id; | |
2068 } | |
2069 } | |
2070 else | |
2071 cur_si->si_attr = syn_id2attr(syn_id); | |
2072 cur_si->si_cont_list = NULL; | |
2073 cur_si->si_next_list = next_list; | |
2074 check_keepend(); | |
2075 } | |
2076 else | |
2077 vim_free(next_list); | |
2078 } | |
2079 } | |
2080 } | |
2081 | |
2082 /* | |
205 | 2083 * 3. Check for patterns (only if no keyword found). |
7 | 2084 */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2085 if (syn_id == 0 && syn_block->b_syn_patterns.ga_len) |
7 | 2086 { |
2087 /* | |
2088 * If we didn't check for a match yet, or we are past it, check | |
2089 * for any match with a pattern. | |
2090 */ | |
2091 if (next_match_idx < 0 || next_match_col < (int)current_col) | |
2092 { | |
2093 /* | |
2094 * Check all relevant patterns for a match at this | |
2095 * position. This is complicated, because matching with a | |
2096 * pattern takes quite a bit of time, thus we want to | |
2097 * avoid doing it when it's not needed. | |
2098 */ | |
2099 next_match_idx = 0; /* no match in this line yet */ | |
2100 next_match_col = MAXCOL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2101 for (idx = syn_block->b_syn_patterns.ga_len; --idx >= 0; ) |
7 | 2102 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2103 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 2104 if ( spp->sp_syncing == syncing |
2105 && (displaying || !(spp->sp_flags & HL_DISPLAY)) | |
2106 && (spp->sp_type == SPTYPE_MATCH | |
2107 || spp->sp_type == SPTYPE_START) | |
2108 && (current_next_list != NULL | |
2109 ? in_id_list(NULL, current_next_list, | |
2110 &spp->sp_syn, 0) | |
2111 : (cur_si == NULL | |
2112 ? !(spp->sp_flags & HL_CONTAINED) | |
2113 : in_id_list(cur_si, | |
2114 cur_si->si_cont_list, &spp->sp_syn, | |
2115 spp->sp_flags & HL_CONTAINED)))) | |
2116 { | |
6375 | 2117 int r; |
2118 | |
7 | 2119 /* If we already tried matching in this line, and |
2120 * there isn't a match before next_match_col, skip | |
2121 * this item. */ | |
2122 if (spp->sp_line_id == current_line_id | |
2123 && spp->sp_startcol >= next_match_col) | |
2124 continue; | |
2125 spp->sp_line_id = current_line_id; | |
2126 | |
2127 lc_col = current_col - spp->sp_offsets[SPO_LC_OFF]; | |
2128 if (lc_col < 0) | |
2129 lc_col = 0; | |
2130 | |
2131 regmatch.rmm_ic = spp->sp_ic; | |
2132 regmatch.regprog = spp->sp_prog; | |
6375 | 2133 r = syn_regexec(®match, |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2134 current_lnum, |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2135 (colnr_T)lc_col, |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
2136 IF_SYN_TIME(&spp->sp_time)); |
6375 | 2137 spp->sp_prog = regmatch.regprog; |
2138 if (!r) | |
7 | 2139 { |
2140 /* no match in this line, try another one */ | |
2141 spp->sp_startcol = MAXCOL; | |
2142 continue; | |
2143 } | |
2144 | |
2145 /* | |
2146 * Compute the first column of the match. | |
2147 */ | |
2148 syn_add_start_off(&pos, ®match, | |
2149 spp, SPO_MS_OFF, -1); | |
2150 if (pos.lnum > current_lnum) | |
2151 { | |
2152 /* must have used end of match in a next line, | |
2153 * we can't handle that */ | |
2154 spp->sp_startcol = MAXCOL; | |
2155 continue; | |
2156 } | |
2157 startcol = pos.col; | |
2158 | |
2159 /* remember the next column where this pattern | |
2160 * matches in the current line */ | |
2161 spp->sp_startcol = startcol; | |
2162 | |
2163 /* | |
2164 * If a previously found match starts at a lower | |
2165 * column number, don't use this one. | |
2166 */ | |
2167 if (startcol >= next_match_col) | |
2168 continue; | |
2169 | |
2170 /* | |
2171 * If we matched this pattern at this position | |
2172 * before, skip it. Must retry in the next | |
2173 * column, because it may match from there. | |
2174 */ | |
2175 if (did_match_already(idx, &zero_width_next_ga)) | |
2176 { | |
2177 try_next_column = TRUE; | |
2178 continue; | |
2179 } | |
2180 | |
2181 endpos.lnum = regmatch.endpos[0].lnum; | |
2182 endpos.col = regmatch.endpos[0].col; | |
2183 | |
2184 /* Compute the highlight start. */ | |
2185 syn_add_start_off(&hl_startpos, ®match, | |
2186 spp, SPO_HS_OFF, -1); | |
2187 | |
2188 /* Compute the region start. */ | |
2189 /* Default is to use the end of the match. */ | |
2190 syn_add_end_off(&eos_pos, ®match, | |
2191 spp, SPO_RS_OFF, 0); | |
2192 | |
2193 /* | |
2194 * Grab the external submatches before they get | |
2195 * overwritten. Reference count doesn't change. | |
2196 */ | |
2197 unref_extmatch(cur_extmatch); | |
2198 cur_extmatch = re_extmatch_out; | |
2199 re_extmatch_out = NULL; | |
2200 | |
2201 flags = 0; | |
2202 eoe_pos.lnum = 0; /* avoid warning */ | |
2203 eoe_pos.col = 0; | |
2204 end_idx = 0; | |
2205 hl_endpos.lnum = 0; | |
2206 | |
2207 /* | |
2208 * For a "oneline" the end must be found in the | |
2209 * same line too. Search for it after the end of | |
2210 * the match with the start pattern. Set the | |
2211 * resulting end positions at the same time. | |
2212 */ | |
2213 if (spp->sp_type == SPTYPE_START | |
2214 && (spp->sp_flags & HL_ONELINE)) | |
2215 { | |
2216 lpos_T startpos; | |
2217 | |
2218 startpos = endpos; | |
2219 find_endpos(idx, &startpos, &endpos, &hl_endpos, | |
2220 &flags, &eoe_pos, &end_idx, cur_extmatch); | |
2221 if (endpos.lnum == 0) | |
2222 continue; /* not found */ | |
2223 } | |
2224 | |
2225 /* | |
2226 * For a "match" the size must be > 0 after the | |
2227 * end offset needs has been added. Except when | |
2228 * syncing. | |
2229 */ | |
2230 else if (spp->sp_type == SPTYPE_MATCH) | |
2231 { | |
2232 syn_add_end_off(&hl_endpos, ®match, spp, | |
2233 SPO_HE_OFF, 0); | |
2234 syn_add_end_off(&endpos, ®match, spp, | |
2235 SPO_ME_OFF, 0); | |
2236 if (endpos.lnum == current_lnum | |
2237 && (int)endpos.col + syncing < startcol) | |
2238 { | |
2239 /* | |
2240 * If an empty string is matched, may need | |
2241 * to try matching again at next column. | |
2242 */ | |
2243 if (regmatch.startpos[0].col | |
2244 == regmatch.endpos[0].col) | |
2245 try_next_column = TRUE; | |
2246 continue; | |
2247 } | |
2248 } | |
2249 | |
2250 /* | |
2251 * keep the best match so far in next_match_* | |
2252 */ | |
2253 /* Highlighting must start after startpos and end | |
2254 * before endpos. */ | |
2255 if (hl_startpos.lnum == current_lnum | |
2256 && (int)hl_startpos.col < startcol) | |
2257 hl_startpos.col = startcol; | |
2258 limit_pos_zero(&hl_endpos, &endpos); | |
2259 | |
2260 next_match_idx = idx; | |
2261 next_match_col = startcol; | |
2262 next_match_m_endpos = endpos; | |
2263 next_match_h_endpos = hl_endpos; | |
2264 next_match_h_startpos = hl_startpos; | |
2265 next_match_flags = flags; | |
2266 next_match_eos_pos = eos_pos; | |
2267 next_match_eoe_pos = eoe_pos; | |
2268 next_match_end_idx = end_idx; | |
2269 unref_extmatch(next_match_extmatch); | |
2270 next_match_extmatch = cur_extmatch; | |
2271 cur_extmatch = NULL; | |
2272 } | |
2273 } | |
2274 } | |
2275 | |
2276 /* | |
2277 * If we found a match at the current column, use it. | |
2278 */ | |
2279 if (next_match_idx >= 0 && next_match_col == (int)current_col) | |
2280 { | |
2281 synpat_T *lspp; | |
2282 | |
2283 /* When a zero-width item matched which has a nextgroup, | |
2284 * don't push the item but set nextgroup. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2285 lspp = &(SYN_ITEMS(syn_block)[next_match_idx]); |
7 | 2286 if (next_match_m_endpos.lnum == current_lnum |
2287 && next_match_m_endpos.col == current_col | |
2288 && lspp->sp_next_list != NULL) | |
2289 { | |
2290 current_next_list = lspp->sp_next_list; | |
2291 current_next_flags = lspp->sp_flags; | |
2292 keep_next_list = TRUE; | |
2293 zero_width_next_list = TRUE; | |
2294 | |
2295 /* Add the index to a list, so that we can check | |
2296 * later that we don't match it again (and cause an | |
2297 * endless loop). */ | |
2298 if (ga_grow(&zero_width_next_ga, 1) == OK) | |
2299 { | |
2300 ((int *)(zero_width_next_ga.ga_data)) | |
2301 [zero_width_next_ga.ga_len++] = next_match_idx; | |
2302 } | |
2303 next_match_idx = -1; | |
2304 } | |
2305 else | |
2306 cur_si = push_next_match(cur_si); | |
2307 found_match = TRUE; | |
2308 } | |
2309 } | |
2310 } | |
2311 | |
2312 /* | |
2313 * Handle searching for nextgroup match. | |
2314 */ | |
2315 if (current_next_list != NULL && !keep_next_list) | |
2316 { | |
2317 /* | |
2318 * If a nextgroup was not found, continue looking for one if: | |
2319 * - this is an empty line and the "skipempty" option was given | |
2320 * - we are on white space and the "skipwhite" option was given | |
2321 */ | |
2322 if (!found_match) | |
2323 { | |
2324 line = syn_getcurline(); | |
2325 if (((current_next_flags & HL_SKIPWHITE) | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2326 && VIM_ISWHITE(line[current_col])) |
7 | 2327 || ((current_next_flags & HL_SKIPEMPTY) |
2328 && *line == NUL)) | |
2329 break; | |
2330 } | |
2331 | |
2332 /* | |
2333 * If a nextgroup was found: Use it, and continue looking for | |
2334 * contained matches. | |
2335 * If a nextgroup was not found: Continue looking for a normal | |
2336 * match. | |
2337 * When did set current_next_list for a zero-width item and no | |
2338 * match was found don't loop (would get stuck). | |
2339 */ | |
2340 current_next_list = NULL; | |
2341 next_match_idx = -1; | |
2342 if (!zero_width_next_list) | |
2343 found_match = TRUE; | |
2344 } | |
2345 | |
2346 } while (found_match); | |
2347 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2348 restore_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2349 |
7 | 2350 /* |
2351 * Use attributes from the current state, if within its highlighting. | |
2352 * If not, use attributes from the current-but-one state, etc. | |
2353 */ | |
2354 current_attr = 0; | |
2355 #ifdef FEAT_EVAL | |
2356 current_id = 0; | |
2357 current_trans_id = 0; | |
2358 #endif | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2359 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2360 current_flags = 0; |
11579
52e3a77c097b
patch 8.0.0672: third item of synconcealed() changes too often
Christian Brabandt <cb@256bit.org>
parents:
11541
diff
changeset
|
2361 current_seqnr = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2362 #endif |
7 | 2363 if (cur_si != NULL) |
2364 { | |
221 | 2365 #ifndef FEAT_EVAL |
2366 int current_trans_id = 0; | |
2367 #endif | |
7 | 2368 for (idx = current_state.ga_len - 1; idx >= 0; --idx) |
2369 { | |
2370 sip = &CUR_STATE(idx); | |
2371 if ((current_lnum > sip->si_h_startpos.lnum | |
2372 || (current_lnum == sip->si_h_startpos.lnum | |
2373 && current_col >= sip->si_h_startpos.col)) | |
2374 && (sip->si_h_endpos.lnum == 0 | |
2375 || current_lnum < sip->si_h_endpos.lnum | |
2376 || (current_lnum == sip->si_h_endpos.lnum | |
2377 && current_col < sip->si_h_endpos.col))) | |
2378 { | |
2379 current_attr = sip->si_attr; | |
2380 #ifdef FEAT_EVAL | |
2381 current_id = sip->si_id; | |
221 | 2382 #endif |
7 | 2383 current_trans_id = sip->si_trans_id; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2384 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2385 current_flags = sip->si_flags; |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
2386 current_seqnr = sip->si_seqnr; |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
2387 current_sub_char = sip->si_cchar; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2388 #endif |
7 | 2389 break; |
2390 } | |
2391 } | |
2392 | |
221 | 2393 if (can_spell != NULL) |
2394 { | |
2395 struct sp_syn sps; | |
2396 | |
2397 /* | |
2398 * set "can_spell" to TRUE if spell checking is supposed to be | |
2399 * done in the current item. | |
2400 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2401 if (syn_block->b_spell_cluster_id == 0) |
227 | 2402 { |
320 | 2403 /* There is no @Spell cluster: Do spelling for items without |
2404 * @NoSpell cluster. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2405 if (syn_block->b_nospell_cluster_id == 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2406 || current_trans_id == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2407 *can_spell = (syn_block->b_syn_spell != SYNSPL_NOTOP); |
227 | 2408 else |
2409 { | |
2410 sps.inc_tag = 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2411 sps.id = syn_block->b_nospell_cluster_id; |
227 | 2412 sps.cont_in_list = NULL; |
2413 *can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0); | |
2414 } | |
2415 } | |
221 | 2416 else |
2417 { | |
320 | 2418 /* The @Spell cluster is defined: Do spelling in items with |
419 | 2419 * the @Spell cluster. But not when @NoSpell is also there. |
2420 * At the toplevel only spell check when ":syn spell toplevel" | |
2421 * was used. */ | |
320 | 2422 if (current_trans_id == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2423 *can_spell = (syn_block->b_syn_spell == SYNSPL_TOP); |
320 | 2424 else |
2425 { | |
2426 sps.inc_tag = 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2427 sps.id = syn_block->b_spell_cluster_id; |
320 | 2428 sps.cont_in_list = NULL; |
2429 *can_spell = in_id_list(sip, sip->si_cont_list, &sps, 0); | |
2430 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2431 if (syn_block->b_nospell_cluster_id != 0) |
320 | 2432 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2433 sps.id = syn_block->b_nospell_cluster_id; |
320 | 2434 if (in_id_list(sip, sip->si_cont_list, &sps, 0)) |
2435 *can_spell = FALSE; | |
2436 } | |
2437 } | |
221 | 2438 } |
2439 } | |
2440 | |
2441 | |
7 | 2442 /* |
2443 * Check for end of current state (and the states before it) at the | |
2444 * next column. Don't do this for syncing, because we would miss a | |
2445 * single character match. | |
2446 * First check if the current state ends at the current column. It | |
2447 * may be for an empty match and a containing item might end in the | |
2448 * current column. | |
2449 */ | |
1504 | 2450 if (!syncing && !keep_state) |
7 | 2451 { |
2452 check_state_ends(); | |
442 | 2453 if (current_state.ga_len > 0 |
2454 && syn_getcurline()[current_col] != NUL) | |
7 | 2455 { |
2456 ++current_col; | |
2457 check_state_ends(); | |
2458 --current_col; | |
2459 } | |
2460 } | |
2461 } | |
221 | 2462 else if (can_spell != NULL) |
419 | 2463 /* Default: Only do spelling when there is no @Spell cluster or when |
2464 * ":syn spell toplevel" was used. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2465 *can_spell = syn_block->b_syn_spell == SYNSPL_DEFAULT |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2466 ? (syn_block->b_spell_cluster_id == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2467 : (syn_block->b_syn_spell == SYNSPL_TOP); |
7 | 2468 |
2020 | 2469 /* nextgroup ends at end of line, unless "skipnl" or "skipempty" present */ |
7 | 2470 if (current_next_list != NULL |
2471 && syn_getcurline()[current_col + 1] == NUL | |
2472 && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) | |
2473 current_next_list = NULL; | |
2474 | |
2475 if (zero_width_next_ga.ga_len > 0) | |
2476 ga_clear(&zero_width_next_ga); | |
2477 | |
2478 /* No longer need external matches. But keep next_match_extmatch. */ | |
2479 unref_extmatch(re_extmatch_out); | |
2480 re_extmatch_out = NULL; | |
2481 unref_extmatch(cur_extmatch); | |
2482 | |
2483 return current_attr; | |
2484 } | |
2485 | |
2486 | |
2487 /* | |
2488 * Check if we already matched pattern "idx" at the current column. | |
2489 */ | |
2490 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2491 did_match_already(int idx, garray_T *gap) |
7 | 2492 { |
2493 int i; | |
2494 | |
2495 for (i = current_state.ga_len; --i >= 0; ) | |
2496 if (CUR_STATE(i).si_m_startcol == (int)current_col | |
2497 && CUR_STATE(i).si_m_lnum == (int)current_lnum | |
2498 && CUR_STATE(i).si_idx == idx) | |
2499 return TRUE; | |
2500 | |
2501 /* Zero-width matches with a nextgroup argument are not put on the syntax | |
2502 * stack, and can only be matched once anyway. */ | |
2503 for (i = gap->ga_len; --i >= 0; ) | |
2504 if (((int *)(gap->ga_data))[i] == idx) | |
2505 return TRUE; | |
2506 | |
2507 return FALSE; | |
2508 } | |
2509 | |
2510 /* | |
2511 * Push the next match onto the stack. | |
2512 */ | |
2513 static stateitem_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2514 push_next_match(stateitem_T *cur_si) |
7 | 2515 { |
2516 synpat_T *spp; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2517 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2518 int save_flags; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2519 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2520 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2521 spp = &(SYN_ITEMS(syn_block)[next_match_idx]); |
7 | 2522 |
2523 /* | |
2524 * Push the item in current_state stack; | |
2525 */ | |
2526 if (push_current_state(next_match_idx) == OK) | |
2527 { | |
2528 /* | |
2529 * If it's a start-skip-end type that crosses lines, figure out how | |
2530 * much it continues in this line. Otherwise just fill in the length. | |
2531 */ | |
2532 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2533 cur_si->si_h_startpos = next_match_h_startpos; | |
2534 cur_si->si_m_startcol = current_col; | |
2535 cur_si->si_m_lnum = current_lnum; | |
2536 cur_si->si_flags = spp->sp_flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2537 #ifdef FEAT_CONCEAL |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
2538 cur_si->si_seqnr = next_seqnr++; |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
2539 cur_si->si_cchar = spp->sp_cchar; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2540 if (current_state.ga_len > 1) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2541 cur_si->si_flags |= |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2542 CUR_STATE(current_state.ga_len - 2).si_flags & HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2543 #endif |
7 | 2544 cur_si->si_next_list = spp->sp_next_list; |
2545 cur_si->si_extmatch = ref_extmatch(next_match_extmatch); | |
2546 if (spp->sp_type == SPTYPE_START && !(spp->sp_flags & HL_ONELINE)) | |
2547 { | |
2548 /* Try to find the end pattern in the current line */ | |
2549 update_si_end(cur_si, (int)(next_match_m_endpos.col), TRUE); | |
2550 check_keepend(); | |
2551 } | |
2552 else | |
2553 { | |
2554 cur_si->si_m_endpos = next_match_m_endpos; | |
2555 cur_si->si_h_endpos = next_match_h_endpos; | |
2556 cur_si->si_ends = TRUE; | |
2557 cur_si->si_flags |= next_match_flags; | |
2558 cur_si->si_eoe_pos = next_match_eoe_pos; | |
2559 cur_si->si_end_idx = next_match_end_idx; | |
2560 } | |
2561 if (keepend_level < 0 && (cur_si->si_flags & HL_KEEPEND)) | |
2562 keepend_level = current_state.ga_len - 1; | |
2563 check_keepend(); | |
2564 update_si_attr(current_state.ga_len - 1); | |
2565 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2566 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2567 save_flags = cur_si->si_flags & (HL_CONCEAL | HL_CONCEALENDS); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2568 #endif |
7 | 2569 /* |
2570 * If the start pattern has another highlight group, push another item | |
2571 * on the stack for the start pattern. | |
2572 */ | |
2573 if ( spp->sp_type == SPTYPE_START | |
2574 && spp->sp_syn_match_id != 0 | |
2575 && push_current_state(next_match_idx) == OK) | |
2576 { | |
2577 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2578 cur_si->si_h_startpos = next_match_h_startpos; | |
2579 cur_si->si_m_startcol = current_col; | |
2580 cur_si->si_m_lnum = current_lnum; | |
2581 cur_si->si_m_endpos = next_match_eos_pos; | |
2582 cur_si->si_h_endpos = next_match_eos_pos; | |
2583 cur_si->si_ends = TRUE; | |
2584 cur_si->si_end_idx = 0; | |
2585 cur_si->si_flags = HL_MATCH; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2586 #ifdef FEAT_CONCEAL |
2418
da067045878f
Fix for "concealends". (Vince Negri)
Bram Moolenaar <bram@vim.org>
parents:
2401
diff
changeset
|
2587 cur_si->si_seqnr = next_seqnr++; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2588 cur_si->si_flags |= save_flags; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2589 if (cur_si->si_flags & HL_CONCEALENDS) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2590 cur_si->si_flags |= HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2591 #endif |
7 | 2592 cur_si->si_next_list = NULL; |
2593 check_keepend(); | |
2594 update_si_attr(current_state.ga_len - 1); | |
2595 } | |
2596 } | |
2597 | |
2598 next_match_idx = -1; /* try other match next time */ | |
2599 | |
2600 return cur_si; | |
2601 } | |
2602 | |
2603 /* | |
2604 * Check for end of current state (and the states before it). | |
2605 */ | |
2606 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2607 check_state_ends(void) |
7 | 2608 { |
2609 stateitem_T *cur_si; | |
2863 | 2610 int had_extend; |
7 | 2611 |
2612 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2613 for (;;) | |
2614 { | |
2615 if (cur_si->si_ends | |
2616 && (cur_si->si_m_endpos.lnum < current_lnum | |
2617 || (cur_si->si_m_endpos.lnum == current_lnum | |
2618 && cur_si->si_m_endpos.col <= current_col))) | |
2619 { | |
2620 /* | |
2621 * If there is an end pattern group ID, highlight the end pattern | |
2622 * now. No need to pop the current item from the stack. | |
2623 * Only do this if the end pattern continues beyond the current | |
2624 * position. | |
2625 */ | |
2626 if (cur_si->si_end_idx | |
2627 && (cur_si->si_eoe_pos.lnum > current_lnum | |
2628 || (cur_si->si_eoe_pos.lnum == current_lnum | |
2629 && cur_si->si_eoe_pos.col > current_col))) | |
2630 { | |
2631 cur_si->si_idx = cur_si->si_end_idx; | |
2632 cur_si->si_end_idx = 0; | |
2633 cur_si->si_m_endpos = cur_si->si_eoe_pos; | |
2634 cur_si->si_h_endpos = cur_si->si_eoe_pos; | |
2635 cur_si->si_flags |= HL_MATCH; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2636 #ifdef FEAT_CONCEAL |
2418
da067045878f
Fix for "concealends". (Vince Negri)
Bram Moolenaar <bram@vim.org>
parents:
2401
diff
changeset
|
2637 cur_si->si_seqnr = next_seqnr++; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2638 if (cur_si->si_flags & HL_CONCEALENDS) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2639 cur_si->si_flags |= HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2640 #endif |
7 | 2641 update_si_attr(current_state.ga_len - 1); |
36 | 2642 |
2831 | 2643 /* nextgroup= should not match in the end pattern */ |
2644 current_next_list = NULL; | |
2645 | |
36 | 2646 /* what matches next may be different now, clear it */ |
2647 next_match_idx = 0; | |
2648 next_match_col = MAXCOL; | |
7 | 2649 break; |
2650 } | |
2651 else | |
2652 { | |
2653 /* handle next_list, unless at end of line and no "skipnl" or | |
2654 * "skipempty" */ | |
2655 current_next_list = cur_si->si_next_list; | |
2656 current_next_flags = cur_si->si_flags; | |
2657 if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)) | |
2658 && syn_getcurline()[current_col] == NUL) | |
2659 current_next_list = NULL; | |
2660 | |
2661 /* When the ended item has "extend", another item with | |
2662 * "keepend" now needs to check for its end. */ | |
2863 | 2663 had_extend = (cur_si->si_flags & HL_EXTEND); |
7 | 2664 |
2665 pop_current_state(); | |
2666 | |
2667 if (current_state.ga_len == 0) | |
2668 break; | |
2669 | |
1503 | 2670 if (had_extend && keepend_level >= 0) |
7 | 2671 { |
2672 syn_update_ends(FALSE); | |
2673 if (current_state.ga_len == 0) | |
2674 break; | |
2675 } | |
2676 | |
2677 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2678 | |
2679 /* | |
2680 * Only for a region the search for the end continues after | |
2681 * the end of the contained item. If the contained match | |
2682 * included the end-of-line, break here, the region continues. | |
2683 * Don't do this when: | |
2684 * - "keepend" is used for the contained item | |
2685 * - not at the end of the line (could be end="x$"me=e-1). | |
2686 * - "excludenl" is used (HL_HAS_EOL won't be set) | |
2687 */ | |
2688 if (cur_si->si_idx >= 0 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2689 && SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type |
7 | 2690 == SPTYPE_START |
2691 && !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) | |
2692 { | |
2693 update_si_end(cur_si, (int)current_col, TRUE); | |
2694 check_keepend(); | |
2695 if ((current_next_flags & HL_HAS_EOL) | |
2696 && keepend_level < 0 | |
2697 && syn_getcurline()[current_col] == NUL) | |
2698 break; | |
2699 } | |
2700 } | |
2701 } | |
2702 else | |
2703 break; | |
2704 } | |
2705 } | |
2706 | |
2707 /* | |
2708 * Update an entry in the current_state stack for a match or region. This | |
2709 * fills in si_attr, si_next_list and si_cont_list. | |
2710 */ | |
2711 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2712 update_si_attr(int idx) |
7 | 2713 { |
2714 stateitem_T *sip = &CUR_STATE(idx); | |
2715 synpat_T *spp; | |
2716 | |
1371 | 2717 /* This should not happen... */ |
2718 if (sip->si_idx < 0) | |
2719 return; | |
2720 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2721 spp = &(SYN_ITEMS(syn_block)[sip->si_idx]); |
7 | 2722 if (sip->si_flags & HL_MATCH) |
2723 sip->si_id = spp->sp_syn_match_id; | |
2724 else | |
2725 sip->si_id = spp->sp_syn.id; | |
2726 sip->si_attr = syn_id2attr(sip->si_id); | |
2727 sip->si_trans_id = sip->si_id; | |
2728 if (sip->si_flags & HL_MATCH) | |
2729 sip->si_cont_list = NULL; | |
2730 else | |
2731 sip->si_cont_list = spp->sp_cont_list; | |
2732 | |
2733 /* | |
2734 * For transparent items, take attr from outer item. | |
2735 * Also take cont_list, if there is none. | |
2736 * Don't do this for the matchgroup of a start or end pattern. | |
2737 */ | |
2738 if ((spp->sp_flags & HL_TRANSP) && !(sip->si_flags & HL_MATCH)) | |
2739 { | |
2740 if (idx == 0) | |
2741 { | |
2742 sip->si_attr = 0; | |
2743 sip->si_trans_id = 0; | |
2744 if (sip->si_cont_list == NULL) | |
2745 sip->si_cont_list = ID_LIST_ALL; | |
2746 } | |
2747 else | |
2748 { | |
2749 sip->si_attr = CUR_STATE(idx - 1).si_attr; | |
2750 sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id; | |
36 | 2751 sip->si_h_startpos = CUR_STATE(idx - 1).si_h_startpos; |
2752 sip->si_h_endpos = CUR_STATE(idx - 1).si_h_endpos; | |
7 | 2753 if (sip->si_cont_list == NULL) |
2754 { | |
2755 sip->si_flags |= HL_TRANS_CONT; | |
2756 sip->si_cont_list = CUR_STATE(idx - 1).si_cont_list; | |
2757 } | |
2758 } | |
2759 } | |
2760 } | |
2761 | |
2762 /* | |
2763 * Check the current stack for patterns with "keepend" flag. | |
2764 * Propagate the match-end to contained items, until a "skipend" item is found. | |
2765 */ | |
2766 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2767 check_keepend(void) |
7 | 2768 { |
2769 int i; | |
2770 lpos_T maxpos; | |
991 | 2771 lpos_T maxpos_h; |
7 | 2772 stateitem_T *sip; |
2773 | |
2774 /* | |
2775 * This check can consume a lot of time; only do it from the level where | |
2776 * there really is a keepend. | |
2777 */ | |
2778 if (keepend_level < 0) | |
2779 return; | |
2780 | |
2781 /* | |
2782 * Find the last index of an "extend" item. "keepend" items before that | |
2783 * won't do anything. If there is no "extend" item "i" will be | |
2784 * "keepend_level" and all "keepend" items will work normally. | |
2785 */ | |
2786 for (i = current_state.ga_len - 1; i > keepend_level; --i) | |
2787 if (CUR_STATE(i).si_flags & HL_EXTEND) | |
2788 break; | |
2789 | |
2790 maxpos.lnum = 0; | |
1702 | 2791 maxpos.col = 0; |
991 | 2792 maxpos_h.lnum = 0; |
1702 | 2793 maxpos_h.col = 0; |
7 | 2794 for ( ; i < current_state.ga_len; ++i) |
2795 { | |
2796 sip = &CUR_STATE(i); | |
2797 if (maxpos.lnum != 0) | |
2798 { | |
2799 limit_pos_zero(&sip->si_m_endpos, &maxpos); | |
991 | 2800 limit_pos_zero(&sip->si_h_endpos, &maxpos_h); |
7 | 2801 limit_pos_zero(&sip->si_eoe_pos, &maxpos); |
2802 sip->si_ends = TRUE; | |
2803 } | |
991 | 2804 if (sip->si_ends && (sip->si_flags & HL_KEEPEND)) |
2805 { | |
2806 if (maxpos.lnum == 0 | |
7 | 2807 || maxpos.lnum > sip->si_m_endpos.lnum |
2808 || (maxpos.lnum == sip->si_m_endpos.lnum | |
991 | 2809 && maxpos.col > sip->si_m_endpos.col)) |
2810 maxpos = sip->si_m_endpos; | |
2811 if (maxpos_h.lnum == 0 | |
2812 || maxpos_h.lnum > sip->si_h_endpos.lnum | |
2813 || (maxpos_h.lnum == sip->si_h_endpos.lnum | |
2814 && maxpos_h.col > sip->si_h_endpos.col)) | |
2815 maxpos_h = sip->si_h_endpos; | |
2816 } | |
7 | 2817 } |
2818 } | |
2819 | |
2820 /* | |
2821 * Update an entry in the current_state stack for a start-skip-end pattern. | |
2822 * This finds the end of the current item, if it's in the current line. | |
2823 * | |
2824 * Return the flags for the matched END. | |
2825 */ | |
2826 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2827 update_si_end( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2828 stateitem_T *sip, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2829 int startcol, /* where to start searching for the end */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2830 int force) /* when TRUE overrule a previous end */ |
7 | 2831 { |
2832 lpos_T startpos; | |
2833 lpos_T endpos; | |
2834 lpos_T hl_endpos; | |
2835 lpos_T end_endpos; | |
2836 int end_idx; | |
2837 | |
1371 | 2838 /* return quickly for a keyword */ |
2839 if (sip->si_idx < 0) | |
2840 return; | |
2841 | |
7 | 2842 /* Don't update when it's already done. Can be a match of an end pattern |
2843 * that started in a previous line. Watch out: can also be a "keepend" | |
2844 * from a containing item. */ | |
2845 if (!force && sip->si_m_endpos.lnum >= current_lnum) | |
2846 return; | |
2847 | |
2848 /* | |
2849 * We need to find the end of the region. It may continue in the next | |
2850 * line. | |
2851 */ | |
2852 end_idx = 0; | |
2853 startpos.lnum = current_lnum; | |
2854 startpos.col = startcol; | |
2855 find_endpos(sip->si_idx, &startpos, &endpos, &hl_endpos, | |
2856 &(sip->si_flags), &end_endpos, &end_idx, sip->si_extmatch); | |
2857 | |
2858 if (endpos.lnum == 0) | |
2859 { | |
2860 /* No end pattern matched. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2861 if (SYN_ITEMS(syn_block)[sip->si_idx].sp_flags & HL_ONELINE) |
7 | 2862 { |
2863 /* a "oneline" never continues in the next line */ | |
2864 sip->si_ends = TRUE; | |
2865 sip->si_m_endpos.lnum = current_lnum; | |
2866 sip->si_m_endpos.col = (colnr_T)STRLEN(syn_getcurline()); | |
2867 } | |
2868 else | |
2869 { | |
2870 /* continues in the next line */ | |
2871 sip->si_ends = FALSE; | |
2872 sip->si_m_endpos.lnum = 0; | |
2873 } | |
2874 sip->si_h_endpos = sip->si_m_endpos; | |
2875 } | |
2876 else | |
2877 { | |
2878 /* match within this line */ | |
2879 sip->si_m_endpos = endpos; | |
2880 sip->si_h_endpos = hl_endpos; | |
2881 sip->si_eoe_pos = end_endpos; | |
2882 sip->si_ends = TRUE; | |
2883 sip->si_end_idx = end_idx; | |
2884 } | |
2885 } | |
2886 | |
2887 /* | |
2888 * Add a new state to the current state stack. | |
2889 * It is cleared and the index set to "idx". | |
2890 * Return FAIL if it's not possible (out of memory). | |
2891 */ | |
2892 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2893 push_current_state(int idx) |
7 | 2894 { |
2895 if (ga_grow(¤t_state, 1) == FAIL) | |
2896 return FAIL; | |
2897 vim_memset(&CUR_STATE(current_state.ga_len), 0, sizeof(stateitem_T)); | |
2898 CUR_STATE(current_state.ga_len).si_idx = idx; | |
2899 ++current_state.ga_len; | |
2900 return OK; | |
2901 } | |
2902 | |
2903 /* | |
2904 * Remove a state from the current_state stack. | |
2905 */ | |
2906 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2907 pop_current_state(void) |
7 | 2908 { |
2909 if (current_state.ga_len) | |
2910 { | |
2911 unref_extmatch(CUR_STATE(current_state.ga_len - 1).si_extmatch); | |
2912 --current_state.ga_len; | |
2913 } | |
2914 /* after the end of a pattern, try matching a keyword or pattern */ | |
2915 next_match_idx = -1; | |
2916 | |
2917 /* if first state with "keepend" is popped, reset keepend_level */ | |
2918 if (keepend_level >= current_state.ga_len) | |
2919 keepend_level = -1; | |
2920 } | |
2921 | |
2922 /* | |
2923 * Find the end of a start/skip/end syntax region after "startpos". | |
2924 * Only checks one line. | |
2925 * Also handles a match item that continued from a previous line. | |
2926 * If not found, the syntax item continues in the next line. m_endpos->lnum | |
2927 * will be 0. | |
2928 * If found, the end of the region and the end of the highlighting is | |
2929 * computed. | |
2930 */ | |
2931 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2932 find_endpos( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2933 int idx, /* index of the pattern */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2934 lpos_T *startpos, /* where to start looking for an END match */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2935 lpos_T *m_endpos, /* return: end of match */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2936 lpos_T *hl_endpos, /* return: end of highlighting */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2937 long *flagsp, /* return: flags of matching END */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2938 lpos_T *end_endpos, /* return: end of end pattern match */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2939 int *end_idx, /* return: group ID for end pat. match, or 0 */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2940 reg_extmatch_T *start_ext) /* submatches from the start pattern */ |
7 | 2941 { |
2942 colnr_T matchcol; | |
2943 synpat_T *spp, *spp_skip; | |
2944 int start_idx; | |
2945 int best_idx; | |
2946 regmmatch_T regmatch; | |
2947 regmmatch_T best_regmatch; /* startpos/endpos of best match */ | |
2948 lpos_T pos; | |
2949 char_u *line; | |
2950 int had_match = FALSE; | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2951 char_u buf_chartab[32]; /* chartab array for syn option iskyeyword */ |
7 | 2952 |
1371 | 2953 /* just in case we are invoked for a keyword */ |
2954 if (idx < 0) | |
2955 return; | |
2956 | |
7 | 2957 /* |
2958 * Check for being called with a START pattern. | |
2959 * Can happen with a match that continues to the next line, because it | |
2960 * contained a region. | |
2961 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2962 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 2963 if (spp->sp_type != SPTYPE_START) |
2964 { | |
2965 *hl_endpos = *startpos; | |
2966 return; | |
2967 } | |
2968 | |
2969 /* | |
2970 * Find the SKIP or first END pattern after the last START pattern. | |
2971 */ | |
2972 for (;;) | |
2973 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2974 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 2975 if (spp->sp_type != SPTYPE_START) |
2976 break; | |
2977 ++idx; | |
2978 } | |
2979 | |
2980 /* | |
2981 * Lookup the SKIP pattern (if present) | |
2982 */ | |
2983 if (spp->sp_type == SPTYPE_SKIP) | |
2984 { | |
2985 spp_skip = spp; | |
2986 ++idx; | |
2987 } | |
2988 else | |
2989 spp_skip = NULL; | |
2990 | |
2991 /* Setup external matches for syn_regexec(). */ | |
2992 unref_extmatch(re_extmatch_in); | |
2993 re_extmatch_in = ref_extmatch(start_ext); | |
2994 | |
2995 matchcol = startpos->col; /* start looking for a match at sstart */ | |
2996 start_idx = idx; /* remember the first END pattern. */ | |
2997 best_regmatch.startpos[0].col = 0; /* avoid compiler warning */ | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2998 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2999 /* use syntax iskeyword option */ |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3000 save_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3001 |
7 | 3002 for (;;) |
3003 { | |
3004 /* | |
3005 * Find end pattern that matches first after "matchcol". | |
3006 */ | |
3007 best_idx = -1; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3008 for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx) |
7 | 3009 { |
3010 int lc_col = matchcol; | |
6375 | 3011 int r; |
7 | 3012 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3013 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 3014 if (spp->sp_type != SPTYPE_END) /* past last END pattern */ |
3015 break; | |
3016 lc_col -= spp->sp_offsets[SPO_LC_OFF]; | |
3017 if (lc_col < 0) | |
3018 lc_col = 0; | |
3019 | |
3020 regmatch.rmm_ic = spp->sp_ic; | |
3021 regmatch.regprog = spp->sp_prog; | |
6375 | 3022 r = syn_regexec(®match, startpos->lnum, lc_col, |
3023 IF_SYN_TIME(&spp->sp_time)); | |
3024 spp->sp_prog = regmatch.regprog; | |
3025 if (r) | |
7 | 3026 { |
3027 if (best_idx == -1 || regmatch.startpos[0].col | |
3028 < best_regmatch.startpos[0].col) | |
3029 { | |
3030 best_idx = idx; | |
3031 best_regmatch.startpos[0] = regmatch.startpos[0]; | |
3032 best_regmatch.endpos[0] = regmatch.endpos[0]; | |
3033 } | |
3034 } | |
3035 } | |
3036 | |
3037 /* | |
3038 * If all end patterns have been tried, and there is no match, the | |
3039 * item continues until end-of-line. | |
3040 */ | |
3041 if (best_idx == -1) | |
3042 break; | |
3043 | |
3044 /* | |
3045 * If the skip pattern matches before the end pattern, | |
3046 * continue searching after the skip pattern. | |
3047 */ | |
3048 if (spp_skip != NULL) | |
3049 { | |
3050 int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF]; | |
6375 | 3051 int r; |
7 | 3052 |
3053 if (lc_col < 0) | |
3054 lc_col = 0; | |
3055 regmatch.rmm_ic = spp_skip->sp_ic; | |
3056 regmatch.regprog = spp_skip->sp_prog; | |
6375 | 3057 r = syn_regexec(®match, startpos->lnum, lc_col, |
3058 IF_SYN_TIME(&spp_skip->sp_time)); | |
3059 spp_skip->sp_prog = regmatch.regprog; | |
3060 if (r && regmatch.startpos[0].col | |
7 | 3061 <= best_regmatch.startpos[0].col) |
3062 { | |
7500
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
3063 int line_len; |
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
3064 |
7 | 3065 /* Add offset to skip pattern match */ |
3066 syn_add_end_off(&pos, ®match, spp_skip, SPO_ME_OFF, 1); | |
3067 | |
3068 /* If the skip pattern goes on to the next line, there is no | |
3069 * match with an end pattern in this line. */ | |
3070 if (pos.lnum > startpos->lnum) | |
3071 break; | |
3072 | |
3073 line = ml_get_buf(syn_buf, startpos->lnum, FALSE); | |
7500
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
3074 line_len = (int)STRLEN(line); |
7 | 3075 |
3076 /* take care of an empty match or negative offset */ | |
3077 if (pos.col <= matchcol) | |
3078 ++matchcol; | |
3079 else if (pos.col <= regmatch.endpos[0].col) | |
3080 matchcol = pos.col; | |
3081 else | |
3082 /* Be careful not to jump over the NUL at the end-of-line */ | |
3083 for (matchcol = regmatch.endpos[0].col; | |
7500
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
3084 matchcol < line_len && matchcol < pos.col; |
7 | 3085 ++matchcol) |
3086 ; | |
3087 | |
3088 /* if the skip pattern includes end-of-line, break here */ | |
7500
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
3089 if (matchcol >= line_len) |
7 | 3090 break; |
3091 | |
3092 continue; /* start with first end pattern again */ | |
3093 } | |
3094 } | |
3095 | |
3096 /* | |
3097 * Match from start pattern to end pattern. | |
3098 * Correct for match and highlight offset of end pattern. | |
3099 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3100 spp = &(SYN_ITEMS(syn_block)[best_idx]); |
7 | 3101 syn_add_end_off(m_endpos, &best_regmatch, spp, SPO_ME_OFF, 1); |
3102 /* can't end before the start */ | |
3103 if (m_endpos->lnum == startpos->lnum && m_endpos->col < startpos->col) | |
3104 m_endpos->col = startpos->col; | |
3105 | |
3106 syn_add_end_off(end_endpos, &best_regmatch, spp, SPO_HE_OFF, 1); | |
3107 /* can't end before the start */ | |
3108 if (end_endpos->lnum == startpos->lnum | |
3109 && end_endpos->col < startpos->col) | |
3110 end_endpos->col = startpos->col; | |
3111 /* can't end after the match */ | |
3112 limit_pos(end_endpos, m_endpos); | |
3113 | |
3114 /* | |
3115 * If the end group is highlighted differently, adjust the pointers. | |
3116 */ | |
3117 if (spp->sp_syn_match_id != spp->sp_syn.id && spp->sp_syn_match_id != 0) | |
3118 { | |
3119 *end_idx = best_idx; | |
3120 if (spp->sp_off_flags & (1 << (SPO_RE_OFF + SPO_COUNT))) | |
3121 { | |
3122 hl_endpos->lnum = best_regmatch.endpos[0].lnum; | |
3123 hl_endpos->col = best_regmatch.endpos[0].col; | |
3124 } | |
3125 else | |
3126 { | |
3127 hl_endpos->lnum = best_regmatch.startpos[0].lnum; | |
3128 hl_endpos->col = best_regmatch.startpos[0].col; | |
3129 } | |
3130 hl_endpos->col += spp->sp_offsets[SPO_RE_OFF]; | |
3131 | |
3132 /* can't end before the start */ | |
3133 if (hl_endpos->lnum == startpos->lnum | |
3134 && hl_endpos->col < startpos->col) | |
3135 hl_endpos->col = startpos->col; | |
3136 limit_pos(hl_endpos, m_endpos); | |
3137 | |
3138 /* now the match ends where the highlighting ends, it is turned | |
3139 * into the matchgroup for the end */ | |
3140 *m_endpos = *hl_endpos; | |
3141 } | |
3142 else | |
3143 { | |
3144 *end_idx = 0; | |
3145 *hl_endpos = *end_endpos; | |
3146 } | |
3147 | |
3148 *flagsp = spp->sp_flags; | |
3149 | |
3150 had_match = TRUE; | |
3151 break; | |
3152 } | |
3153 | |
3154 /* no match for an END pattern in this line */ | |
3155 if (!had_match) | |
3156 m_endpos->lnum = 0; | |
3157 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3158 restore_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3159 |
7 | 3160 /* Remove external matches. */ |
3161 unref_extmatch(re_extmatch_in); | |
3162 re_extmatch_in = NULL; | |
3163 } | |
3164 | |
3165 /* | |
3166 * Limit "pos" not to be after "limit". | |
3167 */ | |
3168 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3169 limit_pos(lpos_T *pos, lpos_T *limit) |
7 | 3170 { |
3171 if (pos->lnum > limit->lnum) | |
3172 *pos = *limit; | |
3173 else if (pos->lnum == limit->lnum && pos->col > limit->col) | |
3174 pos->col = limit->col; | |
3175 } | |
3176 | |
3177 /* | |
3178 * Limit "pos" not to be after "limit", unless pos->lnum is zero. | |
3179 */ | |
3180 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3181 limit_pos_zero( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3182 lpos_T *pos, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3183 lpos_T *limit) |
7 | 3184 { |
3185 if (pos->lnum == 0) | |
3186 *pos = *limit; | |
3187 else | |
3188 limit_pos(pos, limit); | |
3189 } | |
3190 | |
3191 /* | |
3192 * Add offset to matched text for end of match or highlight. | |
3193 */ | |
3194 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3195 syn_add_end_off( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3196 lpos_T *result, /* returned position */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3197 regmmatch_T *regmatch, /* start/end of match */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3198 synpat_T *spp, /* matched pattern */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3199 int idx, /* index of offset */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3200 int extra) /* extra chars for offset to start */ |
7 | 3201 { |
3202 int col; | |
1624 | 3203 int off; |
3204 char_u *base; | |
3205 char_u *p; | |
7 | 3206 |
3207 if (spp->sp_off_flags & (1 << idx)) | |
3208 { | |
3209 result->lnum = regmatch->startpos[0].lnum; | |
1624 | 3210 col = regmatch->startpos[0].col; |
3211 off = spp->sp_offsets[idx] + extra; | |
7 | 3212 } |
3213 else | |
3214 { | |
3215 result->lnum = regmatch->endpos[0].lnum; | |
3216 col = regmatch->endpos[0].col; | |
1624 | 3217 off = spp->sp_offsets[idx]; |
3218 } | |
3219 /* Don't go past the end of the line. Matters for "rs=e+2" when there | |
3220 * is a matchgroup. Watch out for match with last NL in the buffer. */ | |
3221 if (result->lnum > syn_buf->b_ml.ml_line_count) | |
3222 col = 0; | |
3223 else if (off != 0) | |
3224 { | |
3225 base = ml_get_buf(syn_buf, result->lnum, FALSE); | |
3226 p = base + col; | |
3227 if (off > 0) | |
3228 { | |
3229 while (off-- > 0 && *p != NUL) | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11119
diff
changeset
|
3230 MB_PTR_ADV(p); |
1624 | 3231 } |
3232 else if (off < 0) | |
3233 { | |
3234 while (off++ < 0 && base < p) | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11119
diff
changeset
|
3235 MB_PTR_BACK(base, p); |
1624 | 3236 } |
3237 col = (int)(p - base); | |
3238 } | |
3239 result->col = col; | |
7 | 3240 } |
3241 | |
3242 /* | |
3243 * Add offset to matched text for start of match or highlight. | |
3244 * Avoid resulting column to become negative. | |
3245 */ | |
3246 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3247 syn_add_start_off( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3248 lpos_T *result, /* returned position */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3249 regmmatch_T *regmatch, /* start/end of match */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3250 synpat_T *spp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3251 int idx, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3252 int extra) /* extra chars for offset to end */ |
7 | 3253 { |
3254 int col; | |
1624 | 3255 int off; |
3256 char_u *base; | |
3257 char_u *p; | |
7 | 3258 |
3259 if (spp->sp_off_flags & (1 << (idx + SPO_COUNT))) | |
3260 { | |
3261 result->lnum = regmatch->endpos[0].lnum; | |
1624 | 3262 col = regmatch->endpos[0].col; |
3263 off = spp->sp_offsets[idx] + extra; | |
7 | 3264 } |
3265 else | |
3266 { | |
3267 result->lnum = regmatch->startpos[0].lnum; | |
3268 col = regmatch->startpos[0].col; | |
1624 | 3269 off = spp->sp_offsets[idx]; |
3270 } | |
2092
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3271 if (result->lnum > syn_buf->b_ml.ml_line_count) |
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3272 { |
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3273 /* a "\n" at the end of the pattern may take us below the last line */ |
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3274 result->lnum = syn_buf->b_ml.ml_line_count; |
2100
7d121c69f540
updated for version 7.2.383
Bram Moolenaar <bram@zimbu.org>
parents:
2092
diff
changeset
|
3275 col = (int)STRLEN(ml_get_buf(syn_buf, result->lnum, FALSE)); |
2092
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3276 } |
1624 | 3277 if (off != 0) |
3278 { | |
3279 base = ml_get_buf(syn_buf, result->lnum, FALSE); | |
3280 p = base + col; | |
3281 if (off > 0) | |
3282 { | |
3283 while (off-- && *p != NUL) | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11119
diff
changeset
|
3284 MB_PTR_ADV(p); |
1624 | 3285 } |
3286 else if (off < 0) | |
3287 { | |
3288 while (off++ && base < p) | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11119
diff
changeset
|
3289 MB_PTR_BACK(base, p); |
1624 | 3290 } |
3291 col = (int)(p - base); | |
3292 } | |
3293 result->col = col; | |
7 | 3294 } |
3295 | |
3296 /* | |
3297 * Get current line in syntax buffer. | |
3298 */ | |
3299 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3300 syn_getcurline(void) |
7 | 3301 { |
3302 return ml_get_buf(syn_buf, current_lnum, FALSE); | |
3303 } | |
3304 | |
3305 /* | |
410 | 3306 * Call vim_regexec() to find a match with "rmp" in "syn_buf". |
7 | 3307 * Returns TRUE when there is a match. |
3308 */ | |
3309 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3310 syn_regexec( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3311 regmmatch_T *rmp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3312 linenr_T lnum, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3313 colnr_T col, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3314 syn_time_T *st UNUSED) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3315 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3316 int r; |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3317 #ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3318 int timed_out = FALSE; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3319 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
3320 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3321 proftime_T pt; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3322 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3323 if (syn_time_on) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3324 profile_start(&pt); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3325 #endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3326 |
410 | 3327 rmp->rmm_maxcol = syn_buf->b_p_smc; |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3328 r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3329 #ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3330 syn_tm, &timed_out |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3331 #else |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3332 NULL, NULL |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3333 #endif |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3334 ); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3335 |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
3336 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3337 if (syn_time_on) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3338 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3339 profile_end(&pt); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3340 profile_add(&st->total, &pt); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3341 if (profile_cmp(&pt, &st->slowest) < 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3342 st->slowest = pt; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3343 ++st->count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3344 if (r > 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3345 ++st->match; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3346 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3347 #endif |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3348 #ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3349 if (timed_out) |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3350 syn_win->w_s->b_syn_slow = TRUE; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3351 #endif |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3352 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3353 if (r > 0) |
7 | 3354 { |
3355 rmp->startpos[0].lnum += lnum; | |
3356 rmp->endpos[0].lnum += lnum; | |
3357 return TRUE; | |
3358 } | |
3359 return FALSE; | |
3360 } | |
3361 | |
3362 /* | |
3363 * Check one position in a line for a matching keyword. | |
3364 * The caller must check if a keyword can start at startcol. | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3365 * Return its ID if found, 0 otherwise. |
7 | 3366 */ |
3367 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3368 check_keyword_id( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3369 char_u *line, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3370 int startcol, /* position in line to check for keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3371 int *endcolp, /* return: character after found keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3372 long *flagsp, /* return: flags of matching keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3373 short **next_listp, /* return: next_list of matching keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3374 stateitem_T *cur_si, /* item at the top of the stack */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3375 int *ccharp UNUSED) /* conceal substitution char */ |
7 | 3376 { |
134 | 3377 keyentry_T *kp; |
3378 char_u *kwp; | |
7 | 3379 int round; |
134 | 3380 int kwlen; |
7 | 3381 char_u keyword[MAXKEYWLEN + 1]; /* assume max. keyword len is 80 */ |
134 | 3382 hashtab_T *ht; |
3383 hashitem_T *hi; | |
7 | 3384 |
3385 /* Find first character after the keyword. First character was already | |
3386 * checked. */ | |
134 | 3387 kwp = line + startcol; |
3388 kwlen = 0; | |
7 | 3389 do |
3390 { | |
3391 #ifdef FEAT_MBYTE | |
3392 if (has_mbyte) | |
474 | 3393 kwlen += (*mb_ptr2len)(kwp + kwlen); |
7 | 3394 else |
3395 #endif | |
134 | 3396 ++kwlen; |
3397 } | |
4043 | 3398 while (vim_iswordp_buf(kwp + kwlen, syn_buf)); |
134 | 3399 |
3400 if (kwlen > MAXKEYWLEN) | |
7 | 3401 return 0; |
3402 | |
3403 /* | |
3404 * Must make a copy of the keyword, so we can add a NUL and make it | |
3405 * lowercase. | |
3406 */ | |
419 | 3407 vim_strncpy(keyword, kwp, kwlen); |
7 | 3408 |
3409 /* | |
3410 * Try twice: | |
3411 * 1. matching case | |
3412 * 2. ignoring case | |
3413 */ | |
3414 for (round = 1; round <= 2; ++round) | |
3415 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3416 ht = round == 1 ? &syn_block->b_keywtab : &syn_block->b_keywtab_ic; |
134 | 3417 if (ht->ht_used == 0) |
7 | 3418 continue; |
134 | 3419 if (round == 2) /* ignore case */ |
3420 (void)str_foldcase(kwp, kwlen, keyword, MAXKEYWLEN + 1); | |
7 | 3421 |
3422 /* | |
134 | 3423 * Find keywords that match. There can be several with different |
3424 * attributes. | |
7 | 3425 * When current_next_list is non-zero accept only that group, otherwise: |
3426 * Accept a not-contained keyword at toplevel. | |
3427 * Accept a keyword at other levels only if it is in the contains list. | |
3428 */ | |
134 | 3429 hi = hash_find(ht, keyword); |
3430 if (!HASHITEM_EMPTY(hi)) | |
3431 for (kp = HI2KE(hi); kp != NULL; kp = kp->ke_next) | |
7 | 3432 { |
134 | 3433 if (current_next_list != 0 |
3434 ? in_id_list(NULL, current_next_list, &kp->k_syn, 0) | |
3435 : (cur_si == NULL | |
3436 ? !(kp->flags & HL_CONTAINED) | |
3437 : in_id_list(cur_si, cur_si->si_cont_list, | |
3438 &kp->k_syn, kp->flags & HL_CONTAINED))) | |
3439 { | |
3440 *endcolp = startcol + kwlen; | |
3441 *flagsp = kp->flags; | |
3442 *next_listp = kp->next_list; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3443 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3444 *ccharp = kp->k_char; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3445 #endif |
134 | 3446 return kp->k_syn.id; |
3447 } | |
7 | 3448 } |
3449 } | |
3450 return 0; | |
3451 } | |
3452 | |
3453 /* | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3454 * Handle ":syntax conceal" command. |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3455 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3456 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3457 syn_cmd_conceal(exarg_T *eap UNUSED, int syncing UNUSED) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3458 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3459 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3460 char_u *arg = eap->arg; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3461 char_u *next; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3462 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3463 eap->nextcmd = find_nextcmd(arg); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3464 if (eap->skip) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3465 return; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3466 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3467 next = skiptowhite(arg); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3468 if (*arg == NUL) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3469 { |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3470 if (curwin->w_s->b_syn_conceal) |
11514
7c42cf66d5be
patch 8.0.0640: mismatch between help and actual message
Christian Brabandt <cb@256bit.org>
parents:
11465
diff
changeset
|
3471 MSG(_("syntax conceal on")); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3472 else |
11514
7c42cf66d5be
patch 8.0.0640: mismatch between help and actual message
Christian Brabandt <cb@256bit.org>
parents:
11465
diff
changeset
|
3473 MSG(_("syntax conceal off")); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3474 } |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3475 else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3476 curwin->w_s->b_syn_conceal = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3477 else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3478 curwin->w_s->b_syn_conceal = FALSE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3479 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3480 EMSG2(_("E390: Illegal argument: %s"), arg); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3481 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3482 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3483 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3484 /* |
7 | 3485 * Handle ":syntax case" command. |
3486 */ | |
3487 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3488 syn_cmd_case(exarg_T *eap, int syncing UNUSED) |
7 | 3489 { |
3490 char_u *arg = eap->arg; | |
3491 char_u *next; | |
3492 | |
3493 eap->nextcmd = find_nextcmd(arg); | |
3494 if (eap->skip) | |
3495 return; | |
3496 | |
3497 next = skiptowhite(arg); | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3498 if (*arg == NUL) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3499 { |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3500 if (curwin->w_s->b_syn_ic) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3501 MSG(_("syntax case ignore")); |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3502 else |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3503 MSG(_("syntax case match")); |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3504 } |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3505 else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3506 curwin->w_s->b_syn_ic = FALSE; |
7 | 3507 else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3508 curwin->w_s->b_syn_ic = TRUE; |
7 | 3509 else |
3510 EMSG2(_("E390: Illegal argument: %s"), arg); | |
3511 } | |
3512 | |
3513 /* | |
419 | 3514 * Handle ":syntax spell" command. |
3515 */ | |
3516 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3517 syn_cmd_spell(exarg_T *eap, int syncing UNUSED) |
419 | 3518 { |
3519 char_u *arg = eap->arg; | |
3520 char_u *next; | |
3521 | |
3522 eap->nextcmd = find_nextcmd(arg); | |
3523 if (eap->skip) | |
3524 return; | |
3525 | |
3526 next = skiptowhite(arg); | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3527 if (*arg == NUL) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3528 { |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3529 if (curwin->w_s->b_syn_spell == SYNSPL_TOP) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3530 MSG(_("syntax spell toplevel")); |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3531 else if (curwin->w_s->b_syn_spell == SYNSPL_NOTOP) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3532 MSG(_("syntax spell notoplevel")); |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3533 else |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3534 MSG(_("syntax spell default")); |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3535 } |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3536 else if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3537 curwin->w_s->b_syn_spell = SYNSPL_TOP; |
419 | 3538 else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3539 curwin->w_s->b_syn_spell = SYNSPL_NOTOP; |
1064 | 3540 else if (STRNICMP(arg, "default", 7) == 0 && next - arg == 7) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3541 curwin->w_s->b_syn_spell = SYNSPL_DEFAULT; |
419 | 3542 else |
6880 | 3543 { |
419 | 3544 EMSG2(_("E390: Illegal argument: %s"), arg); |
6880 | 3545 return; |
3546 } | |
3547 | |
3548 /* assume spell checking changed, force a redraw */ | |
3549 redraw_win_later(curwin, NOT_VALID); | |
419 | 3550 } |
3551 | |
3552 /* | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3553 * Handle ":syntax iskeyword" command. |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3554 */ |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3555 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3556 syn_cmd_iskeyword(exarg_T *eap, int syncing UNUSED) |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3557 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3558 char_u *arg = eap->arg; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3559 char_u save_chartab[32]; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3560 char_u *save_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3561 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3562 if (eap->skip) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3563 return; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3564 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3565 arg = skipwhite(arg); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3566 if (*arg == NUL) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3567 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3568 MSG_PUTS("\n"); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3569 MSG_PUTS(_("syntax iskeyword ")); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3570 if (curwin->w_s->b_syn_isk != empty_option) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3571 msg_outtrans(curwin->w_s->b_syn_isk); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3572 else |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3573 msg_outtrans((char_u *)"not set"); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3574 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3575 else |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3576 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3577 if (STRNICMP(arg, "clear", 5) == 0) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3578 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3579 mch_memmove(curwin->w_s->b_syn_chartab, curbuf->b_chartab, |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3580 (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3581 clear_string_option(&curwin->w_s->b_syn_isk); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3582 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3583 else |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3584 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3585 mch_memmove(save_chartab, curbuf->b_chartab, (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3586 save_isk = curbuf->b_p_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3587 curbuf->b_p_isk = vim_strsave(arg); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3588 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3589 buf_init_chartab(curbuf, FALSE); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3590 mch_memmove(curwin->w_s->b_syn_chartab, curbuf->b_chartab, |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3591 (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3592 mch_memmove(curbuf->b_chartab, save_chartab, (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3593 clear_string_option(&curwin->w_s->b_syn_isk); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3594 curwin->w_s->b_syn_isk = curbuf->b_p_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3595 curbuf->b_p_isk = save_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3596 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3597 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3598 redraw_win_later(curwin, NOT_VALID); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3599 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3600 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3601 /* |
7 | 3602 * Clear all syntax info for one buffer. |
3603 */ | |
3604 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3605 syntax_clear(synblock_T *block) |
7 | 3606 { |
3607 int i; | |
3608 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3609 block->b_syn_error = FALSE; /* clear previous error */ |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3610 #ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3611 block->b_syn_slow = FALSE; /* clear previous timeout */ |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3612 #endif |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3613 block->b_syn_ic = FALSE; /* Use case, by default */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3614 block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3615 block->b_syn_containedin = FALSE; |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3616 #ifdef FEAT_CONCEAL |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3617 block->b_syn_conceal = FALSE; |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3618 #endif |
7 | 3619 |
3620 /* free the keywords */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3621 clear_keywtab(&block->b_keywtab); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3622 clear_keywtab(&block->b_keywtab_ic); |
7 | 3623 |
3624 /* free the syntax patterns */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3625 for (i = block->b_syn_patterns.ga_len; --i >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3626 syn_clear_pattern(block, i); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3627 ga_clear(&block->b_syn_patterns); |
7 | 3628 |
3629 /* free the syntax clusters */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3630 for (i = block->b_syn_clusters.ga_len; --i >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3631 syn_clear_cluster(block, i); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3632 ga_clear(&block->b_syn_clusters); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3633 block->b_spell_cluster_id = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3634 block->b_nospell_cluster_id = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3635 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3636 block->b_syn_sync_flags = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3637 block->b_syn_sync_minlines = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3638 block->b_syn_sync_maxlines = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3639 block->b_syn_sync_linebreaks = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3640 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
3641 vim_regfree(block->b_syn_linecont_prog); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3642 block->b_syn_linecont_prog = NULL; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
3643 VIM_CLEAR(block->b_syn_linecont_pat); |
7 | 3644 #ifdef FEAT_FOLDING |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3645 block->b_syn_folditems = 0; |
7 | 3646 #endif |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3647 clear_string_option(&block->b_syn_isk); |
7 | 3648 |
3649 /* free the stored states */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3650 syn_stack_free_all(block); |
7 | 3651 invalidate_current_state(); |
2743 | 3652 |
3653 /* Reset the counter for ":syn include" */ | |
3654 running_syn_inc_tag = 0; | |
7 | 3655 } |
3656 | |
3657 /* | |
2253
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3658 * Get rid of ownsyntax for window "wp". |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3659 */ |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3660 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3661 reset_synblock(win_T *wp) |
2253
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3662 { |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3663 if (wp->w_s != &wp->w_buffer->b_s) |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3664 { |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3665 syntax_clear(wp->w_s); |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3666 vim_free(wp->w_s); |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3667 wp->w_s = &wp->w_buffer->b_s; |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3668 } |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3669 } |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3670 |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3671 /* |
7 | 3672 * Clear syncing info for one buffer. |
3673 */ | |
3674 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3675 syntax_sync_clear(void) |
7 | 3676 { |
3677 int i; | |
3678 | |
3679 /* free the syntax patterns */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3680 for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3681 if (SYN_ITEMS(curwin->w_s)[i].sp_syncing) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3682 syn_remove_pattern(curwin->w_s, i); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3683 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3684 curwin->w_s->b_syn_sync_flags = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3685 curwin->w_s->b_syn_sync_minlines = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3686 curwin->w_s->b_syn_sync_maxlines = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3687 curwin->w_s->b_syn_sync_linebreaks = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3688 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
3689 vim_regfree(curwin->w_s->b_syn_linecont_prog); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3690 curwin->w_s->b_syn_linecont_prog = NULL; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
3691 VIM_CLEAR(curwin->w_s->b_syn_linecont_pat); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3692 clear_string_option(&curwin->w_s->b_syn_isk); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3693 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3694 syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ |
7 | 3695 } |
3696 | |
3697 /* | |
3698 * Remove one pattern from the buffer's pattern list. | |
3699 */ | |
3700 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3701 syn_remove_pattern( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3702 synblock_T *block, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3703 int idx) |
7 | 3704 { |
3705 synpat_T *spp; | |
3706 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3707 spp = &(SYN_ITEMS(block)[idx]); |
7 | 3708 #ifdef FEAT_FOLDING |
3709 if (spp->sp_flags & HL_FOLD) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3710 --block->b_syn_folditems; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3711 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3712 syn_clear_pattern(block, idx); |
7 | 3713 mch_memmove(spp, spp + 1, |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3714 sizeof(synpat_T) * (block->b_syn_patterns.ga_len - idx - 1)); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3715 --block->b_syn_patterns.ga_len; |
7 | 3716 } |
3717 | |
3718 /* | |
3719 * Clear and free one syntax pattern. When clearing all, must be called from | |
3720 * last to first! | |
3721 */ | |
3722 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3723 syn_clear_pattern(synblock_T *block, int i) |
7 | 3724 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3725 vim_free(SYN_ITEMS(block)[i].sp_pattern); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
3726 vim_regfree(SYN_ITEMS(block)[i].sp_prog); |
7 | 3727 /* Only free sp_cont_list and sp_next_list of first start pattern */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3728 if (i == 0 || SYN_ITEMS(block)[i - 1].sp_type != SPTYPE_START) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3729 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3730 vim_free(SYN_ITEMS(block)[i].sp_cont_list); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3731 vim_free(SYN_ITEMS(block)[i].sp_next_list); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3732 vim_free(SYN_ITEMS(block)[i].sp_syn.cont_in_list); |
7 | 3733 } |
3734 } | |
3735 | |
3736 /* | |
3737 * Clear and free one syntax cluster. | |
3738 */ | |
3739 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3740 syn_clear_cluster(synblock_T *block, int i) |
7 | 3741 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3742 vim_free(SYN_CLSTR(block)[i].scl_name); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3743 vim_free(SYN_CLSTR(block)[i].scl_name_u); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3744 vim_free(SYN_CLSTR(block)[i].scl_list); |
7 | 3745 } |
3746 | |
3747 /* | |
3748 * Handle ":syntax clear" command. | |
3749 */ | |
3750 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3751 syn_cmd_clear(exarg_T *eap, int syncing) |
7 | 3752 { |
3753 char_u *arg = eap->arg; | |
3754 char_u *arg_end; | |
3755 int id; | |
3756 | |
3757 eap->nextcmd = find_nextcmd(arg); | |
3758 if (eap->skip) | |
3759 return; | |
3760 | |
3761 /* | |
3762 * We have to disable this within ":syn include @group filename", | |
3763 * because otherwise @group would get deleted. | |
3764 * Only required for Vim 5.x syntax files, 6.0 ones don't contain ":syn | |
3765 * clear". | |
3766 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3767 if (curwin->w_s->b_syn_topgrp != 0) |
7 | 3768 return; |
3769 | |
3770 if (ends_excmd(*arg)) | |
3771 { | |
3772 /* | |
3773 * No argument: Clear all syntax items. | |
3774 */ | |
3775 if (syncing) | |
3776 syntax_sync_clear(); | |
3777 else | |
3778 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3779 syntax_clear(curwin->w_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3780 if (curwin->w_s == &curwin->w_buffer->b_s) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3781 do_unlet((char_u *)"b:current_syntax", TRUE); |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
3782 do_unlet((char_u *)"w:current_syntax", TRUE); |
7 | 3783 } |
3784 } | |
3785 else | |
3786 { | |
3787 /* | |
3788 * Clear the group IDs that are in the argument. | |
3789 */ | |
3790 while (!ends_excmd(*arg)) | |
3791 { | |
3792 arg_end = skiptowhite(arg); | |
3793 if (*arg == '@') | |
3794 { | |
3795 id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1)); | |
3796 if (id == 0) | |
3797 { | |
3798 EMSG2(_("E391: No such syntax cluster: %s"), arg); | |
3799 break; | |
3800 } | |
3801 else | |
3802 { | |
3803 /* | |
3804 * We can't physically delete a cluster without changing | |
3805 * the IDs of other clusters, so we do the next best thing | |
3806 * and make it empty. | |
3807 */ | |
3808 short scl_id = id - SYNID_CLUSTER; | |
3809 | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
3810 VIM_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list); |
7 | 3811 } |
3812 } | |
3813 else | |
3814 { | |
3815 id = syn_namen2id(arg, (int)(arg_end - arg)); | |
3816 if (id == 0) | |
3817 { | |
3818 EMSG2(_(e_nogroup), arg); | |
3819 break; | |
3820 } | |
3821 else | |
3822 syn_clear_one(id, syncing); | |
3823 } | |
3824 arg = skipwhite(arg_end); | |
3825 } | |
3826 } | |
745 | 3827 redraw_curbuf_later(SOME_VALID); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3828 syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ |
7 | 3829 } |
3830 | |
3831 /* | |
3832 * Clear one syntax group for the current buffer. | |
3833 */ | |
3834 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3835 syn_clear_one(int id, int syncing) |
7 | 3836 { |
3837 synpat_T *spp; | |
3838 int idx; | |
3839 | |
3840 /* Clear keywords only when not ":syn sync clear group-name" */ | |
3841 if (!syncing) | |
3842 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3843 (void)syn_clear_keyword(id, &curwin->w_s->b_keywtab); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3844 (void)syn_clear_keyword(id, &curwin->w_s->b_keywtab_ic); |
7 | 3845 } |
3846 | |
3847 /* clear the patterns for "id" */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3848 for (idx = curwin->w_s->b_syn_patterns.ga_len; --idx >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3849 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3850 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
7 | 3851 if (spp->sp_syn.id != id || spp->sp_syncing != syncing) |
3852 continue; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3853 syn_remove_pattern(curwin->w_s, idx); |
7 | 3854 } |
3855 } | |
3856 | |
3857 /* | |
3858 * Handle ":syntax on" command. | |
3859 */ | |
3860 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3861 syn_cmd_on(exarg_T *eap, int syncing UNUSED) |
7 | 3862 { |
3863 syn_cmd_onoff(eap, "syntax"); | |
3864 } | |
3865 | |
3866 /* | |
3867 * Handle ":syntax enable" command. | |
3868 */ | |
3869 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3870 syn_cmd_enable(exarg_T *eap, int syncing UNUSED) |
7 | 3871 { |
3872 set_internal_string_var((char_u *)"syntax_cmd", (char_u *)"enable"); | |
3873 syn_cmd_onoff(eap, "syntax"); | |
148 | 3874 do_unlet((char_u *)"g:syntax_cmd", TRUE); |
7 | 3875 } |
3876 | |
3877 /* | |
3878 * Handle ":syntax reset" command. | |
8815
50d9fb580ffe
commit https://github.com/vim/vim/commit/8bc189e81aa98ba4aebb03a9dc9527a210fce816
Christian Brabandt <cb@256bit.org>
parents:
8806
diff
changeset
|
3879 * It actually resets highlighting, not syntax. |
7 | 3880 */ |
3881 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3882 syn_cmd_reset(exarg_T *eap, int syncing UNUSED) |
7 | 3883 { |
3884 eap->nextcmd = check_nextcmd(eap->arg); | |
3885 if (!eap->skip) | |
3886 { | |
3887 set_internal_string_var((char_u *)"syntax_cmd", (char_u *)"reset"); | |
3888 do_cmdline_cmd((char_u *)"runtime! syntax/syncolor.vim"); | |
148 | 3889 do_unlet((char_u *)"g:syntax_cmd", TRUE); |
7 | 3890 } |
3891 } | |
3892 | |
3893 /* | |
3894 * Handle ":syntax manual" command. | |
3895 */ | |
3896 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3897 syn_cmd_manual(exarg_T *eap, int syncing UNUSED) |
7 | 3898 { |
3899 syn_cmd_onoff(eap, "manual"); | |
3900 } | |
3901 | |
3902 /* | |
3903 * Handle ":syntax off" command. | |
3904 */ | |
3905 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3906 syn_cmd_off(exarg_T *eap, int syncing UNUSED) |
7 | 3907 { |
3908 syn_cmd_onoff(eap, "nosyntax"); | |
3909 } | |
3910 | |
3911 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3912 syn_cmd_onoff(exarg_T *eap, char *name) |
7 | 3913 { |
3914 char_u buf[100]; | |
3915 | |
3916 eap->nextcmd = check_nextcmd(eap->arg); | |
3917 if (!eap->skip) | |
3918 { | |
3919 STRCPY(buf, "so "); | |
274 | 3920 vim_snprintf((char *)buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name); |
7 | 3921 do_cmdline_cmd(buf); |
3922 } | |
3923 } | |
3924 | |
3925 /* | |
3926 * Handle ":syntax [list]" command: list current syntax words. | |
3927 */ | |
3928 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3929 syn_cmd_list( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3930 exarg_T *eap, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3931 int syncing) /* when TRUE: list syncing items */ |
7 | 3932 { |
3933 char_u *arg = eap->arg; | |
3934 int id; | |
3935 char_u *arg_end; | |
3936 | |
3937 eap->nextcmd = find_nextcmd(arg); | |
3938 if (eap->skip) | |
3939 return; | |
3940 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3941 if (!syntax_present(curwin)) |
7 | 3942 { |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3943 MSG(_(msg_no_items)); |
7 | 3944 return; |
3945 } | |
3946 | |
3947 if (syncing) | |
3948 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3949 if (curwin->w_s->b_syn_sync_flags & SF_CCOMMENT) |
7 | 3950 { |
3951 MSG_PUTS(_("syncing on C-style comments")); | |
3952 syn_lines_msg(); | |
3953 syn_match_msg(); | |
3954 return; | |
3955 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3956 else if (!(curwin->w_s->b_syn_sync_flags & SF_MATCH)) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3957 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3958 if (curwin->w_s->b_syn_sync_minlines == 0) |
7 | 3959 MSG_PUTS(_("no syncing")); |
3960 else | |
3961 { | |
3962 MSG_PUTS(_("syncing starts ")); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3963 msg_outnum(curwin->w_s->b_syn_sync_minlines); |
7 | 3964 MSG_PUTS(_(" lines before top line")); |
3965 syn_match_msg(); | |
3966 } | |
3967 return; | |
3968 } | |
3969 MSG_PUTS_TITLE(_("\n--- Syntax sync items ---")); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3970 if (curwin->w_s->b_syn_sync_minlines > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3971 || curwin->w_s->b_syn_sync_maxlines > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3972 || curwin->w_s->b_syn_sync_linebreaks > 0) |
7 | 3973 { |
3974 MSG_PUTS(_("\nsyncing on items")); | |
3975 syn_lines_msg(); | |
3976 syn_match_msg(); | |
3977 } | |
3978 } | |
3979 else | |
3980 MSG_PUTS_TITLE(_("\n--- Syntax items ---")); | |
3981 if (ends_excmd(*arg)) | |
3982 { | |
3983 /* | |
3984 * No argument: List all group IDs and all syntax clusters. | |
3985 */ | |
3986 for (id = 1; id <= highlight_ga.ga_len && !got_int; ++id) | |
3987 syn_list_one(id, syncing, FALSE); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3988 for (id = 0; id < curwin->w_s->b_syn_clusters.ga_len && !got_int; ++id) |
7 | 3989 syn_list_cluster(id); |
3990 } | |
3991 else | |
3992 { | |
3993 /* | |
3994 * List the group IDs and syntax clusters that are in the argument. | |
3995 */ | |
3996 while (!ends_excmd(*arg) && !got_int) | |
3997 { | |
3998 arg_end = skiptowhite(arg); | |
3999 if (*arg == '@') | |
4000 { | |
4001 id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1)); | |
4002 if (id == 0) | |
4003 EMSG2(_("E392: No such syntax cluster: %s"), arg); | |
4004 else | |
4005 syn_list_cluster(id - SYNID_CLUSTER); | |
4006 } | |
4007 else | |
4008 { | |
4009 id = syn_namen2id(arg, (int)(arg_end - arg)); | |
4010 if (id == 0) | |
4011 EMSG2(_(e_nogroup), arg); | |
4012 else | |
4013 syn_list_one(id, syncing, TRUE); | |
4014 } | |
4015 arg = skipwhite(arg_end); | |
4016 } | |
4017 } | |
4018 eap->nextcmd = check_nextcmd(arg); | |
4019 } | |
4020 | |
4021 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4022 syn_lines_msg(void) |
7 | 4023 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4024 if (curwin->w_s->b_syn_sync_maxlines > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4025 || curwin->w_s->b_syn_sync_minlines > 0) |
7 | 4026 { |
4027 MSG_PUTS("; "); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4028 if (curwin->w_s->b_syn_sync_minlines > 0) |
7 | 4029 { |
4030 MSG_PUTS(_("minimal ")); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4031 msg_outnum(curwin->w_s->b_syn_sync_minlines); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4032 if (curwin->w_s->b_syn_sync_maxlines) |
7 | 4033 MSG_PUTS(", "); |
4034 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4035 if (curwin->w_s->b_syn_sync_maxlines > 0) |
7 | 4036 { |
4037 MSG_PUTS(_("maximal ")); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4038 msg_outnum(curwin->w_s->b_syn_sync_maxlines); |
7 | 4039 } |
4040 MSG_PUTS(_(" lines before top line")); | |
4041 } | |
4042 } | |
4043 | |
4044 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4045 syn_match_msg(void) |
7 | 4046 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4047 if (curwin->w_s->b_syn_sync_linebreaks > 0) |
7 | 4048 { |
4049 MSG_PUTS(_("; match ")); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4050 msg_outnum(curwin->w_s->b_syn_sync_linebreaks); |
7 | 4051 MSG_PUTS(_(" line breaks")); |
4052 } | |
4053 } | |
4054 | |
4055 static int last_matchgroup; | |
4056 | |
4057 struct name_list | |
4058 { | |
4059 int flag; | |
4060 char *name; | |
4061 }; | |
4062 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
4063 static void syn_list_flags(struct name_list *nl, int flags, int attr); |
7 | 4064 |
4065 /* | |
4066 * List one syntax item, for ":syntax" or "syntax list syntax_name". | |
4067 */ | |
4068 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4069 syn_list_one( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4070 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4071 int syncing, /* when TRUE: list syncing items */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4072 int link_only) /* when TRUE; list link-only too */ |
7 | 4073 { |
4074 int attr; | |
4075 int idx; | |
4076 int did_header = FALSE; | |
4077 synpat_T *spp; | |
4078 static struct name_list namelist1[] = | |
4079 { | |
4080 {HL_DISPLAY, "display"}, | |
4081 {HL_CONTAINED, "contained"}, | |
4082 {HL_ONELINE, "oneline"}, | |
4083 {HL_KEEPEND, "keepend"}, | |
4084 {HL_EXTEND, "extend"}, | |
4085 {HL_EXCLUDENL, "excludenl"}, | |
4086 {HL_TRANSP, "transparent"}, | |
4087 {HL_FOLD, "fold"}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4088 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4089 {HL_CONCEAL, "conceal"}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4090 {HL_CONCEALENDS, "concealends"}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4091 #endif |
7 | 4092 {0, NULL} |
4093 }; | |
4094 static struct name_list namelist2[] = | |
4095 { | |
4096 {HL_SKIPWHITE, "skipwhite"}, | |
4097 {HL_SKIPNL, "skipnl"}, | |
4098 {HL_SKIPEMPTY, "skipempty"}, | |
4099 {0, NULL} | |
4100 }; | |
4101 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
4102 attr = HL_ATTR(HLF_D); /* highlight like directories */ |
7 | 4103 |
4104 /* list the keywords for "id" */ | |
4105 if (!syncing) | |
4106 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4107 did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab, FALSE, attr); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4108 did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab_ic, |
7 | 4109 did_header, attr); |
4110 } | |
4111 | |
4112 /* list the patterns for "id" */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4113 for (idx = 0; idx < curwin->w_s->b_syn_patterns.ga_len && !got_int; ++idx) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4114 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4115 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
7 | 4116 if (spp->sp_syn.id != id || spp->sp_syncing != syncing) |
4117 continue; | |
4118 | |
4119 (void)syn_list_header(did_header, 999, id); | |
4120 did_header = TRUE; | |
4121 last_matchgroup = 0; | |
4122 if (spp->sp_type == SPTYPE_MATCH) | |
4123 { | |
4124 put_pattern("match", ' ', spp, attr); | |
4125 msg_putchar(' '); | |
4126 } | |
4127 else if (spp->sp_type == SPTYPE_START) | |
4128 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4129 while (SYN_ITEMS(curwin->w_s)[idx].sp_type == SPTYPE_START) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4130 put_pattern("start", '=', &SYN_ITEMS(curwin->w_s)[idx++], attr); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4131 if (SYN_ITEMS(curwin->w_s)[idx].sp_type == SPTYPE_SKIP) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4132 put_pattern("skip", '=', &SYN_ITEMS(curwin->w_s)[idx++], attr); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4133 while (idx < curwin->w_s->b_syn_patterns.ga_len |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4134 && SYN_ITEMS(curwin->w_s)[idx].sp_type == SPTYPE_END) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4135 put_pattern("end", '=', &SYN_ITEMS(curwin->w_s)[idx++], attr); |
7 | 4136 --idx; |
4137 msg_putchar(' '); | |
4138 } | |
4139 syn_list_flags(namelist1, spp->sp_flags, attr); | |
4140 | |
4141 if (spp->sp_cont_list != NULL) | |
4142 put_id_list((char_u *)"contains", spp->sp_cont_list, attr); | |
4143 | |
4144 if (spp->sp_syn.cont_in_list != NULL) | |
4145 put_id_list((char_u *)"containedin", | |
4146 spp->sp_syn.cont_in_list, attr); | |
4147 | |
4148 if (spp->sp_next_list != NULL) | |
4149 { | |
4150 put_id_list((char_u *)"nextgroup", spp->sp_next_list, attr); | |
4151 syn_list_flags(namelist2, spp->sp_flags, attr); | |
4152 } | |
4153 if (spp->sp_flags & (HL_SYNC_HERE|HL_SYNC_THERE)) | |
4154 { | |
4155 if (spp->sp_flags & HL_SYNC_HERE) | |
4156 msg_puts_attr((char_u *)"grouphere", attr); | |
4157 else | |
4158 msg_puts_attr((char_u *)"groupthere", attr); | |
4159 msg_putchar(' '); | |
4160 if (spp->sp_sync_idx >= 0) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4161 msg_outtrans(HL_TABLE()[SYN_ITEMS(curwin->w_s) |
7 | 4162 [spp->sp_sync_idx].sp_syn.id - 1].sg_name); |
4163 else | |
4164 MSG_PUTS("NONE"); | |
4165 msg_putchar(' '); | |
4166 } | |
4167 } | |
4168 | |
4169 /* list the link, if there is one */ | |
4170 if (HL_TABLE()[id - 1].sg_link && (did_header || link_only) && !got_int) | |
4171 { | |
4172 (void)syn_list_header(did_header, 999, id); | |
4173 msg_puts_attr((char_u *)"links to", attr); | |
4174 msg_putchar(' '); | |
4175 msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name); | |
4176 } | |
4177 } | |
4178 | |
4179 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4180 syn_list_flags(struct name_list *nlist, int flags, int attr) |
7 | 4181 { |
4182 int i; | |
4183 | |
3263 | 4184 for (i = 0; nlist[i].flag != 0; ++i) |
4185 if (flags & nlist[i].flag) | |
4186 { | |
4187 msg_puts_attr((char_u *)nlist[i].name, attr); | |
7 | 4188 msg_putchar(' '); |
4189 } | |
4190 } | |
4191 | |
4192 /* | |
4193 * List one syntax cluster, for ":syntax" or "syntax list syntax_name". | |
4194 */ | |
4195 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4196 syn_list_cluster(int id) |
7 | 4197 { |
4198 int endcol = 15; | |
4199 | |
4200 /* slight hack: roughly duplicate the guts of syn_list_header() */ | |
4201 msg_putchar('\n'); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4202 msg_outtrans(SYN_CLSTR(curwin->w_s)[id].scl_name); |
7 | 4203 |
4204 if (msg_col >= endcol) /* output at least one space */ | |
4205 endcol = msg_col + 1; | |
4206 if (Columns <= endcol) /* avoid hang for tiny window */ | |
4207 endcol = Columns - 1; | |
4208 | |
4209 msg_advance(endcol); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4210 if (SYN_CLSTR(curwin->w_s)[id].scl_list != NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4211 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4212 put_id_list((char_u *)"cluster", SYN_CLSTR(curwin->w_s)[id].scl_list, |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
4213 HL_ATTR(HLF_D)); |
7 | 4214 } |
4215 else | |
4216 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
4217 msg_puts_attr((char_u *)"cluster", HL_ATTR(HLF_D)); |
7 | 4218 msg_puts((char_u *)"=NONE"); |
4219 } | |
4220 } | |
4221 | |
4222 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4223 put_id_list(char_u *name, short *list, int attr) |
7 | 4224 { |
4225 short *p; | |
4226 | |
4227 msg_puts_attr(name, attr); | |
4228 msg_putchar('='); | |
4229 for (p = list; *p; ++p) | |
4230 { | |
4231 if (*p >= SYNID_ALLBUT && *p < SYNID_TOP) | |
4232 { | |
4233 if (p[1]) | |
4234 MSG_PUTS("ALLBUT"); | |
4235 else | |
4236 MSG_PUTS("ALL"); | |
4237 } | |
4238 else if (*p >= SYNID_TOP && *p < SYNID_CONTAINED) | |
4239 { | |
4240 MSG_PUTS("TOP"); | |
4241 } | |
4242 else if (*p >= SYNID_CONTAINED && *p < SYNID_CLUSTER) | |
4243 { | |
4244 MSG_PUTS("CONTAINED"); | |
4245 } | |
4246 else if (*p >= SYNID_CLUSTER) | |
4247 { | |
4248 short scl_id = *p - SYNID_CLUSTER; | |
4249 | |
4250 msg_putchar('@'); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4251 msg_outtrans(SYN_CLSTR(curwin->w_s)[scl_id].scl_name); |
7 | 4252 } |
4253 else | |
4254 msg_outtrans(HL_TABLE()[*p - 1].sg_name); | |
4255 if (p[1]) | |
4256 msg_putchar(','); | |
4257 } | |
4258 msg_putchar(' '); | |
4259 } | |
4260 | |
4261 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4262 put_pattern( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4263 char *s, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4264 int c, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4265 synpat_T *spp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4266 int attr) |
7 | 4267 { |
4268 long n; | |
4269 int mask; | |
4270 int first; | |
4271 static char *sepchars = "/+=-#@\"|'^&"; | |
4272 int i; | |
4273 | |
4274 /* May have to write "matchgroup=group" */ | |
4275 if (last_matchgroup != spp->sp_syn_match_id) | |
4276 { | |
4277 last_matchgroup = spp->sp_syn_match_id; | |
4278 msg_puts_attr((char_u *)"matchgroup", attr); | |
4279 msg_putchar('='); | |
4280 if (last_matchgroup == 0) | |
4281 msg_outtrans((char_u *)"NONE"); | |
4282 else | |
4283 msg_outtrans(HL_TABLE()[last_matchgroup - 1].sg_name); | |
4284 msg_putchar(' '); | |
4285 } | |
4286 | |
4287 /* output the name of the pattern and an '=' or ' ' */ | |
4288 msg_puts_attr((char_u *)s, attr); | |
4289 msg_putchar(c); | |
4290 | |
4291 /* output the pattern, in between a char that is not in the pattern */ | |
4292 for (i = 0; vim_strchr(spp->sp_pattern, sepchars[i]) != NULL; ) | |
4293 if (sepchars[++i] == NUL) | |
4294 { | |
4295 i = 0; /* no good char found, just use the first one */ | |
4296 break; | |
4297 } | |
4298 msg_putchar(sepchars[i]); | |
4299 msg_outtrans(spp->sp_pattern); | |
4300 msg_putchar(sepchars[i]); | |
4301 | |
4302 /* output any pattern options */ | |
4303 first = TRUE; | |
4304 for (i = 0; i < SPO_COUNT; ++i) | |
4305 { | |
4306 mask = (1 << i); | |
4307 if (spp->sp_off_flags & (mask + (mask << SPO_COUNT))) | |
4308 { | |
4309 if (!first) | |
4310 msg_putchar(','); /* separate with commas */ | |
4311 msg_puts((char_u *)spo_name_tab[i]); | |
4312 n = spp->sp_offsets[i]; | |
4313 if (i != SPO_LC_OFF) | |
4314 { | |
4315 if (spp->sp_off_flags & mask) | |
4316 msg_putchar('s'); | |
4317 else | |
4318 msg_putchar('e'); | |
4319 if (n > 0) | |
4320 msg_putchar('+'); | |
4321 } | |
4322 if (n || i == SPO_LC_OFF) | |
4323 msg_outnum(n); | |
4324 first = FALSE; | |
4325 } | |
4326 } | |
4327 msg_putchar(' '); | |
4328 } | |
4329 | |
4330 /* | |
4331 * List or clear the keywords for one syntax group. | |
4332 * Return TRUE if the header has been printed. | |
4333 */ | |
4334 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4335 syn_list_keywords( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4336 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4337 hashtab_T *ht, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4338 int did_header, /* header has already been printed */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4339 int attr) |
7 | 4340 { |
4341 int outlen; | |
134 | 4342 hashitem_T *hi; |
4343 keyentry_T *kp; | |
4344 int todo; | |
7 | 4345 int prev_contained = 0; |
4346 short *prev_next_list = NULL; | |
4347 short *prev_cont_in_list = NULL; | |
4348 int prev_skipnl = 0; | |
4349 int prev_skipwhite = 0; | |
4350 int prev_skipempty = 0; | |
4351 | |
4352 /* | |
4353 * Unfortunately, this list of keywords is not sorted on alphabet but on | |
4354 * hash value... | |
4355 */ | |
835 | 4356 todo = (int)ht->ht_used; |
134 | 4357 for (hi = ht->ht_array; todo > 0 && !got_int; ++hi) |
4358 { | |
4359 if (!HASHITEM_EMPTY(hi)) | |
4360 { | |
4361 --todo; | |
4362 for (kp = HI2KE(hi); kp != NULL && !got_int; kp = kp->ke_next) | |
7 | 4363 { |
134 | 4364 if (kp->k_syn.id == id) |
7 | 4365 { |
134 | 4366 if (prev_contained != (kp->flags & HL_CONTAINED) |
4367 || prev_skipnl != (kp->flags & HL_SKIPNL) | |
4368 || prev_skipwhite != (kp->flags & HL_SKIPWHITE) | |
4369 || prev_skipempty != (kp->flags & HL_SKIPEMPTY) | |
4370 || prev_cont_in_list != kp->k_syn.cont_in_list | |
4371 || prev_next_list != kp->next_list) | |
4372 outlen = 9999; | |
4373 else | |
4374 outlen = (int)STRLEN(kp->keyword); | |
4375 /* output "contained" and "nextgroup" on each line */ | |
4376 if (syn_list_header(did_header, outlen, id)) | |
4377 { | |
4378 prev_contained = 0; | |
4379 prev_next_list = NULL; | |
4380 prev_cont_in_list = NULL; | |
4381 prev_skipnl = 0; | |
4382 prev_skipwhite = 0; | |
4383 prev_skipempty = 0; | |
4384 } | |
4385 did_header = TRUE; | |
4386 if (prev_contained != (kp->flags & HL_CONTAINED)) | |
4387 { | |
4388 msg_puts_attr((char_u *)"contained", attr); | |
4389 msg_putchar(' '); | |
4390 prev_contained = (kp->flags & HL_CONTAINED); | |
4391 } | |
4392 if (kp->k_syn.cont_in_list != prev_cont_in_list) | |
4393 { | |
4394 put_id_list((char_u *)"containedin", | |
4395 kp->k_syn.cont_in_list, attr); | |
4396 msg_putchar(' '); | |
4397 prev_cont_in_list = kp->k_syn.cont_in_list; | |
4398 } | |
4399 if (kp->next_list != prev_next_list) | |
4400 { | |
4401 put_id_list((char_u *)"nextgroup", kp->next_list, attr); | |
4402 msg_putchar(' '); | |
4403 prev_next_list = kp->next_list; | |
4404 if (kp->flags & HL_SKIPNL) | |
4405 { | |
4406 msg_puts_attr((char_u *)"skipnl", attr); | |
4407 msg_putchar(' '); | |
4408 prev_skipnl = (kp->flags & HL_SKIPNL); | |
4409 } | |
4410 if (kp->flags & HL_SKIPWHITE) | |
4411 { | |
4412 msg_puts_attr((char_u *)"skipwhite", attr); | |
4413 msg_putchar(' '); | |
4414 prev_skipwhite = (kp->flags & HL_SKIPWHITE); | |
4415 } | |
4416 if (kp->flags & HL_SKIPEMPTY) | |
4417 { | |
4418 msg_puts_attr((char_u *)"skipempty", attr); | |
4419 msg_putchar(' '); | |
4420 prev_skipempty = (kp->flags & HL_SKIPEMPTY); | |
4421 } | |
4422 } | |
4423 msg_outtrans(kp->keyword); | |
7 | 4424 } |
4425 } | |
4426 } | |
4427 } | |
4428 | |
4429 return did_header; | |
4430 } | |
4431 | |
4432 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4433 syn_clear_keyword(int id, hashtab_T *ht) |
134 | 4434 { |
4435 hashitem_T *hi; | |
4436 keyentry_T *kp; | |
4437 keyentry_T *kp_prev; | |
4438 keyentry_T *kp_next; | |
4439 int todo; | |
4440 | |
4441 hash_lock(ht); | |
835 | 4442 todo = (int)ht->ht_used; |
134 | 4443 for (hi = ht->ht_array; todo > 0; ++hi) |
4444 { | |
4445 if (!HASHITEM_EMPTY(hi)) | |
4446 { | |
4447 --todo; | |
4448 kp_prev = NULL; | |
4449 for (kp = HI2KE(hi); kp != NULL; ) | |
7 | 4450 { |
134 | 4451 if (kp->k_syn.id == id) |
4452 { | |
4453 kp_next = kp->ke_next; | |
4454 if (kp_prev == NULL) | |
4455 { | |
4456 if (kp_next == NULL) | |
4457 hash_remove(ht, hi); | |
4458 else | |
4459 hi->hi_key = KE2HIKEY(kp_next); | |
4460 } | |
4461 else | |
4462 kp_prev->ke_next = kp_next; | |
4463 vim_free(kp->next_list); | |
4464 vim_free(kp->k_syn.cont_in_list); | |
4465 vim_free(kp); | |
4466 kp = kp_next; | |
4467 } | |
7 | 4468 else |
134 | 4469 { |
4470 kp_prev = kp; | |
4471 kp = kp->ke_next; | |
4472 } | |
7 | 4473 } |
134 | 4474 } |
4475 } | |
4476 hash_unlock(ht); | |
4477 } | |
4478 | |
4479 /* | |
4480 * Clear a whole keyword table. | |
7 | 4481 */ |
4482 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4483 clear_keywtab(hashtab_T *ht) |
134 | 4484 { |
4485 hashitem_T *hi; | |
4486 int todo; | |
4487 keyentry_T *kp; | |
4488 keyentry_T *kp_next; | |
4489 | |
835 | 4490 todo = (int)ht->ht_used; |
134 | 4491 for (hi = ht->ht_array; todo > 0; ++hi) |
4492 { | |
4493 if (!HASHITEM_EMPTY(hi)) | |
4494 { | |
4495 --todo; | |
4496 for (kp = HI2KE(hi); kp != NULL; kp = kp_next) | |
7 | 4497 { |
134 | 4498 kp_next = kp->ke_next; |
4499 vim_free(kp->next_list); | |
4500 vim_free(kp->k_syn.cont_in_list); | |
4501 vim_free(kp); | |
7 | 4502 } |
134 | 4503 } |
4504 } | |
4505 hash_clear(ht); | |
4506 hash_init(ht); | |
7 | 4507 } |
4508 | |
4509 /* | |
4510 * Add a keyword to the list of keywords. | |
4511 */ | |
4512 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4513 add_keyword( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4514 char_u *name, /* name of keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4515 int id, /* group ID for this keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4516 int flags, /* flags for this keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4517 short *cont_in_list, /* containedin for this keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4518 short *next_list, /* nextgroup for this keyword */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4519 int conceal_char) |
7 | 4520 { |
134 | 4521 keyentry_T *kp; |
4522 hashtab_T *ht; | |
4523 hashitem_T *hi; | |
154 | 4524 char_u *name_ic; |
134 | 4525 long_u hash; |
154 | 4526 char_u name_folded[MAXKEYWLEN + 1]; |
7 | 4527 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4528 if (curwin->w_s->b_syn_ic) |
154 | 4529 name_ic = str_foldcase(name, (int)STRLEN(name), |
4530 name_folded, MAXKEYWLEN + 1); | |
4531 else | |
4532 name_ic = name; | |
134 | 4533 kp = (keyentry_T *)alloc((int)(sizeof(keyentry_T) + STRLEN(name_ic))); |
4534 if (kp == NULL) | |
4535 return; | |
4536 STRCPY(kp->keyword, name_ic); | |
4537 kp->k_syn.id = id; | |
4538 kp->k_syn.inc_tag = current_syn_inc_tag; | |
4539 kp->flags = flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4540 kp->k_char = conceal_char; |
134 | 4541 kp->k_syn.cont_in_list = copy_id_list(cont_in_list); |
4542 if (cont_in_list != NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4543 curwin->w_s->b_syn_containedin = TRUE; |
134 | 4544 kp->next_list = copy_id_list(next_list); |
4545 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4546 if (curwin->w_s->b_syn_ic) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4547 ht = &curwin->w_s->b_keywtab_ic; |
7 | 4548 else |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4549 ht = &curwin->w_s->b_keywtab; |
134 | 4550 |
4551 hash = hash_hash(kp->keyword); | |
4552 hi = hash_lookup(ht, kp->keyword, hash); | |
4553 if (HASHITEM_EMPTY(hi)) | |
4554 { | |
4555 /* new keyword, add to hashtable */ | |
4556 kp->ke_next = NULL; | |
4557 hash_add_item(ht, hi, kp->keyword, hash); | |
4558 } | |
4559 else | |
4560 { | |
4561 /* keyword already exists, prepend to list */ | |
4562 kp->ke_next = HI2KE(hi); | |
4563 hi->hi_key = KE2HIKEY(kp); | |
4564 } | |
7 | 4565 } |
4566 | |
4567 /* | |
4568 * Get the start and end of the group name argument. | |
4569 * Return a pointer to the first argument. | |
4570 * Return NULL if the end of the command was found instead of further args. | |
4571 */ | |
4572 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4573 get_group_name( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4574 char_u *arg, /* start of the argument */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4575 char_u **name_end) /* pointer to end of the name */ |
7 | 4576 { |
4577 char_u *rest; | |
4578 | |
4579 *name_end = skiptowhite(arg); | |
4580 rest = skipwhite(*name_end); | |
4581 | |
4582 /* | |
4583 * Check if there are enough arguments. The first argument may be a | |
4584 * pattern, where '|' is allowed, so only check for NUL. | |
4585 */ | |
4586 if (ends_excmd(*arg) || *rest == NUL) | |
4587 return NULL; | |
4588 return rest; | |
4589 } | |
4590 | |
4591 /* | |
4592 * Check for syntax command option arguments. | |
4593 * This can be called at any place in the list of arguments, and just picks | |
4594 * out the arguments that are known. Can be called several times in a row to | |
4595 * collect all options in between other arguments. | |
4596 * Return a pointer to the next argument (which isn't an option). | |
4597 * Return NULL for any error; | |
4598 */ | |
4599 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4600 get_syn_options( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4601 char_u *arg, /* next argument to be checked */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4602 syn_opt_arg_T *opt, /* various things */ |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4603 int *conceal_char UNUSED, |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4604 int skip) /* TRUE if skipping over command */ |
154 | 4605 { |
7 | 4606 char_u *gname_start, *gname; |
4607 int syn_id; | |
4608 int len; | |
154 | 4609 char *p; |
7 | 4610 int i; |
4611 int fidx; | |
4612 static struct flag | |
4613 { | |
4614 char *name; | |
154 | 4615 int argtype; |
4616 int flags; | |
4617 } flagtab[] = { {"cCoOnNtTaAiInNeEdD", 0, HL_CONTAINED}, | |
4618 {"oOnNeElLiInNeE", 0, HL_ONELINE}, | |
4619 {"kKeEeEpPeEnNdD", 0, HL_KEEPEND}, | |
4620 {"eExXtTeEnNdD", 0, HL_EXTEND}, | |
4621 {"eExXcClLuUdDeEnNlL", 0, HL_EXCLUDENL}, | |
4622 {"tTrRaAnNsSpPaArReEnNtT", 0, HL_TRANSP}, | |
4623 {"sSkKiIpPnNlL", 0, HL_SKIPNL}, | |
4624 {"sSkKiIpPwWhHiItTeE", 0, HL_SKIPWHITE}, | |
4625 {"sSkKiIpPeEmMpPtTyY", 0, HL_SKIPEMPTY}, | |
4626 {"gGrRoOuUpPhHeErReE", 0, HL_SYNC_HERE}, | |
4627 {"gGrRoOuUpPtThHeErReE", 0, HL_SYNC_THERE}, | |
4628 {"dDiIsSpPlLaAyY", 0, HL_DISPLAY}, | |
4629 {"fFoOlLdD", 0, HL_FOLD}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4630 {"cCoOnNcCeEaAlL", 0, HL_CONCEAL}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4631 {"cCoOnNcCeEaAlLeEnNdDsS", 0, HL_CONCEALENDS}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4632 {"cCcChHaArR", 11, 0}, |
154 | 4633 {"cCoOnNtTaAiInNsS", 1, 0}, |
4634 {"cCoOnNtTaAiInNeEdDiInN", 2, 0}, | |
4635 {"nNeExXtTgGrRoOuUpP", 3, 0}, | |
7 | 4636 }; |
154 | 4637 static char *first_letters = "cCoOkKeEtTsSgGdDfFnN"; |
7 | 4638 |
4639 if (arg == NULL) /* already detected error */ | |
4640 return NULL; | |
4641 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4642 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4643 if (curwin->w_s->b_syn_conceal) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4644 opt->flags |= HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4645 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4646 |
7 | 4647 for (;;) |
4648 { | |
154 | 4649 /* |
4650 * This is used very often when a large number of keywords is defined. | |
4651 * Need to skip quickly when no option name is found. | |
4652 * Also avoid tolower(), it's slow. | |
4653 */ | |
4654 if (strchr(first_letters, *arg) == NULL) | |
4655 break; | |
7 | 4656 |
4657 for (fidx = sizeof(flagtab) / sizeof(struct flag); --fidx >= 0; ) | |
4658 { | |
154 | 4659 p = flagtab[fidx].name; |
4660 for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) | |
4661 if (arg[len] != p[i] && arg[len] != p[i + 1]) | |
4662 break; | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
4663 if (p[i] == NUL && (VIM_ISWHITE(arg[len]) |
154 | 4664 || (flagtab[fidx].argtype > 0 |
4665 ? arg[len] == '=' | |
4666 : ends_excmd(arg[len])))) | |
7 | 4667 { |
154 | 4668 if (opt->keyword |
4669 && (flagtab[fidx].flags == HL_DISPLAY | |
4670 || flagtab[fidx].flags == HL_FOLD | |
4671 || flagtab[fidx].flags == HL_EXTEND)) | |
7 | 4672 /* treat "display", "fold" and "extend" as a keyword */ |
4673 fidx = -1; | |
4674 break; | |
4675 } | |
4676 } | |
154 | 4677 if (fidx < 0) /* no match found */ |
4678 break; | |
4679 | |
4680 if (flagtab[fidx].argtype == 1) | |
4681 { | |
4682 if (!opt->has_cont_list) | |
7 | 4683 { |
4684 EMSG(_("E395: contains argument not accepted here")); | |
4685 return NULL; | |
4686 } | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4687 if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) |
7 | 4688 return NULL; |
4689 } | |
154 | 4690 else if (flagtab[fidx].argtype == 2) |
4691 { | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4692 if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) |
7 | 4693 return NULL; |
4694 } | |
154 | 4695 else if (flagtab[fidx].argtype == 3) |
4696 { | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4697 if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) |
7 | 4698 return NULL; |
4699 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4700 else if (flagtab[fidx].argtype == 11 && arg[5] == '=') |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4701 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4702 #ifdef FEAT_MBYTE |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4703 /* cchar=? */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4704 if (has_mbyte) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4705 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4706 # ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4707 *conceal_char = mb_ptr2char(arg + 6); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4708 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4709 arg += mb_ptr2len(arg + 6) - 1; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4710 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4711 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4712 #endif |
2251
646d34788036
Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4713 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4714 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4715 *conceal_char = arg[6]; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4716 #else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4717 ; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4718 #endif |
2251
646d34788036
Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4719 } |
2686 | 4720 #ifdef FEAT_CONCEAL |
4721 if (!vim_isprintc_strict(*conceal_char)) | |
4722 { | |
4723 EMSG(_("E844: invalid cchar value")); | |
4724 return NULL; | |
4725 } | |
4726 #endif | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4727 arg = skipwhite(arg + 7); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4728 } |
7 | 4729 else |
154 | 4730 { |
4731 opt->flags |= flagtab[fidx].flags; | |
4732 arg = skipwhite(arg + len); | |
4733 | |
4734 if (flagtab[fidx].flags == HL_SYNC_HERE | |
4735 || flagtab[fidx].flags == HL_SYNC_THERE) | |
4736 { | |
4737 if (opt->sync_idx == NULL) | |
4738 { | |
4739 EMSG(_("E393: group[t]here not accepted here")); | |
4740 return NULL; | |
4741 } | |
4742 gname_start = arg; | |
4743 arg = skiptowhite(arg); | |
4744 if (gname_start == arg) | |
4745 return NULL; | |
4746 gname = vim_strnsave(gname_start, (int)(arg - gname_start)); | |
4747 if (gname == NULL) | |
4748 return NULL; | |
4749 if (STRCMP(gname, "NONE") == 0) | |
4750 *opt->sync_idx = NONE_IDX; | |
4751 else | |
4752 { | |
4753 syn_id = syn_name2id(gname); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4754 for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4755 if (SYN_ITEMS(curwin->w_s)[i].sp_syn.id == syn_id |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4756 && SYN_ITEMS(curwin->w_s)[i].sp_type == SPTYPE_START) |
154 | 4757 { |
4758 *opt->sync_idx = i; | |
4759 break; | |
4760 } | |
4761 if (i < 0) | |
4762 { | |
4763 EMSG2(_("E394: Didn't find region item for %s"), gname); | |
4764 vim_free(gname); | |
4765 return NULL; | |
4766 } | |
4767 } | |
4768 | |
4769 vim_free(gname); | |
4770 arg = skipwhite(arg); | |
4771 } | |
4772 #ifdef FEAT_FOLDING | |
4773 else if (flagtab[fidx].flags == HL_FOLD | |
4774 && foldmethodIsSyntax(curwin)) | |
4775 /* Need to update folds later. */ | |
4776 foldUpdateAll(curwin); | |
4777 #endif | |
4778 } | |
4779 } | |
7 | 4780 |
4781 return arg; | |
4782 } | |
4783 | |
4784 /* | |
4785 * Adjustments to syntax item when declared in a ":syn include"'d file. | |
4786 * Set the contained flag, and if the item is not already contained, add it | |
4787 * to the specified top-level group, if any. | |
4788 */ | |
4789 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4790 syn_incl_toplevel(int id, int *flagsp) |
7 | 4791 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4792 if ((*flagsp & HL_CONTAINED) || curwin->w_s->b_syn_topgrp == 0) |
7 | 4793 return; |
4794 *flagsp |= HL_CONTAINED; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4795 if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER) |
7 | 4796 { |
4797 /* We have to alloc this, because syn_combine_list() will free it. */ | |
4798 short *grp_list = (short *)alloc((unsigned)(2 * sizeof(short))); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4799 int tlg_id = curwin->w_s->b_syn_topgrp - SYNID_CLUSTER; |
7 | 4800 |
4801 if (grp_list != NULL) | |
4802 { | |
4803 grp_list[0] = id; | |
4804 grp_list[1] = 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4805 syn_combine_list(&SYN_CLSTR(curwin->w_s)[tlg_id].scl_list, &grp_list, |
7 | 4806 CLUSTER_ADD); |
4807 } | |
4808 } | |
4809 } | |
4810 | |
4811 /* | |
4812 * Handle ":syntax include [@{group-name}] filename" command. | |
4813 */ | |
4814 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4815 syn_cmd_include(exarg_T *eap, int syncing UNUSED) |
7 | 4816 { |
4817 char_u *arg = eap->arg; | |
4818 int sgl_id = 1; | |
4819 char_u *group_name_end; | |
4820 char_u *rest; | |
4821 char_u *errormsg = NULL; | |
4822 int prev_toplvl_grp; | |
4823 int prev_syn_inc_tag; | |
4824 int source = FALSE; | |
4825 | |
4826 eap->nextcmd = find_nextcmd(arg); | |
4827 if (eap->skip) | |
4828 return; | |
4829 | |
4830 if (arg[0] == '@') | |
4831 { | |
4832 ++arg; | |
4833 rest = get_group_name(arg, &group_name_end); | |
4834 if (rest == NULL) | |
4835 { | |
4836 EMSG((char_u *)_("E397: Filename required")); | |
4837 return; | |
4838 } | |
4839 sgl_id = syn_check_cluster(arg, (int)(group_name_end - arg)); | |
2743 | 4840 if (sgl_id == 0) |
4841 return; | |
7 | 4842 /* separate_nextcmd() and expand_filename() depend on this */ |
4843 eap->arg = rest; | |
4844 } | |
4845 | |
4846 /* | |
4847 * Everything that's left, up to the next command, should be the | |
4848 * filename to include. | |
4849 */ | |
4850 eap->argt |= (XFILE | NOSPC); | |
4851 separate_nextcmd(eap); | |
4852 if (*eap->arg == '<' || *eap->arg == '$' || mch_isFullName(eap->arg)) | |
4853 { | |
4854 /* For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the | |
4855 * file. Need to expand the file name first. In other cases | |
4856 * ":runtime!" is used. */ | |
4857 source = TRUE; | |
4858 if (expand_filename(eap, syn_cmdlinep, &errormsg) == FAIL) | |
4859 { | |
4860 if (errormsg != NULL) | |
4861 EMSG(errormsg); | |
4862 return; | |
4863 } | |
4864 } | |
4865 | |
4866 /* | |
4867 * Save and restore the existing top-level grouplist id and ":syn | |
4868 * include" tag around the actual inclusion. | |
4869 */ | |
2743 | 4870 if (running_syn_inc_tag >= MAX_SYN_INC_TAG) |
4871 { | |
4872 EMSG((char_u *)_("E847: Too many syntax includes")); | |
4873 return; | |
4874 } | |
7 | 4875 prev_syn_inc_tag = current_syn_inc_tag; |
4876 current_syn_inc_tag = ++running_syn_inc_tag; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4877 prev_toplvl_grp = curwin->w_s->b_syn_topgrp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4878 curwin->w_s->b_syn_topgrp = sgl_id; |
1299 | 4879 if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8514
diff
changeset
|
4880 : source_runtime(eap->arg, DIP_ALL) == FAIL) |
7 | 4881 EMSG2(_(e_notopen), eap->arg); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4882 curwin->w_s->b_syn_topgrp = prev_toplvl_grp; |
7 | 4883 current_syn_inc_tag = prev_syn_inc_tag; |
4884 } | |
4885 | |
4886 /* | |
4887 * Handle ":syntax keyword {group-name} [{option}] keyword .." command. | |
4888 */ | |
4889 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4890 syn_cmd_keyword(exarg_T *eap, int syncing UNUSED) |
7 | 4891 { |
4892 char_u *arg = eap->arg; | |
4893 char_u *group_name_end; | |
4894 int syn_id; | |
4895 char_u *rest; | |
2743 | 4896 char_u *keyword_copy = NULL; |
7 | 4897 char_u *p; |
154 | 4898 char_u *kw; |
4899 syn_opt_arg_T syn_opt_arg; | |
4900 int cnt; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4901 int conceal_char = NUL; |
7 | 4902 |
4903 rest = get_group_name(arg, &group_name_end); | |
4904 | |
4905 if (rest != NULL) | |
4906 { | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4907 if (eap->skip) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4908 syn_id = -1; |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4909 else |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4910 syn_id = syn_check_group(arg, (int)(group_name_end - arg)); |
2743 | 4911 if (syn_id != 0) |
4912 /* allocate a buffer, for removing backslashes in the keyword */ | |
4913 keyword_copy = alloc((unsigned)STRLEN(rest) + 1); | |
7 | 4914 if (keyword_copy != NULL) |
4915 { | |
154 | 4916 syn_opt_arg.flags = 0; |
4917 syn_opt_arg.keyword = TRUE; | |
4918 syn_opt_arg.sync_idx = NULL; | |
4919 syn_opt_arg.has_cont_list = FALSE; | |
4920 syn_opt_arg.cont_in_list = NULL; | |
4921 syn_opt_arg.next_list = NULL; | |
4922 | |
7 | 4923 /* |
4924 * The options given apply to ALL keywords, so all options must be | |
4925 * found before keywords can be created. | |
154 | 4926 * 1: collect the options and copy the keywords to keyword_copy. |
7 | 4927 */ |
154 | 4928 cnt = 0; |
4929 p = keyword_copy; | |
4930 for ( ; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) | |
7 | 4931 { |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4932 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4933 eap->skip); |
154 | 4934 if (rest == NULL || ends_excmd(*rest)) |
4935 break; | |
4936 /* Copy the keyword, removing backslashes, and add a NUL. */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
4937 while (*rest != NUL && !VIM_ISWHITE(*rest)) |
154 | 4938 { |
4939 if (*rest == '\\' && rest[1] != NUL) | |
4940 ++rest; | |
4941 *p++ = *rest++; | |
4942 } | |
4943 *p++ = NUL; | |
4944 ++cnt; | |
4945 } | |
4946 | |
4947 if (!eap->skip) | |
4948 { | |
4949 /* Adjust flags for use of ":syn include". */ | |
4950 syn_incl_toplevel(syn_id, &syn_opt_arg.flags); | |
4951 | |
7 | 4952 /* |
154 | 4953 * 2: Add an entry for each keyword. |
7 | 4954 */ |
154 | 4955 for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) |
7 | 4956 { |
154 | 4957 for (p = vim_strchr(kw, '['); ; ) |
7 | 4958 { |
154 | 4959 if (p != NULL) |
4960 *p = NUL; | |
4961 add_keyword(kw, syn_id, syn_opt_arg.flags, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4962 syn_opt_arg.cont_in_list, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4963 syn_opt_arg.next_list, conceal_char); |
168 | 4964 if (p == NULL) |
4965 break; | |
4966 if (p[1] == NUL) | |
4967 { | |
838 | 4968 EMSG2(_("E789: Missing ']': %s"), kw); |
7017 | 4969 goto error; |
168 | 4970 } |
4971 if (p[1] == ']') | |
4972 { | |
7017 | 4973 if (p[2] != NUL) |
4974 { | |
4975 EMSG3(_("E890: trailing char after ']': %s]%s"), | |
4976 kw, &p[2]); | |
4977 goto error; | |
4978 } | |
168 | 4979 kw = p + 1; /* skip over the "]" */ |
4980 break; | |
4981 } | |
154 | 4982 #ifdef FEAT_MBYTE |
4983 if (has_mbyte) | |
7 | 4984 { |
474 | 4985 int l = (*mb_ptr2len)(p + 1); |
154 | 4986 |
4987 mch_memmove(p, p + 1, l); | |
4988 p += l; | |
4989 } | |
4990 else | |
7 | 4991 #endif |
154 | 4992 { |
4993 p[0] = p[1]; | |
4994 ++p; | |
7 | 4995 } |
4996 } | |
4997 } | |
4998 } | |
7017 | 4999 error: |
7 | 5000 vim_free(keyword_copy); |
168 | 5001 vim_free(syn_opt_arg.cont_in_list); |
5002 vim_free(syn_opt_arg.next_list); | |
7 | 5003 } |
5004 } | |
5005 | |
5006 if (rest != NULL) | |
5007 eap->nextcmd = check_nextcmd(rest); | |
5008 else | |
5009 EMSG2(_(e_invarg2), arg); | |
5010 | |
745 | 5011 redraw_curbuf_later(SOME_VALID); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5012 syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ |
7 | 5013 } |
5014 | |
5015 /* | |
5016 * Handle ":syntax match {name} [{options}] {pattern} [{options}]". | |
5017 * | |
5018 * Also ":syntax sync match {name} [[grouphere | groupthere] {group-name}] .." | |
5019 */ | |
5020 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5021 syn_cmd_match( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5022 exarg_T *eap, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5023 int syncing) /* TRUE for ":syntax sync match .. " */ |
7 | 5024 { |
5025 char_u *arg = eap->arg; | |
5026 char_u *group_name_end; | |
5027 char_u *rest; | |
5028 synpat_T item; /* the item found in the line */ | |
5029 int syn_id; | |
5030 int idx; | |
154 | 5031 syn_opt_arg_T syn_opt_arg; |
7 | 5032 int sync_idx = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5033 int conceal_char = NUL; |
7 | 5034 |
5035 /* Isolate the group name, check for validity */ | |
5036 rest = get_group_name(arg, &group_name_end); | |
5037 | |
5038 /* Get options before the pattern */ | |
154 | 5039 syn_opt_arg.flags = 0; |
5040 syn_opt_arg.keyword = FALSE; | |
5041 syn_opt_arg.sync_idx = syncing ? &sync_idx : NULL; | |
5042 syn_opt_arg.has_cont_list = TRUE; | |
5043 syn_opt_arg.cont_list = NULL; | |
5044 syn_opt_arg.cont_in_list = NULL; | |
5045 syn_opt_arg.next_list = NULL; | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5046 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); |
7 | 5047 |
5048 /* get the pattern. */ | |
5049 init_syn_patterns(); | |
5050 vim_memset(&item, 0, sizeof(item)); | |
5051 rest = get_syn_pattern(rest, &item); | |
154 | 5052 if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) |
5053 syn_opt_arg.flags |= HL_HAS_EOL; | |
7 | 5054 |
5055 /* Get options after the pattern */ | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5056 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); |
7 | 5057 |
5058 if (rest != NULL) /* all arguments are valid */ | |
5059 { | |
5060 /* | |
5061 * Check for trailing command and illegal trailing arguments. | |
5062 */ | |
5063 eap->nextcmd = check_nextcmd(rest); | |
5064 if (!ends_excmd(*rest) || eap->skip) | |
5065 rest = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5066 else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL |
7 | 5067 && (syn_id = syn_check_group(arg, |
5068 (int)(group_name_end - arg))) != 0) | |
5069 { | |
154 | 5070 syn_incl_toplevel(syn_id, &syn_opt_arg.flags); |
7 | 5071 /* |
5072 * Store the pattern in the syn_items list | |
5073 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5074 idx = curwin->w_s->b_syn_patterns.ga_len; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5075 SYN_ITEMS(curwin->w_s)[idx] = item; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5076 SYN_ITEMS(curwin->w_s)[idx].sp_syncing = syncing; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5077 SYN_ITEMS(curwin->w_s)[idx].sp_type = SPTYPE_MATCH; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5078 SYN_ITEMS(curwin->w_s)[idx].sp_syn.id = syn_id; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5079 SYN_ITEMS(curwin->w_s)[idx].sp_syn.inc_tag = current_syn_inc_tag; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5080 SYN_ITEMS(curwin->w_s)[idx].sp_flags = syn_opt_arg.flags; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5081 SYN_ITEMS(curwin->w_s)[idx].sp_sync_idx = sync_idx; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5082 SYN_ITEMS(curwin->w_s)[idx].sp_cont_list = syn_opt_arg.cont_list; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5083 SYN_ITEMS(curwin->w_s)[idx].sp_syn.cont_in_list = |
154 | 5084 syn_opt_arg.cont_in_list; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5085 #ifdef FEAT_CONCEAL |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
5086 SYN_ITEMS(curwin->w_s)[idx].sp_cchar = conceal_char; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5087 #endif |
154 | 5088 if (syn_opt_arg.cont_in_list != NULL) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5089 curwin->w_s->b_syn_containedin = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5090 SYN_ITEMS(curwin->w_s)[idx].sp_next_list = syn_opt_arg.next_list; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5091 ++curwin->w_s->b_syn_patterns.ga_len; |
7 | 5092 |
5093 /* remember that we found a match for syncing on */ | |
154 | 5094 if (syn_opt_arg.flags & (HL_SYNC_HERE|HL_SYNC_THERE)) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5095 curwin->w_s->b_syn_sync_flags |= SF_MATCH; |
7 | 5096 #ifdef FEAT_FOLDING |
154 | 5097 if (syn_opt_arg.flags & HL_FOLD) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5098 ++curwin->w_s->b_syn_folditems; |
7 | 5099 #endif |
5100 | |
745 | 5101 redraw_curbuf_later(SOME_VALID); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5102 syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ |
7 | 5103 return; /* don't free the progs and patterns now */ |
5104 } | |
5105 } | |
5106 | |
5107 /* | |
5108 * Something failed, free the allocated memory. | |
5109 */ | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
5110 vim_regfree(item.sp_prog); |
7 | 5111 vim_free(item.sp_pattern); |
154 | 5112 vim_free(syn_opt_arg.cont_list); |
5113 vim_free(syn_opt_arg.cont_in_list); | |
5114 vim_free(syn_opt_arg.next_list); | |
7 | 5115 |
5116 if (rest == NULL) | |
5117 EMSG2(_(e_invarg2), arg); | |
5118 } | |
5119 | |
5120 /* | |
5121 * Handle ":syntax region {group-name} [matchgroup={group-name}] | |
5122 * start {start} .. [skip {skip}] end {end} .. [{options}]". | |
5123 */ | |
5124 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5125 syn_cmd_region( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5126 exarg_T *eap, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5127 int syncing) /* TRUE for ":syntax sync region .." */ |
7 | 5128 { |
5129 char_u *arg = eap->arg; | |
5130 char_u *group_name_end; | |
5131 char_u *rest; /* next arg, NULL on error */ | |
5132 char_u *key_end; | |
5133 char_u *key = NULL; | |
5134 char_u *p; | |
5135 int item; | |
5136 #define ITEM_START 0 | |
5137 #define ITEM_SKIP 1 | |
5138 #define ITEM_END 2 | |
5139 #define ITEM_MATCHGROUP 3 | |
5140 struct pat_ptr | |
5141 { | |
5142 synpat_T *pp_synp; /* pointer to syn_pattern */ | |
5143 int pp_matchgroup_id; /* matchgroup ID */ | |
5144 struct pat_ptr *pp_next; /* pointer to next pat_ptr */ | |
5145 } *(pat_ptrs[3]); | |
5146 /* patterns found in the line */ | |
5147 struct pat_ptr *ppp; | |
5148 struct pat_ptr *ppp_next; | |
5149 int pat_count = 0; /* nr of syn_patterns found */ | |
5150 int syn_id; | |
5151 int matchgroup_id = 0; | |
5152 int not_enough = FALSE; /* not enough arguments */ | |
5153 int illegal = FALSE; /* illegal arguments */ | |
5154 int success = FALSE; | |
5155 int idx; | |
154 | 5156 syn_opt_arg_T syn_opt_arg; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5157 int conceal_char = NUL; |
7 | 5158 |
5159 /* Isolate the group name, check for validity */ | |
5160 rest = get_group_name(arg, &group_name_end); | |
5161 | |
5162 pat_ptrs[0] = NULL; | |
5163 pat_ptrs[1] = NULL; | |
5164 pat_ptrs[2] = NULL; | |
5165 | |
5166 init_syn_patterns(); | |
5167 | |
154 | 5168 syn_opt_arg.flags = 0; |
5169 syn_opt_arg.keyword = FALSE; | |
5170 syn_opt_arg.sync_idx = NULL; | |
5171 syn_opt_arg.has_cont_list = TRUE; | |
5172 syn_opt_arg.cont_list = NULL; | |
5173 syn_opt_arg.cont_in_list = NULL; | |
5174 syn_opt_arg.next_list = NULL; | |
5175 | |
7 | 5176 /* |
5177 * get the options, patterns and matchgroup. | |
5178 */ | |
5179 while (rest != NULL && !ends_excmd(*rest)) | |
5180 { | |
5181 /* Check for option arguments */ | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5182 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); |
7 | 5183 if (rest == NULL || ends_excmd(*rest)) |
5184 break; | |
5185 | |
5186 /* must be a pattern or matchgroup then */ | |
5187 key_end = rest; | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5188 while (*key_end && !VIM_ISWHITE(*key_end) && *key_end != '=') |
7 | 5189 ++key_end; |
5190 vim_free(key); | |
5191 key = vim_strnsave_up(rest, (int)(key_end - rest)); | |
5192 if (key == NULL) /* out of memory */ | |
5193 { | |
5194 rest = NULL; | |
5195 break; | |
5196 } | |
5197 if (STRCMP(key, "MATCHGROUP") == 0) | |
5198 item = ITEM_MATCHGROUP; | |
5199 else if (STRCMP(key, "START") == 0) | |
5200 item = ITEM_START; | |
5201 else if (STRCMP(key, "END") == 0) | |
5202 item = ITEM_END; | |
5203 else if (STRCMP(key, "SKIP") == 0) | |
5204 { | |
5205 if (pat_ptrs[ITEM_SKIP] != NULL) /* one skip pattern allowed */ | |
5206 { | |
5207 illegal = TRUE; | |
5208 break; | |
5209 } | |
5210 item = ITEM_SKIP; | |
5211 } | |
5212 else | |
5213 break; | |
5214 rest = skipwhite(key_end); | |
5215 if (*rest != '=') | |
5216 { | |
5217 rest = NULL; | |
5218 EMSG2(_("E398: Missing '=': %s"), arg); | |
5219 break; | |
5220 } | |
5221 rest = skipwhite(rest + 1); | |
5222 if (*rest == NUL) | |
5223 { | |
5224 not_enough = TRUE; | |
5225 break; | |
5226 } | |
5227 | |
5228 if (item == ITEM_MATCHGROUP) | |
5229 { | |
5230 p = skiptowhite(rest); | |
5231 if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip) | |
5232 matchgroup_id = 0; | |
5233 else | |
5234 { | |
5235 matchgroup_id = syn_check_group(rest, (int)(p - rest)); | |
5236 if (matchgroup_id == 0) | |
5237 { | |
5238 illegal = TRUE; | |
5239 break; | |
5240 } | |
5241 } | |
5242 rest = skipwhite(p); | |
5243 } | |
5244 else | |
5245 { | |
5246 /* | |
5247 * Allocate room for a syn_pattern, and link it in the list of | |
5248 * syn_patterns for this item, at the start (because the list is | |
5249 * used from end to start). | |
5250 */ | |
5251 ppp = (struct pat_ptr *)alloc((unsigned)sizeof(struct pat_ptr)); | |
5252 if (ppp == NULL) | |
5253 { | |
5254 rest = NULL; | |
5255 break; | |
5256 } | |
5257 ppp->pp_next = pat_ptrs[item]; | |
5258 pat_ptrs[item] = ppp; | |
5259 ppp->pp_synp = (synpat_T *)alloc_clear((unsigned)sizeof(synpat_T)); | |
5260 if (ppp->pp_synp == NULL) | |
5261 { | |
5262 rest = NULL; | |
5263 break; | |
5264 } | |
5265 | |
5266 /* | |
5267 * Get the syntax pattern and the following offset(s). | |
5268 */ | |
5269 /* Enable the appropriate \z specials. */ | |
5270 if (item == ITEM_START) | |
5271 reg_do_extmatch = REX_SET; | |
5272 else if (item == ITEM_SKIP || item == ITEM_END) | |
5273 reg_do_extmatch = REX_USE; | |
5274 rest = get_syn_pattern(rest, ppp->pp_synp); | |
5275 reg_do_extmatch = 0; | |
5276 if (item == ITEM_END && vim_regcomp_had_eol() | |
154 | 5277 && !(syn_opt_arg.flags & HL_EXCLUDENL)) |
7 | 5278 ppp->pp_synp->sp_flags |= HL_HAS_EOL; |
5279 ppp->pp_matchgroup_id = matchgroup_id; | |
5280 ++pat_count; | |
5281 } | |
5282 } | |
5283 vim_free(key); | |
5284 if (illegal || not_enough) | |
5285 rest = NULL; | |
5286 | |
5287 /* | |
5288 * Must have a "start" and "end" pattern. | |
5289 */ | |
5290 if (rest != NULL && (pat_ptrs[ITEM_START] == NULL || | |
5291 pat_ptrs[ITEM_END] == NULL)) | |
5292 { | |
5293 not_enough = TRUE; | |
5294 rest = NULL; | |
5295 } | |
5296 | |
5297 if (rest != NULL) | |
5298 { | |
5299 /* | |
5300 * Check for trailing garbage or command. | |
5301 * If OK, add the item. | |
5302 */ | |
5303 eap->nextcmd = check_nextcmd(rest); | |
5304 if (!ends_excmd(*rest) || eap->skip) | |
5305 rest = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5306 else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) != FAIL |
7 | 5307 && (syn_id = syn_check_group(arg, |
5308 (int)(group_name_end - arg))) != 0) | |
5309 { | |
154 | 5310 syn_incl_toplevel(syn_id, &syn_opt_arg.flags); |
7 | 5311 /* |
5312 * Store the start/skip/end in the syn_items list | |
5313 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5314 idx = curwin->w_s->b_syn_patterns.ga_len; |
7 | 5315 for (item = ITEM_START; item <= ITEM_END; ++item) |
5316 { | |
5317 for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp->pp_next) | |
5318 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5319 SYN_ITEMS(curwin->w_s)[idx] = *(ppp->pp_synp); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5320 SYN_ITEMS(curwin->w_s)[idx].sp_syncing = syncing; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5321 SYN_ITEMS(curwin->w_s)[idx].sp_type = |
7 | 5322 (item == ITEM_START) ? SPTYPE_START : |
5323 (item == ITEM_SKIP) ? SPTYPE_SKIP : SPTYPE_END; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5324 SYN_ITEMS(curwin->w_s)[idx].sp_flags |= syn_opt_arg.flags; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5325 SYN_ITEMS(curwin->w_s)[idx].sp_syn.id = syn_id; |
2743 | 5326 SYN_ITEMS(curwin->w_s)[idx].sp_syn.inc_tag = |
5327 current_syn_inc_tag; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5328 SYN_ITEMS(curwin->w_s)[idx].sp_syn_match_id = |
7 | 5329 ppp->pp_matchgroup_id; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5330 #ifdef FEAT_CONCEAL |
2425
b5ee68272ae5
Fix: concealed regions didn't get redrawn correctly when moving the cursor
Bram Moolenaar <bram@vim.org>
parents:
2418
diff
changeset
|
5331 SYN_ITEMS(curwin->w_s)[idx].sp_cchar = conceal_char; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5332 #endif |
7 | 5333 if (item == ITEM_START) |
5334 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5335 SYN_ITEMS(curwin->w_s)[idx].sp_cont_list = |
154 | 5336 syn_opt_arg.cont_list; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5337 SYN_ITEMS(curwin->w_s)[idx].sp_syn.cont_in_list = |
154 | 5338 syn_opt_arg.cont_in_list; |
5339 if (syn_opt_arg.cont_in_list != NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5340 curwin->w_s->b_syn_containedin = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5341 SYN_ITEMS(curwin->w_s)[idx].sp_next_list = |
154 | 5342 syn_opt_arg.next_list; |
7 | 5343 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5344 ++curwin->w_s->b_syn_patterns.ga_len; |
7 | 5345 ++idx; |
5346 #ifdef FEAT_FOLDING | |
154 | 5347 if (syn_opt_arg.flags & HL_FOLD) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5348 ++curwin->w_s->b_syn_folditems; |
7 | 5349 #endif |
5350 } | |
5351 } | |
5352 | |
745 | 5353 redraw_curbuf_later(SOME_VALID); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5354 syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ |
7 | 5355 success = TRUE; /* don't free the progs and patterns now */ |
5356 } | |
5357 } | |
5358 | |
5359 /* | |
5360 * Free the allocated memory. | |
5361 */ | |
5362 for (item = ITEM_START; item <= ITEM_END; ++item) | |
5363 for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp_next) | |
5364 { | |
5365 if (!success) | |
5366 { | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
5367 vim_regfree(ppp->pp_synp->sp_prog); |
7 | 5368 vim_free(ppp->pp_synp->sp_pattern); |
5369 } | |
5370 vim_free(ppp->pp_synp); | |
5371 ppp_next = ppp->pp_next; | |
5372 vim_free(ppp); | |
5373 } | |
5374 | |
5375 if (!success) | |
5376 { | |
154 | 5377 vim_free(syn_opt_arg.cont_list); |
5378 vim_free(syn_opt_arg.cont_in_list); | |
5379 vim_free(syn_opt_arg.next_list); | |
7 | 5380 if (not_enough) |
5381 EMSG2(_("E399: Not enough arguments: syntax region %s"), arg); | |
5382 else if (illegal || rest == NULL) | |
5383 EMSG2(_(e_invarg2), arg); | |
5384 } | |
5385 } | |
5386 | |
5387 /* | |
5388 * A simple syntax group ID comparison function suitable for use in qsort() | |
5389 */ | |
5390 static int | |
5391 #ifdef __BORLANDC__ | |
5392 _RTLENTRYF | |
5393 #endif | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5394 syn_compare_stub(const void *v1, const void *v2) |
7 | 5395 { |
5396 const short *s1 = v1; | |
5397 const short *s2 = v2; | |
5398 | |
5399 return (*s1 > *s2 ? 1 : *s1 < *s2 ? -1 : 0); | |
5400 } | |
5401 | |
5402 /* | |
5403 * Combines lists of syntax clusters. | |
5404 * *clstr1 and *clstr2 must both be allocated memory; they will be consumed. | |
5405 */ | |
5406 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5407 syn_combine_list(short **clstr1, short **clstr2, int list_op) |
7 | 5408 { |
5409 int count1 = 0; | |
5410 int count2 = 0; | |
5411 short *g1; | |
5412 short *g2; | |
5413 short *clstr = NULL; | |
5414 int count; | |
5415 int round; | |
5416 | |
5417 /* | |
5418 * Handle degenerate cases. | |
5419 */ | |
5420 if (*clstr2 == NULL) | |
5421 return; | |
5422 if (*clstr1 == NULL || list_op == CLUSTER_REPLACE) | |
5423 { | |
5424 if (list_op == CLUSTER_REPLACE) | |
5425 vim_free(*clstr1); | |
5426 if (list_op == CLUSTER_REPLACE || list_op == CLUSTER_ADD) | |
5427 *clstr1 = *clstr2; | |
5428 else | |
5429 vim_free(*clstr2); | |
5430 return; | |
5431 } | |
5432 | |
5433 for (g1 = *clstr1; *g1; g1++) | |
5434 ++count1; | |
5435 for (g2 = *clstr2; *g2; g2++) | |
5436 ++count2; | |
5437 | |
5438 /* | |
5439 * For speed purposes, sort both lists. | |
5440 */ | |
5441 qsort(*clstr1, (size_t)count1, sizeof(short), syn_compare_stub); | |
5442 qsort(*clstr2, (size_t)count2, sizeof(short), syn_compare_stub); | |
5443 | |
5444 /* | |
5445 * We proceed in two passes; in round 1, we count the elements to place | |
5446 * in the new list, and in round 2, we allocate and populate the new | |
5447 * list. For speed, we use a mergesort-like method, adding the smaller | |
5448 * of the current elements in each list to the new list. | |
5449 */ | |
5450 for (round = 1; round <= 2; round++) | |
5451 { | |
5452 g1 = *clstr1; | |
5453 g2 = *clstr2; | |
5454 count = 0; | |
5455 | |
5456 /* | |
5457 * First, loop through the lists until one of them is empty. | |
5458 */ | |
5459 while (*g1 && *g2) | |
5460 { | |
5461 /* | |
5462 * We always want to add from the first list. | |
5463 */ | |
5464 if (*g1 < *g2) | |
5465 { | |
5466 if (round == 2) | |
5467 clstr[count] = *g1; | |
5468 count++; | |
5469 g1++; | |
5470 continue; | |
5471 } | |
5472 /* | |
5473 * We only want to add from the second list if we're adding the | |
5474 * lists. | |
5475 */ | |
5476 if (list_op == CLUSTER_ADD) | |
5477 { | |
5478 if (round == 2) | |
5479 clstr[count] = *g2; | |
5480 count++; | |
5481 } | |
5482 if (*g1 == *g2) | |
5483 g1++; | |
5484 g2++; | |
5485 } | |
5486 | |
5487 /* | |
5488 * Now add the leftovers from whichever list didn't get finished | |
5489 * first. As before, we only want to add from the second list if | |
5490 * we're adding the lists. | |
5491 */ | |
5492 for (; *g1; g1++, count++) | |
5493 if (round == 2) | |
5494 clstr[count] = *g1; | |
5495 if (list_op == CLUSTER_ADD) | |
5496 for (; *g2; g2++, count++) | |
5497 if (round == 2) | |
5498 clstr[count] = *g2; | |
5499 | |
5500 if (round == 1) | |
5501 { | |
5502 /* | |
5503 * If the group ended up empty, we don't need to allocate any | |
5504 * space for it. | |
5505 */ | |
5506 if (count == 0) | |
5507 { | |
5508 clstr = NULL; | |
5509 break; | |
5510 } | |
5511 clstr = (short *)alloc((unsigned)((count + 1) * sizeof(short))); | |
5512 if (clstr == NULL) | |
5513 break; | |
5514 clstr[count] = 0; | |
5515 } | |
5516 } | |
5517 | |
5518 /* | |
5519 * Finally, put the new list in place. | |
5520 */ | |
5521 vim_free(*clstr1); | |
5522 vim_free(*clstr2); | |
5523 *clstr1 = clstr; | |
5524 } | |
5525 | |
5526 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5527 * Lookup a syntax cluster name and return its ID. |
7 | 5528 * If it is not found, 0 is returned. |
5529 */ | |
5530 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5531 syn_scl_name2id(char_u *name) |
7 | 5532 { |
5533 int i; | |
5534 char_u *name_u; | |
5535 | |
5536 /* Avoid using stricmp() too much, it's slow on some systems */ | |
5537 name_u = vim_strsave_up(name); | |
5538 if (name_u == NULL) | |
5539 return 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5540 for (i = curwin->w_s->b_syn_clusters.ga_len; --i >= 0; ) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5541 if (SYN_CLSTR(curwin->w_s)[i].scl_name_u != NULL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5542 && STRCMP(name_u, SYN_CLSTR(curwin->w_s)[i].scl_name_u) == 0) |
7 | 5543 break; |
5544 vim_free(name_u); | |
5545 return (i < 0 ? 0 : i + SYNID_CLUSTER); | |
5546 } | |
5547 | |
5548 /* | |
5549 * Like syn_scl_name2id(), but take a pointer + length argument. | |
5550 */ | |
5551 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5552 syn_scl_namen2id(char_u *linep, int len) |
7 | 5553 { |
5554 char_u *name; | |
5555 int id = 0; | |
5556 | |
5557 name = vim_strnsave(linep, len); | |
5558 if (name != NULL) | |
5559 { | |
5560 id = syn_scl_name2id(name); | |
5561 vim_free(name); | |
5562 } | |
5563 return id; | |
5564 } | |
5565 | |
5566 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5567 * Find syntax cluster name in the table and return its ID. |
7 | 5568 * The argument is a pointer to the name and the length of the name. |
5569 * If it doesn't exist yet, a new entry is created. | |
5570 * Return 0 for failure. | |
5571 */ | |
5572 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5573 syn_check_cluster(char_u *pp, int len) |
7 | 5574 { |
5575 int id; | |
5576 char_u *name; | |
5577 | |
5578 name = vim_strnsave(pp, len); | |
5579 if (name == NULL) | |
5580 return 0; | |
5581 | |
5582 id = syn_scl_name2id(name); | |
5583 if (id == 0) /* doesn't exist yet */ | |
5584 id = syn_add_cluster(name); | |
5585 else | |
5586 vim_free(name); | |
5587 return id; | |
5588 } | |
5589 | |
5590 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5591 * Add new syntax cluster and return its ID. |
7 | 5592 * "name" must be an allocated string, it will be consumed. |
5593 * Return 0 for failure. | |
5594 */ | |
5595 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5596 syn_add_cluster(char_u *name) |
221 | 5597 { |
5598 int len; | |
7 | 5599 |
5600 /* | |
5601 * First call for this growarray: init growing array. | |
5602 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5603 if (curwin->w_s->b_syn_clusters.ga_data == NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5604 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5605 curwin->w_s->b_syn_clusters.ga_itemsize = sizeof(syn_cluster_T); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5606 curwin->w_s->b_syn_clusters.ga_growsize = 10; |
7 | 5607 } |
5608 | |
2743 | 5609 len = curwin->w_s->b_syn_clusters.ga_len; |
5610 if (len >= MAX_CLUSTER_ID) | |
5611 { | |
5612 EMSG((char_u *)_("E848: Too many syntax clusters")); | |
5613 vim_free(name); | |
5614 return 0; | |
5615 } | |
5616 | |
7 | 5617 /* |
5618 * Make room for at least one other cluster entry. | |
5619 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5620 if (ga_grow(&curwin->w_s->b_syn_clusters, 1) == FAIL) |
7 | 5621 { |
5622 vim_free(name); | |
5623 return 0; | |
5624 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5625 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5626 vim_memset(&(SYN_CLSTR(curwin->w_s)[len]), 0, sizeof(syn_cluster_T)); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5627 SYN_CLSTR(curwin->w_s)[len].scl_name = name; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5628 SYN_CLSTR(curwin->w_s)[len].scl_name_u = vim_strsave_up(name); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5629 SYN_CLSTR(curwin->w_s)[len].scl_list = NULL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5630 ++curwin->w_s->b_syn_clusters.ga_len; |
7 | 5631 |
221 | 5632 if (STRICMP(name, "Spell") == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5633 curwin->w_s->b_spell_cluster_id = len + SYNID_CLUSTER; |
227 | 5634 if (STRICMP(name, "NoSpell") == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5635 curwin->w_s->b_nospell_cluster_id = len + SYNID_CLUSTER; |
221 | 5636 |
7 | 5637 return len + SYNID_CLUSTER; |
5638 } | |
5639 | |
5640 /* | |
5641 * Handle ":syntax cluster {cluster-name} [contains={groupname},..] | |
5642 * [add={groupname},..] [remove={groupname},..]". | |
5643 */ | |
5644 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5645 syn_cmd_cluster(exarg_T *eap, int syncing UNUSED) |
7 | 5646 { |
5647 char_u *arg = eap->arg; | |
5648 char_u *group_name_end; | |
5649 char_u *rest; | |
5650 int scl_id; | |
5651 short *clstr_list; | |
5652 int got_clstr = FALSE; | |
5653 int opt_len; | |
5654 int list_op; | |
5655 | |
5656 eap->nextcmd = find_nextcmd(arg); | |
5657 if (eap->skip) | |
5658 return; | |
5659 | |
5660 rest = get_group_name(arg, &group_name_end); | |
5661 | |
5662 if (rest != NULL) | |
5663 { | |
2743 | 5664 scl_id = syn_check_cluster(arg, (int)(group_name_end - arg)); |
5665 if (scl_id == 0) | |
5666 return; | |
5667 scl_id -= SYNID_CLUSTER; | |
7 | 5668 |
5669 for (;;) | |
5670 { | |
5671 if (STRNICMP(rest, "add", 3) == 0 | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5672 && (VIM_ISWHITE(rest[3]) || rest[3] == '=')) |
7 | 5673 { |
5674 opt_len = 3; | |
5675 list_op = CLUSTER_ADD; | |
5676 } | |
5677 else if (STRNICMP(rest, "remove", 6) == 0 | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5678 && (VIM_ISWHITE(rest[6]) || rest[6] == '=')) |
7 | 5679 { |
5680 opt_len = 6; | |
5681 list_op = CLUSTER_SUBTRACT; | |
5682 } | |
5683 else if (STRNICMP(rest, "contains", 8) == 0 | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5684 && (VIM_ISWHITE(rest[8]) || rest[8] == '=')) |
7 | 5685 { |
5686 opt_len = 8; | |
5687 list_op = CLUSTER_REPLACE; | |
5688 } | |
5689 else | |
5690 break; | |
5691 | |
5692 clstr_list = NULL; | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5693 if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL) |
7 | 5694 { |
5695 EMSG2(_(e_invarg2), rest); | |
5696 break; | |
5697 } | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5698 if (scl_id >= 0) |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5699 syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, |
7 | 5700 &clstr_list, list_op); |
10648
4f3decf25b7d
patch 8.0.0214: leaking memory when syntax cluster id is unknown
Christian Brabandt <cb@256bit.org>
parents:
10629
diff
changeset
|
5701 else |
4f3decf25b7d
patch 8.0.0214: leaking memory when syntax cluster id is unknown
Christian Brabandt <cb@256bit.org>
parents:
10629
diff
changeset
|
5702 vim_free(clstr_list); |
7 | 5703 got_clstr = TRUE; |
5704 } | |
5705 | |
5706 if (got_clstr) | |
5707 { | |
745 | 5708 redraw_curbuf_later(SOME_VALID); |
2743 | 5709 syn_stack_free_all(curwin->w_s); /* Need to recompute all. */ |
7 | 5710 } |
5711 } | |
5712 | |
5713 if (!got_clstr) | |
5714 EMSG(_("E400: No cluster specified")); | |
5715 if (rest == NULL || !ends_excmd(*rest)) | |
5716 EMSG2(_(e_invarg2), arg); | |
5717 } | |
5718 | |
5719 /* | |
5720 * On first call for current buffer: Init growing array. | |
5721 */ | |
5722 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5723 init_syn_patterns(void) |
7 | 5724 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5725 curwin->w_s->b_syn_patterns.ga_itemsize = sizeof(synpat_T); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5726 curwin->w_s->b_syn_patterns.ga_growsize = 10; |
7 | 5727 } |
5728 | |
5729 /* | |
5730 * Get one pattern for a ":syntax match" or ":syntax region" command. | |
5731 * Stores the pattern and program in a synpat_T. | |
5732 * Returns a pointer to the next argument, or NULL in case of an error. | |
5733 */ | |
5734 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5735 get_syn_pattern(char_u *arg, synpat_T *ci) |
7 | 5736 { |
5737 char_u *end; | |
5738 int *p; | |
5739 int idx; | |
5740 char_u *cpo_save; | |
5741 | |
5742 /* need at least three chars */ | |
6993 | 5743 if (arg == NULL || arg[0] == NUL || arg[1] == NUL || arg[2] == NUL) |
7 | 5744 return NULL; |
5745 | |
5746 end = skip_regexp(arg + 1, *arg, TRUE, NULL); | |
5747 if (*end != *arg) /* end delimiter not found */ | |
5748 { | |
5749 EMSG2(_("E401: Pattern delimiter not found: %s"), arg); | |
5750 return NULL; | |
5751 } | |
5752 /* store the pattern and compiled regexp program */ | |
5753 if ((ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1))) == NULL) | |
5754 return NULL; | |
5755 | |
5756 /* Make 'cpoptions' empty, to avoid the 'l' flag */ | |
5757 cpo_save = p_cpo; | |
5758 p_cpo = (char_u *)""; | |
5759 ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC); | |
5760 p_cpo = cpo_save; | |
5761 | |
5762 if (ci->sp_prog == NULL) | |
5763 return NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5764 ci->sp_ic = curwin->w_s->b_syn_ic; |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
5765 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5766 syn_clear_time(&ci->sp_time); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5767 #endif |
7 | 5768 |
5769 /* | |
5770 * Check for a match, highlight or region offset. | |
5771 */ | |
5772 ++end; | |
5773 do | |
5774 { | |
5775 for (idx = SPO_COUNT; --idx >= 0; ) | |
5776 if (STRNCMP(end, spo_name_tab[idx], 3) == 0) | |
5777 break; | |
5778 if (idx >= 0) | |
5779 { | |
5780 p = &(ci->sp_offsets[idx]); | |
5781 if (idx != SPO_LC_OFF) | |
5782 switch (end[3]) | |
5783 { | |
5784 case 's': break; | |
5785 case 'b': break; | |
5786 case 'e': idx += SPO_COUNT; break; | |
5787 default: idx = -1; break; | |
5788 } | |
5789 if (idx >= 0) | |
5790 { | |
5791 ci->sp_off_flags |= (1 << idx); | |
5792 if (idx == SPO_LC_OFF) /* lc=99 */ | |
5793 { | |
5794 end += 3; | |
5795 *p = getdigits(&end); | |
5796 | |
5797 /* "lc=" offset automatically sets "ms=" offset */ | |
5798 if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) | |
5799 { | |
5800 ci->sp_off_flags |= (1 << SPO_MS_OFF); | |
5801 ci->sp_offsets[SPO_MS_OFF] = *p; | |
5802 } | |
5803 } | |
5804 else /* yy=x+99 */ | |
5805 { | |
5806 end += 4; | |
5807 if (*end == '+') | |
5808 { | |
5809 ++end; | |
5810 *p = getdigits(&end); /* positive offset */ | |
5811 } | |
5812 else if (*end == '-') | |
5813 { | |
5814 ++end; | |
5815 *p = -getdigits(&end); /* negative offset */ | |
5816 } | |
5817 } | |
5818 if (*end != ',') | |
5819 break; | |
5820 ++end; | |
5821 } | |
5822 } | |
5823 } while (idx >= 0); | |
5824 | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5825 if (!ends_excmd(*end) && !VIM_ISWHITE(*end)) |
7 | 5826 { |
5827 EMSG2(_("E402: Garbage after pattern: %s"), arg); | |
5828 return NULL; | |
5829 } | |
5830 return skipwhite(end); | |
5831 } | |
5832 | |
5833 /* | |
5834 * Handle ":syntax sync .." command. | |
5835 */ | |
5836 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5837 syn_cmd_sync(exarg_T *eap, int syncing UNUSED) |
7 | 5838 { |
5839 char_u *arg_start = eap->arg; | |
5840 char_u *arg_end; | |
5841 char_u *key = NULL; | |
5842 char_u *next_arg; | |
5843 int illegal = FALSE; | |
5844 int finished = FALSE; | |
5845 long n; | |
5846 char_u *cpo_save; | |
5847 | |
5848 if (ends_excmd(*arg_start)) | |
5849 { | |
5850 syn_cmd_list(eap, TRUE); | |
5851 return; | |
5852 } | |
5853 | |
5854 while (!ends_excmd(*arg_start)) | |
5855 { | |
5856 arg_end = skiptowhite(arg_start); | |
5857 next_arg = skipwhite(arg_end); | |
5858 vim_free(key); | |
5859 key = vim_strnsave_up(arg_start, (int)(arg_end - arg_start)); | |
5860 if (STRCMP(key, "CCOMMENT") == 0) | |
5861 { | |
5862 if (!eap->skip) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5863 curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT; |
7 | 5864 if (!ends_excmd(*next_arg)) |
5865 { | |
5866 arg_end = skiptowhite(next_arg); | |
5867 if (!eap->skip) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5868 curwin->w_s->b_syn_sync_id = syn_check_group(next_arg, |
7 | 5869 (int)(arg_end - next_arg)); |
5870 next_arg = skipwhite(arg_end); | |
5871 } | |
5872 else if (!eap->skip) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5873 curwin->w_s->b_syn_sync_id = syn_name2id((char_u *)"Comment"); |
7 | 5874 } |
5875 else if ( STRNCMP(key, "LINES", 5) == 0 | |
5876 || STRNCMP(key, "MINLINES", 8) == 0 | |
5877 || STRNCMP(key, "MAXLINES", 8) == 0 | |
5878 || STRNCMP(key, "LINEBREAKS", 10) == 0) | |
5879 { | |
5880 if (key[4] == 'S') | |
5881 arg_end = key + 6; | |
5882 else if (key[0] == 'L') | |
5883 arg_end = key + 11; | |
5884 else | |
5885 arg_end = key + 9; | |
5886 if (arg_end[-1] != '=' || !VIM_ISDIGIT(*arg_end)) | |
5887 { | |
5888 illegal = TRUE; | |
5889 break; | |
5890 } | |
5891 n = getdigits(&arg_end); | |
5892 if (!eap->skip) | |
5893 { | |
5894 if (key[4] == 'B') | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5895 curwin->w_s->b_syn_sync_linebreaks = n; |
7 | 5896 else if (key[1] == 'A') |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5897 curwin->w_s->b_syn_sync_maxlines = n; |
7 | 5898 else |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5899 curwin->w_s->b_syn_sync_minlines = n; |
7 | 5900 } |
5901 } | |
5902 else if (STRCMP(key, "FROMSTART") == 0) | |
5903 { | |
5904 if (!eap->skip) | |
5905 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5906 curwin->w_s->b_syn_sync_minlines = MAXLNUM; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5907 curwin->w_s->b_syn_sync_maxlines = 0; |
7 | 5908 } |
5909 } | |
5910 else if (STRCMP(key, "LINECONT") == 0) | |
5911 { | |
7504
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5912 if (*next_arg == NUL) /* missing pattern */ |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5913 { |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5914 illegal = TRUE; |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5915 break; |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5916 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5917 if (curwin->w_s->b_syn_linecont_pat != NULL) |
7 | 5918 { |
5919 EMSG(_("E403: syntax sync: line continuations pattern specified twice")); | |
5920 finished = TRUE; | |
5921 break; | |
5922 } | |
5923 arg_end = skip_regexp(next_arg + 1, *next_arg, TRUE, NULL); | |
5924 if (*arg_end != *next_arg) /* end delimiter not found */ | |
5925 { | |
5926 illegal = TRUE; | |
5927 break; | |
5928 } | |
5929 | |
5930 if (!eap->skip) | |
5931 { | |
5932 /* store the pattern and compiled regexp program */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5933 if ((curwin->w_s->b_syn_linecont_pat = vim_strnsave(next_arg + 1, |
7 | 5934 (int)(arg_end - next_arg - 1))) == NULL) |
5935 { | |
5936 finished = TRUE; | |
5937 break; | |
5938 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5939 curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic; |
7 | 5940 |
5941 /* Make 'cpoptions' empty, to avoid the 'l' flag */ | |
5942 cpo_save = p_cpo; | |
5943 p_cpo = (char_u *)""; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5944 curwin->w_s->b_syn_linecont_prog = |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5945 vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC); |
7 | 5946 p_cpo = cpo_save; |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
5947 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5948 syn_clear_time(&curwin->w_s->b_syn_linecont_time); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5949 #endif |
7 | 5950 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5951 if (curwin->w_s->b_syn_linecont_prog == NULL) |
7 | 5952 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
5953 VIM_CLEAR(curwin->w_s->b_syn_linecont_pat); |
7 | 5954 finished = TRUE; |
5955 break; | |
5956 } | |
5957 } | |
5958 next_arg = skipwhite(arg_end + 1); | |
5959 } | |
5960 else | |
5961 { | |
5962 eap->arg = next_arg; | |
5963 if (STRCMP(key, "MATCH") == 0) | |
5964 syn_cmd_match(eap, TRUE); | |
5965 else if (STRCMP(key, "REGION") == 0) | |
5966 syn_cmd_region(eap, TRUE); | |
5967 else if (STRCMP(key, "CLEAR") == 0) | |
5968 syn_cmd_clear(eap, TRUE); | |
5969 else | |
5970 illegal = TRUE; | |
5971 finished = TRUE; | |
5972 break; | |
5973 } | |
5974 arg_start = next_arg; | |
5975 } | |
5976 vim_free(key); | |
5977 if (illegal) | |
5978 EMSG2(_("E404: Illegal arguments: %s"), arg_start); | |
5979 else if (!finished) | |
5980 { | |
5981 eap->nextcmd = check_nextcmd(arg_start); | |
745 | 5982 redraw_curbuf_later(SOME_VALID); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5983 syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ |
7 | 5984 } |
5985 } | |
5986 | |
5987 /* | |
5988 * Convert a line of highlight group names into a list of group ID numbers. | |
5989 * "arg" should point to the "contains" or "nextgroup" keyword. | |
5990 * "arg" is advanced to after the last group name. | |
5991 * Careful: the argument is modified (NULs added). | |
5992 * returns FAIL for some error, OK for success. | |
5993 */ | |
5994 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5995 get_id_list( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5996 char_u **arg, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5997 int keylen, /* length of keyword */ |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5998 short **list, /* where to store the resulting list, if not |
7 | 5999 NULL, the list is silently skipped! */ |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
6000 int skip) |
7 | 6001 { |
6002 char_u *p = NULL; | |
6003 char_u *end; | |
6004 int round; | |
6005 int count; | |
6006 int total_count = 0; | |
6007 short *retval = NULL; | |
6008 char_u *name; | |
6009 regmatch_T regmatch; | |
6010 int id; | |
6011 int i; | |
6012 int failed = FALSE; | |
6013 | |
6014 /* | |
6015 * We parse the list twice: | |
6016 * round == 1: count the number of items, allocate the array. | |
6017 * round == 2: fill the array with the items. | |
6018 * In round 1 new groups may be added, causing the number of items to | |
6019 * grow when a regexp is used. In that case round 1 is done once again. | |
6020 */ | |
6021 for (round = 1; round <= 2; ++round) | |
6022 { | |
6023 /* | |
6024 * skip "contains" | |
6025 */ | |
6026 p = skipwhite(*arg + keylen); | |
6027 if (*p != '=') | |
6028 { | |
6029 EMSG2(_("E405: Missing equal sign: %s"), *arg); | |
6030 break; | |
6031 } | |
6032 p = skipwhite(p + 1); | |
6033 if (ends_excmd(*p)) | |
6034 { | |
6035 EMSG2(_("E406: Empty argument: %s"), *arg); | |
6036 break; | |
6037 } | |
6038 | |
6039 /* | |
6040 * parse the arguments after "contains" | |
6041 */ | |
6042 count = 0; | |
6043 while (!ends_excmd(*p)) | |
6044 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
6045 for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end) |
7 | 6046 ; |
6047 name = alloc((int)(end - p + 3)); /* leave room for "^$" */ | |
6048 if (name == NULL) | |
6049 { | |
6050 failed = TRUE; | |
6051 break; | |
6052 } | |
419 | 6053 vim_strncpy(name + 1, p, end - p); |
7 | 6054 if ( STRCMP(name + 1, "ALLBUT") == 0 |
6055 || STRCMP(name + 1, "ALL") == 0 | |
6056 || STRCMP(name + 1, "TOP") == 0 | |
6057 || STRCMP(name + 1, "CONTAINED") == 0) | |
6058 { | |
6059 if (TOUPPER_ASC(**arg) != 'C') | |
6060 { | |
6061 EMSG2(_("E407: %s not allowed here"), name + 1); | |
6062 failed = TRUE; | |
6063 vim_free(name); | |
6064 break; | |
6065 } | |
6066 if (count != 0) | |
6067 { | |
10648
4f3decf25b7d
patch 8.0.0214: leaking memory when syntax cluster id is unknown
Christian Brabandt <cb@256bit.org>
parents:
10629
diff
changeset
|
6068 EMSG2(_("E408: %s must be first in contains list"), |
4f3decf25b7d
patch 8.0.0214: leaking memory when syntax cluster id is unknown
Christian Brabandt <cb@256bit.org>
parents:
10629
diff
changeset
|
6069 name + 1); |
7 | 6070 failed = TRUE; |
6071 vim_free(name); | |
6072 break; | |
6073 } | |
6074 if (name[1] == 'A') | |
6075 id = SYNID_ALLBUT; | |
6076 else if (name[1] == 'T') | |
6077 id = SYNID_TOP; | |
6078 else | |
6079 id = SYNID_CONTAINED; | |
6080 id += current_syn_inc_tag; | |
6081 } | |
6082 else if (name[1] == '@') | |
6083 { | |
10629
16fc46021e51
patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10624
diff
changeset
|
6084 if (skip) |
16fc46021e51
patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10624
diff
changeset
|
6085 id = -1; |
16fc46021e51
patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10624
diff
changeset
|
6086 else |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
6087 id = syn_check_cluster(name + 2, (int)(end - p - 1)); |
7 | 6088 } |
6089 else | |
6090 { | |
6091 /* | |
6092 * Handle full group name. | |
6093 */ | |
6094 if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL) | |
6095 id = syn_check_group(name + 1, (int)(end - p)); | |
6096 else | |
6097 { | |
6098 /* | |
6099 * Handle match of regexp with group names. | |
6100 */ | |
6101 *name = '^'; | |
6102 STRCAT(name, "$"); | |
6103 regmatch.regprog = vim_regcomp(name, RE_MAGIC); | |
6104 if (regmatch.regprog == NULL) | |
6105 { | |
6106 failed = TRUE; | |
6107 vim_free(name); | |
6108 break; | |
6109 } | |
6110 | |
6111 regmatch.rm_ic = TRUE; | |
6112 id = 0; | |
6113 for (i = highlight_ga.ga_len; --i >= 0; ) | |
6114 { | |
6115 if (vim_regexec(®match, HL_TABLE()[i].sg_name, | |
6116 (colnr_T)0)) | |
6117 { | |
6118 if (round == 2) | |
6119 { | |
6120 /* Got more items than expected; can happen | |
6121 * when adding items that match: | |
6122 * "contains=a.*b,axb". | |
6123 * Go back to first round */ | |
6124 if (count >= total_count) | |
6125 { | |
6126 vim_free(retval); | |
6127 round = 1; | |
6128 } | |
6129 else | |
6130 retval[count] = i + 1; | |
6131 } | |
6132 ++count; | |
6133 id = -1; /* remember that we found one */ | |
6134 } | |
6135 } | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6136 vim_regfree(regmatch.regprog); |
7 | 6137 } |
6138 } | |
6139 vim_free(name); | |
6140 if (id == 0) | |
6141 { | |
6142 EMSG2(_("E409: Unknown group name: %s"), p); | |
6143 failed = TRUE; | |
6144 break; | |
6145 } | |
6146 if (id > 0) | |
6147 { | |
6148 if (round == 2) | |
6149 { | |
6150 /* Got more items than expected, go back to first round */ | |
6151 if (count >= total_count) | |
6152 { | |
6153 vim_free(retval); | |
6154 round = 1; | |
6155 } | |
6156 else | |
6157 retval[count] = id; | |
6158 } | |
6159 ++count; | |
6160 } | |
6161 p = skipwhite(end); | |
6162 if (*p != ',') | |
6163 break; | |
6164 p = skipwhite(p + 1); /* skip comma in between arguments */ | |
6165 } | |
6166 if (failed) | |
6167 break; | |
6168 if (round == 1) | |
6169 { | |
6170 retval = (short *)alloc((unsigned)((count + 1) * sizeof(short))); | |
6171 if (retval == NULL) | |
6172 break; | |
6173 retval[count] = 0; /* zero means end of the list */ | |
6174 total_count = count; | |
6175 } | |
6176 } | |
6177 | |
6178 *arg = p; | |
6179 if (failed || retval == NULL) | |
6180 { | |
6181 vim_free(retval); | |
6182 return FAIL; | |
6183 } | |
6184 | |
6185 if (*list == NULL) | |
6186 *list = retval; | |
6187 else | |
6188 vim_free(retval); /* list already found, don't overwrite it */ | |
6189 | |
6190 return OK; | |
6191 } | |
6192 | |
6193 /* | |
6194 * Make a copy of an ID list. | |
6195 */ | |
6196 static short * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6197 copy_id_list(short *list) |
7 | 6198 { |
6199 int len; | |
6200 int count; | |
6201 short *retval; | |
6202 | |
6203 if (list == NULL) | |
6204 return NULL; | |
6205 | |
6206 for (count = 0; list[count]; ++count) | |
6207 ; | |
6208 len = (count + 1) * sizeof(short); | |
6209 retval = (short *)alloc((unsigned)len); | |
6210 if (retval != NULL) | |
6211 mch_memmove(retval, list, (size_t)len); | |
6212 | |
6213 return retval; | |
6214 } | |
6215 | |
6216 /* | |
6217 * Check if syntax group "ssp" is in the ID list "list" of "cur_si". | |
6218 * "cur_si" can be NULL if not checking the "containedin" list. | |
6219 * Used to check if a syntax item is in the "contains" or "nextgroup" list of | |
6220 * the current item. | |
6221 * This function is called very often, keep it fast!! | |
6222 */ | |
6223 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6224 in_id_list( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6225 stateitem_T *cur_si, /* current item or NULL */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6226 short *list, /* id list */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6227 struct sp_syn *ssp, /* group id and ":syn include" tag of group */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6228 int contained) /* group id is contained */ |
7 | 6229 { |
6230 int retval; | |
6231 short *scl_list; | |
6232 short item; | |
6233 short id = ssp->id; | |
6234 static int depth = 0; | |
6235 int r; | |
6236 | |
4352 | 6237 /* If ssp has a "containedin" list and "cur_si" is in it, return TRUE. */ |
36 | 6238 if (cur_si != NULL && ssp->cont_in_list != NULL |
6239 && !(cur_si->si_flags & HL_MATCH)) | |
7 | 6240 { |
6241 /* Ignore transparent items without a contains argument. Double check | |
6242 * that we don't go back past the first one. */ | |
6243 while ((cur_si->si_flags & HL_TRANS_CONT) | |
6244 && cur_si > (stateitem_T *)(current_state.ga_data)) | |
6245 --cur_si; | |
6246 /* cur_si->si_idx is -1 for keywords, these never contain anything. */ | |
6247 if (cur_si->si_idx >= 0 && in_id_list(NULL, ssp->cont_in_list, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6248 &(SYN_ITEMS(syn_block)[cur_si->si_idx].sp_syn), |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6249 SYN_ITEMS(syn_block)[cur_si->si_idx].sp_flags & HL_CONTAINED)) |
7 | 6250 return TRUE; |
6251 } | |
6252 | |
6253 if (list == NULL) | |
6254 return FALSE; | |
6255 | |
6256 /* | |
6257 * If list is ID_LIST_ALL, we are in a transparent item that isn't | |
6258 * inside anything. Only allow not-contained groups. | |
6259 */ | |
6260 if (list == ID_LIST_ALL) | |
6261 return !contained; | |
6262 | |
6263 /* | |
6264 * If the first item is "ALLBUT", return TRUE if "id" is NOT in the | |
6265 * contains list. We also require that "id" is at the same ":syn include" | |
6266 * level as the list. | |
6267 */ | |
6268 item = *list; | |
6269 if (item >= SYNID_ALLBUT && item < SYNID_CLUSTER) | |
6270 { | |
6271 if (item < SYNID_TOP) | |
6272 { | |
6273 /* ALL or ALLBUT: accept all groups in the same file */ | |
6274 if (item - SYNID_ALLBUT != ssp->inc_tag) | |
6275 return FALSE; | |
6276 } | |
6277 else if (item < SYNID_CONTAINED) | |
6278 { | |
6279 /* TOP: accept all not-contained groups in the same file */ | |
6280 if (item - SYNID_TOP != ssp->inc_tag || contained) | |
6281 return FALSE; | |
6282 } | |
6283 else | |
6284 { | |
6285 /* CONTAINED: accept all contained groups in the same file */ | |
6286 if (item - SYNID_CONTAINED != ssp->inc_tag || !contained) | |
6287 return FALSE; | |
6288 } | |
6289 item = *++list; | |
6290 retval = FALSE; | |
6291 } | |
6292 else | |
6293 retval = TRUE; | |
6294 | |
6295 /* | |
6296 * Return "retval" if id is in the contains list. | |
6297 */ | |
6298 while (item != 0) | |
6299 { | |
6300 if (item == id) | |
6301 return retval; | |
6302 if (item >= SYNID_CLUSTER) | |
6303 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6304 scl_list = SYN_CLSTR(syn_block)[item - SYNID_CLUSTER].scl_list; |
7 | 6305 /* restrict recursiveness to 30 to avoid an endless loop for a |
6306 * cluster that includes itself (indirectly) */ | |
6307 if (scl_list != NULL && depth < 30) | |
6308 { | |
6309 ++depth; | |
6310 r = in_id_list(NULL, scl_list, ssp, contained); | |
6311 --depth; | |
6312 if (r) | |
6313 return retval; | |
6314 } | |
6315 } | |
6316 item = *++list; | |
6317 } | |
6318 return !retval; | |
6319 } | |
6320 | |
6321 struct subcommand | |
6322 { | |
7807
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6323 char *name; /* subcommand name */ |
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6324 void (*func)(exarg_T *, int); /* function to call */ |
7 | 6325 }; |
6326 | |
6327 static struct subcommand subcommands[] = | |
6328 { | |
6329 {"case", syn_cmd_case}, | |
6330 {"clear", syn_cmd_clear}, | |
6331 {"cluster", syn_cmd_cluster}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6332 {"conceal", syn_cmd_conceal}, |
7 | 6333 {"enable", syn_cmd_enable}, |
6334 {"include", syn_cmd_include}, | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
6335 {"iskeyword", syn_cmd_iskeyword}, |
7 | 6336 {"keyword", syn_cmd_keyword}, |
6337 {"list", syn_cmd_list}, | |
6338 {"manual", syn_cmd_manual}, | |
6339 {"match", syn_cmd_match}, | |
6340 {"on", syn_cmd_on}, | |
6341 {"off", syn_cmd_off}, | |
6342 {"region", syn_cmd_region}, | |
6343 {"reset", syn_cmd_reset}, | |
419 | 6344 {"spell", syn_cmd_spell}, |
7 | 6345 {"sync", syn_cmd_sync}, |
6346 {"", syn_cmd_list}, | |
6347 {NULL, NULL} | |
6348 }; | |
6349 | |
6350 /* | |
6351 * ":syntax". | |
6352 * This searches the subcommands[] table for the subcommand name, and calls a | |
6353 * syntax_subcommand() function to do the rest. | |
6354 */ | |
6355 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6356 ex_syntax(exarg_T *eap) |
7 | 6357 { |
6358 char_u *arg = eap->arg; | |
6359 char_u *subcmd_end; | |
6360 char_u *subcmd_name; | |
6361 int i; | |
6362 | |
6363 syn_cmdlinep = eap->cmdlinep; | |
6364 | |
6365 /* isolate subcommand name */ | |
6366 for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end) | |
6367 ; | |
6368 subcmd_name = vim_strnsave(arg, (int)(subcmd_end - arg)); | |
6369 if (subcmd_name != NULL) | |
6370 { | |
6371 if (eap->skip) /* skip error messages for all subcommands */ | |
6372 ++emsg_skip; | |
6373 for (i = 0; ; ++i) | |
6374 { | |
6375 if (subcommands[i].name == NULL) | |
6376 { | |
6377 EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name); | |
6378 break; | |
6379 } | |
6380 if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) | |
6381 { | |
6382 eap->arg = skipwhite(subcmd_end); | |
6383 (subcommands[i].func)(eap, FALSE); | |
6384 break; | |
6385 } | |
6386 } | |
6387 vim_free(subcmd_name); | |
6388 if (eap->skip) | |
6389 --emsg_skip; | |
6390 } | |
6391 } | |
6392 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6393 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6394 ex_ownsyntax(exarg_T *eap) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6395 { |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6396 char_u *old_value; |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6397 char_u *new_value; |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6398 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6399 if (curwin->w_s == &curwin->w_buffer->b_s) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6400 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6401 curwin->w_s = (synblock_T *)alloc(sizeof(synblock_T)); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6402 memset(curwin->w_s, 0, sizeof(synblock_T)); |
7030
8d513ddfe3ec
commit https://github.com/vim/vim/commit/670acbc70f371409b46b722bd9a1166e53574f42
Christian Brabandt <cb@256bit.org>
parents:
7017
diff
changeset
|
6403 hash_init(&curwin->w_s->b_keywtab); |
8d513ddfe3ec
commit https://github.com/vim/vim/commit/670acbc70f371409b46b722bd9a1166e53574f42
Christian Brabandt <cb@256bit.org>
parents:
7017
diff
changeset
|
6404 hash_init(&curwin->w_s->b_keywtab_ic); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6405 #ifdef FEAT_SPELL |
6386 | 6406 /* TODO: keep the spell checking as it was. */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6407 curwin->w_p_spell = FALSE; /* No spell checking */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6408 clear_string_option(&curwin->w_s->b_p_spc); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6409 clear_string_option(&curwin->w_s->b_p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6410 clear_string_option(&curwin->w_s->b_p_spl); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6411 #endif |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
6412 clear_string_option(&curwin->w_s->b_syn_isk); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6413 } |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6414 |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6415 /* save value of b:current_syntax */ |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6416 old_value = get_var_value((char_u *)"b:current_syntax"); |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6417 if (old_value != NULL) |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6418 old_value = vim_strsave(old_value); |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6419 |
8362
a541dd5cfd3a
commit https://github.com/vim/vim/commit/d1413d90983fc6c579ad66ba4d4611b057197f94
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
6420 #ifdef FEAT_AUTOCMD |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6421 /* Apply the "syntax" autocommand event, this finds and loads the syntax |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6422 * file. */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6423 apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, TRUE, curbuf); |
8362
a541dd5cfd3a
commit https://github.com/vim/vim/commit/d1413d90983fc6c579ad66ba4d4611b057197f94
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
6424 #endif |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6425 |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6426 /* move value of b:current_syntax to w:current_syntax */ |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6427 new_value = get_var_value((char_u *)"b:current_syntax"); |
2256
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6428 if (new_value != NULL) |
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6429 set_internal_string_var((char_u *)"w:current_syntax", new_value); |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6430 |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6431 /* restore value of b:current_syntax */ |
2256
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6432 if (old_value == NULL) |
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6433 do_unlet((char_u *)"b:current_syntax", TRUE); |
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6434 else |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6435 { |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6436 set_internal_string_var((char_u *)"b:current_syntax", old_value); |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6437 vim_free(old_value); |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6438 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6439 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6440 |
7 | 6441 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6442 syntax_present(win_T *win) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6443 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6444 return (win->w_s->b_syn_patterns.ga_len != 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6445 || win->w_s->b_syn_clusters.ga_len != 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6446 || win->w_s->b_keywtab.ht_used > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6447 || win->w_s->b_keywtab_ic.ht_used > 0); |
7 | 6448 } |
6449 | |
6450 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
6451 | |
6452 static enum | |
6453 { | |
6454 EXP_SUBCMD, /* expand ":syn" sub-commands */ | |
10534
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6455 EXP_CASE, /* expand ":syn case" arguments */ |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6456 EXP_SPELL, /* expand ":syn spell" arguments */ |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6457 EXP_SYNC /* expand ":syn sync" arguments */ |
7 | 6458 } expand_what; |
6459 | |
1322 | 6460 /* |
6461 * Reset include_link, include_default, include_none to 0. | |
6462 * Called when we are done expanding. | |
6463 */ | |
6464 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6465 reset_expand_highlight(void) |
1322 | 6466 { |
6467 include_link = include_default = include_none = 0; | |
6468 } | |
6469 | |
6470 /* | |
6471 * Handle command line completion for :match and :echohl command: Add "None" | |
6472 * as highlight group. | |
6473 */ | |
6474 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6475 set_context_in_echohl_cmd(expand_T *xp, char_u *arg) |
1322 | 6476 { |
6477 xp->xp_context = EXPAND_HIGHLIGHT; | |
6478 xp->xp_pattern = arg; | |
6479 include_none = 1; | |
6480 } | |
7 | 6481 |
6482 /* | |
6483 * Handle command line completion for :syntax command. | |
6484 */ | |
6485 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6486 set_context_in_syntax_cmd(expand_T *xp, char_u *arg) |
7 | 6487 { |
6488 char_u *p; | |
6489 | |
6490 /* Default: expand subcommands */ | |
6491 xp->xp_context = EXPAND_SYNTAX; | |
6492 expand_what = EXP_SUBCMD; | |
6493 xp->xp_pattern = arg; | |
1322 | 6494 include_link = 0; |
6495 include_default = 0; | |
7 | 6496 |
6497 /* (part of) subcommand already typed */ | |
6498 if (*arg != NUL) | |
6499 { | |
6500 p = skiptowhite(arg); | |
6501 if (*p != NUL) /* past first word */ | |
6502 { | |
6503 xp->xp_pattern = skipwhite(p); | |
6504 if (*skiptowhite(xp->xp_pattern) != NUL) | |
6505 xp->xp_context = EXPAND_NOTHING; | |
6506 else if (STRNICMP(arg, "case", p - arg) == 0) | |
6507 expand_what = EXP_CASE; | |
10534
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6508 else if (STRNICMP(arg, "spell", p - arg) == 0) |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6509 expand_what = EXP_SPELL; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6510 else if (STRNICMP(arg, "sync", p - arg) == 0) |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6511 expand_what = EXP_SYNC; |
7 | 6512 else if ( STRNICMP(arg, "keyword", p - arg) == 0 |
6513 || STRNICMP(arg, "region", p - arg) == 0 | |
6514 || STRNICMP(arg, "match", p - arg) == 0 | |
6515 || STRNICMP(arg, "list", p - arg) == 0) | |
6516 xp->xp_context = EXPAND_HIGHLIGHT; | |
6517 else | |
6518 xp->xp_context = EXPAND_NOTHING; | |
6519 } | |
6520 } | |
6521 } | |
6522 | |
6523 /* | |
6524 * Function given to ExpandGeneric() to obtain the list syntax names for | |
6525 * expansion. | |
6526 */ | |
6527 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6528 get_syntax_name(expand_T *xp UNUSED, int idx) |
7 | 6529 { |
10534
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6530 switch (expand_what) |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6531 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6532 case EXP_SUBCMD: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6533 return (char_u *)subcommands[idx].name; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6534 case EXP_CASE: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6535 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6536 static char *case_args[] = {"match", "ignore", NULL}; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6537 return (char_u *)case_args[idx]; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6538 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6539 case EXP_SPELL: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6540 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6541 static char *spell_args[] = |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6542 {"toplevel", "notoplevel", "default", NULL}; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6543 return (char_u *)spell_args[idx]; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6544 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6545 case EXP_SYNC: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6546 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6547 static char *sync_args[] = |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6548 {"ccomment", "clear", "fromstart", |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6549 "linebreaks=", "linecont", "lines=", "match", |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6550 "maxlines=", "minlines=", "region", NULL}; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6551 return (char_u *)sync_args[idx]; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6552 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6553 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6554 return NULL; |
7 | 6555 } |
6556 | |
6557 #endif /* FEAT_CMDL_COMPL */ | |
6558 | |
6559 /* | |
6560 * Function called for expression evaluation: get syntax ID at file position. | |
6561 */ | |
6562 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6563 syn_get_id( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6564 win_T *wp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6565 long lnum, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6566 colnr_T col, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6567 int trans, /* remove transparency */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6568 int *spellp, /* return: can do spell checking */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6569 int keep_state) /* keep state of char at "col" */ |
7 | 6570 { |
6571 /* When the position is not after the current position and in the same | |
6572 * line of the same buffer, need to restart parsing. */ | |
499 | 6573 if (wp->w_buffer != syn_buf |
7 | 6574 || lnum != current_lnum |
253 | 6575 || col < current_col) |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6576 syntax_start(wp, lnum); |
7685
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6577 else if (wp->w_buffer == syn_buf |
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6578 && lnum == current_lnum |
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6579 && col > current_col) |
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6580 /* next_match may not be correct when moving around, e.g. with the |
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6581 * "skip" expression in searchpair() */ |
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6582 next_match_idx = -1; |
7 | 6583 |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6584 (void)get_syntax_attr(col, spellp, keep_state); |
7 | 6585 |
6586 return (trans ? current_trans_id : current_id); | |
6587 } | |
6588 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6589 #if defined(FEAT_CONCEAL) || defined(PROTO) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6590 /* |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6591 * Get extra information about the syntax item. Must be called right after |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6592 * get_syntax_attr(). |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
6593 * Stores the current item sequence nr in "*seqnrp". |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6594 * Returns the current flags. |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6595 */ |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6596 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6597 get_syntax_info(int *seqnrp) |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
6598 { |
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
6599 *seqnrp = current_seqnr; |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6600 return current_flags; |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6601 } |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6602 |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6603 /* |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6604 * Return conceal substitution character |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6605 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6606 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6607 syn_get_sub_char(void) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6608 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6609 return current_sub_char; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6610 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6611 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6612 |
1500 | 6613 #if defined(FEAT_EVAL) || defined(PROTO) |
6614 /* | |
6615 * Return the syntax ID at position "i" in the current stack. | |
6616 * The caller must have called syn_get_id() before to fill the stack. | |
6617 * Returns -1 when "i" is out of range. | |
6618 */ | |
6619 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6620 syn_get_stack_item(int i) |
1500 | 6621 { |
1504 | 6622 if (i >= current_state.ga_len) |
6623 { | |
6624 /* Need to invalidate the state, because we didn't properly finish it | |
6625 * for the last character, "keep_state" was TRUE. */ | |
6626 invalidate_current_state(); | |
6627 current_col = MAXCOL; | |
1500 | 6628 return -1; |
1504 | 6629 } |
1500 | 6630 return CUR_STATE(i).si_id; |
6631 } | |
6632 #endif | |
6633 | |
7 | 6634 #if defined(FEAT_FOLDING) || defined(PROTO) |
6635 /* | |
6636 * Function called to get folding level for line "lnum" in window "wp". | |
6637 */ | |
6638 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6639 syn_get_foldlevel(win_T *wp, long lnum) |
7 | 6640 { |
6641 int level = 0; | |
6642 int i; | |
6643 | |
6644 /* Return quickly when there are no fold items at all. */ | |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6645 if (wp->w_s->b_syn_folditems != 0 |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6646 && !wp->w_s->b_syn_error |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6647 # ifdef SYN_TIME_LIMIT |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6648 && !wp->w_s->b_syn_slow |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6649 # endif |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6650 ) |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6651 { |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6652 syntax_start(wp, lnum); |
7 | 6653 |
6654 for (i = 0; i < current_state.ga_len; ++i) | |
6655 if (CUR_STATE(i).si_flags & HL_FOLD) | |
6656 ++level; | |
6657 } | |
6658 if (level > wp->w_p_fdn) | |
1028 | 6659 { |
7 | 6660 level = wp->w_p_fdn; |
1028 | 6661 if (level < 0) |
6662 level = 0; | |
6663 } | |
7 | 6664 return level; |
6665 } | |
6666 #endif | |
6667 | |
6567 | 6668 #if defined(FEAT_PROFILE) || defined(PROTO) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6669 /* |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6670 * ":syntime". |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6671 */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6672 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6673 ex_syntime(exarg_T *eap) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6674 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6675 if (STRCMP(eap->arg, "on") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6676 syn_time_on = TRUE; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6677 else if (STRCMP(eap->arg, "off") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6678 syn_time_on = FALSE; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6679 else if (STRCMP(eap->arg, "clear") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6680 syntime_clear(); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6681 else if (STRCMP(eap->arg, "report") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6682 syntime_report(); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6683 else |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6684 EMSG2(_(e_invarg2), eap->arg); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6685 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6686 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6687 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6688 syn_clear_time(syn_time_T *st) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6689 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6690 profile_zero(&st->total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6691 profile_zero(&st->slowest); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6692 st->count = 0; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6693 st->match = 0; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6694 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6695 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6696 /* |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6697 * Clear the syntax timing for the current buffer. |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6698 */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6699 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6700 syntime_clear(void) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6701 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6702 int idx; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6703 synpat_T *spp; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6704 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6705 if (!syntax_present(curwin)) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6706 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6707 MSG(_(msg_no_items)); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6708 return; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6709 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6710 for (idx = 0; idx < curwin->w_s->b_syn_patterns.ga_len; ++idx) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6711 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6712 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6713 syn_clear_time(&spp->sp_time); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6714 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6715 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6716 |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6717 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6718 /* |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6719 * Function given to ExpandGeneric() to obtain the possible arguments of the |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6720 * ":syntime {on,off,clear,report}" command. |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6721 */ |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6722 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6723 get_syntime_arg(expand_T *xp UNUSED, int idx) |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6724 { |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6725 switch (idx) |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6726 { |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6727 case 0: return (char_u *)"on"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6728 case 1: return (char_u *)"off"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6729 case 2: return (char_u *)"clear"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6730 case 3: return (char_u *)"report"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6731 } |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6732 return NULL; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6733 } |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6734 #endif |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6735 |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6736 typedef struct |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6737 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6738 proftime_T total; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6739 int count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6740 int match; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6741 proftime_T slowest; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6742 proftime_T average; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6743 int id; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6744 char_u *pattern; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6745 } time_entry_T; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6746 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6747 static int |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6748 #ifdef __BORLANDC__ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6749 _RTLENTRYF |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6750 #endif |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6751 syn_compare_syntime(const void *v1, const void *v2) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6752 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6753 const time_entry_T *s1 = v1; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6754 const time_entry_T *s2 = v2; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6755 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6756 return profile_cmp(&s1->total, &s2->total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6757 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6758 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6759 /* |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6760 * Clear the syntax timing for the current buffer. |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6761 */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6762 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6763 syntime_report(void) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6764 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6765 int idx; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6766 synpat_T *spp; |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6767 # ifdef FEAT_FLOAT |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6768 proftime_T tm; |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6769 # endif |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6770 int len; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6771 proftime_T total_total; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6772 int total_count = 0; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6773 garray_T ga; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6774 time_entry_T *p; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6775 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6776 if (!syntax_present(curwin)) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6777 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6778 MSG(_(msg_no_items)); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6779 return; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6780 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6781 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6782 ga_init2(&ga, sizeof(time_entry_T), 50); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6783 profile_zero(&total_total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6784 for (idx = 0; idx < curwin->w_s->b_syn_patterns.ga_len; ++idx) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6785 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6786 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6787 if (spp->sp_time.count > 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6788 { |
7009 | 6789 (void)ga_grow(&ga, 1); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6790 p = ((time_entry_T *)ga.ga_data) + ga.ga_len; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6791 p->total = spp->sp_time.total; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6792 profile_add(&total_total, &spp->sp_time.total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6793 p->count = spp->sp_time.count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6794 p->match = spp->sp_time.match; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6795 total_count += spp->sp_time.count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6796 p->slowest = spp->sp_time.slowest; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6797 # ifdef FEAT_FLOAT |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6798 profile_divide(&spp->sp_time.total, spp->sp_time.count, &tm); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6799 p->average = tm; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6800 # endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6801 p->id = spp->sp_syn.id; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6802 p->pattern = spp->sp_pattern; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6803 ++ga.ga_len; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6804 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6805 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6806 |
10530
ea5adbeccfc1
commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents:
10499
diff
changeset
|
6807 /* Sort on total time. Skip if there are no items to avoid passing NULL |
ea5adbeccfc1
commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents:
10499
diff
changeset
|
6808 * pointer to qsort(). */ |
ea5adbeccfc1
commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents:
10499
diff
changeset
|
6809 if (ga.ga_len > 1) |
ea5adbeccfc1
commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents:
10499
diff
changeset
|
6810 qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T), |
4776
e4bc21965079
updated for version 7.3.1135
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
6811 syn_compare_syntime); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6812 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6813 MSG_PUTS_TITLE(_(" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN")); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6814 MSG_PUTS("\n"); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6815 for (idx = 0; idx < ga.ga_len && !got_int; ++idx) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6816 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6817 p = ((time_entry_T *)ga.ga_data) + idx; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6818 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6819 MSG_PUTS(profile_msg(&p->total)); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6820 MSG_PUTS(" "); /* make sure there is always a separating space */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6821 msg_advance(13); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6822 msg_outnum(p->count); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6823 MSG_PUTS(" "); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6824 msg_advance(20); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6825 msg_outnum(p->match); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6826 MSG_PUTS(" "); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6827 msg_advance(26); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6828 MSG_PUTS(profile_msg(&p->slowest)); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6829 MSG_PUTS(" "); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6830 msg_advance(38); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6831 # ifdef FEAT_FLOAT |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6832 MSG_PUTS(profile_msg(&p->average)); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6833 MSG_PUTS(" "); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6834 # endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6835 msg_advance(50); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6836 msg_outtrans(HL_TABLE()[p->id - 1].sg_name); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6837 MSG_PUTS(" "); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6838 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6839 msg_advance(69); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6840 if (Columns < 80) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6841 len = 20; /* will wrap anyway */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6842 else |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6843 len = Columns - 70; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6844 if (len > (int)STRLEN(p->pattern)) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6845 len = (int)STRLEN(p->pattern); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6846 msg_outtrans_len(p->pattern, len); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6847 MSG_PUTS("\n"); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6848 } |
4791
65cef998f860
updated for version 7.3.1142
Bram Moolenaar <bram@vim.org>
parents:
4776
diff
changeset
|
6849 ga_clear(&ga); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6850 if (!got_int) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6851 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6852 MSG_PUTS("\n"); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6853 MSG_PUTS(profile_msg(&total_total)); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6854 msg_advance(13); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6855 msg_outnum(total_count); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6856 MSG_PUTS("\n"); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6857 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6858 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6859 #endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6860 |
7 | 6861 #endif /* FEAT_SYN_HL */ |
6862 | |
6863 /************************************** | |
6864 * Highlighting stuff * | |
6865 **************************************/ | |
6866 | |
6867 /* | |
6868 * The default highlight groups. These are compiled-in for fast startup and | |
6869 * they still work when the runtime files can't be found. | |
6870 * When making changes here, also change runtime/colors/default.vim! | |
806 | 6871 * The #ifdefs are needed to reduce the amount of static data. Helps to make |
6872 * the 16 bit DOS (museum) version compile. | |
7 | 6873 */ |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
6874 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
809 | 6875 # define CENT(a, b) b |
6876 #else | |
6877 # define CENT(a, b) a | |
6878 #endif | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6879 static char *(highlight_init_both[]) = { |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6880 CENT("ErrorMsg term=standout ctermbg=DarkRed ctermfg=White", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6881 "ErrorMsg term=standout ctermbg=DarkRed ctermfg=White guibg=Red guifg=White"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6882 CENT("IncSearch term=reverse cterm=reverse", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6883 "IncSearch term=reverse cterm=reverse gui=reverse"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6884 CENT("ModeMsg term=bold cterm=bold", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6885 "ModeMsg term=bold cterm=bold gui=bold"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6886 CENT("NonText term=bold ctermfg=Blue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6887 "NonText term=bold ctermfg=Blue gui=bold guifg=Blue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6888 CENT("StatusLine term=reverse,bold cterm=reverse,bold", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6889 "StatusLine term=reverse,bold cterm=reverse,bold gui=reverse,bold"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6890 CENT("StatusLineNC term=reverse cterm=reverse", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6891 "StatusLineNC term=reverse cterm=reverse gui=reverse"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6892 "default link EndOfBuffer NonText", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6893 CENT("VertSplit term=reverse cterm=reverse", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6894 "VertSplit term=reverse cterm=reverse gui=reverse"), |
806 | 6895 #ifdef FEAT_CLIPBOARD |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6896 CENT("VisualNOS term=underline,bold cterm=underline,bold", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6897 "VisualNOS term=underline,bold cterm=underline,bold gui=underline,bold"), |
806 | 6898 #endif |
6899 #ifdef FEAT_DIFF | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6900 CENT("DiffText term=reverse cterm=bold ctermbg=Red", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6901 "DiffText term=reverse cterm=bold ctermbg=Red gui=bold guibg=Red"), |
806 | 6902 #endif |
6903 #ifdef FEAT_INS_EXPAND | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6904 CENT("PmenuSbar ctermbg=Grey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6905 "PmenuSbar ctermbg=Grey guibg=Grey"), |
806 | 6906 #endif |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6907 CENT("TabLineSel term=bold cterm=bold", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6908 "TabLineSel term=bold cterm=bold gui=bold"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6909 CENT("TabLineFill term=reverse cterm=reverse", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6910 "TabLineFill term=reverse cterm=reverse gui=reverse"), |
7 | 6911 #ifdef FEAT_GUI |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6912 "Cursor guibg=fg guifg=bg", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6913 "lCursor guibg=fg guifg=bg", /* should be different, but what? */ |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6914 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6915 "default link QuickFixLine Search", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6916 NULL |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6917 }; |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6918 |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6919 /* Default colors only used with a light background. */ |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6920 static char *(highlight_init_light[]) = { |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6921 CENT("Directory term=bold ctermfg=DarkBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6922 "Directory term=bold ctermfg=DarkBlue guifg=Blue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6923 CENT("LineNr term=underline ctermfg=Brown", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6924 "LineNr term=underline ctermfg=Brown guifg=Brown"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6925 CENT("CursorLineNr term=bold ctermfg=Brown", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6926 "CursorLineNr term=bold ctermfg=Brown gui=bold guifg=Brown"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6927 CENT("MoreMsg term=bold ctermfg=DarkGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6928 "MoreMsg term=bold ctermfg=DarkGreen gui=bold guifg=SeaGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6929 CENT("Question term=standout ctermfg=DarkGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6930 "Question term=standout ctermfg=DarkGreen gui=bold guifg=SeaGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6931 CENT("Search term=reverse ctermbg=Yellow ctermfg=NONE", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6932 "Search term=reverse ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE"), |
806 | 6933 #ifdef FEAT_SPELL |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6934 CENT("SpellBad term=reverse ctermbg=LightRed", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6935 "SpellBad term=reverse ctermbg=LightRed guisp=Red gui=undercurl"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6936 CENT("SpellCap term=reverse ctermbg=LightBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6937 "SpellCap term=reverse ctermbg=LightBlue guisp=Blue gui=undercurl"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6938 CENT("SpellRare term=reverse ctermbg=LightMagenta", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6939 "SpellRare term=reverse ctermbg=LightMagenta guisp=Magenta gui=undercurl"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6940 CENT("SpellLocal term=underline ctermbg=Cyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6941 "SpellLocal term=underline ctermbg=Cyan guisp=DarkCyan gui=undercurl"), |
806 | 6942 #endif |
6943 #ifdef FEAT_INS_EXPAND | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6944 CENT("PmenuThumb ctermbg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6945 "PmenuThumb ctermbg=Black guibg=Black"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6946 CENT("Pmenu ctermbg=LightMagenta ctermfg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6947 "Pmenu ctermbg=LightMagenta ctermfg=Black guibg=LightMagenta"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6948 CENT("PmenuSel ctermbg=LightGrey ctermfg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6949 "PmenuSel ctermbg=LightGrey ctermfg=Black guibg=Grey"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6950 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6951 CENT("SpecialKey term=bold ctermfg=DarkBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6952 "SpecialKey term=bold ctermfg=DarkBlue guifg=Blue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6953 CENT("Title term=bold ctermfg=DarkMagenta", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6954 "Title term=bold ctermfg=DarkMagenta gui=bold guifg=Magenta"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6955 CENT("WarningMsg term=standout ctermfg=DarkRed", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6956 "WarningMsg term=standout ctermfg=DarkRed guifg=Red"), |
806 | 6957 #ifdef FEAT_WILDMENU |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6958 CENT("WildMenu term=standout ctermbg=Yellow ctermfg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6959 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), |
806 | 6960 #endif |
6961 #ifdef FEAT_FOLDING | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6962 CENT("Folded term=standout ctermbg=Grey ctermfg=DarkBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6963 "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6964 CENT("FoldColumn term=standout ctermbg=Grey ctermfg=DarkBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6965 "FoldColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue"), |
806 | 6966 #endif |
6967 #ifdef FEAT_SIGNS | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6968 CENT("SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6969 "SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6970 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6971 CENT("Visual term=reverse", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6972 "Visual term=reverse guibg=LightGrey"), |
806 | 6973 #ifdef FEAT_DIFF |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6974 CENT("DiffAdd term=bold ctermbg=LightBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6975 "DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6976 CENT("DiffChange term=bold ctermbg=LightMagenta", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6977 "DiffChange term=bold ctermbg=LightMagenta guibg=LightMagenta"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6978 CENT("DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6979 "DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan gui=bold guifg=Blue guibg=LightCyan"), |
806 | 6980 #endif |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6981 CENT("TabLine term=underline cterm=underline ctermfg=black ctermbg=LightGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6982 "TabLine term=underline cterm=underline ctermfg=black ctermbg=LightGrey gui=underline guibg=LightGrey"), |
806 | 6983 #ifdef FEAT_SYN_HL |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6984 CENT("CursorColumn term=reverse ctermbg=LightGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6985 "CursorColumn term=reverse ctermbg=LightGrey guibg=Grey90"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6986 CENT("CursorLine term=underline cterm=underline", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6987 "CursorLine term=underline cterm=underline guibg=Grey90"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6988 CENT("ColorColumn term=reverse ctermbg=LightRed", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6989 "ColorColumn term=reverse ctermbg=LightRed guibg=LightRed"), |
806 | 6990 #endif |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6991 #ifdef FEAT_CONCEAL |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6992 CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6993 "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"), |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6994 #endif |
834 | 6995 #ifdef FEAT_AUTOCMD |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6996 CENT("MatchParen term=reverse ctermbg=Cyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
6997 "MatchParen term=reverse ctermbg=Cyan guibg=Cyan"), |
834 | 6998 #endif |
806 | 6999 #ifdef FEAT_GUI |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7000 "Normal gui=NONE", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7001 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7002 #ifdef FEAT_TERMINAL |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7003 CENT("StatusLineTerm term=reverse,bold cterm=bold ctermfg=White ctermbg=DarkGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7004 "StatusLineTerm term=reverse,bold cterm=bold ctermfg=White ctermbg=DarkGreen gui=bold guifg=bg guibg=DarkGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7005 CENT("StatusLineTermNC term=reverse ctermfg=White ctermbg=DarkGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7006 "StatusLineTermNC term=reverse ctermfg=White ctermbg=DarkGreen guifg=bg guibg=DarkGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7007 #endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7008 #ifdef FEAT_MENU |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7009 CENT("ToolbarLine term=underline ctermbg=LightGrey", |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7010 "ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"), |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7011 CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey", |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
7012 "ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold guifg=White guibg=Grey40"), |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7013 #endif |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7014 NULL |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7015 }; |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7016 |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7017 /* Default colors only used with a dark background. */ |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7018 static char *(highlight_init_dark[]) = { |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7019 CENT("Directory term=bold ctermfg=LightCyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7020 "Directory term=bold ctermfg=LightCyan guifg=Cyan"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7021 CENT("LineNr term=underline ctermfg=Yellow", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7022 "LineNr term=underline ctermfg=Yellow guifg=Yellow"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7023 CENT("CursorLineNr term=bold ctermfg=Yellow", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7024 "CursorLineNr term=bold ctermfg=Yellow gui=bold guifg=Yellow"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7025 CENT("MoreMsg term=bold ctermfg=LightGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7026 "MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7027 CENT("Question term=standout ctermfg=LightGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7028 "Question term=standout ctermfg=LightGreen gui=bold guifg=Green"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7029 CENT("Search term=reverse ctermbg=Yellow ctermfg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7030 "Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7031 CENT("SpecialKey term=bold ctermfg=LightBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7032 "SpecialKey term=bold ctermfg=LightBlue guifg=Cyan"), |
806 | 7033 #ifdef FEAT_SPELL |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7034 CENT("SpellBad term=reverse ctermbg=Red", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7035 "SpellBad term=reverse ctermbg=Red guisp=Red gui=undercurl"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7036 CENT("SpellCap term=reverse ctermbg=Blue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7037 "SpellCap term=reverse ctermbg=Blue guisp=Blue gui=undercurl"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7038 CENT("SpellRare term=reverse ctermbg=Magenta", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7039 "SpellRare term=reverse ctermbg=Magenta guisp=Magenta gui=undercurl"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7040 CENT("SpellLocal term=underline ctermbg=Cyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7041 "SpellLocal term=underline ctermbg=Cyan guisp=Cyan gui=undercurl"), |
806 | 7042 #endif |
7043 #ifdef FEAT_INS_EXPAND | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7044 CENT("PmenuThumb ctermbg=White", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7045 "PmenuThumb ctermbg=White guibg=White"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7046 CENT("Pmenu ctermbg=Magenta ctermfg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7047 "Pmenu ctermbg=Magenta ctermfg=Black guibg=Magenta"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7048 CENT("PmenuSel ctermbg=Black ctermfg=DarkGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7049 "PmenuSel ctermbg=Black ctermfg=DarkGrey guibg=DarkGrey"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7050 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7051 CENT("Title term=bold ctermfg=LightMagenta", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7052 "Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7053 CENT("WarningMsg term=standout ctermfg=LightRed", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7054 "WarningMsg term=standout ctermfg=LightRed guifg=Red"), |
806 | 7055 #ifdef FEAT_WILDMENU |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7056 CENT("WildMenu term=standout ctermbg=Yellow ctermfg=Black", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7057 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), |
806 | 7058 #endif |
7059 #ifdef FEAT_FOLDING | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7060 CENT("Folded term=standout ctermbg=DarkGrey ctermfg=Cyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7061 "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7062 CENT("FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7063 "FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan"), |
806 | 7064 #endif |
7065 #ifdef FEAT_SIGNS | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7066 CENT("SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7067 "SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7068 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7069 CENT("Visual term=reverse", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7070 "Visual term=reverse guibg=DarkGrey"), |
806 | 7071 #ifdef FEAT_DIFF |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7072 CENT("DiffAdd term=bold ctermbg=DarkBlue", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7073 "DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7074 CENT("DiffChange term=bold ctermbg=DarkMagenta", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7075 "DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7076 CENT("DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7077 "DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan"), |
806 | 7078 #endif |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7079 CENT("TabLine term=underline cterm=underline ctermfg=white ctermbg=DarkGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7080 "TabLine term=underline cterm=underline ctermfg=white ctermbg=DarkGrey gui=underline guibg=DarkGrey"), |
806 | 7081 #ifdef FEAT_SYN_HL |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7082 CENT("CursorColumn term=reverse ctermbg=DarkGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7083 "CursorColumn term=reverse ctermbg=DarkGrey guibg=Grey40"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7084 CENT("CursorLine term=underline cterm=underline", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7085 "CursorLine term=underline cterm=underline guibg=Grey40"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7086 CENT("ColorColumn term=reverse ctermbg=DarkRed", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7087 "ColorColumn term=reverse ctermbg=DarkRed guibg=DarkRed"), |
834 | 7088 #endif |
7089 #ifdef FEAT_AUTOCMD | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7090 CENT("MatchParen term=reverse ctermbg=DarkCyan", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7091 "MatchParen term=reverse ctermbg=DarkCyan guibg=DarkCyan"), |
806 | 7092 #endif |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7093 #ifdef FEAT_CONCEAL |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7094 CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7095 "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"), |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7096 #endif |
806 | 7097 #ifdef FEAT_GUI |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7098 "Normal gui=NONE", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7099 #endif |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7100 #ifdef FEAT_TERMINAL |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7101 CENT("StatusLineTerm term=reverse,bold cterm=bold ctermfg=Black ctermbg=LightGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7102 "StatusLineTerm term=reverse,bold cterm=bold ctermfg=Black ctermbg=LightGreen gui=bold guifg=bg guibg=LightGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7103 CENT("StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen", |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7104 "StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen guifg=bg guibg=LightGreen"), |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7105 #endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7106 #ifdef FEAT_MENU |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7107 CENT("ToolbarLine term=underline ctermbg=DarkGrey", |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
7108 "ToolbarLine term=underline ctermbg=DarkGrey guibg=Grey50"), |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7109 CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey", |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7110 "ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold guifg=Black guibg=LightGrey"), |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7111 #endif |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7112 NULL |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
7113 }; |
7 | 7114 |
7115 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7116 init_highlight( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7117 int both, /* include groups where 'bg' doesn't matter */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7118 int reset) /* clear group first */ |
7 | 7119 { |
7120 int i; | |
7121 char **pp; | |
7122 static int had_both = FALSE; | |
7123 #ifdef FEAT_EVAL | |
7124 char_u *p; | |
7125 | |
7126 /* | |
7127 * Try finding the color scheme file. Used when a color file was loaded | |
7128 * and 'background' or 't_Co' is changed. | |
7129 */ | |
7130 p = get_var_value((char_u *)"g:colors_name"); | |
6671 | 7131 if (p != NULL) |
7132 { | |
7133 /* The value of g:colors_name could be freed when sourcing the script, | |
7134 * making "p" invalid, so copy it. */ | |
7135 char_u *copy_p = vim_strsave(p); | |
7136 int r; | |
7137 | |
7138 if (copy_p != NULL) | |
7139 { | |
7140 r = load_colors(copy_p); | |
7141 vim_free(copy_p); | |
7142 if (r == OK) | |
7143 return; | |
7144 } | |
7145 } | |
7146 | |
7 | 7147 #endif |
7148 | |
7149 /* | |
7150 * Didn't use a color file, use the compiled-in colors. | |
7151 */ | |
7152 if (both) | |
7153 { | |
7154 had_both = TRUE; | |
7155 pp = highlight_init_both; | |
7156 for (i = 0; pp[i] != NULL; ++i) | |
7157 do_highlight((char_u *)pp[i], reset, TRUE); | |
7158 } | |
7159 else if (!had_both) | |
7160 /* Don't do anything before the call with both == TRUE from main(). | |
7161 * Not everything has been setup then, and that call will overrule | |
7162 * everything anyway. */ | |
7163 return; | |
7164 | |
7165 if (*p_bg == 'l') | |
7166 pp = highlight_init_light; | |
7167 else | |
7168 pp = highlight_init_dark; | |
7169 for (i = 0; pp[i] != NULL; ++i) | |
7170 do_highlight((char_u *)pp[i], reset, TRUE); | |
7171 | |
836 | 7172 /* Reverse looks ugly, but grey may not work for 8 colors. Thus let it |
844 | 7173 * depend on the number of colors available. |
7174 * With 8 colors brown is equal to yellow, need to use black for Search fg | |
1697 | 7175 * to avoid Statement highlighted text disappears. |
7176 * Clear the attributes, needed when changing the t_Co value. */ | |
527 | 7177 if (t_colors > 8) |
1697 | 7178 do_highlight((char_u *)(*p_bg == 'l' |
7179 ? "Visual cterm=NONE ctermbg=LightGrey" | |
7180 : "Visual cterm=NONE ctermbg=DarkGrey"), FALSE, TRUE); | |
836 | 7181 else |
844 | 7182 { |
1697 | 7183 do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE", |
7184 FALSE, TRUE); | |
844 | 7185 if (*p_bg == 'l') |
7186 do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE); | |
7187 } | |
527 | 7188 |
7 | 7189 #ifdef FEAT_SYN_HL |
7190 /* | |
7191 * If syntax highlighting is enabled load the highlighting for it. | |
7192 */ | |
7193 if (get_var_value((char_u *)"g:syntax_on") != NULL) | |
24 | 7194 { |
7195 static int recursive = 0; | |
7196 | |
7197 if (recursive >= 5) | |
7198 EMSG(_("E679: recursive loop loading syncolor.vim")); | |
7199 else | |
7200 { | |
7201 ++recursive; | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8514
diff
changeset
|
7202 (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); |
24 | 7203 --recursive; |
7204 } | |
7205 } | |
7 | 7206 #endif |
7207 } | |
7208 | |
7209 /* | |
12 | 7210 * Load color file "name". |
7 | 7211 * Return OK for success, FAIL for failure. |
7212 */ | |
7213 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7214 load_colors(char_u *name) |
7 | 7215 { |
7216 char_u *buf; | |
7217 int retval = FAIL; | |
7218 static int recursive = FALSE; | |
7219 | |
7220 /* When being called recursively, this is probably because setting | |
7221 * 'background' caused the highlighting to be reloaded. This means it is | |
7222 * working, thus we should return OK. */ | |
7223 if (recursive) | |
7224 return OK; | |
7225 | |
7226 recursive = TRUE; | |
12 | 7227 buf = alloc((unsigned)(STRLEN(name) + 12)); |
7 | 7228 if (buf != NULL) |
7229 { | |
12 | 7230 sprintf((char *)buf, "colors/%s.vim", name); |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8514
diff
changeset
|
7231 retval = source_runtime(buf, DIP_START + DIP_OPT); |
7 | 7232 vim_free(buf); |
12 | 7233 #ifdef FEAT_AUTOCMD |
5521 | 7234 apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); |
12 | 7235 #endif |
7 | 7236 } |
7237 recursive = FALSE; | |
7238 | |
7239 return retval; | |
7240 } | |
7241 | |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7242 static char *(color_names[28]) = { |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7243 "Black", "DarkBlue", "DarkGreen", "DarkCyan", |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7244 "DarkRed", "DarkMagenta", "Brown", "DarkYellow", |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7245 "Gray", "Grey", "LightGray", "LightGrey", |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7246 "DarkGray", "DarkGrey", |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7247 "Blue", "LightBlue", "Green", "LightGreen", |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7248 "Cyan", "LightCyan", "Red", "LightRed", "Magenta", |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7249 "LightMagenta", "Yellow", "LightYellow", "White", "NONE"}; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7250 /* indices: |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7251 * 0, 1, 2, 3, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7252 * 4, 5, 6, 7, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7253 * 8, 9, 10, 11, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7254 * 12, 13, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7255 * 14, 15, 16, 17, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7256 * 18, 19, 20, 21, 22, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7257 * 23, 24, 25, 26, 27 */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7258 static int color_numbers_16[28] = {0, 1, 2, 3, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7259 4, 5, 6, 6, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7260 7, 7, 7, 7, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7261 8, 8, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7262 9, 9, 10, 10, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7263 11, 11, 12, 12, 13, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7264 13, 14, 14, 15, -1}; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7265 /* for xterm with 88 colors... */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7266 static int color_numbers_88[28] = {0, 4, 2, 6, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7267 1, 5, 32, 72, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7268 84, 84, 7, 7, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7269 82, 82, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7270 12, 43, 10, 61, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7271 14, 63, 9, 74, 13, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7272 75, 11, 78, 15, -1}; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7273 /* for xterm with 256 colors... */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7274 static int color_numbers_256[28] = {0, 4, 2, 6, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7275 1, 5, 130, 130, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7276 248, 248, 7, 7, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7277 242, 242, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7278 12, 81, 10, 121, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7279 14, 159, 9, 224, 13, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7280 225, 11, 229, 15, -1}; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7281 /* for terminals with less than 16 colors... */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7282 static int color_numbers_8[28] = {0, 4, 2, 6, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7283 1, 5, 3, 3, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7284 7, 7, 7, 7, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7285 0+8, 0+8, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7286 4+8, 4+8, 2+8, 2+8, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7287 6+8, 6+8, 1+8, 1+8, 5+8, |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7288 5+8, 3+8, 3+8, 7+8, -1}; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7289 |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7290 /* |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7291 * Lookup the "cterm" value to be used for color with index "idx" in |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7292 * color_names[]. |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7293 * "boldp" will be set to TRUE or FALSE for a foreground color when using 8 |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7294 * colors, otherwise it will be unchanged. |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7295 */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7296 int |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7297 lookup_color(int idx, int foreground, int *boldp) |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7298 { |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7299 int color = color_numbers_16[idx]; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7300 char_u *p; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7301 |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7302 /* Use the _16 table to check if it's a valid color name. */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7303 if (color < 0) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7304 return -1; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7305 |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7306 if (t_colors == 8) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7307 { |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7308 /* t_Co is 8: use the 8 colors table */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7309 #if defined(__QNXNTO__) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7310 color = color_numbers_8_qansi[idx]; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7311 #else |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7312 color = color_numbers_8[idx]; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7313 #endif |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7314 if (foreground) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7315 { |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7316 /* set/reset bold attribute to get light foreground |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7317 * colors (on some terminals, e.g. "linux") */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7318 if (color & 8) |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7319 *boldp = TRUE; |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7320 else |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7321 *boldp = FALSE; |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7322 } |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7323 color &= 7; /* truncate to 8 colors */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7324 } |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7325 else if (t_colors == 16 || t_colors == 88 |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7326 || t_colors >= 256) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7327 { |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7328 /* |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7329 * Guess: if the termcap entry ends in 'm', it is |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7330 * probably an xterm-like terminal. Use the changed |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7331 * order for colors. |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7332 */ |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7333 if (*T_CAF != NUL) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7334 p = T_CAF; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7335 else |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7336 p = T_CSF; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7337 if (*p != NUL && (t_colors > 256 |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7338 || *(p + STRLEN(p) - 1) == 'm')) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7339 { |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7340 if (t_colors == 88) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7341 color = color_numbers_88[idx]; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7342 else if (t_colors >= 256) |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7343 color = color_numbers_256[idx]; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7344 else |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7345 color = color_numbers_8[idx]; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7346 } |
12594
573f8bdeb95a
patch 8.0.1175: build failure without +termresponse
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
7347 #ifdef FEAT_TERMRESPONSE |
12592
895da0cbb16e
patch 8.0.1174: Mac Terminal.app has wrong color for white
Christian Brabandt <cb@256bit.org>
parents:
12572
diff
changeset
|
7348 if (t_colors >= 256 && color == 15 && is_mac_terminal) |
895da0cbb16e
patch 8.0.1174: Mac Terminal.app has wrong color for white
Christian Brabandt <cb@256bit.org>
parents:
12572
diff
changeset
|
7349 /* Terminal.app has a bug: 15 is light grey. Use white |
895da0cbb16e
patch 8.0.1174: Mac Terminal.app has wrong color for white
Christian Brabandt <cb@256bit.org>
parents:
12572
diff
changeset
|
7350 * from the color cube instead. */ |
895da0cbb16e
patch 8.0.1174: Mac Terminal.app has wrong color for white
Christian Brabandt <cb@256bit.org>
parents:
12572
diff
changeset
|
7351 color = 231; |
12594
573f8bdeb95a
patch 8.0.1175: build failure without +termresponse
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
7352 #endif |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7353 } |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7354 return color; |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7355 } |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7356 |
7 | 7357 /* |
7358 * Handle the ":highlight .." command. | |
7359 * When using ":hi clear" this is called recursively for each group with | |
7360 * "forceit" and "init" both TRUE. | |
7361 */ | |
7362 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7363 do_highlight( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7364 char_u *line, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7365 int forceit, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
7366 int init) /* TRUE when called for initializing */ |
7 | 7367 { |
7368 char_u *name_end; | |
7369 char_u *p; | |
7370 char_u *linep; | |
7371 char_u *key_start; | |
7372 char_u *arg_start; | |
7373 char_u *key = NULL, *arg = NULL; | |
7374 long i; | |
7375 int off; | |
7376 int len; | |
7377 int attr; | |
7378 int id; | |
7379 int idx; | |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7380 struct hl_group item_before; |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
7381 int did_change = FALSE; |
7 | 7382 int dodefault = FALSE; |
7383 int doclear = FALSE; | |
7384 int dolink = FALSE; | |
7385 int error = FALSE; | |
7386 int color; | |
7387 int is_normal_group = FALSE; /* "Normal" group */ | |
12973
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7388 #ifdef FEAT_TERMINAL |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7389 int is_terminal_group = FALSE; /* "Terminal" group */ |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7390 #endif |
7 | 7391 #ifdef FEAT_GUI_X11 |
7392 int is_menu_group = FALSE; /* "Menu" group */ | |
7393 int is_scrollbar_group = FALSE; /* "Scrollbar" group */ | |
7394 int is_tooltip_group = FALSE; /* "Tooltip" group */ | |
7395 int do_colors = FALSE; /* need to update colors? */ | |
7396 #else | |
7397 # define is_menu_group 0 | |
7398 # define is_tooltip_group 0 | |
7399 #endif | |
12397
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
7400 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
7401 int did_highlight_changed = FALSE; |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
7402 #endif |
7 | 7403 |
7404 /* | |
7405 * If no argument, list current highlighting. | |
7406 */ | |
7407 if (ends_excmd(*line)) | |
7408 { | |
7409 for (i = 1; i <= highlight_ga.ga_len && !got_int; ++i) | |
7410 /* TODO: only call when the group has attributes set */ | |
7411 highlight_list_one((int)i); | |
7412 return; | |
7413 } | |
7414 | |
7415 /* | |
7416 * Isolate the name. | |
7417 */ | |
7418 name_end = skiptowhite(line); | |
7419 linep = skipwhite(name_end); | |
7420 | |
7421 /* | |
7422 * Check for "default" argument. | |
7423 */ | |
7424 if (STRNCMP(line, "default", name_end - line) == 0) | |
7425 { | |
7426 dodefault = TRUE; | |
7427 line = linep; | |
7428 name_end = skiptowhite(line); | |
7429 linep = skipwhite(name_end); | |
7430 } | |
7431 | |
7432 /* | |
7433 * Check for "clear" or "link" argument. | |
7434 */ | |
7435 if (STRNCMP(line, "clear", name_end - line) == 0) | |
7436 doclear = TRUE; | |
7437 if (STRNCMP(line, "link", name_end - line) == 0) | |
7438 dolink = TRUE; | |
7439 | |
7440 /* | |
7441 * ":highlight {group-name}": list highlighting for one group. | |
7442 */ | |
7443 if (!doclear && !dolink && ends_excmd(*linep)) | |
7444 { | |
7445 id = syn_namen2id(line, (int)(name_end - line)); | |
7446 if (id == 0) | |
7447 EMSG2(_("E411: highlight group not found: %s"), line); | |
7448 else | |
7449 highlight_list_one(id); | |
7450 return; | |
7451 } | |
7452 | |
7453 /* | |
7454 * Handle ":highlight link {from} {to}" command. | |
7455 */ | |
7456 if (dolink) | |
7457 { | |
7458 char_u *from_start = linep; | |
7459 char_u *from_end; | |
7460 char_u *to_start; | |
7461 char_u *to_end; | |
7462 int from_id; | |
7463 int to_id; | |
7464 | |
7465 from_end = skiptowhite(from_start); | |
7466 to_start = skipwhite(from_end); | |
7467 to_end = skiptowhite(to_start); | |
7468 | |
7469 if (ends_excmd(*from_start) || ends_excmd(*to_start)) | |
7470 { | |
7471 EMSG2(_("E412: Not enough arguments: \":highlight link %s\""), | |
7472 from_start); | |
7473 return; | |
7474 } | |
7475 | |
7476 if (!ends_excmd(*skipwhite(to_end))) | |
7477 { | |
7478 EMSG2(_("E413: Too many arguments: \":highlight link %s\""), from_start); | |
7479 return; | |
7480 } | |
7481 | |
7482 from_id = syn_check_group(from_start, (int)(from_end - from_start)); | |
7483 if (STRNCMP(to_start, "NONE", 4) == 0) | |
7484 to_id = 0; | |
7485 else | |
7486 to_id = syn_check_group(to_start, (int)(to_end - to_start)); | |
7487 | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7488 if (from_id > 0 && (!init || HL_TABLE()[from_id - 1].sg_set == 0)) |
7 | 7489 { |
7490 /* | |
7491 * Don't allow a link when there already is some highlighting | |
7492 * for the group, unless '!' is used | |
7493 */ | |
7494 if (to_id > 0 && !forceit && !init | |
7495 && hl_has_settings(from_id - 1, dodefault)) | |
7496 { | |
7497 if (sourcing_name == NULL && !dodefault) | |
7498 EMSG(_("E414: group has settings, highlight link ignored")); | |
7499 } | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7500 else if (HL_TABLE()[from_id - 1].sg_link != to_id |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7501 #ifdef FEAT_EVAL |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7502 || HL_TABLE()[from_id - 1].sg_scriptID != current_SID |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7503 #endif |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7504 || HL_TABLE()[from_id - 1].sg_cleared) |
7 | 7505 { |
7506 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7507 HL_TABLE()[from_id - 1].sg_set |= SG_LINK; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7508 HL_TABLE()[from_id - 1].sg_link = to_id; |
448 | 7509 #ifdef FEAT_EVAL |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7510 HL_TABLE()[from_id - 1].sg_scriptID = current_SID; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7511 #endif |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7512 HL_TABLE()[from_id - 1].sg_cleared = FALSE; |
745 | 7513 redraw_all_later(SOME_VALID); |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7514 |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7515 /* Only call highlight_changed() once after multiple changes. */ |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7516 need_highlight_changed = TRUE; |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7517 } |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7518 } |
7 | 7519 |
7520 return; | |
7521 } | |
7522 | |
7523 if (doclear) | |
7524 { | |
7525 /* | |
7526 * ":highlight clear [group]" command. | |
7527 */ | |
7528 line = linep; | |
7529 if (ends_excmd(*line)) | |
7530 { | |
7531 #ifdef FEAT_GUI | |
7532 /* First, we do not destroy the old values, but allocate the new | |
7533 * ones and update the display. THEN we destroy the old values. | |
7534 * If we destroy the old values first, then the old values | |
7535 * (such as GuiFont's or GuiFontset's) will still be displayed but | |
7536 * invalid because they were free'd. | |
7537 */ | |
7538 if (gui.in_use) | |
7539 { | |
7540 # ifdef FEAT_BEVAL_TIP | |
7541 gui_init_tooltip_font(); | |
7542 # endif | |
7543 # if defined(FEAT_MENU) && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF)) | |
7544 gui_init_menu_font(); | |
7545 # endif | |
7546 } | |
7547 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_X11) | |
7548 gui_mch_def_colors(); | |
7549 # endif | |
7550 # ifdef FEAT_GUI_X11 | |
7551 # ifdef FEAT_MENU | |
7552 | |
7553 /* This only needs to be done when there is no Menu highlight | |
7554 * group defined by default, which IS currently the case. | |
7555 */ | |
7556 gui_mch_new_menu_colors(); | |
7557 # endif | |
7558 if (gui.in_use) | |
7559 { | |
7560 gui_new_scrollbar_colors(); | |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12594
diff
changeset
|
7561 # ifdef FEAT_BEVAL_GUI |
7 | 7562 gui_mch_new_tooltip_colors(); |
7563 # endif | |
7564 # ifdef FEAT_MENU | |
7565 gui_mch_new_menu_font(); | |
7566 # endif | |
7567 } | |
7568 # endif | |
7569 | |
7570 /* Ok, we're done allocating the new default graphics items. | |
7571 * The screen should already be refreshed at this point. | |
7572 * It is now Ok to clear out the old data. | |
7573 */ | |
7574 #endif | |
7575 #ifdef FEAT_EVAL | |
148 | 7576 do_unlet((char_u *)"colors_name", TRUE); |
7 | 7577 #endif |
7578 restore_cterm_colors(); | |
7579 | |
7580 /* | |
7581 * Clear all default highlight groups and load the defaults. | |
7582 */ | |
7583 for (idx = 0; idx < highlight_ga.ga_len; ++idx) | |
7584 highlight_clear(idx); | |
7585 init_highlight(TRUE, TRUE); | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
7586 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
7587 if (USE_24BIT) |
7 | 7588 highlight_gui_started(); |
12397
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
7589 else |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
7590 #endif |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
7591 highlight_changed(); |
7 | 7592 redraw_later_clear(); |
7593 return; | |
7594 } | |
7595 name_end = skiptowhite(line); | |
7596 linep = skipwhite(name_end); | |
7597 } | |
7598 | |
7599 /* | |
7600 * Find the group name in the table. If it does not exist yet, add it. | |
7601 */ | |
7602 id = syn_check_group(line, (int)(name_end - line)); | |
7603 if (id == 0) /* failed (out of memory) */ | |
7604 return; | |
7605 idx = id - 1; /* index is ID minus one */ | |
7606 | |
7607 /* Return if "default" was used and the group already has settings. */ | |
7608 if (dodefault && hl_has_settings(idx, TRUE)) | |
7609 return; | |
7610 | |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7611 /* Make a copy so we can check if any attribute actually changed. */ |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7612 item_before = HL_TABLE()[idx]; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7613 |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7614 if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0) |
7 | 7615 is_normal_group = TRUE; |
12973
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7616 #ifdef FEAT_TERMINAL |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7617 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TERMINAL") == 0) |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7618 is_terminal_group = TRUE; |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
7619 #endif |
7 | 7620 #ifdef FEAT_GUI_X11 |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7621 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0) |
7 | 7622 is_menu_group = TRUE; |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7623 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "SCROLLBAR") == 0) |
7 | 7624 is_scrollbar_group = TRUE; |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7625 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TOOLTIP") == 0) |
7 | 7626 is_tooltip_group = TRUE; |
7627 #endif | |
7628 | |
7629 /* Clear the highlighting for ":hi clear {group}" and ":hi clear". */ | |
7630 if (doclear || (forceit && init)) | |
7631 { | |
7632 highlight_clear(idx); | |
7633 if (!doclear) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7634 HL_TABLE()[idx].sg_set = 0; |
7 | 7635 } |
7636 | |
7637 if (!doclear) | |
7638 while (!ends_excmd(*linep)) | |
7639 { | |
7640 key_start = linep; | |
7641 if (*linep == '=') | |
7642 { | |
7643 EMSG2(_("E415: unexpected equal sign: %s"), key_start); | |
7644 error = TRUE; | |
7645 break; | |
7646 } | |
7647 | |
7648 /* | |
7649 * Isolate the key ("term", "ctermfg", "ctermbg", "font", "guifg" or | |
7650 * "guibg"). | |
7651 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
7652 while (*linep && !VIM_ISWHITE(*linep) && *linep != '=') |
7 | 7653 ++linep; |
7654 vim_free(key); | |
7655 key = vim_strnsave_up(key_start, (int)(linep - key_start)); | |
7656 if (key == NULL) | |
7657 { | |
7658 error = TRUE; | |
7659 break; | |
7660 } | |
7661 linep = skipwhite(linep); | |
7662 | |
7663 if (STRCMP(key, "NONE") == 0) | |
7664 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7665 if (!init || HL_TABLE()[idx].sg_set == 0) |
7 | 7666 { |
7667 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7668 HL_TABLE()[idx].sg_set |= SG_TERM+SG_CTERM+SG_GUI; |
7 | 7669 highlight_clear(idx); |
7670 } | |
7671 continue; | |
7672 } | |
7673 | |
7674 /* | |
7675 * Check for the equal sign. | |
7676 */ | |
7677 if (*linep != '=') | |
7678 { | |
7679 EMSG2(_("E416: missing equal sign: %s"), key_start); | |
7680 error = TRUE; | |
7681 break; | |
7682 } | |
7683 ++linep; | |
7684 | |
7685 /* | |
7686 * Isolate the argument. | |
7687 */ | |
7688 linep = skipwhite(linep); | |
7689 if (*linep == '\'') /* guifg='color name' */ | |
7690 { | |
7691 arg_start = ++linep; | |
7692 linep = vim_strchr(linep, '\''); | |
7693 if (linep == NULL) | |
7694 { | |
7695 EMSG2(_(e_invarg2), key_start); | |
7696 error = TRUE; | |
7697 break; | |
7698 } | |
7699 } | |
7700 else | |
7701 { | |
7702 arg_start = linep; | |
7703 linep = skiptowhite(linep); | |
7704 } | |
7705 if (linep == arg_start) | |
7706 { | |
7707 EMSG2(_("E417: missing argument: %s"), key_start); | |
7708 error = TRUE; | |
7709 break; | |
7710 } | |
7711 vim_free(arg); | |
7712 arg = vim_strnsave(arg_start, (int)(linep - arg_start)); | |
7713 if (arg == NULL) | |
7714 { | |
7715 error = TRUE; | |
7716 break; | |
7717 } | |
7718 if (*linep == '\'') | |
7719 ++linep; | |
7720 | |
7721 /* | |
7722 * Store the argument. | |
7723 */ | |
7724 if ( STRCMP(key, "TERM") == 0 | |
7725 || STRCMP(key, "CTERM") == 0 | |
7726 || STRCMP(key, "GUI") == 0) | |
7727 { | |
7728 attr = 0; | |
7729 off = 0; | |
7730 while (arg[off] != NUL) | |
7731 { | |
7732 for (i = sizeof(hl_attr_table) / sizeof(int); --i >= 0; ) | |
7733 { | |
7734 len = (int)STRLEN(hl_name_table[i]); | |
7735 if (STRNICMP(arg + off, hl_name_table[i], len) == 0) | |
7736 { | |
7737 attr |= hl_attr_table[i]; | |
7738 off += len; | |
7739 break; | |
7740 } | |
7741 } | |
7742 if (i < 0) | |
7743 { | |
7744 EMSG2(_("E418: Illegal value: %s"), arg); | |
7745 error = TRUE; | |
7746 break; | |
7747 } | |
7748 if (arg[off] == ',') /* another one follows */ | |
7749 ++off; | |
7750 } | |
7751 if (error) | |
7752 break; | |
7753 if (*key == 'T') | |
7754 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7755 if (!init || !(HL_TABLE()[idx].sg_set & SG_TERM)) |
7 | 7756 { |
7757 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7758 HL_TABLE()[idx].sg_set |= SG_TERM; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7759 HL_TABLE()[idx].sg_term = attr; |
7 | 7760 } |
7761 } | |
7762 else if (*key == 'C') | |
7763 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7764 if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) |
7 | 7765 { |
7766 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7767 HL_TABLE()[idx].sg_set |= SG_CTERM; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7768 HL_TABLE()[idx].sg_cterm = attr; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7769 HL_TABLE()[idx].sg_cterm_bold = FALSE; |
7 | 7770 } |
7771 } | |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
7772 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
7 | 7773 else |
7774 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7775 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) |
7 | 7776 { |
7777 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7778 HL_TABLE()[idx].sg_set |= SG_GUI; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7779 HL_TABLE()[idx].sg_gui = attr; |
7 | 7780 } |
7781 } | |
7782 #endif | |
7783 } | |
7784 else if (STRCMP(key, "FONT") == 0) | |
7785 { | |
7786 /* in non-GUI fonts are simply ignored */ | |
7787 #ifdef FEAT_GUI | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7788 if (HL_TABLE()[idx].sg_font_name != NULL |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7789 && STRCMP(HL_TABLE()[idx].sg_font_name, arg) == 0) |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7790 { |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7791 /* Font name didn't change, ignore. */ |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7792 } |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
7793 else if (!gui.shell_created) |
7 | 7794 { |
7795 /* GUI not started yet, always accept the name. */ | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7796 vim_free(HL_TABLE()[idx].sg_font_name); |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7797 HL_TABLE()[idx].sg_font_name = vim_strsave(arg); |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
7798 did_change = TRUE; |
7 | 7799 } |
7800 else | |
7801 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7802 GuiFont temp_sg_font = HL_TABLE()[idx].sg_font; |
7 | 7803 # ifdef FEAT_XFONTSET |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7804 GuiFontset temp_sg_fontset = HL_TABLE()[idx].sg_fontset; |
7 | 7805 # endif |
7806 /* First, save the current font/fontset. | |
7807 * Then try to allocate the font/fontset. | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7808 * If the allocation fails, HL_TABLE()[idx].sg_font OR |
7 | 7809 * sg_fontset will be set to NOFONT or NOFONTSET respectively. |
7810 */ | |
7811 | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7812 HL_TABLE()[idx].sg_font = NOFONT; |
7 | 7813 # ifdef FEAT_XFONTSET |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7814 HL_TABLE()[idx].sg_fontset = NOFONTSET; |
7 | 7815 # endif |
7816 hl_do_font(idx, arg, is_normal_group, is_menu_group, | |
3881 | 7817 is_tooltip_group, FALSE); |
7 | 7818 |
7819 # ifdef FEAT_XFONTSET | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7820 if (HL_TABLE()[idx].sg_fontset != NOFONTSET) |
7 | 7821 { |
3881 | 7822 /* New fontset was accepted. Free the old one, if there |
7823 * was one. */ | |
7 | 7824 gui_mch_free_fontset(temp_sg_fontset); |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7825 vim_free(HL_TABLE()[idx].sg_font_name); |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7826 HL_TABLE()[idx].sg_font_name = vim_strsave(arg); |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
7827 did_change = TRUE; |
7 | 7828 } |
7829 else | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7830 HL_TABLE()[idx].sg_fontset = temp_sg_fontset; |
7 | 7831 # endif |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7832 if (HL_TABLE()[idx].sg_font != NOFONT) |
7 | 7833 { |
7834 /* New font was accepted. Free the old one, if there was | |
3881 | 7835 * one. */ |
7 | 7836 gui_mch_free_font(temp_sg_font); |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7837 vim_free(HL_TABLE()[idx].sg_font_name); |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7838 HL_TABLE()[idx].sg_font_name = vim_strsave(arg); |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
7839 did_change = TRUE; |
7 | 7840 } |
7841 else | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7842 HL_TABLE()[idx].sg_font = temp_sg_font; |
7 | 7843 } |
7844 #endif | |
7845 } | |
7846 else if (STRCMP(key, "CTERMFG") == 0 || STRCMP(key, "CTERMBG") == 0) | |
7847 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7848 if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) |
7 | 7849 { |
7850 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7851 HL_TABLE()[idx].sg_set |= SG_CTERM; |
7 | 7852 |
7853 /* When setting the foreground color, and previously the "bold" | |
7854 * flag was set for a light color, reset it now */ | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7855 if (key[5] == 'F' && HL_TABLE()[idx].sg_cterm_bold) |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7856 { |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7857 HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7858 HL_TABLE()[idx].sg_cterm_bold = FALSE; |
7 | 7859 } |
7860 | |
7861 if (VIM_ISDIGIT(*arg)) | |
7862 color = atoi((char *)arg); | |
7863 else if (STRICMP(arg, "fg") == 0) | |
7864 { | |
7865 if (cterm_normal_fg_color) | |
7866 color = cterm_normal_fg_color - 1; | |
7867 else | |
7868 { | |
7869 EMSG(_("E419: FG color unknown")); | |
7870 error = TRUE; | |
7871 break; | |
7872 } | |
7873 } | |
7874 else if (STRICMP(arg, "bg") == 0) | |
7875 { | |
7876 if (cterm_normal_bg_color > 0) | |
7877 color = cterm_normal_bg_color - 1; | |
7878 else | |
7879 { | |
7880 EMSG(_("E420: BG color unknown")); | |
7881 error = TRUE; | |
7882 break; | |
7883 } | |
7884 } | |
7885 else | |
7886 { | |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7887 int bold = MAYBE; |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7888 |
7 | 7889 #if defined(__QNXNTO__) |
7890 static int *color_numbers_8_qansi = color_numbers_8; | |
7891 /* On qnx, the 8 & 16 color arrays are the same */ | |
7892 if (STRNCMP(T_NAME, "qansi", 5) == 0) | |
7893 color_numbers_8_qansi = color_numbers_16; | |
7894 #endif | |
7895 | |
7896 /* reduce calls to STRICMP a bit, it can be slow */ | |
7897 off = TOUPPER_ASC(*arg); | |
7898 for (i = (sizeof(color_names) / sizeof(char *)); --i >= 0; ) | |
7899 if (off == color_names[i][0] | |
7900 && STRICMP(arg + 1, color_names[i] + 1) == 0) | |
7901 break; | |
7902 if (i < 0) | |
7903 { | |
7904 EMSG2(_("E421: Color name or number not recognized: %s"), key_start); | |
7905 error = TRUE; | |
7906 break; | |
7907 } | |
7908 | |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7909 color = lookup_color(i, key[5] == 'F', &bold); |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7910 |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7911 /* set/reset bold attribute to get light foreground |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7912 * colors (on some terminals, e.g. "linux") */ |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7913 if (bold == TRUE) |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7914 { |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7915 HL_TABLE()[idx].sg_cterm |= HL_BOLD; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7916 HL_TABLE()[idx].sg_cterm_bold = TRUE; |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7917 } |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11890
diff
changeset
|
7918 else if (bold == FALSE) |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7919 HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7920 } |
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
7921 |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7922 /* Add one to the argument, to avoid zero. Zero is used for |
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7923 * "NONE", then "color" is -1. */ |
7 | 7924 if (key[5] == 'F') |
7925 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7926 HL_TABLE()[idx].sg_cterm_fg = color + 1; |
7 | 7927 if (is_normal_group) |
7928 { | |
7929 cterm_normal_fg_color = color + 1; | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7930 cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD); |
7 | 7931 #ifdef FEAT_GUI |
7932 /* Don't do this if the GUI is used. */ | |
7933 if (!gui.in_use && !gui.starting) | |
7934 #endif | |
7935 { | |
7936 must_redraw = CLEAR; | |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7937 if (termcap_active && color >= 0) |
7 | 7938 term_fg_color(color); |
7939 } | |
7940 } | |
7941 } | |
7942 else | |
7943 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7944 HL_TABLE()[idx].sg_cterm_bg = color + 1; |
7 | 7945 if (is_normal_group) |
7946 { | |
7947 cterm_normal_bg_color = color + 1; | |
7948 #ifdef FEAT_GUI | |
7949 /* Don't mess with 'background' if the GUI is used. */ | |
7950 if (!gui.in_use && !gui.starting) | |
7951 #endif | |
7952 { | |
7953 must_redraw = CLEAR; | |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7954 if (color >= 0) |
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7955 { |
11465
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7956 int dark = -1; |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7957 |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7958 if (termcap_active) |
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7959 term_bg_color(color); |
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7960 if (t_colors < 16) |
11465
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7961 dark = (color == 0 || color == 4); |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7962 /* Limit the heuristic to the standard 16 colors */ |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7963 else if (color < 16) |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7964 dark = (color < 7 || color == 8); |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7965 /* Set the 'background' option if the value is |
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7966 * wrong. */ |
11465
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7967 if (dark != -1 |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7968 && dark != (*p_bg == 'd') |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7969 && !option_was_set((char_u *)"bg")) |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7970 { |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7971 set_option_value((char_u *)"bg", 0L, |
11465
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7972 (char_u *)(dark ? "dark" : "light"), 0); |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7973 reset_option_was_set((char_u *)"bg"); |
7cbcba782c4e
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Christian Brabandt <cb@256bit.org>
parents:
11254
diff
changeset
|
7974 } |
2136
431ebc9412a8
updated for version 7.2.418
Bram Moolenaar <bram@zimbu.org>
parents:
2123
diff
changeset
|
7975 } |
7 | 7976 } |
7977 } | |
7978 } | |
7979 } | |
7980 } | |
7981 else if (STRCMP(key, "GUIFG") == 0) | |
7982 { | |
12537
a24356fd94d8
patch 8.0.1147: fail to build with tiny features
Christian Brabandt <cb@256bit.org>
parents:
12535
diff
changeset
|
7983 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
7984 char_u **namep = &HL_TABLE()[idx].sg_gui_fg_name; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
7985 |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7986 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) |
7 | 7987 { |
205 | 7988 if (!init) |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7989 HL_TABLE()[idx].sg_set |= SG_GUI; |
205 | 7990 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
7991 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
7992 /* In GUI guifg colors are only used when recognized */ |
205 | 7993 i = color_name2handle(arg); |
9029
f06767547415
commit https://github.com/vim/vim/commit/631225627d448b591e529a5d3e7ac74ef44b8459
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
7994 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT) |
205 | 7995 { |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
7996 HL_TABLE()[idx].sg_gui_fg = i; |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
7997 # endif |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
7998 if (*namep == NULL || STRCMP(*namep, arg) != 0) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
7999 { |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8000 vim_free(*namep); |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8001 if (STRCMP(arg, "NONE") != 0) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8002 *namep = vim_strsave(arg); |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8003 else |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8004 *namep = NULL; |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8005 did_change = TRUE; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8006 } |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8007 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8008 # ifdef FEAT_GUI_X11 |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8009 if (is_menu_group && gui.menu_fg_pixel != i) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8010 { |
205 | 8011 gui.menu_fg_pixel = i; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8012 do_colors = TRUE; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8013 } |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8014 if (is_scrollbar_group && gui.scroll_fg_pixel != i) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8015 { |
205 | 8016 gui.scroll_fg_pixel = i; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8017 do_colors = TRUE; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8018 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12594
diff
changeset
|
8019 # ifdef FEAT_BEVAL_GUI |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8020 if (is_tooltip_group && gui.tooltip_fg_pixel != i) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8021 { |
205 | 8022 gui.tooltip_fg_pixel = i; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8023 do_colors = TRUE; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8024 } |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8025 # endif |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8026 # endif |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8027 } |
7 | 8028 # endif |
8029 } | |
8030 #endif | |
8031 } | |
8032 else if (STRCMP(key, "GUIBG") == 0) | |
8033 { | |
12537
a24356fd94d8
patch 8.0.1147: fail to build with tiny features
Christian Brabandt <cb@256bit.org>
parents:
12535
diff
changeset
|
8034 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8035 char_u **namep = &HL_TABLE()[idx].sg_gui_bg_name; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8036 |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8037 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) |
7 | 8038 { |
205 | 8039 if (!init) |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8040 HL_TABLE()[idx].sg_set |= SG_GUI; |
205 | 8041 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8042 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8043 /* In GUI guifg colors are only used when recognized */ |
205 | 8044 i = color_name2handle(arg); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8045 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT) |
205 | 8046 { |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8047 HL_TABLE()[idx].sg_gui_bg = i; |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8048 # endif |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8049 if (*namep == NULL || STRCMP(*namep, arg) != 0) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8050 { |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8051 vim_free(*namep); |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8052 if (STRCMP(arg, "NONE") != 0) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8053 *namep = vim_strsave(arg); |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8054 else |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8055 *namep = NULL; |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8056 did_change = TRUE; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8057 } |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8058 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8059 # ifdef FEAT_GUI_X11 |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8060 if (is_menu_group && gui.menu_bg_pixel != i) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8061 { |
205 | 8062 gui.menu_bg_pixel = i; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8063 do_colors = TRUE; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8064 } |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8065 if (is_scrollbar_group && gui.scroll_bg_pixel != i) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8066 { |
205 | 8067 gui.scroll_bg_pixel = i; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8068 do_colors = TRUE; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8069 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12594
diff
changeset
|
8070 # ifdef FEAT_BEVAL_GUI |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8071 if (is_tooltip_group && gui.tooltip_bg_pixel != i) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8072 { |
205 | 8073 gui.tooltip_bg_pixel = i; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8074 do_colors = TRUE; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8075 } |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8076 # endif |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8077 # endif |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8078 } |
7 | 8079 # endif |
8080 } | |
205 | 8081 #endif |
8082 } | |
8083 else if (STRCMP(key, "GUISP") == 0) | |
8084 { | |
12537
a24356fd94d8
patch 8.0.1147: fail to build with tiny features
Christian Brabandt <cb@256bit.org>
parents:
12535
diff
changeset
|
8085 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8086 char_u **namep = &HL_TABLE()[idx].sg_gui_sp_name; |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8087 |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8088 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) |
205 | 8089 { |
8090 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8091 HL_TABLE()[idx].sg_set |= SG_GUI; |
205 | 8092 |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8093 # ifdef FEAT_GUI |
205 | 8094 i = color_name2handle(arg); |
8095 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) | |
8096 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8097 HL_TABLE()[idx].sg_gui_sp = i; |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8098 # endif |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8099 if (*namep == NULL || STRCMP(*namep, arg) != 0) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8100 { |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8101 vim_free(*namep); |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8102 if (STRCMP(arg, "NONE") != 0) |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8103 *namep = vim_strsave(arg); |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8104 else |
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8105 *namep = NULL; |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8106 did_change = TRUE; |
12535
523162252b06
patch 8.0.1146: redraw when highlight is set with same names
Christian Brabandt <cb@256bit.org>
parents:
12511
diff
changeset
|
8107 } |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8108 # ifdef FEAT_GUI |
205 | 8109 } |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8110 # endif |
205 | 8111 } |
7 | 8112 #endif |
8113 } | |
8114 else if (STRCMP(key, "START") == 0 || STRCMP(key, "STOP") == 0) | |
8115 { | |
8116 char_u buf[100]; | |
8117 char_u *tname; | |
8118 | |
8119 if (!init) | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8120 HL_TABLE()[idx].sg_set |= SG_TERM; |
7 | 8121 |
8122 /* | |
8123 * The "start" and "stop" arguments can be a literal escape | |
1222 | 8124 * sequence, or a comma separated list of terminal codes. |
7 | 8125 */ |
8126 if (STRNCMP(arg, "t_", 2) == 0) | |
8127 { | |
8128 off = 0; | |
8129 buf[0] = 0; | |
8130 while (arg[off] != NUL) | |
8131 { | |
8132 /* Isolate one termcap name */ | |
8133 for (len = 0; arg[off + len] && | |
8134 arg[off + len] != ','; ++len) | |
8135 ; | |
8136 tname = vim_strnsave(arg + off, len); | |
8137 if (tname == NULL) /* out of memory */ | |
8138 { | |
8139 error = TRUE; | |
8140 break; | |
8141 } | |
8142 /* lookup the escape sequence for the item */ | |
8143 p = get_term_code(tname); | |
8144 vim_free(tname); | |
8145 if (p == NULL) /* ignore non-existing things */ | |
8146 p = (char_u *)""; | |
8147 | |
8148 /* Append it to the already found stuff */ | |
8149 if ((int)(STRLEN(buf) + STRLEN(p)) >= 99) | |
8150 { | |
8151 EMSG2(_("E422: terminal code too long: %s"), arg); | |
8152 error = TRUE; | |
8153 break; | |
8154 } | |
8155 STRCAT(buf, p); | |
8156 | |
8157 /* Advance to the next item */ | |
8158 off += len; | |
8159 if (arg[off] == ',') /* another one follows */ | |
8160 ++off; | |
8161 } | |
8162 } | |
8163 else | |
8164 { | |
8165 /* | |
8166 * Copy characters from arg[] to buf[], translating <> codes. | |
8167 */ | |
2593 | 8168 for (p = arg, off = 0; off < 100 - 6 && *p; ) |
7 | 8169 { |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9141
diff
changeset
|
8170 len = trans_special(&p, buf + off, FALSE, FALSE); |
2593 | 8171 if (len > 0) /* recognized special char */ |
7 | 8172 off += len; |
8173 else /* copy as normal char */ | |
8174 buf[off++] = *p++; | |
8175 } | |
8176 buf[off] = NUL; | |
8177 } | |
8178 if (error) | |
8179 break; | |
8180 | |
8181 if (STRCMP(buf, "NONE") == 0) /* resetting the value */ | |
8182 p = NULL; | |
8183 else | |
8184 p = vim_strsave(buf); | |
8185 if (key[2] == 'A') | |
8186 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8187 vim_free(HL_TABLE()[idx].sg_start); |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8188 HL_TABLE()[idx].sg_start = p; |
7 | 8189 } |
8190 else | |
8191 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8192 vim_free(HL_TABLE()[idx].sg_stop); |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8193 HL_TABLE()[idx].sg_stop = p; |
7 | 8194 } |
8195 } | |
8196 else | |
8197 { | |
8198 EMSG2(_("E423: Illegal argument: %s"), key_start); | |
8199 error = TRUE; | |
8200 break; | |
8201 } | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8202 HL_TABLE()[idx].sg_cleared = FALSE; |
7 | 8203 |
8204 /* | |
8205 * When highlighting has been given for a group, don't link it. | |
8206 */ | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8207 if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8208 HL_TABLE()[idx].sg_link = 0; |
7 | 8209 |
8210 /* | |
8211 * Continue with next argument. | |
8212 */ | |
8213 linep = skipwhite(linep); | |
8214 } | |
8215 | |
8216 /* | |
8217 * If there is an error, and it's a new entry, remove it from the table. | |
8218 */ | |
8219 if (error && idx == highlight_ga.ga_len) | |
8220 syn_unadd_group(); | |
8221 else | |
8222 { | |
8223 if (is_normal_group) | |
8224 { | |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8225 HL_TABLE()[idx].sg_term_attr = 0; |
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8226 HL_TABLE()[idx].sg_cterm_attr = 0; |
7 | 8227 #ifdef FEAT_GUI |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8228 HL_TABLE()[idx].sg_gui_attr = 0; |
7 | 8229 /* |
8230 * Need to update all groups, because they might be using "bg" | |
8231 * and/or "fg", which have been changed now. | |
8232 */ | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8233 #endif |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8234 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8235 if (USE_24BIT) |
12397
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8236 { |
7 | 8237 highlight_gui_started(); |
12397
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8238 did_highlight_changed = TRUE; |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8239 redraw_all_later(NOT_VALID); |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8240 } |
7 | 8241 #endif |
8242 } | |
12973
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
8243 #ifdef FEAT_TERMINAL |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
8244 else if (is_terminal_group) |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
8245 set_terminal_default_colors( |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
8246 HL_TABLE()[idx].sg_cterm_fg, HL_TABLE()[idx].sg_cterm_bg); |
418941f0df08
patch 8.0.1362: terminal window colors wrong when using Terminal highlighting
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
8247 #endif |
7 | 8248 #ifdef FEAT_GUI_X11 |
8249 # ifdef FEAT_MENU | |
8250 else if (is_menu_group) | |
8251 { | |
8252 if (gui.in_use && do_colors) | |
8253 gui_mch_new_menu_colors(); | |
8254 } | |
8255 # endif | |
8256 else if (is_scrollbar_group) | |
8257 { | |
8258 if (gui.in_use && do_colors) | |
8259 gui_new_scrollbar_colors(); | |
8260 } | |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12594
diff
changeset
|
8261 # ifdef FEAT_BEVAL_GUI |
7 | 8262 else if (is_tooltip_group) |
8263 { | |
8264 if (gui.in_use && do_colors) | |
8265 gui_mch_new_tooltip_colors(); | |
8266 } | |
8267 # endif | |
8268 #endif | |
8269 else | |
8270 set_hl_attr(idx); | |
448 | 8271 #ifdef FEAT_EVAL |
12417
c14c81302b75
patch 8.0.1088: occasional memory use after free
Christian Brabandt <cb@256bit.org>
parents:
12397
diff
changeset
|
8272 HL_TABLE()[idx].sg_scriptID = current_SID; |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8273 #endif |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8274 } |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8275 |
7 | 8276 vim_free(key); |
8277 vim_free(arg); | |
8278 | |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8279 /* Only call highlight_changed() once, after a sequence of highlight |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8280 * commands, and only if an attribute actually changed. */ |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8281 if ((did_change |
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8282 || memcmp(&HL_TABLE()[idx], &item_before, sizeof(item_before)) != 0) |
12397
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8283 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8284 && !did_highlight_changed |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8285 #endif |
2bac51746e2b
patch 8.0.1078: using freed memory with ":hi Normal"
Christian Brabandt <cb@256bit.org>
parents:
12385
diff
changeset
|
8286 ) |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8287 { |
12572
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8288 /* Do not trigger a redraw when highlighting is changed while |
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8289 * redrawing. This may happen when evaluating 'statusline' changes the |
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8290 * StatusLine group. */ |
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8291 if (!updating_screen) |
31737ff54115
patch 8.0.1164: changing StatusLine highlight does not always work
Christian Brabandt <cb@256bit.org>
parents:
12562
diff
changeset
|
8292 redraw_all_later(NOT_VALID); |
12385
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8293 need_highlight_changed = TRUE; |
972732a27d7c
patch 8.0.1072: :highlight command causes a redraw even when nothing changed
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
8294 } |
7 | 8295 } |
8296 | |
356 | 8297 #if defined(EXITFREE) || defined(PROTO) |
8298 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8299 free_highlight(void) |
356 | 8300 { |
8301 int i; | |
8302 | |
8303 for (i = 0; i < highlight_ga.ga_len; ++i) | |
359 | 8304 { |
356 | 8305 highlight_clear(i); |
359 | 8306 vim_free(HL_TABLE()[i].sg_name); |
8307 vim_free(HL_TABLE()[i].sg_name_u); | |
8308 } | |
356 | 8309 ga_clear(&highlight_ga); |
8310 } | |
8311 #endif | |
8312 | |
7 | 8313 /* |
8314 * Reset the cterm colors to what they were before Vim was started, if | |
8315 * possible. Otherwise reset them to zero. | |
8316 */ | |
8317 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8318 restore_cterm_colors(void) |
7 | 8319 { |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
7835
diff
changeset
|
8320 #if defined(WIN3264) && !defined(FEAT_GUI_W32) |
7 | 8321 /* Since t_me has been set, this probably means that the user |
8322 * wants to use this as default colors. Need to reset default | |
8323 * background/foreground colors. */ | |
8324 mch_set_normal_colors(); | |
8325 #else | |
8326 cterm_normal_fg_color = 0; | |
8327 cterm_normal_fg_bold = 0; | |
8328 cterm_normal_bg_color = 0; | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8329 # ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8330 cterm_normal_fg_gui_color = INVALCOLOR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8331 cterm_normal_bg_gui_color = INVALCOLOR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8332 # endif |
7 | 8333 #endif |
8334 } | |
8335 | |
8336 /* | |
8337 * Return TRUE if highlight group "idx" has any settings. | |
8338 * When "check_link" is TRUE also check for an existing link. | |
8339 */ | |
8340 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8341 hl_has_settings(int idx, int check_link) |
7 | 8342 { |
8343 return ( HL_TABLE()[idx].sg_term_attr != 0 | |
8344 || HL_TABLE()[idx].sg_cterm_attr != 0 | |
5954 | 8345 || HL_TABLE()[idx].sg_cterm_fg != 0 |
8346 || HL_TABLE()[idx].sg_cterm_bg != 0 | |
7 | 8347 #ifdef FEAT_GUI |
8348 || HL_TABLE()[idx].sg_gui_attr != 0 | |
5954 | 8349 || HL_TABLE()[idx].sg_gui_fg_name != NULL |
8350 || HL_TABLE()[idx].sg_gui_bg_name != NULL | |
8351 || HL_TABLE()[idx].sg_gui_sp_name != NULL | |
11119
d8a550329a97
patch 8.0.0447: getting font name does not work on X11
Christian Brabandt <cb@256bit.org>
parents:
11073
diff
changeset
|
8352 || HL_TABLE()[idx].sg_font_name != NULL |
7 | 8353 #endif |
8354 || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK))); | |
8355 } | |
8356 | |
8357 /* | |
8358 * Clear highlighting for one group. | |
8359 */ | |
8360 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8361 highlight_clear(int idx) |
7 | 8362 { |
10624
5ac9d7920f11
patch 8.0.0201: completion of highlight groups includes cleared names
Christian Brabandt <cb@256bit.org>
parents:
10618
diff
changeset
|
8363 HL_TABLE()[idx].sg_cleared = TRUE; |
5ac9d7920f11
patch 8.0.0201: completion of highlight groups includes cleared names
Christian Brabandt <cb@256bit.org>
parents:
10618
diff
changeset
|
8364 |
7 | 8365 HL_TABLE()[idx].sg_term = 0; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
8366 VIM_CLEAR(HL_TABLE()[idx].sg_start); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
8367 VIM_CLEAR(HL_TABLE()[idx].sg_stop); |
7 | 8368 HL_TABLE()[idx].sg_term_attr = 0; |
8369 HL_TABLE()[idx].sg_cterm = 0; | |
8370 HL_TABLE()[idx].sg_cterm_bold = FALSE; | |
8371 HL_TABLE()[idx].sg_cterm_fg = 0; | |
8372 HL_TABLE()[idx].sg_cterm_bg = 0; | |
8373 HL_TABLE()[idx].sg_cterm_attr = 0; | |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8374 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
7 | 8375 HL_TABLE()[idx].sg_gui = 0; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
8376 VIM_CLEAR(HL_TABLE()[idx].sg_gui_fg_name); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
8377 VIM_CLEAR(HL_TABLE()[idx].sg_gui_bg_name); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
8378 VIM_CLEAR(HL_TABLE()[idx].sg_gui_sp_name); |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8379 #endif |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8380 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8381 HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8382 HL_TABLE()[idx].sg_gui_bg = INVALCOLOR; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8383 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8384 #ifdef FEAT_GUI |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
8385 HL_TABLE()[idx].sg_gui_sp = INVALCOLOR; |
7 | 8386 gui_mch_free_font(HL_TABLE()[idx].sg_font); |
8387 HL_TABLE()[idx].sg_font = NOFONT; | |
8388 # ifdef FEAT_XFONTSET | |
8389 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); | |
8390 HL_TABLE()[idx].sg_fontset = NOFONTSET; | |
8391 # endif | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
8392 VIM_CLEAR(HL_TABLE()[idx].sg_font_name); |
7 | 8393 HL_TABLE()[idx].sg_gui_attr = 0; |
8394 #endif | |
448 | 8395 #ifdef FEAT_EVAL |
8396 /* Clear the script ID only when there is no link, since that is not | |
8397 * cleared. */ | |
8398 if (HL_TABLE()[idx].sg_link == 0) | |
8399 HL_TABLE()[idx].sg_scriptID = 0; | |
8400 #endif | |
7 | 8401 } |
8402 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8403 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
7 | 8404 /* |
8405 * Set the normal foreground and background colors according to the "Normal" | |
2020 | 8406 * highlighting group. For X11 also set "Menu", "Scrollbar", and |
7 | 8407 * "Tooltip" colors. |
8408 */ | |
8409 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8410 set_normal_colors(void) |
7 | 8411 { |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8412 #ifdef FEAT_GUI |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8413 # ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8414 if (gui.in_use) |
7 | 8415 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8416 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8417 if (set_group_colors((char_u *)"Normal", |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8418 &gui.norm_pixel, &gui.back_pixel, |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8419 FALSE, TRUE, FALSE)) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8420 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8421 gui_mch_new_colors(); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8422 must_redraw = CLEAR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8423 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8424 # ifdef FEAT_GUI_X11 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8425 if (set_group_colors((char_u *)"Menu", |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8426 &gui.menu_fg_pixel, &gui.menu_bg_pixel, |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8427 TRUE, FALSE, FALSE)) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8428 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8429 # ifdef FEAT_MENU |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8430 gui_mch_new_menu_colors(); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8431 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8432 must_redraw = CLEAR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8433 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12594
diff
changeset
|
8434 # ifdef FEAT_BEVAL_GUI |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8435 if (set_group_colors((char_u *)"Tooltip", |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8436 &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel, |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8437 FALSE, FALSE, TRUE)) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8438 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8439 # ifdef FEAT_TOOLBAR |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8440 gui_mch_new_tooltip_colors(); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8441 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8442 must_redraw = CLEAR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8443 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8444 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8445 if (set_group_colors((char_u *)"Scrollbar", |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8446 &gui.scroll_fg_pixel, &gui.scroll_bg_pixel, |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8447 FALSE, FALSE, FALSE)) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8448 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8449 gui_new_scrollbar_colors(); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8450 must_redraw = CLEAR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8451 } |
7 | 8452 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8453 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8454 #endif |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8455 #ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8456 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8457 else |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8458 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8459 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8460 int idx; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8461 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8462 idx = syn_name2id((char_u *)"Normal") - 1; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8463 if (idx >= 0) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8464 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8465 gui_do_one_color(idx, FALSE, FALSE); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8466 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8467 if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8468 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8469 cterm_normal_fg_gui_color = HL_TABLE()[idx].sg_gui_fg; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8470 must_redraw = CLEAR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8471 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8472 if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8473 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8474 cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8475 must_redraw = CLEAR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8476 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8477 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8478 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8479 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8480 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8481 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8482 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8483 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 8484 /* |
8485 * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". | |
8486 */ | |
8487 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8488 set_group_colors( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8489 char_u *name, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8490 guicolor_T *fgp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8491 guicolor_T *bgp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8492 int do_menu, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8493 int use_norm, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8494 int do_tooltip) |
7 | 8495 { |
8496 int idx; | |
8497 | |
8498 idx = syn_name2id(name) - 1; | |
8499 if (idx >= 0) | |
8500 { | |
8501 gui_do_one_color(idx, do_menu, do_tooltip); | |
8502 | |
8503 if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR) | |
8504 *fgp = HL_TABLE()[idx].sg_gui_fg; | |
8505 else if (use_norm) | |
8506 *fgp = gui.def_norm_pixel; | |
8507 if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR) | |
8508 *bgp = HL_TABLE()[idx].sg_gui_bg; | |
8509 else if (use_norm) | |
8510 *bgp = gui.def_back_pixel; | |
8511 return TRUE; | |
8512 } | |
8513 return FALSE; | |
8514 } | |
8515 | |
8516 /* | |
8517 * Get the font of the "Normal" group. | |
8518 * Returns "" when it's not found or not set. | |
8519 */ | |
8520 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8521 hl_get_font_name(void) |
7 | 8522 { |
8523 int id; | |
8524 char_u *s; | |
8525 | |
8526 id = syn_name2id((char_u *)"Normal"); | |
8527 if (id > 0) | |
8528 { | |
8529 s = HL_TABLE()[id - 1].sg_font_name; | |
8530 if (s != NULL) | |
8531 return s; | |
8532 } | |
8533 return (char_u *)""; | |
8534 } | |
8535 | |
8536 /* | |
8537 * Set font for "Normal" group. Called by gui_mch_init_font() when a font has | |
8538 * actually chosen to be used. | |
8539 */ | |
8540 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8541 hl_set_font_name(char_u *font_name) |
7 | 8542 { |
8543 int id; | |
8544 | |
8545 id = syn_name2id((char_u *)"Normal"); | |
8546 if (id > 0) | |
8547 { | |
8548 vim_free(HL_TABLE()[id - 1].sg_font_name); | |
8549 HL_TABLE()[id - 1].sg_font_name = vim_strsave(font_name); | |
8550 } | |
8551 } | |
8552 | |
8553 /* | |
8554 * Set background color for "Normal" group. Called by gui_set_bg_color() | |
8555 * when the color is known. | |
8556 */ | |
8557 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8558 hl_set_bg_color_name( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8559 char_u *name) /* must have been allocated */ |
7 | 8560 { |
8561 int id; | |
8562 | |
8563 if (name != NULL) | |
8564 { | |
8565 id = syn_name2id((char_u *)"Normal"); | |
8566 if (id > 0) | |
8567 { | |
8568 vim_free(HL_TABLE()[id - 1].sg_gui_bg_name); | |
8569 HL_TABLE()[id - 1].sg_gui_bg_name = name; | |
8570 } | |
8571 } | |
8572 } | |
8573 | |
8574 /* | |
8575 * Set foreground color for "Normal" group. Called by gui_set_fg_color() | |
8576 * when the color is known. | |
8577 */ | |
8578 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8579 hl_set_fg_color_name( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8580 char_u *name) /* must have been allocated */ |
7 | 8581 { |
8582 int id; | |
8583 | |
8584 if (name != NULL) | |
8585 { | |
8586 id = syn_name2id((char_u *)"Normal"); | |
8587 if (id > 0) | |
8588 { | |
8589 vim_free(HL_TABLE()[id - 1].sg_gui_fg_name); | |
8590 HL_TABLE()[id - 1].sg_gui_fg_name = name; | |
8591 } | |
8592 } | |
8593 } | |
8594 | |
8595 /* | |
8596 * Return the handle for a font name. | |
8597 * Returns NOFONT when failed. | |
8598 */ | |
8599 static GuiFont | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8600 font_name2handle(char_u *name) |
7 | 8601 { |
8602 if (STRCMP(name, "NONE") == 0) | |
8603 return NOFONT; | |
8604 | |
8605 return gui_mch_get_font(name, TRUE); | |
8606 } | |
8607 | |
8608 # ifdef FEAT_XFONTSET | |
8609 /* | |
8610 * Return the handle for a fontset name. | |
8611 * Returns NOFONTSET when failed. | |
8612 */ | |
8613 static GuiFontset | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8614 fontset_name2handle(char_u *name, int fixed_width) |
7 | 8615 { |
8616 if (STRCMP(name, "NONE") == 0) | |
8617 return NOFONTSET; | |
8618 | |
8619 return gui_mch_get_fontset(name, TRUE, fixed_width); | |
8620 } | |
8621 # endif | |
8622 | |
8623 /* | |
8624 * Get the font or fontset for one highlight group. | |
8625 */ | |
8626 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8627 hl_do_font( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8628 int idx, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8629 char_u *arg, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8630 int do_normal, /* set normal font */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8631 int do_menu UNUSED, /* set menu font */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8632 int do_tooltip UNUSED, /* set tooltip font */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8633 int free_font) /* free current font/fontset */ |
7 | 8634 { |
8635 # ifdef FEAT_XFONTSET | |
8636 /* If 'guifontset' is not empty, first try using the name as a | |
8637 * fontset. If that doesn't work, use it as a font name. */ | |
8638 if (*p_guifontset != NUL | |
8639 # ifdef FONTSET_ALWAYS | |
8640 || do_menu | |
8641 # endif | |
8642 # ifdef FEAT_BEVAL_TIP | |
8643 /* In Athena & Motif, the Tooltip highlight group is always a fontset */ | |
8644 || do_tooltip | |
8645 # endif | |
8646 ) | |
4344 | 8647 { |
3900 | 8648 if (free_font) |
3881 | 8649 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); |
7 | 8650 HL_TABLE()[idx].sg_fontset = fontset_name2handle(arg, 0 |
8651 # ifdef FONTSET_ALWAYS | |
8652 || do_menu | |
8653 # endif | |
8654 # ifdef FEAT_BEVAL_TIP | |
8655 || do_tooltip | |
8656 # endif | |
8657 ); | |
4344 | 8658 } |
7 | 8659 if (HL_TABLE()[idx].sg_fontset != NOFONTSET) |
8660 { | |
3881 | 8661 /* If it worked and it's the Normal group, use it as the normal |
8662 * fontset. Same for the Menu group. */ | |
7 | 8663 if (do_normal) |
8664 gui_init_font(arg, TRUE); | |
8665 # if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) && defined(FEAT_MENU) | |
8666 if (do_menu) | |
8667 { | |
8668 # ifdef FONTSET_ALWAYS | |
8669 gui.menu_fontset = HL_TABLE()[idx].sg_fontset; | |
8670 # else | |
8671 /* YIKES! This is a bug waiting to crash the program */ | |
8672 gui.menu_font = HL_TABLE()[idx].sg_fontset; | |
8673 # endif | |
8674 gui_mch_new_menu_font(); | |
8675 } | |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12594
diff
changeset
|
8676 # ifdef FEAT_BEVAL_GUI |
7 | 8677 if (do_tooltip) |
8678 { | |
8679 /* The Athena widget set cannot currently handle switching between | |
8680 * displaying a single font and a fontset. | |
8681 * If the XtNinternational resource is set to True at widget | |
1222 | 8682 * creation, then a fontset is always used, otherwise an |
7 | 8683 * XFontStruct is used. |
8684 */ | |
8685 gui.tooltip_fontset = (XFontSet)HL_TABLE()[idx].sg_fontset; | |
8686 gui_mch_new_tooltip_font(); | |
8687 } | |
8688 # endif | |
8689 # endif | |
8690 } | |
8691 else | |
8692 # endif | |
8693 { | |
3881 | 8694 if (free_font) |
8695 gui_mch_free_font(HL_TABLE()[idx].sg_font); | |
7 | 8696 HL_TABLE()[idx].sg_font = font_name2handle(arg); |
8697 /* If it worked and it's the Normal group, use it as the | |
8698 * normal font. Same for the Menu group. */ | |
8699 if (HL_TABLE()[idx].sg_font != NOFONT) | |
8700 { | |
8701 if (do_normal) | |
8702 gui_init_font(arg, FALSE); | |
8703 #ifndef FONTSET_ALWAYS | |
8704 # if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) && defined(FEAT_MENU) | |
8705 if (do_menu) | |
8706 { | |
8707 gui.menu_font = HL_TABLE()[idx].sg_font; | |
8708 gui_mch_new_menu_font(); | |
8709 } | |
8710 # endif | |
8711 #endif | |
8712 } | |
8713 } | |
8714 } | |
8715 | |
8716 #endif /* FEAT_GUI */ | |
8717 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8718 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8719 /* |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8720 * Return the handle for a color name. |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8721 * Returns INVALCOLOR when failed. |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8722 */ |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12068
diff
changeset
|
8723 guicolor_T |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8724 color_name2handle(char_u *name) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8725 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8726 if (STRCMP(name, "NONE") == 0) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8727 return INVALCOLOR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8728 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8729 if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8730 { |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8731 #if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8732 if (gui.in_use) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8733 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8734 #ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8735 return gui.norm_pixel; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8736 #endif |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8737 #ifdef FEAT_TERMGUICOLORS |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
8738 if (cterm_normal_fg_gui_color != INVALCOLOR) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8739 return cterm_normal_fg_gui_color; |
9141
d6662acfc3de
commit https://github.com/vim/vim/commit/d80629cef03cd40b0bf06c402dfe0b720b3bf608
Christian Brabandt <cb@256bit.org>
parents:
9054
diff
changeset
|
8740 /* Guess that the foreground is black or white. */ |
d6662acfc3de
commit https://github.com/vim/vim/commit/d80629cef03cd40b0bf06c402dfe0b720b3bf608
Christian Brabandt <cb@256bit.org>
parents:
9054
diff
changeset
|
8741 return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "black" : "white")); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8742 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8743 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8744 if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8745 { |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8746 #if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8747 if (gui.in_use) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8748 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8749 #ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8750 return gui.back_pixel; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8751 #endif |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8752 #ifdef FEAT_TERMGUICOLORS |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
8753 if (cterm_normal_bg_gui_color != INVALCOLOR) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8754 return cterm_normal_bg_gui_color; |
9141
d6662acfc3de
commit https://github.com/vim/vim/commit/d80629cef03cd40b0bf06c402dfe0b720b3bf608
Christian Brabandt <cb@256bit.org>
parents:
9054
diff
changeset
|
8755 /* Guess that the background is white or black. */ |
d6662acfc3de
commit https://github.com/vim/vim/commit/d80629cef03cd40b0bf06c402dfe0b720b3bf608
Christian Brabandt <cb@256bit.org>
parents:
9054
diff
changeset
|
8756 return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "white" : "black")); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8757 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8758 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8759 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8760 return GUI_GET_COLOR(name); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8761 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8762 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8763 |
7 | 8764 /* |
8765 * Table with the specifications for an attribute number. | |
8766 * Note that this table is used by ALL buffers. This is required because the | |
8767 * GUI can redraw at any time for any buffer. | |
8768 */ | |
298 | 8769 static garray_T term_attr_table = {0, 0, 0, 0, NULL}; |
7 | 8770 |
8771 #define TERM_ATTR_ENTRY(idx) ((attrentry_T *)term_attr_table.ga_data)[idx] | |
8772 | |
298 | 8773 static garray_T cterm_attr_table = {0, 0, 0, 0, NULL}; |
7 | 8774 |
8775 #define CTERM_ATTR_ENTRY(idx) ((attrentry_T *)cterm_attr_table.ga_data)[idx] | |
8776 | |
8777 #ifdef FEAT_GUI | |
298 | 8778 static garray_T gui_attr_table = {0, 0, 0, 0, NULL}; |
7 | 8779 |
8780 #define GUI_ATTR_ENTRY(idx) ((attrentry_T *)gui_attr_table.ga_data)[idx] | |
8781 #endif | |
8782 | |
8783 /* | |
8784 * Return the attr number for a set of colors and font. | |
8785 * Add a new entry to the term_attr_table, cterm_attr_table or gui_attr_table | |
8786 * if the combination is new. | |
8787 * Return 0 for error (no more room). | |
8788 */ | |
8789 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8790 get_attr_entry(garray_T *table, attrentry_T *aep) |
7 | 8791 { |
8792 int i; | |
359 | 8793 attrentry_T *taep; |
7 | 8794 static int recursive = FALSE; |
8795 | |
8796 /* | |
8797 * Init the table, in case it wasn't done yet. | |
8798 */ | |
8799 table->ga_itemsize = sizeof(attrentry_T); | |
8800 table->ga_growsize = 7; | |
8801 | |
8802 /* | |
8803 * Try to find an entry with the same specifications. | |
8804 */ | |
8805 for (i = 0; i < table->ga_len; ++i) | |
8806 { | |
359 | 8807 taep = &(((attrentry_T *)table->ga_data)[i]); |
8808 if ( aep->ae_attr == taep->ae_attr | |
7 | 8809 && ( |
8810 #ifdef FEAT_GUI | |
8811 (table == &gui_attr_table | |
359 | 8812 && (aep->ae_u.gui.fg_color == taep->ae_u.gui.fg_color |
8813 && aep->ae_u.gui.bg_color | |
8814 == taep->ae_u.gui.bg_color | |
8815 && aep->ae_u.gui.sp_color | |
8816 == taep->ae_u.gui.sp_color | |
8817 && aep->ae_u.gui.font == taep->ae_u.gui.font | |
7 | 8818 # ifdef FEAT_XFONTSET |
359 | 8819 && aep->ae_u.gui.fontset == taep->ae_u.gui.fontset |
7 | 8820 # endif |
8821 )) | |
8822 || | |
8823 #endif | |
8824 (table == &term_attr_table | |
359 | 8825 && (aep->ae_u.term.start == NULL) |
8826 == (taep->ae_u.term.start == NULL) | |
7 | 8827 && (aep->ae_u.term.start == NULL |
8828 || STRCMP(aep->ae_u.term.start, | |
359 | 8829 taep->ae_u.term.start) == 0) |
8830 && (aep->ae_u.term.stop == NULL) | |
8831 == (taep->ae_u.term.stop == NULL) | |
7 | 8832 && (aep->ae_u.term.stop == NULL |
8833 || STRCMP(aep->ae_u.term.stop, | |
359 | 8834 taep->ae_u.term.stop) == 0)) |
7 | 8835 || (table == &cterm_attr_table |
359 | 8836 && aep->ae_u.cterm.fg_color |
8837 == taep->ae_u.cterm.fg_color | |
8838 && aep->ae_u.cterm.bg_color | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8839 == taep->ae_u.cterm.bg_color |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8840 #ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8841 && aep->ae_u.cterm.fg_rgb |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8842 == taep->ae_u.cterm.fg_rgb |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8843 && aep->ae_u.cterm.bg_rgb |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8844 == taep->ae_u.cterm.bg_rgb |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8845 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8846 ))) |
7 | 8847 |
8848 return i + ATTR_OFF; | |
8849 } | |
8850 | |
271 | 8851 if (table->ga_len + ATTR_OFF > MAX_TYPENR) |
7 | 8852 { |
8853 /* | |
8854 * Running out of attribute entries! remove all attributes, and | |
8855 * compute new ones for all groups. | |
8856 * When called recursively, we are really out of numbers. | |
8857 */ | |
8858 if (recursive) | |
8859 { | |
8860 EMSG(_("E424: Too many different highlighting attributes in use")); | |
8861 return 0; | |
8862 } | |
8863 recursive = TRUE; | |
8864 | |
359 | 8865 clear_hl_tables(); |
8866 | |
7 | 8867 must_redraw = CLEAR; |
8868 | |
8869 for (i = 0; i < highlight_ga.ga_len; ++i) | |
8870 set_hl_attr(i); | |
8871 | |
8872 recursive = FALSE; | |
8873 } | |
8874 | |
8875 /* | |
8876 * This is a new combination of colors and font, add an entry. | |
8877 */ | |
8878 if (ga_grow(table, 1) == FAIL) | |
8879 return 0; | |
8880 | |
359 | 8881 taep = &(((attrentry_T *)table->ga_data)[table->ga_len]); |
8882 vim_memset(taep, 0, sizeof(attrentry_T)); | |
8883 taep->ae_attr = aep->ae_attr; | |
7 | 8884 #ifdef FEAT_GUI |
8885 if (table == &gui_attr_table) | |
8886 { | |
359 | 8887 taep->ae_u.gui.fg_color = aep->ae_u.gui.fg_color; |
8888 taep->ae_u.gui.bg_color = aep->ae_u.gui.bg_color; | |
8889 taep->ae_u.gui.sp_color = aep->ae_u.gui.sp_color; | |
8890 taep->ae_u.gui.font = aep->ae_u.gui.font; | |
7 | 8891 # ifdef FEAT_XFONTSET |
359 | 8892 taep->ae_u.gui.fontset = aep->ae_u.gui.fontset; |
7 | 8893 # endif |
8894 } | |
8895 #endif | |
8896 if (table == &term_attr_table) | |
8897 { | |
8898 if (aep->ae_u.term.start == NULL) | |
359 | 8899 taep->ae_u.term.start = NULL; |
7 | 8900 else |
359 | 8901 taep->ae_u.term.start = vim_strsave(aep->ae_u.term.start); |
7 | 8902 if (aep->ae_u.term.stop == NULL) |
359 | 8903 taep->ae_u.term.stop = NULL; |
7 | 8904 else |
359 | 8905 taep->ae_u.term.stop = vim_strsave(aep->ae_u.term.stop); |
7 | 8906 } |
8907 else if (table == &cterm_attr_table) | |
8908 { | |
359 | 8909 taep->ae_u.cterm.fg_color = aep->ae_u.cterm.fg_color; |
8910 taep->ae_u.cterm.bg_color = aep->ae_u.cterm.bg_color; | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
8911 #ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8912 taep->ae_u.cterm.fg_rgb = aep->ae_u.cterm.fg_rgb; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8913 taep->ae_u.cterm.bg_rgb = aep->ae_u.cterm.bg_rgb; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
8914 #endif |
7 | 8915 } |
8916 ++table->ga_len; | |
8917 return (table->ga_len - 1 + ATTR_OFF); | |
8918 } | |
8919 | |
359 | 8920 /* |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8921 * Get an attribute index for a cterm entry. |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8922 * Uses an existing entry when possible or adds one when needed. |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8923 */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8924 int |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8925 get_cterm_attr_idx(int attr, int fg, int bg) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8926 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8927 attrentry_T at_en; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8928 |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8929 vim_memset(&at_en, 0, sizeof(attrentry_T)); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
8930 #ifdef FEAT_TERMGUICOLORS |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
8931 at_en.ae_u.cterm.fg_rgb = INVALCOLOR; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
8932 at_en.ae_u.cterm.bg_rgb = INVALCOLOR; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
8933 #endif |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8934 at_en.ae_attr = attr; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8935 at_en.ae_u.cterm.fg_color = fg; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8936 at_en.ae_u.cterm.bg_color = bg; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8937 return get_attr_entry(&cterm_attr_table, &at_en); |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8938 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8939 |
11755
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8940 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8941 /* |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8942 * Get an attribute index for a 'termguicolors' entry. |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8943 * Uses an existing entry when possible or adds one when needed. |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8944 */ |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8945 int |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8946 get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg) |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8947 { |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8948 attrentry_T at_en; |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8949 |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8950 vim_memset(&at_en, 0, sizeof(attrentry_T)); |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8951 at_en.ae_attr = attr; |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8952 at_en.ae_u.cterm.fg_rgb = fg; |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8953 at_en.ae_u.cterm.bg_rgb = bg; |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8954 return get_attr_entry(&cterm_attr_table, &at_en); |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8955 } |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8956 #endif |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
8957 |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8958 #if defined(FEAT_GUI) || defined(PROTO) |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8959 /* |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8960 * Get an attribute index for a cterm entry. |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8961 * Uses an existing entry when possible or adds one when needed. |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8962 */ |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8963 int |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8964 get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg) |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8965 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8966 attrentry_T at_en; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8967 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8968 vim_memset(&at_en, 0, sizeof(attrentry_T)); |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8969 at_en.ae_attr = attr; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8970 at_en.ae_u.gui.fg_color = fg; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8971 at_en.ae_u.gui.bg_color = bg; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8972 return get_attr_entry(&gui_attr_table, &at_en); |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8973 } |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8974 #endif |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
8975 |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11581
diff
changeset
|
8976 /* |
359 | 8977 * Clear all highlight tables. |
8978 */ | |
8979 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
8980 clear_hl_tables(void) |
359 | 8981 { |
8982 int i; | |
8983 attrentry_T *taep; | |
8984 | |
8985 #ifdef FEAT_GUI | |
8986 ga_clear(&gui_attr_table); | |
8987 #endif | |
8988 for (i = 0; i < term_attr_table.ga_len; ++i) | |
8989 { | |
8990 taep = &(((attrentry_T *)term_attr_table.ga_data)[i]); | |
8991 vim_free(taep->ae_u.term.start); | |
8992 vim_free(taep->ae_u.term.stop); | |
8993 } | |
8994 ga_clear(&term_attr_table); | |
8995 ga_clear(&cterm_attr_table); | |
8996 } | |
8997 | |
745 | 8998 #if defined(FEAT_SYN_HL) || defined(FEAT_SPELL) || defined(PROTO) |
221 | 8999 /* |
348 | 9000 * Combine special attributes (e.g., for spelling) with other attributes |
9001 * (e.g., for syntax highlighting). | |
9002 * "prim_attr" overrules "char_attr". | |
221 | 9003 * This creates a new group when required. |
9004 * Since we expect there to be few spelling mistakes we don't cache the | |
9005 * result. | |
9006 * Return the resulting attributes. | |
9007 */ | |
9008 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9009 hl_combine_attr(int char_attr, int prim_attr) |
221 | 9010 { |
9011 attrentry_T *char_aep = NULL; | |
9012 attrentry_T *spell_aep; | |
9013 attrentry_T new_en; | |
9014 | |
9015 if (char_attr == 0) | |
348 | 9016 return prim_attr; |
9017 if (char_attr <= HL_ALL && prim_attr <= HL_ALL) | |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9018 return ATTR_COMBINE(char_attr, prim_attr); |
221 | 9019 #ifdef FEAT_GUI |
9020 if (gui.in_use) | |
9021 { | |
9022 if (char_attr > HL_ALL) | |
9023 char_aep = syn_gui_attr2entry(char_attr); | |
9024 if (char_aep != NULL) | |
9025 new_en = *char_aep; | |
9026 else | |
9027 { | |
9028 vim_memset(&new_en, 0, sizeof(new_en)); | |
548 | 9029 new_en.ae_u.gui.fg_color = INVALCOLOR; |
9030 new_en.ae_u.gui.bg_color = INVALCOLOR; | |
9031 new_en.ae_u.gui.sp_color = INVALCOLOR; | |
221 | 9032 if (char_attr <= HL_ALL) |
9033 new_en.ae_attr = char_attr; | |
9034 } | |
9035 | |
348 | 9036 if (prim_attr <= HL_ALL) |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9037 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr); |
221 | 9038 else |
9039 { | |
348 | 9040 spell_aep = syn_gui_attr2entry(prim_attr); |
221 | 9041 if (spell_aep != NULL) |
9042 { | |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9043 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, |
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9044 spell_aep->ae_attr); |
221 | 9045 if (spell_aep->ae_u.gui.fg_color != INVALCOLOR) |
9046 new_en.ae_u.gui.fg_color = spell_aep->ae_u.gui.fg_color; | |
9047 if (spell_aep->ae_u.gui.bg_color != INVALCOLOR) | |
9048 new_en.ae_u.gui.bg_color = spell_aep->ae_u.gui.bg_color; | |
9049 if (spell_aep->ae_u.gui.sp_color != INVALCOLOR) | |
9050 new_en.ae_u.gui.sp_color = spell_aep->ae_u.gui.sp_color; | |
9051 if (spell_aep->ae_u.gui.font != NOFONT) | |
9052 new_en.ae_u.gui.font = spell_aep->ae_u.gui.font; | |
9053 # ifdef FEAT_XFONTSET | |
9054 if (spell_aep->ae_u.gui.fontset != NOFONTSET) | |
9055 new_en.ae_u.gui.fontset = spell_aep->ae_u.gui.fontset; | |
9056 # endif | |
9057 } | |
9058 } | |
9059 return get_attr_entry(&gui_attr_table, &new_en); | |
9060 } | |
9061 #endif | |
9062 | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9063 if (IS_CTERM) |
221 | 9064 { |
9065 if (char_attr > HL_ALL) | |
9066 char_aep = syn_cterm_attr2entry(char_attr); | |
9067 if (char_aep != NULL) | |
9068 new_en = *char_aep; | |
9069 else | |
9070 { | |
9071 vim_memset(&new_en, 0, sizeof(new_en)); | |
10499
e88ffb09ff38
commit https://github.com/vim/vim/commit/0cdb72aa38c4a0140c94d56bf8bc17cb30260ebf
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
9072 #ifdef FEAT_TERMGUICOLORS |
e88ffb09ff38
commit https://github.com/vim/vim/commit/0cdb72aa38c4a0140c94d56bf8bc17cb30260ebf
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
9073 new_en.ae_u.cterm.bg_rgb = INVALCOLOR; |
e88ffb09ff38
commit https://github.com/vim/vim/commit/0cdb72aa38c4a0140c94d56bf8bc17cb30260ebf
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
9074 new_en.ae_u.cterm.fg_rgb = INVALCOLOR; |
e88ffb09ff38
commit https://github.com/vim/vim/commit/0cdb72aa38c4a0140c94d56bf8bc17cb30260ebf
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
9075 #endif |
221 | 9076 if (char_attr <= HL_ALL) |
9077 new_en.ae_attr = char_attr; | |
9078 } | |
9079 | |
348 | 9080 if (prim_attr <= HL_ALL) |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9081 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr); |
221 | 9082 else |
9083 { | |
348 | 9084 spell_aep = syn_cterm_attr2entry(prim_attr); |
221 | 9085 if (spell_aep != NULL) |
9086 { | |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9087 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, |
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9088 spell_aep->ae_attr); |
221 | 9089 if (spell_aep->ae_u.cterm.fg_color > 0) |
9090 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color; | |
9091 if (spell_aep->ae_u.cterm.bg_color > 0) | |
9092 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9093 #ifdef FEAT_TERMGUICOLORS |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
9094 if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9095 new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb; |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
9096 if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9097 new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9098 #endif |
221 | 9099 } |
9100 } | |
9101 return get_attr_entry(&cterm_attr_table, &new_en); | |
9102 } | |
9103 | |
9104 if (char_attr > HL_ALL) | |
9105 char_aep = syn_term_attr2entry(char_attr); | |
9106 if (char_aep != NULL) | |
9107 new_en = *char_aep; | |
9108 else | |
9109 { | |
9110 vim_memset(&new_en, 0, sizeof(new_en)); | |
9111 if (char_attr <= HL_ALL) | |
9112 new_en.ae_attr = char_attr; | |
9113 } | |
9114 | |
348 | 9115 if (prim_attr <= HL_ALL) |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9116 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr); |
221 | 9117 else |
9118 { | |
607 | 9119 spell_aep = syn_term_attr2entry(prim_attr); |
221 | 9120 if (spell_aep != NULL) |
9121 { | |
12068
e1b34958f118
patch 8.0.0914: highlight attributes are always combined
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
9122 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, spell_aep->ae_attr); |
221 | 9123 if (spell_aep->ae_u.term.start != NULL) |
9124 { | |
9125 new_en.ae_u.term.start = spell_aep->ae_u.term.start; | |
9126 new_en.ae_u.term.stop = spell_aep->ae_u.term.stop; | |
9127 } | |
9128 } | |
9129 } | |
9130 return get_attr_entry(&term_attr_table, &new_en); | |
9131 } | |
9132 #endif | |
9133 | |
7 | 9134 #ifdef FEAT_GUI |
9135 | |
9136 attrentry_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9137 syn_gui_attr2entry(int attr) |
7 | 9138 { |
9139 attr -= ATTR_OFF; | |
9140 if (attr >= gui_attr_table.ga_len) /* did ":syntax clear" */ | |
9141 return NULL; | |
9142 return &(GUI_ATTR_ENTRY(attr)); | |
9143 } | |
9144 #endif /* FEAT_GUI */ | |
9145 | |
745 | 9146 /* |
9147 * Get the highlight attributes (HL_BOLD etc.) from an attribute nr. | |
9148 * Only to be used when "attr" > HL_ALL. | |
9149 */ | |
9150 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9151 syn_attr2attr(int attr) |
745 | 9152 { |
9153 attrentry_T *aep; | |
9154 | |
9155 #ifdef FEAT_GUI | |
9156 if (gui.in_use) | |
9157 aep = syn_gui_attr2entry(attr); | |
9158 else | |
9159 #endif | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9160 if (IS_CTERM) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9161 aep = syn_cterm_attr2entry(attr); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9162 else |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9163 aep = syn_term_attr2entry(attr); |
745 | 9164 |
9165 if (aep == NULL) /* highlighting not set */ | |
9166 return 0; | |
9167 return aep->ae_attr; | |
9168 } | |
9169 | |
9170 | |
7 | 9171 attrentry_T * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9172 syn_term_attr2entry(int attr) |
7 | 9173 { |
9174 attr -= ATTR_OFF; | |
9175 if (attr >= term_attr_table.ga_len) /* did ":syntax clear" */ | |
9176 return NULL; | |
9177 return &(TERM_ATTR_ENTRY(attr)); | |
9178 } | |
9179 | |
9180 attrentry_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9181 syn_cterm_attr2entry(int attr) |
7 | 9182 { |
9183 attr -= ATTR_OFF; | |
9184 if (attr >= cterm_attr_table.ga_len) /* did ":syntax clear" */ | |
9185 return NULL; | |
9186 return &(CTERM_ATTR_ENTRY(attr)); | |
9187 } | |
9188 | |
9189 #define LIST_ATTR 1 | |
9190 #define LIST_STRING 2 | |
9191 #define LIST_INT 3 | |
9192 | |
9193 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9194 highlight_list_one(int id) |
7 | 9195 { |
9196 struct hl_group *sgp; | |
9197 int didh = FALSE; | |
9198 | |
9199 sgp = &HL_TABLE()[id - 1]; /* index is ID minus one */ | |
9200 | |
9201 didh = highlight_list_arg(id, didh, LIST_ATTR, | |
9202 sgp->sg_term, NULL, "term"); | |
9203 didh = highlight_list_arg(id, didh, LIST_STRING, | |
9204 0, sgp->sg_start, "start"); | |
9205 didh = highlight_list_arg(id, didh, LIST_STRING, | |
9206 0, sgp->sg_stop, "stop"); | |
9207 | |
9208 didh = highlight_list_arg(id, didh, LIST_ATTR, | |
9209 sgp->sg_cterm, NULL, "cterm"); | |
9210 didh = highlight_list_arg(id, didh, LIST_INT, | |
9211 sgp->sg_cterm_fg, NULL, "ctermfg"); | |
9212 didh = highlight_list_arg(id, didh, LIST_INT, | |
9213 sgp->sg_cterm_bg, NULL, "ctermbg"); | |
9214 | |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
9215 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
7 | 9216 didh = highlight_list_arg(id, didh, LIST_ATTR, |
9217 sgp->sg_gui, NULL, "gui"); | |
9218 didh = highlight_list_arg(id, didh, LIST_STRING, | |
9219 0, sgp->sg_gui_fg_name, "guifg"); | |
9220 didh = highlight_list_arg(id, didh, LIST_STRING, | |
9221 0, sgp->sg_gui_bg_name, "guibg"); | |
9222 didh = highlight_list_arg(id, didh, LIST_STRING, | |
301 | 9223 0, sgp->sg_gui_sp_name, "guisp"); |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
9224 #endif |
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
9225 #ifdef FEAT_GUI |
301 | 9226 didh = highlight_list_arg(id, didh, LIST_STRING, |
7 | 9227 0, sgp->sg_font_name, "font"); |
9228 #endif | |
9229 | |
448 | 9230 if (sgp->sg_link && !got_int) |
7 | 9231 { |
9232 (void)syn_list_header(didh, 9999, id); | |
448 | 9233 didh = TRUE; |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
9234 msg_puts_attr((char_u *)"links to", HL_ATTR(HLF_D)); |
7 | 9235 msg_putchar(' '); |
9236 msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name); | |
9237 } | |
448 | 9238 |
694 | 9239 if (!didh) |
9240 highlight_list_arg(id, didh, LIST_STRING, 0, (char_u *)"cleared", ""); | |
448 | 9241 #ifdef FEAT_EVAL |
694 | 9242 if (p_verbose > 0) |
448 | 9243 last_set_msg(sgp->sg_scriptID); |
9244 #endif | |
7 | 9245 } |
9246 | |
9247 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9248 highlight_list_arg( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9249 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9250 int didh, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9251 int type, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9252 int iarg, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9253 char_u *sarg, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9254 char *name) |
7 | 9255 { |
9256 char_u buf[100]; | |
9257 char_u *ts; | |
9258 int i; | |
9259 | |
448 | 9260 if (got_int) |
9261 return FALSE; | |
7 | 9262 if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0)) |
9263 { | |
9264 ts = buf; | |
9265 if (type == LIST_INT) | |
9266 sprintf((char *)buf, "%d", iarg - 1); | |
9267 else if (type == LIST_STRING) | |
9268 ts = sarg; | |
9269 else /* type == LIST_ATTR */ | |
9270 { | |
9271 buf[0] = NUL; | |
9272 for (i = 0; hl_attr_table[i] != 0; ++i) | |
9273 { | |
9274 if (iarg & hl_attr_table[i]) | |
9275 { | |
9276 if (buf[0] != NUL) | |
2768 | 9277 vim_strcat(buf, (char_u *)",", 100); |
9278 vim_strcat(buf, (char_u *)hl_name_table[i], 100); | |
7 | 9279 iarg &= ~hl_attr_table[i]; /* don't want "inverse" */ |
9280 } | |
9281 } | |
9282 } | |
9283 | |
9284 (void)syn_list_header(didh, | |
9285 (int)(vim_strsize(ts) + STRLEN(name) + 1), id); | |
9286 didh = TRUE; | |
448 | 9287 if (!got_int) |
9288 { | |
694 | 9289 if (*name != NUL) |
9290 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
9291 MSG_PUTS_ATTR(name, HL_ATTR(HLF_D)); |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
9292 MSG_PUTS_ATTR("=", HL_ATTR(HLF_D)); |
694 | 9293 } |
448 | 9294 msg_outtrans(ts); |
9295 } | |
7 | 9296 } |
9297 return didh; | |
9298 } | |
9299 | |
9300 #if (((defined(FEAT_EVAL) || defined(FEAT_PRINTER))) && defined(FEAT_SYN_HL)) || defined(PROTO) | |
9301 /* | |
9302 * Return "1" if highlight group "id" has attribute "flag". | |
9303 * Return NULL otherwise. | |
9304 */ | |
9305 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9306 highlight_has_attr( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9307 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9308 int flag, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9309 int modec) /* 'g' for GUI, 'c' for cterm, 't' for term */ |
7 | 9310 { |
9311 int attr; | |
9312 | |
9313 if (id <= 0 || id > highlight_ga.ga_len) | |
9314 return NULL; | |
9315 | |
2318
9cf111138fb9
Allow synIDattr() getting GUI attributes when build without GUI.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
9316 #if defined(FEAT_GUI) || defined(FEAT_EVAL) |
7 | 9317 if (modec == 'g') |
9318 attr = HL_TABLE()[id - 1].sg_gui; | |
9319 else | |
9320 #endif | |
9321 if (modec == 'c') | |
9322 attr = HL_TABLE()[id - 1].sg_cterm; | |
9323 else | |
9324 attr = HL_TABLE()[id - 1].sg_term; | |
9325 | |
9326 if (attr & flag) | |
9327 return (char_u *)"1"; | |
9328 return NULL; | |
9329 } | |
9330 #endif | |
9331 | |
9332 #if (defined(FEAT_SYN_HL) && defined(FEAT_EVAL)) || defined(PROTO) | |
9333 /* | |
9334 * Return color name of highlight group "id". | |
9335 */ | |
9336 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9337 highlight_color( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9338 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9339 char_u *what, /* "font", "fg", "bg", "sp", "fg#", "bg#" or "sp#" */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9340 int modec) /* 'g' for GUI, 'c' for cterm, 't' for term */ |
7 | 9341 { |
9342 static char_u name[20]; | |
9343 int n; | |
205 | 9344 int fg = FALSE; |
9345 int sp = FALSE; | |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9346 int font = FALSE; |
7 | 9347 |
9348 if (id <= 0 || id > highlight_ga.ga_len) | |
9349 return NULL; | |
9350 | |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9351 if (TOLOWER_ASC(what[0]) == 'f' && TOLOWER_ASC(what[1]) == 'g') |
7 | 9352 fg = TRUE; |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9353 else if (TOLOWER_ASC(what[0]) == 'f' && TOLOWER_ASC(what[1]) == 'o' |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
9354 && TOLOWER_ASC(what[2]) == 'n' && TOLOWER_ASC(what[3]) == 't') |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9355 font = TRUE; |
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9356 else if (TOLOWER_ASC(what[0]) == 's' && TOLOWER_ASC(what[1]) == 'p') |
205 | 9357 sp = TRUE; |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9358 else if (!(TOLOWER_ASC(what[0]) == 'b' && TOLOWER_ASC(what[1]) == 'g')) |
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9359 return NULL; |
7 | 9360 if (modec == 'g') |
9361 { | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9362 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9363 # ifdef FEAT_GUI |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9364 /* return font name */ |
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9365 if (font) |
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9366 return HL_TABLE()[id - 1].sg_font_name; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9367 # endif |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9368 |
7 | 9369 /* return #RRGGBB form (only possible when GUI is running) */ |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9370 if ((USE_24BIT) && what[2] == '#') |
7 | 9371 { |
9372 guicolor_T color; | |
9373 long_u rgb; | |
9374 static char_u buf[10]; | |
9375 | |
9376 if (fg) | |
9377 color = HL_TABLE()[id - 1].sg_gui_fg; | |
205 | 9378 else if (sp) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9379 # ifdef FEAT_GUI |
205 | 9380 color = HL_TABLE()[id - 1].sg_gui_sp; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9381 # else |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9382 color = INVALCOLOR; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9383 # endif |
7 | 9384 else |
9385 color = HL_TABLE()[id - 1].sg_gui_bg; | |
9386 if (color == INVALCOLOR) | |
9387 return NULL; | |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
9388 rgb = (long_u)GUI_MCH_GET_RGB(color); |
7 | 9389 sprintf((char *)buf, "#%02x%02x%02x", |
9390 (unsigned)(rgb >> 16), | |
9391 (unsigned)(rgb >> 8) & 255, | |
9392 (unsigned)rgb & 255); | |
9393 return buf; | |
9394 } | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9395 # endif |
7 | 9396 if (fg) |
9397 return (HL_TABLE()[id - 1].sg_gui_fg_name); | |
205 | 9398 if (sp) |
9399 return (HL_TABLE()[id - 1].sg_gui_sp_name); | |
7 | 9400 return (HL_TABLE()[id - 1].sg_gui_bg_name); |
9401 } | |
2106
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9402 if (font || sp) |
15674e198164
updated for version 7.2.389
Bram Moolenaar <bram@zimbu.org>
parents:
2100
diff
changeset
|
9403 return NULL; |
7 | 9404 if (modec == 'c') |
9405 { | |
9406 if (fg) | |
9407 n = HL_TABLE()[id - 1].sg_cterm_fg - 1; | |
9408 else | |
9409 n = HL_TABLE()[id - 1].sg_cterm_bg - 1; | |
8514
260d01c1cd17
commit https://github.com/vim/vim/commit/385111bd86e0b38667879c3e89506ca1ae98e1df
Christian Brabandt <cb@256bit.org>
parents:
8362
diff
changeset
|
9410 if (n < 0) |
260d01c1cd17
commit https://github.com/vim/vim/commit/385111bd86e0b38667879c3e89506ca1ae98e1df
Christian Brabandt <cb@256bit.org>
parents:
8362
diff
changeset
|
9411 return NULL; |
7 | 9412 sprintf((char *)name, "%d", n); |
9413 return name; | |
9414 } | |
9415 /* term doesn't have color */ | |
9416 return NULL; | |
9417 } | |
9418 #endif | |
9419 | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9420 #if (defined(FEAT_SYN_HL) \ |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9421 && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)) \ |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9422 && defined(FEAT_PRINTER)) || defined(PROTO) |
7 | 9423 /* |
9424 * Return color name of highlight group "id" as RGB value. | |
9425 */ | |
9426 long_u | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9427 highlight_gui_color_rgb( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9428 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9429 int fg) /* TRUE = fg, FALSE = bg */ |
7 | 9430 { |
9431 guicolor_T color; | |
9432 | |
9433 if (id <= 0 || id > highlight_ga.ga_len) | |
9434 return 0L; | |
9435 | |
9436 if (fg) | |
9437 color = HL_TABLE()[id - 1].sg_gui_fg; | |
9438 else | |
9439 color = HL_TABLE()[id - 1].sg_gui_bg; | |
9440 | |
9441 if (color == INVALCOLOR) | |
9442 return 0L; | |
9443 | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9444 return GUI_MCH_GET_RGB(color); |
7 | 9445 } |
9446 #endif | |
9447 | |
9448 /* | |
9449 * Output the syntax list header. | |
9450 * Return TRUE when started a new line. | |
9451 */ | |
9452 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9453 syn_list_header( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9454 int did_header, /* did header already */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9455 int outlen, /* length of string that comes */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9456 int id) /* highlight group id */ |
7 | 9457 { |
9458 int endcol = 19; | |
9459 int newline = TRUE; | |
9460 | |
9461 if (!did_header) | |
9462 { | |
9463 msg_putchar('\n'); | |
448 | 9464 if (got_int) |
9465 return TRUE; | |
7 | 9466 msg_outtrans(HL_TABLE()[id - 1].sg_name); |
9467 endcol = 15; | |
9468 } | |
9469 else if (msg_col + outlen + 1 >= Columns) | |
448 | 9470 { |
7 | 9471 msg_putchar('\n'); |
448 | 9472 if (got_int) |
9473 return TRUE; | |
9474 } | |
7 | 9475 else |
9476 { | |
9477 if (msg_col >= endcol) /* wrap around is like starting a new line */ | |
9478 newline = FALSE; | |
9479 } | |
9480 | |
9481 if (msg_col >= endcol) /* output at least one space */ | |
9482 endcol = msg_col + 1; | |
9483 if (Columns <= endcol) /* avoid hang for tiny window */ | |
9484 endcol = Columns - 1; | |
9485 | |
9486 msg_advance(endcol); | |
9487 | |
9488 /* Show "xxx" with the attributes. */ | |
9489 if (!did_header) | |
9490 { | |
9491 msg_puts_attr((char_u *)"xxx", syn_id2attr(id)); | |
9492 msg_putchar(' '); | |
9493 } | |
9494 | |
9495 return newline; | |
9496 } | |
9497 | |
9498 /* | |
9499 * Set the attribute numbers for a highlight group. | |
9500 * Called after one of the attributes has changed. | |
9501 */ | |
9502 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9503 set_hl_attr( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9504 int idx) /* index in array */ |
7 | 9505 { |
9506 attrentry_T at_en; | |
9507 struct hl_group *sgp = HL_TABLE() + idx; | |
9508 | |
9509 /* The "Normal" group doesn't need an attribute number */ | |
9510 if (sgp->sg_name_u != NULL && STRCMP(sgp->sg_name_u, "NORMAL") == 0) | |
9511 return; | |
9512 | |
9513 #ifdef FEAT_GUI | |
9514 /* | |
9515 * For the GUI mode: If there are other than "normal" highlighting | |
9516 * attributes, need to allocate an attr number. | |
9517 */ | |
9518 if (sgp->sg_gui_fg == INVALCOLOR | |
9519 && sgp->sg_gui_bg == INVALCOLOR | |
205 | 9520 && sgp->sg_gui_sp == INVALCOLOR |
7 | 9521 && sgp->sg_font == NOFONT |
9522 # ifdef FEAT_XFONTSET | |
9523 && sgp->sg_fontset == NOFONTSET | |
9524 # endif | |
9525 ) | |
9526 { | |
9527 sgp->sg_gui_attr = sgp->sg_gui; | |
9528 } | |
9529 else | |
9530 { | |
9531 at_en.ae_attr = sgp->sg_gui; | |
9532 at_en.ae_u.gui.fg_color = sgp->sg_gui_fg; | |
9533 at_en.ae_u.gui.bg_color = sgp->sg_gui_bg; | |
205 | 9534 at_en.ae_u.gui.sp_color = sgp->sg_gui_sp; |
7 | 9535 at_en.ae_u.gui.font = sgp->sg_font; |
9536 # ifdef FEAT_XFONTSET | |
9537 at_en.ae_u.gui.fontset = sgp->sg_fontset; | |
9538 # endif | |
9539 sgp->sg_gui_attr = get_attr_entry(&gui_attr_table, &at_en); | |
9540 } | |
9541 #endif | |
9542 /* | |
9543 * For the term mode: If there are other than "normal" highlighting | |
9544 * attributes, need to allocate an attr number. | |
9545 */ | |
9546 if (sgp->sg_start == NULL && sgp->sg_stop == NULL) | |
9547 sgp->sg_term_attr = sgp->sg_term; | |
9548 else | |
9549 { | |
9550 at_en.ae_attr = sgp->sg_term; | |
9551 at_en.ae_u.term.start = sgp->sg_start; | |
9552 at_en.ae_u.term.stop = sgp->sg_stop; | |
9553 sgp->sg_term_attr = get_attr_entry(&term_attr_table, &at_en); | |
9554 } | |
9555 | |
9556 /* | |
9557 * For the color term mode: If there are other than "normal" | |
9558 * highlighting attributes, need to allocate an attr number. | |
9559 */ | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9560 if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9561 # ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9562 && sgp->sg_gui_fg == INVALCOLOR |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9563 && sgp->sg_gui_bg == INVALCOLOR |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9564 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9565 ) |
7 | 9566 sgp->sg_cterm_attr = sgp->sg_cterm; |
9567 else | |
9568 { | |
9569 at_en.ae_attr = sgp->sg_cterm; | |
9570 at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; | |
9571 at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9572 # ifdef FEAT_TERMGUICOLORS |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9573 # ifdef WIN3264 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9574 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9575 int id; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9576 guicolor_T fg, bg; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9577 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9578 id = syn_name2id((char_u *)"Normal"); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9579 if (id > 0) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9580 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9581 syn_id2colors(id, &fg, &bg); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9582 if (sgp->sg_gui_fg == INVALCOLOR) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9583 sgp->sg_gui_fg = fg; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9584 if (sgp->sg_gui_bg == INVALCOLOR) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9585 sgp->sg_gui_bg = bg; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9586 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9587 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9588 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
9589 # endif |
9054
f129fd3ebd98
commit https://github.com/vim/vim/commit/187147aedd588070d0676664d5076d046644094e
Christian Brabandt <cb@256bit.org>
parents:
9029
diff
changeset
|
9590 at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg); |
f129fd3ebd98
commit https://github.com/vim/vim/commit/187147aedd588070d0676664d5076d046644094e
Christian Brabandt <cb@256bit.org>
parents:
9029
diff
changeset
|
9591 at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9592 # endif |
7 | 9593 sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en); |
9594 } | |
9595 } | |
9596 | |
9597 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
9598 * Lookup a highlight group name and return its ID. |
7 | 9599 * If it is not found, 0 is returned. |
9600 */ | |
9601 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9602 syn_name2id(char_u *name) |
7 | 9603 { |
9604 int i; | |
9605 char_u name_u[200]; | |
9606 | |
9607 /* Avoid using stricmp() too much, it's slow on some systems */ | |
9608 /* Avoid alloc()/free(), these are slow too. ID names over 200 chars | |
9609 * don't deserve to be found! */ | |
419 | 9610 vim_strncpy(name_u, name, 199); |
7 | 9611 vim_strup(name_u); |
9612 for (i = highlight_ga.ga_len; --i >= 0; ) | |
9613 if (HL_TABLE()[i].sg_name_u != NULL | |
9614 && STRCMP(name_u, HL_TABLE()[i].sg_name_u) == 0) | |
9615 break; | |
9616 return i + 1; | |
9617 } | |
9618 | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9619 /* |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9620 * Lookup a highlight group name and return its attributes. |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9621 * Return zero if not found. |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9622 */ |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9623 int |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9624 syn_name2attr(char_u *name) |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9625 { |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9626 int id = syn_name2id(name); |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9627 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9628 if (id != 0) |
12511
b85c981b3a8e
patch 8.0.1134: superfluous call to syn_get_final_id()
Christian Brabandt <cb@256bit.org>
parents:
12510
diff
changeset
|
9629 return syn_id2attr(id); |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9630 return 0; |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9631 } |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
9632 |
7 | 9633 #if defined(FEAT_EVAL) || defined(PROTO) |
9634 /* | |
9635 * Return TRUE if highlight group "name" exists. | |
9636 */ | |
9637 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9638 highlight_exists(char_u *name) |
7 | 9639 { |
9640 return (syn_name2id(name) > 0); | |
9641 } | |
819 | 9642 |
9643 # if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) | |
9644 /* | |
9645 * Return the name of highlight group "id". | |
9646 * When not a valid ID return an empty string. | |
9647 */ | |
9648 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9649 syn_id2name(int id) |
819 | 9650 { |
1326 | 9651 if (id <= 0 || id > highlight_ga.ga_len) |
819 | 9652 return (char_u *)""; |
9653 return HL_TABLE()[id - 1].sg_name; | |
9654 } | |
9655 # endif | |
7 | 9656 #endif |
9657 | |
9658 /* | |
9659 * Like syn_name2id(), but take a pointer + length argument. | |
9660 */ | |
9661 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9662 syn_namen2id(char_u *linep, int len) |
7 | 9663 { |
9664 char_u *name; | |
9665 int id = 0; | |
9666 | |
9667 name = vim_strnsave(linep, len); | |
9668 if (name != NULL) | |
9669 { | |
9670 id = syn_name2id(name); | |
9671 vim_free(name); | |
9672 } | |
9673 return id; | |
9674 } | |
9675 | |
9676 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
9677 * Find highlight group name in the table and return its ID. |
7 | 9678 * The argument is a pointer to the name and the length of the name. |
9679 * If it doesn't exist yet, a new entry is created. | |
9680 * Return 0 for failure. | |
9681 */ | |
9682 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9683 syn_check_group(char_u *pp, int len) |
7 | 9684 { |
9685 int id; | |
9686 char_u *name; | |
9687 | |
9688 name = vim_strnsave(pp, len); | |
9689 if (name == NULL) | |
9690 return 0; | |
9691 | |
9692 id = syn_name2id(name); | |
9693 if (id == 0) /* doesn't exist yet */ | |
9694 id = syn_add_group(name); | |
9695 else | |
9696 vim_free(name); | |
9697 return id; | |
9698 } | |
9699 | |
9700 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
9701 * Add new highlight group and return its ID. |
7 | 9702 * "name" must be an allocated string, it will be consumed. |
9703 * Return 0 for failure. | |
9704 */ | |
9705 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9706 syn_add_group(char_u *name) |
7 | 9707 { |
9708 char_u *p; | |
9709 | |
9710 /* Check that the name is ASCII letters, digits and underscore. */ | |
9711 for (p = name; *p != NUL; ++p) | |
9712 { | |
9713 if (!vim_isprintc(*p)) | |
9714 { | |
9715 EMSG(_("E669: Unprintable character in group name")); | |
2020 | 9716 vim_free(name); |
7 | 9717 return 0; |
9718 } | |
9719 else if (!ASCII_ISALNUM(*p) && *p != '_') | |
9720 { | |
9721 /* This is an error, but since there previously was no check only | |
9722 * give a warning. */ | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
9723 msg_source(HL_ATTR(HLF_W)); |
7 | 9724 MSG(_("W18: Invalid character in group name")); |
9725 break; | |
9726 } | |
9727 } | |
9728 | |
9729 /* | |
9730 * First call for this growarray: init growing array. | |
9731 */ | |
9732 if (highlight_ga.ga_data == NULL) | |
9733 { | |
9734 highlight_ga.ga_itemsize = sizeof(struct hl_group); | |
9735 highlight_ga.ga_growsize = 10; | |
9736 } | |
9737 | |
2756 | 9738 if (highlight_ga.ga_len >= MAX_HL_ID) |
9739 { | |
9740 EMSG(_("E849: Too many highlight and syntax groups")); | |
2743 | 9741 vim_free(name); |
9742 return 0; | |
9743 } | |
9744 | |
7 | 9745 /* |
9746 * Make room for at least one other syntax_highlight entry. | |
9747 */ | |
9748 if (ga_grow(&highlight_ga, 1) == FAIL) | |
9749 { | |
9750 vim_free(name); | |
9751 return 0; | |
9752 } | |
9753 | |
9754 vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group)); | |
9755 HL_TABLE()[highlight_ga.ga_len].sg_name = name; | |
9756 HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9757 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
7 | 9758 HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; |
9759 HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9760 # ifdef FEAT_GUI |
205 | 9761 HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9762 # endif |
7 | 9763 #endif |
9764 ++highlight_ga.ga_len; | |
9765 | |
9766 return highlight_ga.ga_len; /* ID is index plus one */ | |
9767 } | |
9768 | |
9769 /* | |
9770 * When, just after calling syn_add_group(), an error is discovered, this | |
9771 * function deletes the new name. | |
9772 */ | |
9773 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9774 syn_unadd_group(void) |
7 | 9775 { |
9776 --highlight_ga.ga_len; | |
9777 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name); | |
9778 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name_u); | |
9779 } | |
9780 | |
9781 /* | |
9782 * Translate a group ID to highlight attributes. | |
9783 */ | |
9784 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9785 syn_id2attr(int hl_id) |
7 | 9786 { |
9787 int attr; | |
9788 struct hl_group *sgp; | |
9789 | |
9790 hl_id = syn_get_final_id(hl_id); | |
9791 sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ | |
9792 | |
9793 #ifdef FEAT_GUI | |
9794 /* | |
9795 * Only use GUI attr when the GUI is being used. | |
9796 */ | |
9797 if (gui.in_use) | |
9798 attr = sgp->sg_gui_attr; | |
9799 else | |
9800 #endif | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9801 if (IS_CTERM) |
7 | 9802 attr = sgp->sg_cterm_attr; |
9803 else | |
9804 attr = sgp->sg_term_attr; | |
9805 | |
9806 return attr; | |
9807 } | |
9808 | |
12445
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9809 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
7 | 9810 /* |
9811 * Get the GUI colors and attributes for a group ID. | |
9812 * NOTE: the colors will be INVALCOLOR when not set, the color otherwise. | |
9813 */ | |
9814 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9815 syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp) |
7 | 9816 { |
9817 struct hl_group *sgp; | |
9818 | |
9819 hl_id = syn_get_final_id(hl_id); | |
9820 sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ | |
9821 | |
9822 *fgp = sgp->sg_gui_fg; | |
9823 *bgp = sgp->sg_gui_bg; | |
9824 return sgp->sg_gui; | |
9825 } | |
9826 #endif | |
9827 | |
12562
1c049248e9ca
patch 8.0.1159: typo in #ifdef
Christian Brabandt <cb@256bit.org>
parents:
12537
diff
changeset
|
9828 #if defined(FEAT_TERMINAL) || defined(PROTO) |
12445
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9829 void |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9830 syn_id2cterm_bg(int hl_id, int *fgp, int *bgp) |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9831 { |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9832 struct hl_group *sgp; |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9833 |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9834 hl_id = syn_get_final_id(hl_id); |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9835 sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9836 *fgp = sgp->sg_cterm_fg - 1; |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9837 *bgp = sgp->sg_cterm_bg - 1; |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9838 } |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9839 #endif |
65de672be458
patch 8.0.1102: terminal window does not use Normal colors
Christian Brabandt <cb@256bit.org>
parents:
12417
diff
changeset
|
9840 |
7 | 9841 /* |
9842 * Translate a group ID to the final group ID (following links). | |
9843 */ | |
9844 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9845 syn_get_final_id(int hl_id) |
7 | 9846 { |
9847 int count; | |
9848 struct hl_group *sgp; | |
9849 | |
9850 if (hl_id > highlight_ga.ga_len || hl_id < 1) | |
9851 return 0; /* Can be called from eval!! */ | |
9852 | |
9853 /* | |
9854 * Follow links until there is no more. | |
9855 * Look out for loops! Break after 100 links. | |
9856 */ | |
9857 for (count = 100; --count >= 0; ) | |
9858 { | |
9859 sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ | |
9860 if (sgp->sg_link == 0 || sgp->sg_link > highlight_ga.ga_len) | |
9861 break; | |
9862 hl_id = sgp->sg_link; | |
9863 } | |
9864 | |
9865 return hl_id; | |
9866 } | |
9867 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9868 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
7 | 9869 /* |
9870 * Call this function just after the GUI has started. | |
9871 * It finds the font and color handles for the highlighting groups. | |
9872 */ | |
9873 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9874 highlight_gui_started(void) |
7 | 9875 { |
9876 int idx; | |
9877 | |
9878 /* First get the colors from the "Normal" and "Menu" group, if set */ | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9879 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9880 # ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9881 if (USE_24BIT) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9882 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9883 set_normal_colors(); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9884 # endif |
7 | 9885 |
9886 for (idx = 0; idx < highlight_ga.ga_len; ++idx) | |
9887 gui_do_one_color(idx, FALSE, FALSE); | |
9888 | |
9889 highlight_changed(); | |
9890 } | |
9891 | |
9892 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9893 gui_do_one_color( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
9894 int idx, |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
9895 int do_menu UNUSED, /* TRUE: might set the menu font */ |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
9896 int do_tooltip UNUSED) /* TRUE: might set the tooltip font */ |
7 | 9897 { |
9898 int didit = FALSE; | |
9899 | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9900 # ifdef FEAT_GUI |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
9901 # ifdef FEAT_TERMGUICOLORS |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9902 if (gui.in_use) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9903 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9904 if (HL_TABLE()[idx].sg_font_name != NULL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9905 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9906 hl_do_font(idx, HL_TABLE()[idx].sg_font_name, FALSE, do_menu, |
3881 | 9907 do_tooltip, TRUE); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9908 didit = TRUE; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9909 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9910 # endif |
7 | 9911 if (HL_TABLE()[idx].sg_gui_fg_name != NULL) |
9912 { | |
9913 HL_TABLE()[idx].sg_gui_fg = | |
9914 color_name2handle(HL_TABLE()[idx].sg_gui_fg_name); | |
9915 didit = TRUE; | |
9916 } | |
9917 if (HL_TABLE()[idx].sg_gui_bg_name != NULL) | |
9918 { | |
9919 HL_TABLE()[idx].sg_gui_bg = | |
9920 color_name2handle(HL_TABLE()[idx].sg_gui_bg_name); | |
9921 didit = TRUE; | |
9922 } | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9923 # ifdef FEAT_GUI |
205 | 9924 if (HL_TABLE()[idx].sg_gui_sp_name != NULL) |
9925 { | |
9926 HL_TABLE()[idx].sg_gui_sp = | |
9927 color_name2handle(HL_TABLE()[idx].sg_gui_sp_name); | |
9928 didit = TRUE; | |
9929 } | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8815
diff
changeset
|
9930 # endif |
7 | 9931 if (didit) /* need to get a new attr number */ |
9932 set_hl_attr(idx); | |
9933 } | |
9934 #endif | |
9935 | |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9936 #if defined(USER_HIGHLIGHT) && defined(FEAT_STL_OPT) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9937 /* |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
9938 * Apply difference between User[1-9] and HLF_S to HLF_SNC, HLF_ST or HLF_STNC. |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9939 */ |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9940 static void |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9941 combine_stl_hlt( |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9942 int id, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9943 int id_S, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9944 int id_alt, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9945 int hlcnt, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9946 int i, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9947 int hlf, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9948 int *table) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9949 { |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9950 struct hl_group *hlt = HL_TABLE(); |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9951 |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9952 if (id_alt == 0) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9953 { |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9954 vim_memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group)); |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9955 hlt[hlcnt + i].sg_term = highlight_attr[hlf]; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9956 hlt[hlcnt + i].sg_cterm = highlight_attr[hlf]; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9957 # if defined(FEAT_GUI) || defined(FEAT_EVAL) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9958 hlt[hlcnt + i].sg_gui = highlight_attr[hlf]; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9959 # endif |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9960 } |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9961 else |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9962 mch_memmove(&hlt[hlcnt + i], |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9963 &hlt[id_alt - 1], |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9964 sizeof(struct hl_group)); |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9965 hlt[hlcnt + i].sg_link = 0; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9966 |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9967 hlt[hlcnt + i].sg_term ^= |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9968 hlt[id - 1].sg_term ^ hlt[id_S - 1].sg_term; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9969 if (hlt[id - 1].sg_start != hlt[id_S - 1].sg_start) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9970 hlt[hlcnt + i].sg_start = hlt[id - 1].sg_start; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9971 if (hlt[id - 1].sg_stop != hlt[id_S - 1].sg_stop) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9972 hlt[hlcnt + i].sg_stop = hlt[id - 1].sg_stop; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9973 hlt[hlcnt + i].sg_cterm ^= |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9974 hlt[id - 1].sg_cterm ^ hlt[id_S - 1].sg_cterm; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9975 if (hlt[id - 1].sg_cterm_fg != hlt[id_S - 1].sg_cterm_fg) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9976 hlt[hlcnt + i].sg_cterm_fg = hlt[id - 1].sg_cterm_fg; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9977 if (hlt[id - 1].sg_cterm_bg != hlt[id_S - 1].sg_cterm_bg) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9978 hlt[hlcnt + i].sg_cterm_bg = hlt[id - 1].sg_cterm_bg; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9979 # if defined(FEAT_GUI) || defined(FEAT_EVAL) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9980 hlt[hlcnt + i].sg_gui ^= |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9981 hlt[id - 1].sg_gui ^ hlt[id_S - 1].sg_gui; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9982 # endif |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9983 # ifdef FEAT_GUI |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9984 if (hlt[id - 1].sg_gui_fg != hlt[id_S - 1].sg_gui_fg) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9985 hlt[hlcnt + i].sg_gui_fg = hlt[id - 1].sg_gui_fg; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9986 if (hlt[id - 1].sg_gui_bg != hlt[id_S - 1].sg_gui_bg) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9987 hlt[hlcnt + i].sg_gui_bg = hlt[id - 1].sg_gui_bg; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9988 if (hlt[id - 1].sg_gui_sp != hlt[id_S - 1].sg_gui_sp) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9989 hlt[hlcnt + i].sg_gui_sp = hlt[id - 1].sg_gui_sp; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9990 if (hlt[id - 1].sg_font != hlt[id_S - 1].sg_font) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9991 hlt[hlcnt + i].sg_font = hlt[id - 1].sg_font; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9992 # ifdef FEAT_XFONTSET |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9993 if (hlt[id - 1].sg_fontset != hlt[id_S - 1].sg_fontset) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9994 hlt[hlcnt + i].sg_fontset = hlt[id - 1].sg_fontset; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9995 # endif |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9996 # endif |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9997 highlight_ga.ga_len = hlcnt + i + 1; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9998 set_hl_attr(hlcnt + i); /* At long last we can apply */ |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
9999 table[i] = syn_id2attr(hlcnt + i + 1); |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10000 } |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10001 #endif |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10002 |
7 | 10003 /* |
10004 * Translate the 'highlight' option into attributes in highlight_attr[] and | |
10005 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of | |
10006 * corresponding highlights to use on top of HLF_SNC is computed. | |
10007 * Called only when the 'highlight' option has been changed and upon first | |
10008 * screen redraw after any :highlight command. | |
10009 * Return FAIL when an invalid flag is found in 'highlight'. OK otherwise. | |
10010 */ | |
10011 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
10012 highlight_changed(void) |
7 | 10013 { |
10014 int hlf; | |
10015 int i; | |
10016 char_u *p; | |
10017 int attr; | |
10018 char_u *end; | |
10019 int id; | |
10020 #ifdef USER_HIGHLIGHT | |
10021 char_u userhl[10]; | |
10022 # ifdef FEAT_STL_OPT | |
10023 int id_SNC = -1; | |
10024 int id_S = -1; | |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10025 # ifdef FEAT_TERMINAL |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10026 int id_ST = -1; |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10027 int id_STNC = -1; |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10028 # endif |
7 | 10029 int hlcnt; |
10030 # endif | |
10031 #endif | |
10032 static int hl_flags[HLF_COUNT] = HL_FLAGS; | |
10033 | |
10034 need_highlight_changed = FALSE; | |
10035 | |
10036 /* | |
10037 * Clear all attributes. | |
10038 */ | |
10039 for (hlf = 0; hlf < (int)HLF_COUNT; ++hlf) | |
10040 highlight_attr[hlf] = 0; | |
10041 | |
10042 /* | |
10043 * First set all attributes to their default value. | |
10044 * Then use the attributes from the 'highlight' option. | |
10045 */ | |
10046 for (i = 0; i < 2; ++i) | |
10047 { | |
10048 if (i) | |
10049 p = p_hl; | |
10050 else | |
10051 p = get_highlight_default(); | |
10052 if (p == NULL) /* just in case */ | |
10053 continue; | |
10054 | |
10055 while (*p) | |
10056 { | |
10057 for (hlf = 0; hlf < (int)HLF_COUNT; ++hlf) | |
10058 if (hl_flags[hlf] == *p) | |
10059 break; | |
10060 ++p; | |
10061 if (hlf == (int)HLF_COUNT || *p == NUL) | |
10062 return FAIL; | |
10063 | |
10064 /* | |
10065 * Allow several hl_flags to be combined, like "bu" for | |
10066 * bold-underlined. | |
10067 */ | |
10068 attr = 0; | |
10069 for ( ; *p && *p != ','; ++p) /* parse upto comma */ | |
10070 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
10071 if (VIM_ISWHITE(*p)) /* ignore white space */ |
7 | 10072 continue; |
10073 | |
10074 if (attr > HL_ALL) /* Combination with ':' is not allowed. */ | |
10075 return FAIL; | |
10076 | |
10077 switch (*p) | |
10078 { | |
10079 case 'b': attr |= HL_BOLD; | |
10080 break; | |
10081 case 'i': attr |= HL_ITALIC; | |
10082 break; | |
10083 case '-': | |
10084 case 'n': /* no highlighting */ | |
10085 break; | |
10086 case 'r': attr |= HL_INVERSE; | |
10087 break; | |
10088 case 's': attr |= HL_STANDOUT; | |
10089 break; | |
10090 case 'u': attr |= HL_UNDERLINE; | |
10091 break; | |
205 | 10092 case 'c': attr |= HL_UNDERCURL; |
10093 break; | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12180
diff
changeset
|
10094 case 't': attr |= HL_STRIKETHROUGH; |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12180
diff
changeset
|
10095 break; |
7 | 10096 case ':': ++p; /* highlight group name */ |
10097 if (attr || *p == NUL) /* no combinations */ | |
10098 return FAIL; | |
10099 end = vim_strchr(p, ','); | |
10100 if (end == NULL) | |
10101 end = p + STRLEN(p); | |
10102 id = syn_check_group(p, (int)(end - p)); | |
10103 if (id == 0) | |
10104 return FAIL; | |
10105 attr = syn_id2attr(id); | |
10106 p = end - 1; | |
10107 #if defined(FEAT_STL_OPT) && defined(USER_HIGHLIGHT) | |
10108 if (hlf == (int)HLF_SNC) | |
10109 id_SNC = syn_get_final_id(id); | |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10110 # ifdef FEAT_TERMINAL |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10111 else if (hlf == (int)HLF_ST) |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10112 id_ST = syn_get_final_id(id); |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10113 else if (hlf == (int)HLF_STNC) |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10114 id_STNC = syn_get_final_id(id); |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10115 # endif |
7 | 10116 else if (hlf == (int)HLF_S) |
10117 id_S = syn_get_final_id(id); | |
10118 #endif | |
10119 break; | |
10120 default: return FAIL; | |
10121 } | |
10122 } | |
10123 highlight_attr[hlf] = attr; | |
10124 | |
10125 p = skip_to_option_part(p); /* skip comma and spaces */ | |
10126 } | |
10127 } | |
10128 | |
10129 #ifdef USER_HIGHLIGHT | |
10130 /* Setup the user highlights | |
10131 * | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10132 * Temporarily utilize 28 more hl entries: |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10133 * 9 for User1-User9 combined with StatusLineNC |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10134 * 9 for User1-User9 combined with StatusLineTerm |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10135 * 9 for User1-User9 combined with StatusLineTermNC |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10136 * 1 for StatusLine default |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10137 * Have to be in there simultaneously in case of table overflows in |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10138 * get_attr_entry() |
7 | 10139 */ |
10140 # ifdef FEAT_STL_OPT | |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10141 if (ga_grow(&highlight_ga, 28) == FAIL) |
7 | 10142 return FAIL; |
10143 hlcnt = highlight_ga.ga_len; | |
12180
88ca0110abd5
patch 8.0.0970: passing invalid highlight id
Christian Brabandt <cb@256bit.org>
parents:
12122
diff
changeset
|
10144 if (id_S == -1) |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10145 { |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10146 /* Make sure id_S is always valid to simplify code below. Use the last |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10147 * entry. */ |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10148 vim_memset(&HL_TABLE()[hlcnt + 27], 0, sizeof(struct hl_group)); |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10149 HL_TABLE()[hlcnt + 18].sg_term = highlight_attr[HLF_S]; |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10150 id_S = hlcnt + 19; |
7 | 10151 } |
10152 # endif | |
10153 for (i = 0; i < 9; i++) | |
10154 { | |
10155 sprintf((char *)userhl, "User%d", i + 1); | |
10156 id = syn_name2id(userhl); | |
10157 if (id == 0) | |
10158 { | |
10159 highlight_user[i] = 0; | |
10160 # ifdef FEAT_STL_OPT | |
10161 highlight_stlnc[i] = 0; | |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10162 # ifdef FEAT_TERMINAL |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10163 highlight_stlterm[i] = 0; |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10164 highlight_stltermnc[i] = 0; |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10165 # endif |
7 | 10166 # endif |
10167 } | |
10168 else | |
10169 { | |
10170 highlight_user[i] = syn_id2attr(id); | |
10171 # ifdef FEAT_STL_OPT | |
12114
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10172 combine_stl_hlt(id, id_S, id_SNC, hlcnt, i, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10173 HLF_SNC, highlight_stlnc); |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10174 # ifdef FEAT_TERMINAL |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10175 combine_stl_hlt(id, id_S, id_ST, hlcnt + 9, i, |
f306e6decaf9
patch 8.0.0937: user highlight groups not adjusted for terminal
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
10176 HLF_ST, highlight_stlterm); |
12122
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10177 combine_stl_hlt(id, id_S, id_STNC, hlcnt + 18, i, |
68c593f649d1
patch 8.0.0941: existing color schemes don't like StatusLineTerm
Christian Brabandt <cb@256bit.org>
parents:
12114
diff
changeset
|
10178 HLF_STNC, highlight_stltermnc); |
7 | 10179 # endif |
10180 # endif | |
10181 } | |
10182 } | |
10183 # ifdef FEAT_STL_OPT | |
10184 highlight_ga.ga_len = hlcnt; | |
10185 # endif | |
10186 | |
10187 #endif /* USER_HIGHLIGHT */ | |
10188 | |
10189 return OK; | |
10190 } | |
10191 | |
1322 | 10192 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
7 | 10193 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
10194 static void highlight_list(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
10195 static void highlight_list_two(int cnt, int attr); |
7 | 10196 |
10197 /* | |
10198 * Handle command line completion for :highlight command. | |
10199 */ | |
10200 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
10201 set_context_in_highlight_cmd(expand_T *xp, char_u *arg) |
7 | 10202 { |
10203 char_u *p; | |
10204 | |
10205 /* Default: expand group names */ | |
10206 xp->xp_context = EXPAND_HIGHLIGHT; | |
10207 xp->xp_pattern = arg; | |
1322 | 10208 include_link = 2; |
10209 include_default = 1; | |
7 | 10210 |
10211 /* (part of) subcommand already typed */ | |
10212 if (*arg != NUL) | |
10213 { | |
10214 p = skiptowhite(arg); | |
10215 if (*p != NUL) /* past "default" or group name */ | |
10216 { | |
1322 | 10217 include_default = 0; |
7 | 10218 if (STRNCMP("default", arg, p - arg) == 0) |
10219 { | |
10220 arg = skipwhite(p); | |
10221 xp->xp_pattern = arg; | |
10222 p = skiptowhite(arg); | |
10223 } | |
10224 if (*p != NUL) /* past group name */ | |
10225 { | |
1322 | 10226 include_link = 0; |
7 | 10227 if (arg[1] == 'i' && arg[0] == 'N') |
10228 highlight_list(); | |
10229 if (STRNCMP("link", arg, p - arg) == 0 | |
10230 || STRNCMP("clear", arg, p - arg) == 0) | |
10231 { | |
10232 xp->xp_pattern = skipwhite(p); | |
10233 p = skiptowhite(xp->xp_pattern); | |
10234 if (*p != NUL) /* past first group name */ | |
10235 { | |
10236 xp->xp_pattern = skipwhite(p); | |
10237 p = skiptowhite(xp->xp_pattern); | |
10238 } | |
10239 } | |
10240 if (*p != NUL) /* past group name(s) */ | |
10241 xp->xp_context = EXPAND_NOTHING; | |
10242 } | |
10243 } | |
10244 } | |
10245 } | |
10246 | |
10247 /* | |
10248 * List highlighting matches in a nice way. | |
10249 */ | |
10250 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
10251 highlight_list(void) |
7 | 10252 { |
10253 int i; | |
10254 | |
10255 for (i = 10; --i >= 0; ) | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
10256 highlight_list_two(i, HL_ATTR(HLF_D)); |
7 | 10257 for (i = 40; --i >= 0; ) |
10258 highlight_list_two(99, 0); | |
10259 } | |
10260 | |
10261 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
10262 highlight_list_two(int cnt, int attr) |
7 | 10263 { |
3543 | 10264 msg_puts_attr((char_u *)&("N \bI \b! \b"[cnt / 11]), attr); |
7 | 10265 msg_clr_eos(); |
10266 out_flush(); | |
10267 ui_delay(cnt == 99 ? 40L : (long)cnt * 50L, FALSE); | |
10268 } | |
10269 | |
10270 #endif /* FEAT_CMDL_COMPL */ | |
10271 | |
10272 #if defined(FEAT_CMDL_COMPL) || (defined(FEAT_SYN_HL) && defined(FEAT_EVAL)) \ | |
10273 || defined(FEAT_SIGNS) || defined(PROTO) | |
10274 /* | |
10275 * Function given to ExpandGeneric() to obtain the list of group names. | |
10276 */ | |
10277 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
10278 get_highlight_name(expand_T *xp UNUSED, int idx) |
7 | 10279 { |
11254
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10280 return get_highlight_name_ext(xp, idx, TRUE); |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10281 } |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10282 |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10283 /* |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10284 * Obtain a highlight group name. |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10285 * When "skip_cleared" is TRUE don't return a cleared entry. |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10286 */ |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10287 char_u * |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10288 get_highlight_name_ext(expand_T *xp UNUSED, int idx, int skip_cleared) |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10289 { |
10660
715836a72361
patch 8.0.0220: completion of highlight names misses a few values
Christian Brabandt <cb@256bit.org>
parents:
10648
diff
changeset
|
10290 if (idx < 0) |
715836a72361
patch 8.0.0220: completion of highlight names misses a few values
Christian Brabandt <cb@256bit.org>
parents:
10648
diff
changeset
|
10291 return NULL; |
11254
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10292 |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10293 /* Items are never removed from the table, skip the ones that were |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10294 * cleared. */ |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10295 if (skip_cleared && idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared) |
918942a3b0ef
patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents:
11189
diff
changeset
|
10296 return (char_u *)""; |
10660
715836a72361
patch 8.0.0220: completion of highlight names misses a few values
Christian Brabandt <cb@256bit.org>
parents:
10648
diff
changeset
|
10297 |
7 | 10298 #ifdef FEAT_CMDL_COMPL |
1322 | 10299 if (idx == highlight_ga.ga_len && include_none != 0) |
10300 return (char_u *)"none"; | |
10301 if (idx == highlight_ga.ga_len + include_none && include_default != 0) | |
10302 return (char_u *)"default"; | |
10303 if (idx == highlight_ga.ga_len + include_none + include_default | |
10304 && include_link != 0) | |
7 | 10305 return (char_u *)"link"; |
1322 | 10306 if (idx == highlight_ga.ga_len + include_none + include_default + 1 |
10307 && include_link != 0) | |
7 | 10308 return (char_u *)"clear"; |
10309 #endif | |
10624
5ac9d7920f11
patch 8.0.0201: completion of highlight groups includes cleared names
Christian Brabandt <cb@256bit.org>
parents:
10618
diff
changeset
|
10310 if (idx >= highlight_ga.ga_len) |
7 | 10311 return NULL; |
10312 return HL_TABLE()[idx].sg_name; | |
10313 } | |
10314 #endif | |
10315 | |
1322 | 10316 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 10317 /* |
10318 * Free all the highlight group fonts. | |
10319 * Used when quitting for systems which need it. | |
10320 */ | |
10321 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
10322 free_highlight_fonts(void) |
7 | 10323 { |
10324 int idx; | |
10325 | |
10326 for (idx = 0; idx < highlight_ga.ga_len; ++idx) | |
10327 { | |
10328 gui_mch_free_font(HL_TABLE()[idx].sg_font); | |
10329 HL_TABLE()[idx].sg_font = NOFONT; | |
10330 # ifdef FEAT_XFONTSET | |
10331 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); | |
10332 HL_TABLE()[idx].sg_fontset = NOFONTSET; | |
10333 # endif | |
10334 } | |
10335 | |
10336 gui_mch_free_font(gui.norm_font); | |
10337 # ifdef FEAT_XFONTSET | |
10338 gui_mch_free_fontset(gui.fontset); | |
10339 # endif | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2256
diff
changeset
|
10340 # ifndef FEAT_GUI_GTK |
7 | 10341 gui_mch_free_font(gui.bold_font); |
10342 gui_mch_free_font(gui.ital_font); | |
10343 gui_mch_free_font(gui.boldital_font); | |
10344 # endif | |
10345 } | |
10346 #endif | |
10347 | |
10348 /************************************** | |
10349 * End of Highlighting stuff * | |
10350 **************************************/ |