Mercurial > vim
annotate src/syntax.c @ 34745:300525584c40
runtime(sshconfig,sshdconfig): update syntax (#14351)
Commit: https://github.com/vim/vim/commit/cbb92b5ceb6a8169b6eddceec3837aac02f21e3b
Author: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Date: Mon Apr 1 05:02:31 2024 +0900
runtime(sshconfig,sshdconfig): update syntax (https://github.com/vim/vim/issues/14351)
* fix case insensitivity of Host and Hostname keys
* improve regexps
* add keywords
Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 31 Mar 2024 22:15:02 +0200 |
parents | 9e093c96dff6 |
children | 3ead9668d632 |
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 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
17 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
18 #define SYN_NAMELEN 50 // maximum length of a syntax name |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
19 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
20 // different types of offsets that are possible |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
21 #define SPO_MS_OFF 0 // match start offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
22 #define SPO_ME_OFF 1 // match end offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
23 #define SPO_HS_OFF 2 // highl. start offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
24 #define SPO_HE_OFF 3 // highl. end offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
25 #define SPO_RS_OFF 4 // region start offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
26 #define SPO_RE_OFF 5 // region end offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
27 #define SPO_LC_OFF 6 // leading context offset |
7 | 28 #define SPO_COUNT 7 |
29 | |
30 static char *(spo_name_tab[SPO_COUNT]) = | |
31 {"ms=", "me=", "hs=", "he=", "rs=", "re=", "lc="}; | |
32 | |
33 /* | |
34 * The patterns that are being searched for are stored in a syn_pattern. | |
35 * A match item consists of one pattern. | |
36 * A start/end item consists of n start patterns and m end patterns. | |
37 * A start/skip/end item consists of n start patterns, one skip pattern and m | |
38 * end patterns. | |
39 * For the latter two, the patterns are always consecutive: start-skip-end. | |
40 * | |
41 * A character offset can be given for the matched text (_m_start and _m_end) | |
42 * and for the actually highlighted text (_h_start and _h_end). | |
13333
b4e7082de11d
patch 8.0.1541: synpat_T is taking too much memory
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
43 * |
b4e7082de11d
patch 8.0.1541: synpat_T is taking too much memory
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
44 * Note that ordering of members is optimized to reduce padding. |
7 | 45 */ |
46 typedef struct syn_pattern | |
47 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
48 char sp_type; // see SPTYPE_ defines below |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
49 char sp_syncing; // this item used for syncing |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
50 short sp_syn_match_id; // highlight group ID of pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
51 short sp_off_flags; // see below |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
52 int sp_offsets[SPO_COUNT]; // offsets |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
53 int sp_flags; // see HL_ defines below |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
54 #ifdef FEAT_CONCEAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
55 int sp_cchar; // conceal substitute character |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
56 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
57 int sp_ic; // ignore-case flag for sp_prog |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
58 int sp_sync_idx; // sync item index (syncing only) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
59 int sp_line_id; // ID of last line where tried |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
60 int sp_startcol; // next match in sp_line_id line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
61 short *sp_cont_list; // cont. group IDs, if non-zero |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
62 short *sp_next_list; // next group IDs, if non-zero |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
63 struct sp_syn sp_syn; // struct passed to in_id_list() |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
64 char_u *sp_pattern; // regexp to match, pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
65 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
|
66 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
67 syn_time_T sp_time; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
68 #endif |
7 | 69 } synpat_T; |
70 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
71 // The sp_off_flags are computed like this: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
72 // offset from the start of the matched text: (1 << SPO_XX_OFF) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
73 // offset from the end of the matched text: (1 << (SPO_XX_OFF + SPO_COUNT)) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
74 // When both are present, only one is used. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
75 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
76 #define SPTYPE_MATCH 1 // match keyword with this group ID |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
77 #define SPTYPE_START 2 // match a regexp, start of item |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
78 #define SPTYPE_END 3 // match a regexp, end of item |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
79 #define SPTYPE_SKIP 4 // match a regexp, skip within item |
7 | 80 |
81 | |
82 #define SYN_ITEMS(buf) ((synpat_T *)((buf)->b_syn_patterns.ga_data)) | |
83 | |
27752
c1d1639b52dd
patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents:
27561
diff
changeset
|
84 #define NONE_IDX (-2) // value of sp_sync_idx for "NONE" |
7 | 85 |
86 /* | |
87 * Flags for b_syn_sync_flags: | |
88 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
89 #define SF_CCOMMENT 0x01 // sync on a C-style comment |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
90 #define SF_MATCH 0x02 // sync by matching a pattern |
7 | 91 |
92 #define SYN_STATE_P(ssp) ((bufstate_T *)((ssp)->ga_data)) | |
93 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
94 #define MAXKEYWLEN 80 // maximum length of a keyword |
7 | 95 |
96 /* | |
97 * The attributes of the syntax item that has been recognized. | |
98 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
99 static int current_attr = 0; // attr of current syntax word |
7 | 100 #ifdef FEAT_EVAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
101 static int current_id = 0; // ID of current char for syn_get_id() |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
102 static int current_trans_id = 0; // idem, transparency removed |
7 | 103 #endif |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
104 #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
|
105 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
|
106 static int current_seqnr = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
107 static int current_sub_char = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
108 #endif |
7 | 109 |
221 | 110 typedef struct syn_cluster_S |
7 | 111 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
112 char_u *scl_name; // syntax cluster name |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
113 char_u *scl_name_u; // uppercase of scl_name |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
114 short *scl_list; // IDs in this syntax cluster |
221 | 115 } syn_cluster_T; |
7 | 116 |
117 /* | |
118 * Methods of combining two clusters | |
119 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
120 #define CLUSTER_REPLACE 1 // replace first list with second |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
121 #define CLUSTER_ADD 2 // add second list to first |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
122 #define CLUSTER_SUBTRACT 3 // subtract second list from first |
7 | 123 |
221 | 124 #define SYN_CLSTR(buf) ((syn_cluster_T *)((buf)->b_syn_clusters.ga_data)) |
7 | 125 |
126 /* | |
127 * Syntax group IDs have different types: | |
2743 | 128 * 0 - 19999 normal syntax groups |
129 * 20000 - 20999 ALLBUT indicator (current_syn_inc_tag added) | |
130 * 21000 - 21999 TOP indicator (current_syn_inc_tag added) | |
131 * 22000 - 22999 CONTAINED indicator (current_syn_inc_tag added) | |
132 * 23000 - 32767 cluster IDs (subtract SYNID_CLUSTER for the cluster ID) | |
133 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
134 #define SYNID_ALLBUT MAX_HL_ID // syntax group ID for contains=ALLBUT |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
135 #define SYNID_TOP 21000 // syntax group ID for contains=TOP |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
136 #define SYNID_CONTAINED 22000 // syntax group ID for contains=CONTAINED |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
137 #define SYNID_CLUSTER 23000 // first syntax group ID for clusters |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
138 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
139 #define MAX_SYN_INC_TAG 999 // maximum before the above overflow |
2743 | 140 #define MAX_CLUSTER_ID (32767 - SYNID_CLUSTER) |
7 | 141 |
142 /* | |
143 * Annoying Hack(TM): ":syn include" needs this pointer to pass to | |
144 * expand_filename(). Most of the other syntax commands don't need it, so | |
145 * instead of passing it to them, we stow it here. | |
146 */ | |
147 static char_u **syn_cmdlinep; | |
148 | |
149 /* | |
150 * 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
|
151 * files from leaking into ALLBUT lists, we assign a unique ID to the |
7 | 152 * rules in each ":syn include"'d file. |
153 */ | |
154 static int current_syn_inc_tag = 0; | |
155 static int running_syn_inc_tag = 0; | |
156 | |
157 /* | |
134 | 158 * In a hashtable item "hi_key" points to "keyword" in a keyentry. |
159 * This avoids adding a pointer to the hashtable item. | |
160 * KE2HIKEY() converts a var pointer to a hashitem key pointer. | |
161 * HIKEY2KE() converts a hashitem key pointer to a var pointer. | |
162 * HI2KE() converts a hashitem pointer to a var pointer. | |
163 */ | |
164 static keyentry_T dumkey; | |
165 #define KE2HIKEY(kp) ((kp)->keyword) | |
166 #define HIKEY2KE(p) ((keyentry_T *)((p) - (dumkey.keyword - (char_u *)&dumkey))) | |
167 #define HI2KE(hi) HIKEY2KE((hi)->hi_key) | |
168 | |
169 /* | |
7 | 170 * To reduce the time spent in keepend(), remember at which level in the state |
171 * stack the first item with "keepend" is present. When "-1", there is no | |
172 * "keepend" on the stack. | |
173 */ | |
174 static int keepend_level = -1; | |
175 | |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
176 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
|
177 |
7 | 178 /* |
179 * For the current state we need to remember more than just the idx. | |
180 * When si_m_endpos.lnum is 0, the items other than si_idx are unknown. | |
181 * (The end positions have the column number of the next char) | |
182 */ | |
183 typedef struct state_item | |
184 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
185 int si_idx; // index of syntax pattern or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
186 // KEYWORD_IDX |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
187 int si_id; // highlight group ID for keywords |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
188 int si_trans_id; // idem, transparency removed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
189 int si_m_lnum; // lnum of the match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
190 int si_m_startcol; // starting column of the match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
191 lpos_T si_m_endpos; // just after end posn of the match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
192 lpos_T si_h_startpos; // start position of the highlighting |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
193 lpos_T si_h_endpos; // end position of the highlighting |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
194 lpos_T si_eoe_pos; // end position of end pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
195 int si_end_idx; // group ID for end pattern or zero |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
196 int si_ends; // if match ends before si_m_endpos |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
197 int si_attr; // attributes in this state |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
198 long si_flags; // HL_HAS_EOL flag in this state, and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
199 // HL_SKIP* for si_next_list |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
200 #ifdef FEAT_CONCEAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
201 int si_seqnr; // sequence number |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
202 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
|
203 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
204 short *si_cont_list; // list of contained groups |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
205 short *si_next_list; // nextgroup IDs after this item ends |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
206 reg_extmatch_T *si_extmatch; // \z(...\) matches from start |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
207 // pattern |
7 | 208 } stateitem_T; |
209 | |
27752
c1d1639b52dd
patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents:
27561
diff
changeset
|
210 #define KEYWORD_IDX (-1) // value of si_idx for keywords |
c1d1639b52dd
patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents:
27561
diff
changeset
|
211 #define ID_LIST_ALL ((short *)-1) // valid of si_cont_list for containing all |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
212 // but contained groups |
7 | 213 |
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
|
214 #ifdef FEAT_CONCEAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
215 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
|
216 #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
|
217 |
7 | 218 /* |
154 | 219 * Struct to reduce the number of arguments to get_syn_options(), it's used |
220 * very often. | |
221 */ | |
222 typedef struct | |
223 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
224 int flags; // flags for contained and transparent |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
225 int keyword; // TRUE for ":syn keyword" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
226 int *sync_idx; // syntax item for "grouphere" argument, NULL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
227 // if not allowed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
228 char has_cont_list; // TRUE if "cont_list" can be used |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
229 short *cont_list; // group IDs for "contains" argument |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
230 short *cont_in_list; // group IDs for "containedin" argument |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
231 short *next_list; // group IDs for "nextgroup" argument |
154 | 232 } syn_opt_arg_T; |
233 | |
234 /* | |
7 | 235 * The next possible match in the current line for any pattern is remembered, |
236 * to avoid having to try for a match in each column. | |
237 * If next_match_idx == -1, not tried (in this line) yet. | |
238 * If next_match_col == MAXCOL, no match found in this line. | |
239 * (All end positions have the column of the char after the end) | |
240 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
241 static int next_match_col; // column for start of next match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
242 static lpos_T next_match_m_endpos; // position for end of next match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
243 static lpos_T next_match_h_startpos; // pos. for highl. start of next match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
244 static lpos_T next_match_h_endpos; // pos. for highl. end of next match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
245 static int next_match_idx; // index of matched item |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
246 static long next_match_flags; // flags for next match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
247 static lpos_T next_match_eos_pos; // end of start pattn (start region) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
248 static lpos_T next_match_eoe_pos; // pos. for end of end pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
249 static int next_match_end_idx; // ID of group for end pattn or zero |
7 | 250 static reg_extmatch_T *next_match_extmatch = NULL; |
251 | |
252 /* | |
253 * A state stack is an array of integers or stateitem_T, stored in a | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
254 * garray_T. A state stack is invalid if its itemsize entry is zero. |
7 | 255 */ |
256 #define INVALID_STATE(ssp) ((ssp)->ga_itemsize == 0) | |
257 #define VALID_STATE(ssp) ((ssp)->ga_itemsize != 0) | |
258 | |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
259 #define FOR_ALL_SYNSTATES(sb, sst) \ |
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
260 for ((sst) = (sb)->b_sst_first; (sst) != NULL; (sst) = (sst)->sst_next) |
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
261 |
7 | 262 /* |
263 * The current state (within the line) of the recognition engine. | |
264 * When current_state.ga_itemsize is 0 the current state is invalid. | |
265 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
266 static win_T *syn_win; // current window for highlighting |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
267 static buf_T *syn_buf; // current buffer for highlighting |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
268 static synblock_T *syn_block; // current buffer for highlighting |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
269 static linenr_T current_lnum = 0; // lnum of current state |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
270 static colnr_T current_col = 0; // column of current state |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
271 static int current_state_stored = 0; // TRUE if stored current state |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
272 // after setting current_finished |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
273 static int current_finished = 0; // current line has been finished |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
274 static garray_T current_state // current stack of state_items |
7 | 275 = {0, 0, 0, 0, NULL}; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
276 static short *current_next_list = NULL; // when non-zero, nextgroup list |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
277 static int current_next_flags = 0; // flags for current_next_list |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
278 static int current_line_id = 0; // unique number for current line |
7 | 279 |
280 #define CUR_STATE(idx) ((stateitem_T *)(current_state.ga_data))[idx] | |
281 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
282 static void syn_sync(win_T *wp, linenr_T lnum, synstate_T *last_valid); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
283 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
|
284 static void syn_start_line(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
285 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
|
286 static void syn_stack_alloc(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
287 static int syn_stack_cleanup(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 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
|
292 static void invalidate_current_state(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
293 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
|
294 static void validate_current_state(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
295 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
|
296 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
|
297 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
|
298 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
|
299 static void check_state_ends(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
300 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
|
301 static void check_keepend(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
302 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
|
303 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
|
304 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
|
305 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
|
306 static void pop_current_state(void); |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
307 #ifdef FEAT_PROFILE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
308 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
|
309 static void syntime_clear(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
310 static void syntime_report(void); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
311 static int syn_time_on = FALSE; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
312 # define IF_SYN_TIME(p) (p) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
313 #else |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
314 # define IF_SYN_TIME(p) NULL |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
315 typedef int syn_time_T; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
316 #endif |
7 | 317 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
318 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
|
319 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
|
320 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
321 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
|
322 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
|
323 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
|
324 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
|
325 static char_u *syn_getcurline(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 static void syn_lines_msg(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
334 static void syn_match_msg(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 static void init_syn_patterns(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
346 static char_u *get_syn_pattern(char_u *arg, synpat_T *ci); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
347 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
|
348 static void syn_combine_list(short **clstr1, short **clstr2, int list_op); |
7 | 349 |
350 /* | |
351 * Start the syntax recognition for a line. This function is normally called | |
352 * from the screen updating, once for each displayed line. | |
353 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get | |
354 * it. Careful: curbuf and curwin are likely to point to another buffer and | |
355 * window. | |
356 */ | |
357 void | |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
358 syntax_start(win_T *wp, linenr_T lnum) |
7 | 359 { |
360 synstate_T *p; | |
361 synstate_T *last_valid = NULL; | |
362 synstate_T *last_min_valid = NULL; | |
1512 | 363 synstate_T *sp, *prev = NULL; |
7 | 364 linenr_T parsed_lnum; |
365 linenr_T first_stored; | |
366 int dist; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
367 static varnumber_T changedtick = 0; // remember the last change ID |
7 | 368 |
2401
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
369 #ifdef FEAT_CONCEAL |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
370 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
|
371 #endif |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
372 |
7 | 373 /* |
374 * After switching buffers, invalidate current_state. | |
26 | 375 * Also do this when a change was made, the current state may be invalid |
376 * then. | |
7 | 377 */ |
8806
8fff73f17ff1
commit https://github.com/vim/vim/commit/b681be175b6991cdc2b8ddd49b0e97e3fe2b201e
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
378 if (syn_block != wp->w_s |
8fff73f17ff1
commit https://github.com/vim/vim/commit/b681be175b6991cdc2b8ddd49b0e97e3fe2b201e
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
379 || 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
|
380 || changedtick != CHANGEDTICK(syn_buf)) |
7 | 381 { |
382 invalidate_current_state(); | |
383 syn_buf = wp->w_buffer; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
384 syn_block = wp->w_s; |
7 | 385 } |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
386 changedtick = CHANGEDTICK(syn_buf); |
7 | 387 syn_win = wp; |
388 | |
389 /* | |
390 * Allocate syntax stack when needed. | |
391 */ | |
392 syn_stack_alloc(); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
393 if (syn_block->b_sst_array == NULL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
394 return; // out of memory |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
395 syn_block->b_sst_lasttick = display_tick; |
7 | 396 |
397 /* | |
398 * If the state of the end of the previous line is useful, store it. | |
399 */ | |
400 if (VALID_STATE(¤t_state) | |
401 && current_lnum < lnum | |
402 && current_lnum < syn_buf->b_ml.ml_line_count) | |
403 { | |
404 (void)syn_finish_line(FALSE); | |
405 if (!current_state_stored) | |
406 { | |
407 ++current_lnum; | |
1512 | 408 (void)store_current_state(); |
7 | 409 } |
410 | |
411 /* | |
412 * If the current_lnum is now the same as "lnum", keep the current | |
413 * state (this happens very often!). Otherwise invalidate | |
414 * current_state and figure it out below. | |
415 */ | |
416 if (current_lnum != lnum) | |
417 invalidate_current_state(); | |
418 } | |
419 else | |
420 invalidate_current_state(); | |
421 | |
422 /* | |
423 * Try to synchronize from a saved state in b_sst_array[]. | |
424 * Only do this if lnum is not before and not to far beyond a saved state. | |
425 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
426 if (INVALID_STATE(¤t_state) && syn_block->b_sst_array != NULL) |
7 | 427 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
428 // Find last valid saved state before start_lnum. |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
429 FOR_ALL_SYNSTATES(syn_block, p) |
7 | 430 { |
431 if (p->sst_lnum > lnum) | |
432 break; | |
433 if (p->sst_lnum <= lnum && p->sst_change_lnum == 0) | |
434 { | |
435 last_valid = p; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
436 if (p->sst_lnum >= lnum - syn_block->b_syn_sync_minlines) |
7 | 437 last_min_valid = p; |
438 } | |
439 } | |
440 if (last_min_valid != NULL) | |
441 load_current_state(last_min_valid); | |
442 } | |
443 | |
444 /* | |
445 * If "lnum" is before or far beyond a line with a saved state, need to | |
446 * re-synchronize. | |
447 */ | |
448 if (INVALID_STATE(¤t_state)) | |
449 { | |
450 syn_sync(wp, lnum, last_valid); | |
2906 | 451 if (current_lnum == 1) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
452 // First line is always valid, no matter "minlines". |
2906 | 453 first_stored = 1; |
454 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
455 // Need to parse "minlines" lines before state can be considered |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
456 // valid to store. |
2906 | 457 first_stored = current_lnum + syn_block->b_syn_sync_minlines; |
7 | 458 } |
459 else | |
460 first_stored = current_lnum; | |
461 | |
462 /* | |
463 * Advance from the sync point or saved state until the current line. | |
464 * Save some entries for syncing with later on. | |
465 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
466 if (syn_block->b_sst_len <= Rows) |
819 | 467 dist = 999999; |
468 else | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
469 dist = syn_buf->b_ml.ml_line_count / (syn_block->b_sst_len - Rows) + 1; |
7 | 470 while (current_lnum < lnum) |
471 { | |
472 syn_start_line(); | |
473 (void)syn_finish_line(FALSE); | |
474 ++current_lnum; | |
475 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
476 // If we parsed at least "minlines" lines or started at a valid |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
477 // state, the current state is considered valid. |
7 | 478 if (current_lnum >= first_stored) |
479 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
480 // Check if the saved state entry is for the current line and is |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
481 // equal to the current state. If so, then validate all saved |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
482 // states that depended on a change before the parsed line. |
7 | 483 if (prev == NULL) |
1512 | 484 prev = syn_stack_find_entry(current_lnum - 1); |
485 if (prev == NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
486 sp = syn_block->b_sst_first; |
7 | 487 else |
1512 | 488 sp = prev; |
489 while (sp != NULL && sp->sst_lnum < current_lnum) | |
490 sp = sp->sst_next; | |
7 | 491 if (sp != NULL |
492 && sp->sst_lnum == current_lnum | |
493 && syn_stack_equal(sp)) | |
494 { | |
495 parsed_lnum = current_lnum; | |
496 prev = sp; | |
497 while (sp != NULL && sp->sst_change_lnum <= parsed_lnum) | |
498 { | |
499 if (sp->sst_lnum <= lnum) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
500 // valid state before desired line, use this one |
7 | 501 prev = sp; |
502 else if (sp->sst_change_lnum == 0) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
503 // past saved states depending on change, break here. |
7 | 504 break; |
505 sp->sst_change_lnum = 0; | |
506 sp = sp->sst_next; | |
507 } | |
508 load_current_state(prev); | |
509 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
510 // Store the state at this line when it's the first one, the line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
511 // where we start parsing, or some distance from the previously |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
512 // saved state. But only when parsed at least 'minlines'. |
7 | 513 else if (prev == NULL |
514 || current_lnum == lnum | |
515 || current_lnum >= prev->sst_lnum + dist) | |
1512 | 516 prev = store_current_state(); |
7 | 517 } |
518 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
519 // This can take a long time: break when CTRL-C pressed. The current |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
520 // state will be wrong then. |
7 | 521 line_breakcheck(); |
522 if (got_int) | |
523 { | |
524 current_lnum = lnum; | |
525 break; | |
526 } | |
527 } | |
528 | |
529 syn_start_line(); | |
530 } | |
531 | |
532 /* | |
533 * We cannot simply discard growarrays full of state_items or buf_states; we | |
534 * have to manually release their extmatch pointers first. | |
535 */ | |
536 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
537 clear_syn_state(synstate_T *p) |
7 | 538 { |
539 int i; | |
540 garray_T *gap; | |
541 | |
542 if (p->sst_stacksize > SST_FIX_STATES) | |
543 { | |
544 gap = &(p->sst_union.sst_ga); | |
545 for (i = 0; i < gap->ga_len; i++) | |
546 unref_extmatch(SYN_STATE_P(gap)[i].bs_extmatch); | |
547 ga_clear(gap); | |
548 } | |
549 else | |
550 { | |
551 for (i = 0; i < p->sst_stacksize; i++) | |
552 unref_extmatch(p->sst_union.sst_stack[i].bs_extmatch); | |
553 } | |
554 } | |
555 | |
556 /* | |
557 * Cleanup the current_state stack. | |
558 */ | |
559 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
560 clear_current_state(void) |
7 | 561 { |
562 int i; | |
563 stateitem_T *sip; | |
564 | |
565 sip = (stateitem_T *)(current_state.ga_data); | |
566 for (i = 0; i < current_state.ga_len; i++) | |
567 unref_extmatch(sip[i].si_extmatch); | |
568 ga_clear(¤t_state); | |
569 } | |
570 | |
571 /* | |
572 * Try to find a synchronisation point for line "lnum". | |
573 * | |
574 * This sets current_lnum and the current state. One of three methods is | |
575 * used: | |
576 * 1. Search backwards for the end of a C-comment. | |
577 * 2. Search backwards for given sync patterns. | |
578 * 3. Simply start on a given number of lines above "lnum". | |
579 */ | |
580 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
581 syn_sync( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
582 win_T *wp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
583 linenr_T start_lnum, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
584 synstate_T *last_valid) |
7 | 585 { |
586 buf_T *curbuf_save; | |
587 win_T *curwin_save; | |
588 pos_T cursor_save; | |
589 int idx; | |
590 linenr_T lnum; | |
591 linenr_T end_lnum; | |
592 linenr_T break_lnum; | |
593 int had_sync_point; | |
594 stateitem_T *cur_si; | |
595 synpat_T *spp; | |
596 int found_flags = 0; | |
597 int found_match_idx = 0; | |
598 linenr_T found_current_lnum = 0; | |
599 int found_current_col= 0; | |
600 lpos_T found_m_endpos; | |
442 | 601 colnr_T prev_current_col; |
7 | 602 |
603 /* | |
604 * Clear any current state that might be hanging around. | |
605 */ | |
606 invalidate_current_state(); | |
607 | |
608 /* | |
609 * Start at least "minlines" back. Default starting point for parsing is | |
610 * there. | |
611 * Start further back, to avoid that scrolling backwards will result in | |
612 * resyncing for every line. Now it resyncs only one out of N lines, | |
613 * where N is minlines * 1.5, or minlines * 2 if minlines is small. | |
614 * Watch out for overflow when minlines is MAXLNUM. | |
615 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
616 if (syn_block->b_syn_sync_minlines > start_lnum) |
7 | 617 start_lnum = 1; |
618 else | |
619 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
620 if (syn_block->b_syn_sync_minlines == 1) |
7 | 621 lnum = 1; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
622 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
|
623 lnum = syn_block->b_syn_sync_minlines * 2; |
7 | 624 else |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
625 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
|
626 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
|
627 && lnum > syn_block->b_syn_sync_maxlines) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
628 lnum = syn_block->b_syn_sync_maxlines; |
7 | 629 if (lnum >= start_lnum) |
630 start_lnum = 1; | |
631 else | |
632 start_lnum -= lnum; | |
633 } | |
634 current_lnum = start_lnum; | |
635 | |
636 /* | |
637 * 1. Search backwards for the end of a C-style comment. | |
638 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
639 if (syn_block->b_syn_sync_flags & SF_CCOMMENT) |
7 | 640 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
641 // Need to make syn_buf the current buffer for a moment, to be able to |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
642 // use find_start_comment(). |
7 | 643 curwin_save = curwin; |
644 curwin = wp; | |
645 curbuf_save = curbuf; | |
646 curbuf = syn_buf; | |
647 | |
648 /* | |
649 * Skip lines that end in a backslash. | |
650 */ | |
651 for ( ; start_lnum > 1; --start_lnum) | |
652 { | |
34540
9e093c96dff6
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Christian Brabandt <cb@256bit.org>
parents:
32120
diff
changeset
|
653 char_u *l = ml_get(start_lnum - 1); |
9e093c96dff6
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Christian Brabandt <cb@256bit.org>
parents:
32120
diff
changeset
|
654 |
9e093c96dff6
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Christian Brabandt <cb@256bit.org>
parents:
32120
diff
changeset
|
655 if (*l == NUL || *(l + ml_get_len(start_lnum - 1) - 1) != '\\') |
7 | 656 break; |
657 } | |
658 current_lnum = start_lnum; | |
659 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
660 // set cursor to start of search |
7 | 661 cursor_save = wp->w_cursor; |
662 wp->w_cursor.lnum = start_lnum; | |
663 wp->w_cursor.col = 0; | |
664 | |
665 /* | |
666 * If the line is inside a comment, need to find the syntax item that | |
667 * defines the comment. | |
668 * Restrict the search for the end of a comment to b_syn_sync_maxlines. | |
669 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
670 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
|
671 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
672 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
|
673 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
|
674 == syn_block->b_syn_sync_id |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
675 && SYN_ITEMS(syn_block)[idx].sp_type == SPTYPE_START) |
7 | 676 { |
677 validate_current_state(); | |
678 if (push_current_state(idx) == OK) | |
679 update_si_attr(current_state.ga_len - 1); | |
680 break; | |
681 } | |
682 } | |
683 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
684 // restore cursor and buffer |
7 | 685 wp->w_cursor = cursor_save; |
686 curwin = curwin_save; | |
687 curbuf = curbuf_save; | |
688 } | |
689 | |
690 /* | |
691 * 2. Search backwards for given sync patterns. | |
692 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
693 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
|
694 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
695 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
|
696 && 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
|
697 break_lnum = start_lnum - syn_block->b_syn_sync_maxlines; |
7 | 698 else |
699 break_lnum = 0; | |
700 | |
699 | 701 found_m_endpos.lnum = 0; |
702 found_m_endpos.col = 0; | |
7 | 703 end_lnum = start_lnum; |
704 lnum = start_lnum; | |
705 while (--lnum > break_lnum) | |
706 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
707 // This can take a long time: break when CTRL-C pressed. |
7 | 708 line_breakcheck(); |
709 if (got_int) | |
710 { | |
711 invalidate_current_state(); | |
712 current_lnum = start_lnum; | |
713 break; | |
714 } | |
715 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
716 // Check if we have run into a valid saved state stack now. |
7 | 717 if (last_valid != NULL && lnum == last_valid->sst_lnum) |
718 { | |
719 load_current_state(last_valid); | |
720 break; | |
721 } | |
722 | |
723 /* | |
724 * Check if the previous line has the line-continuation pattern. | |
725 */ | |
726 if (lnum > 1 && syn_match_linecont(lnum - 1)) | |
727 continue; | |
728 | |
729 /* | |
730 * Start with nothing on the state stack | |
731 */ | |
732 validate_current_state(); | |
733 | |
734 for (current_lnum = lnum; current_lnum < end_lnum; ++current_lnum) | |
735 { | |
736 syn_start_line(); | |
737 for (;;) | |
738 { | |
739 had_sync_point = syn_finish_line(TRUE); | |
740 /* | |
741 * When a sync point has been found, remember where, and | |
742 * continue to look for another one, further on in the line. | |
743 */ | |
744 if (had_sync_point && current_state.ga_len) | |
745 { | |
746 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
747 if (cur_si->si_m_endpos.lnum > start_lnum) | |
748 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
749 // ignore match that goes to after where started |
7 | 750 current_lnum = end_lnum; |
751 break; | |
752 } | |
1371 | 753 if (cur_si->si_idx < 0) |
754 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
755 // Cannot happen? |
1371 | 756 found_flags = 0; |
757 found_match_idx = KEYWORD_IDX; | |
758 } | |
759 else | |
760 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
761 spp = &(SYN_ITEMS(syn_block)[cur_si->si_idx]); |
1371 | 762 found_flags = spp->sp_flags; |
763 found_match_idx = spp->sp_sync_idx; | |
764 } | |
7 | 765 found_current_lnum = current_lnum; |
766 found_current_col = current_col; | |
767 found_m_endpos = cur_si->si_m_endpos; | |
768 /* | |
769 * Continue after the match (be aware of a zero-length | |
770 * match). | |
771 */ | |
772 if (found_m_endpos.lnum > current_lnum) | |
773 { | |
774 current_lnum = found_m_endpos.lnum; | |
775 current_col = found_m_endpos.col; | |
776 if (current_lnum >= end_lnum) | |
777 break; | |
778 } | |
779 else if (found_m_endpos.col > current_col) | |
780 current_col = found_m_endpos.col; | |
781 else | |
782 ++current_col; | |
783 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
784 // syn_current_attr() will have skipped the check for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
785 // an item that ends here, need to do that now. Be |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
786 // careful not to go past the NUL. |
442 | 787 prev_current_col = current_col; |
788 if (syn_getcurline()[current_col] != NUL) | |
789 ++current_col; | |
7 | 790 check_state_ends(); |
442 | 791 current_col = prev_current_col; |
7 | 792 } |
793 else | |
794 break; | |
795 } | |
796 } | |
797 | |
798 /* | |
799 * If a sync point was encountered, break here. | |
800 */ | |
801 if (found_flags) | |
802 { | |
803 /* | |
804 * Put the item that was specified by the sync point on the | |
805 * state stack. If there was no item specified, make the | |
806 * state stack empty. | |
807 */ | |
808 clear_current_state(); | |
809 if (found_match_idx >= 0 | |
810 && push_current_state(found_match_idx) == OK) | |
811 update_si_attr(current_state.ga_len - 1); | |
812 | |
813 /* | |
814 * When using "grouphere", continue from the sync point | |
815 * match, until the end of the line. Parsing starts at | |
816 * the next line. | |
817 * For "groupthere" the parsing starts at start_lnum. | |
818 */ | |
819 if (found_flags & HL_SYNC_HERE) | |
820 { | |
821 if (current_state.ga_len) | |
822 { | |
823 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
824 cur_si->si_h_startpos.lnum = found_current_lnum; | |
825 cur_si->si_h_startpos.col = found_current_col; | |
826 update_si_end(cur_si, (int)current_col, TRUE); | |
827 check_keepend(); | |
828 } | |
829 current_col = found_m_endpos.col; | |
830 current_lnum = found_m_endpos.lnum; | |
831 (void)syn_finish_line(FALSE); | |
832 ++current_lnum; | |
833 } | |
834 else | |
835 current_lnum = start_lnum; | |
836 | |
837 break; | |
838 } | |
839 | |
840 end_lnum = lnum; | |
841 invalidate_current_state(); | |
842 } | |
843 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
844 // Ran into start of the file or exceeded maximum number of lines |
7 | 845 if (lnum <= break_lnum) |
846 { | |
847 invalidate_current_state(); | |
848 current_lnum = break_lnum + 1; | |
849 } | |
850 } | |
851 | |
852 validate_current_state(); | |
853 } | |
854 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
855 static void |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
856 save_chartab(char_u *chartab) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
857 { |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
858 if (syn_block->b_syn_isk == empty_option) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
859 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
860 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
861 mch_memmove(chartab, syn_buf->b_chartab, (size_t)32); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
862 mch_memmove(syn_buf->b_chartab, syn_win->w_s->b_syn_chartab, (size_t)32); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
863 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
864 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
865 static void |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
866 restore_chartab(char_u *chartab) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
867 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
868 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
|
869 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
|
870 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
871 |
7 | 872 /* |
873 * Return TRUE if the line-continuation pattern matches in line "lnum". | |
874 */ | |
875 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
876 syn_match_linecont(linenr_T lnum) |
7 | 877 { |
878 regmmatch_T regmatch; | |
6375 | 879 int r; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
880 char_u buf_chartab[32]; // chartab array for syn iskyeyword |
7 | 881 |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
882 if (syn_block->b_syn_linecont_prog == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
883 return FALSE; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
884 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
885 // use syntax iskeyword option |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
886 save_chartab(buf_chartab); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
887 regmatch.rmm_ic = syn_block->b_syn_linecont_ic; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
888 regmatch.regprog = syn_block->b_syn_linecont_prog; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
889 r = syn_regexec(®match, lnum, (colnr_T)0, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
890 IF_SYN_TIME(&syn_block->b_syn_linecont_time)); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
891 syn_block->b_syn_linecont_prog = regmatch.regprog; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
892 restore_chartab(buf_chartab); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
893 return r; |
7 | 894 } |
895 | |
896 /* | |
897 * Prepare the current state for the start of a line. | |
898 */ | |
899 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
900 syn_start_line(void) |
7 | 901 { |
902 current_finished = FALSE; | |
903 current_col = 0; | |
904 | |
905 /* | |
906 * Need to update the end of a start/skip/end that continues from the | |
907 * previous line and regions that have "keepend". | |
908 */ | |
909 if (current_state.ga_len > 0) | |
2863 | 910 { |
7 | 911 syn_update_ends(TRUE); |
2863 | 912 check_state_ends(); |
913 } | |
7 | 914 |
915 next_match_idx = -1; | |
916 ++current_line_id; | |
11581
2298fda621d3
patch 8.0.0673: build failure without conceal feature
Christian Brabandt <cb@256bit.org>
parents:
11579
diff
changeset
|
917 #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
|
918 next_seqnr = 1; |
11581
2298fda621d3
patch 8.0.0673: build failure without conceal feature
Christian Brabandt <cb@256bit.org>
parents:
11579
diff
changeset
|
919 #endif |
7 | 920 } |
921 | |
922 /* | |
923 * Check for items in the stack that need their end updated. | |
924 * When "startofline" is TRUE the last item is always updated. | |
925 * When "startofline" is FALSE the item with "keepend" is forcefully updated. | |
926 */ | |
927 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
928 syn_update_ends(int startofline) |
7 | 929 { |
930 stateitem_T *cur_si; | |
931 int i; | |
991 | 932 int seen_keepend; |
7 | 933 |
934 if (startofline) | |
935 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
936 // Check for a match carried over from a previous line with a |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
937 // contained region. The match ends as soon as the region ends. |
7 | 938 for (i = 0; i < current_state.ga_len; ++i) |
939 { | |
940 cur_si = &CUR_STATE(i); | |
941 if (cur_si->si_idx >= 0 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
942 && (SYN_ITEMS(syn_block)[cur_si->si_idx]).sp_type |
7 | 943 == SPTYPE_MATCH |
944 && cur_si->si_m_endpos.lnum < current_lnum) | |
945 { | |
946 cur_si->si_flags |= HL_MATCHCONT; | |
947 cur_si->si_m_endpos.lnum = 0; | |
948 cur_si->si_m_endpos.col = 0; | |
949 cur_si->si_h_endpos = cur_si->si_m_endpos; | |
950 cur_si->si_ends = TRUE; | |
951 } | |
952 } | |
953 } | |
954 | |
955 /* | |
956 * Need to update the end of a start/skip/end that continues from the | |
957 * previous line. And regions that have "keepend", because they may | |
991 | 958 * influence contained items. If we've just removed "extend" |
959 * (startofline == 0) then we should update ends of normal regions | |
960 * contained inside "keepend" because "extend" could have extended | |
961 * these "keepend" regions as well as contained normal regions. | |
7 | 962 * Then check for items ending in column 0. |
963 */ | |
964 i = current_state.ga_len - 1; | |
965 if (keepend_level >= 0) | |
966 for ( ; i > keepend_level; --i) | |
967 if (CUR_STATE(i).si_flags & HL_EXTEND) | |
968 break; | |
991 | 969 |
970 seen_keepend = FALSE; | |
7 | 971 for ( ; i < current_state.ga_len; ++i) |
972 { | |
973 cur_si = &CUR_STATE(i); | |
974 if ((cur_si->si_flags & HL_KEEPEND) | |
991 | 975 || (seen_keepend && !startofline) |
7 | 976 || (i == current_state.ga_len - 1 && startofline)) |
977 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
978 cur_si->si_h_startpos.col = 0; // start highl. in col 0 |
7 | 979 cur_si->si_h_startpos.lnum = current_lnum; |
980 | |
981 if (!(cur_si->si_flags & HL_MATCHCONT)) | |
982 update_si_end(cur_si, (int)current_col, !startofline); | |
991 | 983 |
984 if (!startofline && (cur_si->si_flags & HL_KEEPEND)) | |
985 seen_keepend = TRUE; | |
7 | 986 } |
987 } | |
988 check_keepend(); | |
989 } | |
990 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
991 ///////////////////////////////////////// |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
992 // Handling of the state stack cache. |
7 | 993 |
994 /* | |
995 * EXPLANATION OF THE SYNTAX STATE STACK CACHE | |
996 * | |
997 * To speed up syntax highlighting, the state stack for the start of some | |
998 * lines is cached. These entries can be used to start parsing at that point. | |
999 * | |
1000 * The stack is kept in b_sst_array[] for each buffer. There is a list of | |
1001 * valid entries. b_sst_first points to the first one, then follow sst_next. | |
1002 * The entries are sorted on line number. The first entry is often for line 2 | |
1003 * (line 1 always starts with an empty stack). | |
1004 * There is also a list for free entries. This construction is used to avoid | |
1005 * having to allocate and free memory blocks too often. | |
1006 * | |
1007 * When making changes to the buffer, this is logged in b_mod_*. When calling | |
1008 * update_screen() to update the display, it will call | |
1009 * syn_stack_apply_changes() for each displayed buffer to adjust the cached | |
1010 * entries. The entries which are inside the changed area are removed, | |
1011 * because they must be recomputed. Entries below the changed have their line | |
1012 * number adjusted for deleted/inserted lines, and have their sst_change_lnum | |
1013 * set to indicate that a check must be made if the changed lines would change | |
1014 * the cached entry. | |
1015 * | |
1016 * When later displaying lines, an entry is stored for each line. Displayed | |
1017 * lines are likely to be displayed again, in which case the state at the | |
1018 * start of the line is needed. | |
1019 * For not displayed lines, an entry is stored for every so many lines. These | |
1020 * entries will be used e.g., when scrolling backwards. The distance between | |
1021 * entries depends on the number of lines in the buffer. For small buffers | |
1022 * the distance is fixed at SST_DIST, for large buffers there is a fixed | |
1023 * number of entries SST_MAX_ENTRIES, and the distance is computed. | |
1024 */ | |
1025 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1026 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1027 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
|
1028 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1029 synstate_T *p; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1030 |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1031 if (block->b_sst_array == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1032 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1033 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1034 FOR_ALL_SYNSTATES(block, p) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1035 clear_syn_state(p); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1036 VIM_CLEAR(block->b_sst_array); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1037 block->b_sst_first = NULL; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
1038 block->b_sst_len = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1039 } |
7 | 1040 /* |
1041 * Free b_sst_array[] for buffer "buf". | |
1042 * Used when syntax items changed to force resyncing everywhere. | |
1043 */ | |
1044 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1045 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
|
1046 { |
11073
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
1047 #ifdef FEAT_FOLDING |
7 | 1048 win_T *wp; |
11073
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
1049 #endif |
7 | 1050 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1051 syn_stack_free_block(block); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1052 |
7 | 1053 #ifdef FEAT_FOLDING |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1054 // When using "syntax" fold method, must update all folds. |
7 | 1055 FOR_ALL_WINDOWS(wp) |
1056 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1057 if (wp->w_s == block && foldmethodIsSyntax(wp)) |
7 | 1058 foldUpdateAll(wp); |
1059 } | |
1060 #endif | |
1061 } | |
1062 | |
1063 /* | |
1064 * Allocate the syntax state stack for syn_buf when needed. | |
1065 * If the number of entries in b_sst_array[] is much too big or a bit too | |
1066 * small, reallocate it. | |
1067 * Also used to allocate b_sst_array[] for the first time. | |
1068 */ | |
1069 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1070 syn_stack_alloc(void) |
7 | 1071 { |
1072 long len; | |
1073 synstate_T *to, *from; | |
1074 synstate_T *sstp; | |
1075 | |
1076 len = syn_buf->b_ml.ml_line_count / SST_DIST + Rows * 2; | |
1077 if (len < SST_MIN_ENTRIES) | |
1078 len = SST_MIN_ENTRIES; | |
1079 else if (len > SST_MAX_ENTRIES) | |
1080 len = SST_MAX_ENTRIES; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1081 if (syn_block->b_sst_len > len * 2 || syn_block->b_sst_len < len) |
7 | 1082 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1083 // Allocate 50% too much, to avoid reallocating too often. |
7 | 1084 len = syn_buf->b_ml.ml_line_count; |
1085 len = (len + len / 2) / SST_DIST + Rows * 2; | |
1086 if (len < SST_MIN_ENTRIES) | |
1087 len = SST_MIN_ENTRIES; | |
1088 else if (len > SST_MAX_ENTRIES) | |
1089 len = SST_MAX_ENTRIES; | |
1090 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1091 if (syn_block->b_sst_array != NULL) |
7 | 1092 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1093 // When shrinking the array, cleanup the existing stack. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1094 // 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
|
1095 while (syn_block->b_sst_len - syn_block->b_sst_freecount + 2 > len |
7 | 1096 && syn_stack_cleanup()) |
1097 ; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1098 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
|
1099 len = syn_block->b_sst_len - syn_block->b_sst_freecount + 2; |
7 | 1100 } |
1101 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
1102 sstp = ALLOC_CLEAR_MULT(synstate_T, len); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1103 if (sstp == NULL) // out of memory! |
7 | 1104 return; |
1105 | |
1106 to = sstp - 1; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1107 if (syn_block->b_sst_array != NULL) |
7 | 1108 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1109 // 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
|
1110 for (from = syn_block->b_sst_first; from != NULL; |
7 | 1111 from = from->sst_next) |
1112 { | |
1113 ++to; | |
1114 *to = *from; | |
1115 to->sst_next = to + 1; | |
1116 } | |
1117 } | |
1118 if (to != sstp - 1) | |
1119 { | |
1120 to->sst_next = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1121 syn_block->b_sst_first = sstp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1122 syn_block->b_sst_freecount = len - (int)(to - sstp) - 1; |
7 | 1123 } |
1124 else | |
1125 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1126 syn_block->b_sst_first = NULL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1127 syn_block->b_sst_freecount = len; |
7 | 1128 } |
1129 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1130 // Create the list of free entries. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1131 syn_block->b_sst_firstfree = to + 1; |
7 | 1132 while (++to < sstp + len) |
1133 to->sst_next = to + 1; | |
1134 (sstp + len - 1)->sst_next = NULL; | |
1135 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1136 vim_free(syn_block->b_sst_array); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1137 syn_block->b_sst_array = sstp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1138 syn_block->b_sst_len = len; |
7 | 1139 } |
1140 } | |
1141 | |
1142 /* | |
1143 * Check for changes in a buffer to affect stored syntax states. Uses the | |
1144 * b_mod_* fields. | |
1145 * Called from update_screen(), before screen is being updated, once for each | |
1146 * displayed buffer. | |
1147 */ | |
1148 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1149 syn_stack_apply_changes(buf_T *buf) |
7 | 1150 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1151 win_T *wp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1152 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1153 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
|
1154 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1155 FOR_ALL_WINDOWS(wp) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1156 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1157 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
|
1158 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
|
1159 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1160 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1161 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1162 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1163 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
|
1164 { |
7 | 1165 synstate_T *p, *prev, *np; |
1166 linenr_T n; | |
1167 | |
1168 prev = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1169 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
|
1170 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1171 if (p->sst_lnum + block->b_syn_sync_linebreaks > buf->b_mod_top) |
7 | 1172 { |
1173 n = p->sst_lnum + buf->b_mod_xlines; | |
1174 if (n <= buf->b_mod_bot) | |
1175 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1176 // this state is inside the changed area, remove it |
7 | 1177 np = p->sst_next; |
1178 if (prev == NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1179 block->b_sst_first = np; |
7 | 1180 else |
1181 prev->sst_next = np; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1182 syn_stack_free_entry(block, p); |
7 | 1183 p = np; |
1184 continue; | |
1185 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1186 // This state is below the changed area. Remember the line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1187 // that needs to be parsed before this entry can be made valid |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1188 // again. |
7 | 1189 if (p->sst_change_lnum != 0 && p->sst_change_lnum > buf->b_mod_top) |
1190 { | |
1191 if (p->sst_change_lnum + buf->b_mod_xlines > buf->b_mod_top) | |
1192 p->sst_change_lnum += buf->b_mod_xlines; | |
1193 else | |
1194 p->sst_change_lnum = buf->b_mod_top; | |
1195 } | |
1196 if (p->sst_change_lnum == 0 | |
1197 || p->sst_change_lnum < buf->b_mod_bot) | |
1198 p->sst_change_lnum = buf->b_mod_bot; | |
1199 | |
1200 p->sst_lnum = n; | |
1201 } | |
1202 prev = p; | |
1203 p = p->sst_next; | |
1204 } | |
1205 } | |
1206 | |
1207 /* | |
1208 * Reduce the number of entries in the state stack for syn_buf. | |
1209 * Returns TRUE if at least one entry was freed. | |
1210 */ | |
1211 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1212 syn_stack_cleanup(void) |
7 | 1213 { |
1214 synstate_T *p, *prev; | |
1215 disptick_T tick; | |
1216 int above; | |
1217 int dist; | |
1218 int retval = FALSE; | |
1219 | |
14850
85ef79b16181
patch 8.1.0437: may access freed memory when syntax HL times out
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
1220 if (syn_block->b_sst_first == NULL) |
7 | 1221 return retval; |
1222 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1223 // 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
|
1224 if (syn_block->b_sst_len <= Rows) |
819 | 1225 dist = 999999; |
1226 else | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1227 dist = syn_buf->b_ml.ml_line_count / (syn_block->b_sst_len - Rows) + 1; |
7 | 1228 |
1229 /* | |
2020 | 1230 * Go through the list to find the "tick" for the oldest entry that can |
7 | 1231 * be removed. Set "above" when the "tick" for the oldest entry is above |
1232 * "b_sst_lasttick" (the display tick wraps around). | |
1233 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1234 tick = syn_block->b_sst_lasttick; |
7 | 1235 above = FALSE; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1236 prev = syn_block->b_sst_first; |
7 | 1237 for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) |
1238 { | |
1239 if (prev->sst_lnum + dist > p->sst_lnum) | |
1240 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1241 if (p->sst_tick > syn_block->b_sst_lasttick) |
7 | 1242 { |
1243 if (!above || p->sst_tick < tick) | |
1244 tick = p->sst_tick; | |
1245 above = TRUE; | |
1246 } | |
1247 else if (!above && p->sst_tick < tick) | |
1248 tick = p->sst_tick; | |
1249 } | |
1250 } | |
1251 | |
1252 /* | |
1253 * Go through the list to make the entries for the oldest tick at an | |
1254 * interval of several lines. | |
1255 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1256 prev = syn_block->b_sst_first; |
7 | 1257 for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) |
1258 { | |
1259 if (p->sst_tick == tick && prev->sst_lnum + dist > p->sst_lnum) | |
1260 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1261 // Move this entry from used list to free list |
7 | 1262 prev->sst_next = p->sst_next; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1263 syn_stack_free_entry(syn_block, p); |
7 | 1264 p = prev; |
1265 retval = TRUE; | |
1266 } | |
1267 } | |
1268 return retval; | |
1269 } | |
1270 | |
1271 /* | |
1272 * Free the allocated memory for a syn_state item. | |
1273 * Move the entry into the free list. | |
1274 */ | |
1275 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1276 syn_stack_free_entry(synblock_T *block, synstate_T *p) |
7 | 1277 { |
1278 clear_syn_state(p); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1279 p->sst_next = block->b_sst_firstfree; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1280 block->b_sst_firstfree = p; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1281 ++block->b_sst_freecount; |
7 | 1282 } |
1283 | |
1284 /* | |
1285 * Find an entry in the list of state stacks at or before "lnum". | |
1286 * Returns NULL when there is no entry or the first entry is after "lnum". | |
1287 */ | |
1288 static synstate_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1289 syn_stack_find_entry(linenr_T lnum) |
7 | 1290 { |
1291 synstate_T *p, *prev; | |
1292 | |
1293 prev = NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1294 for (p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next) |
7 | 1295 { |
1296 if (p->sst_lnum == lnum) | |
1297 return p; | |
1298 if (p->sst_lnum > lnum) | |
1299 break; | |
1300 } | |
1301 return prev; | |
1302 } | |
1303 | |
1304 /* | |
1305 * Try saving the current state in b_sst_array[]. | |
1306 * The current state must be valid for the start of the current_lnum line! | |
1307 */ | |
1308 static synstate_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1309 store_current_state(void) |
7 | 1310 { |
1311 int i; | |
1312 synstate_T *p; | |
1313 bufstate_T *bp; | |
1314 stateitem_T *cur_si; | |
1512 | 1315 synstate_T *sp = syn_stack_find_entry(current_lnum); |
7 | 1316 |
1317 /* | |
1318 * If the current state contains a start or end pattern that continues | |
1319 * from the previous line, we can't use it. Don't store it then. | |
1320 */ | |
1321 for (i = current_state.ga_len - 1; i >= 0; --i) | |
1322 { | |
1323 cur_si = &CUR_STATE(i); | |
1324 if (cur_si->si_h_startpos.lnum >= current_lnum | |
1325 || cur_si->si_m_endpos.lnum >= current_lnum | |
1326 || cur_si->si_h_endpos.lnum >= current_lnum | |
1327 || (cur_si->si_end_idx | |
1328 && cur_si->si_eoe_pos.lnum >= current_lnum)) | |
1329 break; | |
1330 } | |
1331 if (i >= 0) | |
1332 { | |
1333 if (sp != NULL) | |
1334 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1335 // 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
|
1336 if (syn_block->b_sst_first == sp) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1337 // it's the first entry |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1338 syn_block->b_sst_first = sp->sst_next; |
7 | 1339 else |
1340 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1341 // find the entry just before this one to adjust sst_next |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1342 FOR_ALL_SYNSTATES(syn_block, p) |
7 | 1343 if (p->sst_next == sp) |
1344 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1345 if (p != NULL) // just in case |
840 | 1346 p->sst_next = sp->sst_next; |
7 | 1347 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1348 syn_stack_free_entry(syn_block, sp); |
7 | 1349 sp = NULL; |
1350 } | |
1351 } | |
1352 else if (sp == NULL || sp->sst_lnum != current_lnum) | |
1353 { | |
1354 /* | |
1355 * Add a new entry | |
1356 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1357 // 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
|
1358 if (syn_block->b_sst_freecount == 0) |
7 | 1359 { |
1360 (void)syn_stack_cleanup(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1361 // "sp" may have been moved to the freelist now |
7 | 1362 sp = syn_stack_find_entry(current_lnum); |
1363 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1364 // 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
|
1365 if (syn_block->b_sst_freecount == 0) |
7 | 1366 sp = NULL; |
1367 else | |
1368 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1369 // Take the first item from the free list and put it in the used |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1370 // list, after *sp |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1371 p = syn_block->b_sst_firstfree; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1372 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
|
1373 --syn_block->b_sst_freecount; |
7 | 1374 if (sp == NULL) |
1375 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1376 // Insert in front of the list |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1377 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
|
1378 syn_block->b_sst_first = p; |
7 | 1379 } |
1380 else | |
1381 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1382 // insert in list after *sp |
7 | 1383 p->sst_next = sp->sst_next; |
1384 sp->sst_next = p; | |
1385 } | |
1386 sp = p; | |
1387 sp->sst_stacksize = 0; | |
1388 sp->sst_lnum = current_lnum; | |
1389 } | |
1390 } | |
1391 if (sp != NULL) | |
1392 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1393 // When overwriting an existing state stack, clear it first |
7 | 1394 clear_syn_state(sp); |
1395 sp->sst_stacksize = current_state.ga_len; | |
1396 if (current_state.ga_len > SST_FIX_STATES) | |
1397 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1398 // Need to clear it, might be something remaining from when the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1399 // length was less than SST_FIX_STATES. |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
1400 ga_init2(&sp->sst_union.sst_ga, sizeof(bufstate_T), 1); |
7 | 1401 if (ga_grow(&sp->sst_union.sst_ga, current_state.ga_len) == FAIL) |
1402 sp->sst_stacksize = 0; | |
1403 else | |
1404 sp->sst_union.sst_ga.ga_len = current_state.ga_len; | |
1405 bp = SYN_STATE_P(&(sp->sst_union.sst_ga)); | |
1406 } | |
1407 else | |
1408 bp = sp->sst_union.sst_stack; | |
1409 for (i = 0; i < sp->sst_stacksize; ++i) | |
1410 { | |
1411 bp[i].bs_idx = CUR_STATE(i).si_idx; | |
1412 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
|
1413 #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
|
1414 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
|
1415 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
|
1416 #endif |
7 | 1417 bp[i].bs_extmatch = ref_extmatch(CUR_STATE(i).si_extmatch); |
1418 } | |
1419 sp->sst_next_flags = current_next_flags; | |
1420 sp->sst_next_list = current_next_list; | |
1421 sp->sst_tick = display_tick; | |
1422 sp->sst_change_lnum = 0; | |
1423 } | |
1424 current_state_stored = TRUE; | |
1425 return sp; | |
1426 } | |
1427 | |
1428 /* | |
1429 * Copy a state stack from "from" in b_sst_array[] to current_state; | |
1430 */ | |
1431 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1432 load_current_state(synstate_T *from) |
7 | 1433 { |
1434 int i; | |
1435 bufstate_T *bp; | |
1436 | |
1437 clear_current_state(); | |
1438 validate_current_state(); | |
1439 keepend_level = -1; | |
1440 if (from->sst_stacksize | |
31837
e16361210675
patch 9.0.1251: checking returned value of ga_grow() is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
31809
diff
changeset
|
1441 && ga_grow(¤t_state, from->sst_stacksize) == OK) |
7 | 1442 { |
1443 if (from->sst_stacksize > SST_FIX_STATES) | |
1444 bp = SYN_STATE_P(&(from->sst_union.sst_ga)); | |
1445 else | |
1446 bp = from->sst_union.sst_stack; | |
1447 for (i = 0; i < from->sst_stacksize; ++i) | |
1448 { | |
1449 CUR_STATE(i).si_idx = bp[i].bs_idx; | |
1450 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
|
1451 #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
|
1452 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
|
1453 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
|
1454 #endif |
7 | 1455 CUR_STATE(i).si_extmatch = ref_extmatch(bp[i].bs_extmatch); |
1456 if (keepend_level < 0 && (CUR_STATE(i).si_flags & HL_KEEPEND)) | |
1457 keepend_level = i; | |
1458 CUR_STATE(i).si_ends = FALSE; | |
1459 CUR_STATE(i).si_m_lnum = 0; | |
1460 if (CUR_STATE(i).si_idx >= 0) | |
1461 CUR_STATE(i).si_next_list = | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1462 (SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_next_list; |
7 | 1463 else |
1464 CUR_STATE(i).si_next_list = NULL; | |
1465 update_si_attr(i); | |
1466 } | |
1467 current_state.ga_len = from->sst_stacksize; | |
1468 } | |
1469 current_next_list = from->sst_next_list; | |
1470 current_next_flags = from->sst_next_flags; | |
1471 current_lnum = from->sst_lnum; | |
1472 } | |
1473 | |
1474 /* | |
1475 * Compare saved state stack "*sp" with the current state. | |
1476 * Return TRUE when they are equal. | |
1477 */ | |
1478 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1479 syn_stack_equal(synstate_T *sp) |
7 | 1480 { |
1481 int i, j; | |
1482 bufstate_T *bp; | |
1483 reg_extmatch_T *six, *bsx; | |
1484 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1485 // First a quick check if the stacks have the same size end nextlist. |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1486 if (sp->sst_stacksize != current_state.ga_len |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1487 || sp->sst_next_list != current_next_list) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1488 return FALSE; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1489 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1490 // Need to compare all states on both stacks. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1491 if (sp->sst_stacksize > SST_FIX_STATES) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1492 bp = SYN_STATE_P(&(sp->sst_union.sst_ga)); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1493 else |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1494 bp = sp->sst_union.sst_stack; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1495 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1496 for (i = current_state.ga_len; --i >= 0; ) |
7 | 1497 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1498 // If the item has another index the state is different. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1499 if (bp[i].bs_idx != CUR_STATE(i).si_idx) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1500 break; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1501 if (bp[i].bs_extmatch == CUR_STATE(i).si_extmatch) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1502 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1503 // When the extmatch pointers are different, the strings in them can |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1504 // still be the same. Check if the extmatch references are equal. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1505 bsx = bp[i].bs_extmatch; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1506 six = CUR_STATE(i).si_extmatch; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1507 // If one of the extmatch pointers is NULL the states are different. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1508 if (bsx == NULL || six == NULL) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1509 break; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1510 for (j = 0; j < NSUBEXP; ++j) |
7 | 1511 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1512 // Check each referenced match string. They must all be equal. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1513 if (bsx->matches[j] != six->matches[j]) |
7 | 1514 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1515 // If the pointer is different it can still be the same text. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1516 // Compare the strings, ignore case when the start item has the |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1517 // sp_ic flag set. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1518 if (bsx->matches[j] == NULL || six->matches[j] == NULL) |
7 | 1519 break; |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1520 if ((SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_ic |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1521 ? MB_STRICMP(bsx->matches[j], six->matches[j]) != 0 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1522 : STRCMP(bsx->matches[j], six->matches[j]) != 0) |
7 | 1523 break; |
1524 } | |
1525 } | |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1526 if (j != NSUBEXP) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1527 break; |
7 | 1528 } |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29218
diff
changeset
|
1529 return i < 0 ? TRUE : FALSE; |
7 | 1530 } |
1531 | |
1532 /* | |
1533 * We stop parsing syntax above line "lnum". If the stored state at or below | |
1534 * this line depended on a change before it, it now depends on the line below | |
1535 * the last parsed line. | |
1536 * The window looks like this: | |
1537 * line which changed | |
1538 * displayed line | |
1539 * displayed line | |
1540 * lnum -> line below window | |
1541 */ | |
1542 void | |
30831
fbeebe308514
patch 9.0.0750: crash when popup closed in callback
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
1543 syntax_end_parsing(win_T *wp, linenr_T lnum) |
7 | 1544 { |
1545 synstate_T *sp; | |
1546 | |
30831
fbeebe308514
patch 9.0.0750: crash when popup closed in callback
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
1547 if (syn_block != wp->w_s) |
fbeebe308514
patch 9.0.0750: crash when popup closed in callback
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
1548 return; // not the right window |
7 | 1549 sp = syn_stack_find_entry(lnum); |
1550 if (sp != NULL && sp->sst_lnum < lnum) | |
1551 sp = sp->sst_next; | |
1552 | |
1553 if (sp != NULL && sp->sst_change_lnum != 0) | |
1554 sp->sst_change_lnum = lnum; | |
1555 } | |
1556 | |
1557 /* | |
1558 * End of handling of the state stack. | |
1559 ****************************************/ | |
1560 | |
1561 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1562 invalidate_current_state(void) |
7 | 1563 { |
1564 clear_current_state(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1565 current_state.ga_itemsize = 0; // mark current_state invalid |
7 | 1566 current_next_list = NULL; |
1567 keepend_level = -1; | |
1568 } | |
1569 | |
1570 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1571 validate_current_state(void) |
7 | 1572 { |
1573 current_state.ga_itemsize = sizeof(stateitem_T); | |
1574 current_state.ga_growsize = 3; | |
1575 } | |
1576 | |
1577 /* | |
1578 * Return TRUE if the syntax at start of lnum changed since last time. | |
1579 * This will only be called just after get_syntax_attr() for the previous | |
1580 * line, to check if the next line needs to be redrawn too. | |
1581 */ | |
1582 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1583 syntax_check_changed(linenr_T lnum) |
7 | 1584 { |
1585 int retval = TRUE; | |
1586 synstate_T *sp; | |
1587 | |
1588 /* | |
1589 * Check the state stack when: | |
1590 * - lnum is just below the previously syntaxed line. | |
1591 * - lnum is not before the lines with saved states. | |
1592 * - lnum is not past the lines with saved states. | |
1593 * - lnum is at or before the last changed line. | |
1594 */ | |
1595 if (VALID_STATE(¤t_state) && lnum == current_lnum + 1) | |
1596 { | |
1597 sp = syn_stack_find_entry(lnum); | |
1598 if (sp != NULL && sp->sst_lnum == lnum) | |
1599 { | |
1600 /* | |
1601 * finish the previous line (needed when not all of the line was | |
1602 * drawn) | |
1603 */ | |
1604 (void)syn_finish_line(FALSE); | |
1605 | |
1606 /* | |
1607 * Compare the current state with the previously saved state of | |
1608 * the line. | |
1609 */ | |
1610 if (syn_stack_equal(sp)) | |
1611 retval = FALSE; | |
1612 | |
1613 /* | |
1614 * Store the current state in b_sst_array[] for later use. | |
1615 */ | |
1616 ++current_lnum; | |
1512 | 1617 (void)store_current_state(); |
7 | 1618 } |
1619 } | |
1620 | |
1621 return retval; | |
1622 } | |
1623 | |
1624 /* | |
1625 * Finish the current line. | |
1626 * This doesn't return any attributes, it only gets the state at the end of | |
1627 * the line. It can start anywhere in the line, as long as the current state | |
1628 * is valid. | |
1629 */ | |
1630 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1631 syn_finish_line( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1632 int syncing) // called for syncing |
7 | 1633 { |
1634 stateitem_T *cur_si; | |
442 | 1635 colnr_T prev_current_col; |
7 | 1636 |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1637 while (!current_finished) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1638 { |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1639 (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
|
1640 /* |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1641 * 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
|
1642 */ |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1643 if (syncing && current_state.ga_len) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1644 { |
7 | 1645 /* |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1646 * Check for match with sync item. |
7 | 1647 */ |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1648 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
|
1649 if (cur_si->si_idx >= 0 |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1650 && (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
|
1651 & (HL_SYNC_HERE|HL_SYNC_THERE))) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1652 return TRUE; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1653 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1654 // syn_current_attr() will have skipped the check for an item |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1655 // that ends here, need to do that now. Be careful not to go |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1656 // past the NUL. |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1657 prev_current_col = current_col; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1658 if (syn_getcurline()[current_col] != NUL) |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1659 ++current_col; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1660 check_state_ends(); |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1661 current_col = prev_current_col; |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1662 } |
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1663 ++current_col; |
7 | 1664 } |
1665 return FALSE; | |
1666 } | |
1667 | |
1668 /* | |
1669 * Return highlight attributes for next character. | |
1670 * Must first call syntax_start() once for the line. | |
1671 * "col" is normally 0 for the first use in a line, and increments by one each | |
1672 * time. It's allowed to skip characters and to stop before the end of the | |
1673 * line. But only a "col" after a previously used column is allowed. | |
221 | 1674 * When "can_spell" is not NULL set it to TRUE when spell-checking should be |
1675 * done. | |
7 | 1676 */ |
1677 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1678 get_syntax_attr( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1679 colnr_T col, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1680 int *can_spell, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1681 int keep_state) // keep state of char at "col" |
7 | 1682 { |
1683 int attr = 0; | |
1684 | |
1363 | 1685 if (can_spell != NULL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1686 // Default: Only do spelling when there is no @Spell cluster or when |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1687 // ":syn spell toplevel" was used. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1688 *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
|
1689 ? (syn_block->b_spell_cluster_id == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1690 : (syn_block->b_syn_spell == SYNSPL_TOP); |
1363 | 1691 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1692 // check for out of memory situation |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1693 if (syn_block->b_sst_array == NULL) |
7 | 1694 return 0; |
1695 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1696 // After 'synmaxcol' the attribute is always zero. |
431 | 1697 if (syn_buf->b_p_smc > 0 && col >= (colnr_T)syn_buf->b_p_smc) |
419 | 1698 { |
1699 clear_current_state(); | |
1700 #ifdef FEAT_EVAL | |
1701 current_id = 0; | |
1702 current_trans_id = 0; | |
1703 #endif | |
2401
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
1704 #ifdef FEAT_CONCEAL |
e7751177126b
Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
1705 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
|
1706 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
|
1707 #endif |
419 | 1708 return 0; |
1709 } | |
1710 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1711 // Make sure current_state is valid |
7 | 1712 if (INVALID_STATE(¤t_state)) |
1713 validate_current_state(); | |
1714 | |
1715 /* | |
1716 * Skip from the current column to "col", get the attributes for "col". | |
1717 */ | |
1718 while (current_col <= col) | |
1719 { | |
1504 | 1720 attr = syn_current_attr(FALSE, TRUE, can_spell, |
1721 current_col == col ? keep_state : FALSE); | |
7 | 1722 ++current_col; |
1723 } | |
1724 | |
1725 return attr; | |
1726 } | |
1727 | |
1728 /* | |
1729 * Get syntax attributes for current_lnum, current_col. | |
1730 */ | |
1731 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1732 syn_current_attr( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1733 int syncing, // When 1: called for syncing |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1734 int displaying, // result will be displayed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1735 int *can_spell, // return: do spell checking |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1736 int keep_state) // keep syntax stack afterwards |
7 | 1737 { |
1738 int syn_id; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1739 lpos_T endpos; // was: char_u *endp; |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1740 lpos_T hl_startpos; // was: int hl_startcol; |
7 | 1741 lpos_T hl_endpos; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1742 lpos_T eos_pos; // end-of-start match (start region) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1743 lpos_T eoe_pos; // end-of-end pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1744 int end_idx; // group ID for end pattern |
7 | 1745 int idx; |
1746 synpat_T *spp; | |
221 | 1747 stateitem_T *cur_si, *sip = NULL; |
7 | 1748 int startcol; |
1749 int endcol; | |
1750 long flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1751 int cchar; |
7 | 1752 short *next_list; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1753 int found_match; // found usable match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1754 static int try_next_column = FALSE; // must try in next col |
7 | 1755 int do_keywords; |
1756 regmmatch_T regmatch; | |
1757 lpos_T pos; | |
1758 int lc_col; | |
1759 reg_extmatch_T *cur_extmatch = NULL; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1760 char_u buf_chartab[32]; // chartab array for syn iskyeyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1761 char_u *line; // current line. NOTE: becomes invalid after |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1762 // looking for a pattern match! |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1763 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1764 // variables for zero-width matches that have a "nextgroup" argument |
7 | 1765 int keep_next_list; |
1766 int zero_width_next_list = FALSE; | |
1767 garray_T zero_width_next_ga; | |
1768 | |
1769 /* | |
1770 * No character, no attributes! Past end of line? | |
1771 * Do try matching with an empty line (could be the start of a region). | |
1772 */ | |
1773 line = syn_getcurline(); | |
1774 if (line[current_col] == NUL && current_col != 0) | |
1775 { | |
1776 /* | |
1777 * If we found a match after the last column, use it. | |
1778 */ | |
1779 if (next_match_idx >= 0 && next_match_col >= (int)current_col | |
1780 && next_match_col != MAXCOL) | |
1781 (void)push_next_match(NULL); | |
1782 | |
1783 current_finished = TRUE; | |
1784 current_state_stored = FALSE; | |
1785 return 0; | |
1786 } | |
1787 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1788 // if the current or next character is NUL, we will finish the line now |
7 | 1789 if (line[current_col] == NUL || line[current_col + 1] == NUL) |
1790 { | |
1791 current_finished = TRUE; | |
1792 current_state_stored = FALSE; | |
1793 } | |
1794 | |
1795 /* | |
1796 * When in the previous column there was a match but it could not be used | |
1797 * (empty match or already matched in this column) need to try again in | |
1798 * the next column. | |
1799 */ | |
1800 if (try_next_column) | |
1801 { | |
1802 next_match_idx = -1; | |
1803 try_next_column = FALSE; | |
1804 } | |
1805 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1806 // Only check for keywords when not syncing and there are some. |
7 | 1807 do_keywords = !syncing |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1808 && (syn_block->b_keywtab.ht_used > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1809 || syn_block->b_keywtab_ic.ht_used > 0); |
7 | 1810 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1811 // Init the list of zero-width matches with a nextlist. This is used to |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1812 // avoid matching the same item in the same position twice. |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
1813 ga_init2(&zero_width_next_ga, sizeof(int), 10); |
7 | 1814 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1815 // use syntax iskeyword option |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1816 save_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1817 |
7 | 1818 /* |
1819 * Repeat matching keywords and patterns, to find contained items at the | |
1820 * same column. This stops when there are no extra matches at the current | |
1821 * column. | |
1822 */ | |
1823 do | |
1824 { | |
1825 found_match = FALSE; | |
1826 keep_next_list = FALSE; | |
1827 syn_id = 0; | |
1828 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
1829 |
7 | 1830 /* |
1831 * 1. Check for a current state. | |
1832 * Only when there is no current state, or if the current state may | |
1833 * contain other things, we need to check for keywords and patterns. | |
1834 * Always need to check for contained items if some item has the | |
1835 * "containedin" argument (takes extra time!). | |
1836 */ | |
1837 if (current_state.ga_len) | |
1838 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
1839 else | |
1840 cur_si = NULL; | |
1841 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1842 if (syn_block->b_syn_containedin || cur_si == NULL |
7 | 1843 || cur_si->si_cont_list != NULL) |
1844 { | |
1845 /* | |
1846 * 2. Check for keywords, if on a keyword char after a non-keyword | |
1847 * char. Don't do this when syncing. | |
1848 */ | |
1849 if (do_keywords) | |
1850 { | |
1851 line = syn_getcurline(); | |
4043 | 1852 if (vim_iswordp_buf(line + current_col, syn_buf) |
7 | 1853 && (current_col == 0 |
4043 | 1854 || !vim_iswordp_buf(line + current_col - 1 |
7 | 1855 - (has_mbyte |
1856 ? (*mb_head_off)(line, line + current_col - 1) | |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
1857 : 0) , syn_buf))) |
7 | 1858 { |
1859 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
|
1860 &endcol, &flags, &next_list, cur_si, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1861 &cchar); |
205 | 1862 if (syn_id != 0) |
7 | 1863 { |
1864 if (push_current_state(KEYWORD_IDX) == OK) | |
1865 { | |
1866 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
1867 cur_si->si_m_startcol = current_col; | |
1868 cur_si->si_h_startpos.lnum = current_lnum; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1869 cur_si->si_h_startpos.col = 0; // starts right away |
7 | 1870 cur_si->si_m_endpos.lnum = current_lnum; |
1871 cur_si->si_m_endpos.col = endcol; | |
1872 cur_si->si_h_endpos.lnum = current_lnum; | |
1873 cur_si->si_h_endpos.col = endcol; | |
1874 cur_si->si_ends = TRUE; | |
1875 cur_si->si_end_idx = 0; | |
1876 cur_si->si_flags = flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1877 #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
|
1878 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
|
1879 cur_si->si_cchar = cchar; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1880 if (current_state.ga_len > 1) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1881 cur_si->si_flags |= |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1882 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
|
1883 & HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1884 #endif |
7 | 1885 cur_si->si_id = syn_id; |
1886 cur_si->si_trans_id = syn_id; | |
1887 if (flags & HL_TRANSP) | |
1888 { | |
1889 if (current_state.ga_len < 2) | |
1890 { | |
1891 cur_si->si_attr = 0; | |
1892 cur_si->si_trans_id = 0; | |
1893 } | |
1894 else | |
1895 { | |
1896 cur_si->si_attr = CUR_STATE( | |
1897 current_state.ga_len - 2).si_attr; | |
1898 cur_si->si_trans_id = CUR_STATE( | |
1899 current_state.ga_len - 2).si_trans_id; | |
1900 } | |
1901 } | |
1902 else | |
1903 cur_si->si_attr = syn_id2attr(syn_id); | |
1904 cur_si->si_cont_list = NULL; | |
1905 cur_si->si_next_list = next_list; | |
1906 check_keepend(); | |
1907 } | |
1908 else | |
1909 vim_free(next_list); | |
1910 } | |
1911 } | |
1912 } | |
1913 | |
1914 /* | |
205 | 1915 * 3. Check for patterns (only if no keyword found). |
7 | 1916 */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1917 if (syn_id == 0 && syn_block->b_syn_patterns.ga_len) |
7 | 1918 { |
1919 /* | |
1920 * If we didn't check for a match yet, or we are past it, check | |
1921 * for any match with a pattern. | |
1922 */ | |
1923 if (next_match_idx < 0 || next_match_col < (int)current_col) | |
1924 { | |
1925 /* | |
1926 * Check all relevant patterns for a match at this | |
1927 * position. This is complicated, because matching with a | |
1928 * pattern takes quite a bit of time, thus we want to | |
1929 * avoid doing it when it's not needed. | |
1930 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1931 next_match_idx = 0; // no match in this line yet |
7 | 1932 next_match_col = MAXCOL; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1933 for (idx = syn_block->b_syn_patterns.ga_len; --idx >= 0; ) |
7 | 1934 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1935 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 1936 if ( spp->sp_syncing == syncing |
1937 && (displaying || !(spp->sp_flags & HL_DISPLAY)) | |
1938 && (spp->sp_type == SPTYPE_MATCH | |
1939 || spp->sp_type == SPTYPE_START) | |
1940 && (current_next_list != NULL | |
1941 ? in_id_list(NULL, current_next_list, | |
1942 &spp->sp_syn, 0) | |
1943 : (cur_si == NULL | |
1944 ? !(spp->sp_flags & HL_CONTAINED) | |
1945 : in_id_list(cur_si, | |
1946 cur_si->si_cont_list, &spp->sp_syn, | |
1947 spp->sp_flags & HL_CONTAINED)))) | |
1948 { | |
6375 | 1949 int r; |
1950 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1951 // If we already tried matching in this line, and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1952 // there isn't a match before next_match_col, skip |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1953 // this item. |
7 | 1954 if (spp->sp_line_id == current_line_id |
1955 && spp->sp_startcol >= next_match_col) | |
1956 continue; | |
1957 spp->sp_line_id = current_line_id; | |
1958 | |
1959 lc_col = current_col - spp->sp_offsets[SPO_LC_OFF]; | |
1960 if (lc_col < 0) | |
1961 lc_col = 0; | |
1962 | |
1963 regmatch.rmm_ic = spp->sp_ic; | |
1964 regmatch.regprog = spp->sp_prog; | |
6375 | 1965 r = syn_regexec(®match, |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
1966 current_lnum, |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
1967 (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
|
1968 IF_SYN_TIME(&spp->sp_time)); |
6375 | 1969 spp->sp_prog = regmatch.regprog; |
1970 if (!r) | |
7 | 1971 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1972 // no match in this line, try another one |
7 | 1973 spp->sp_startcol = MAXCOL; |
1974 continue; | |
1975 } | |
1976 | |
1977 /* | |
1978 * Compute the first column of the match. | |
1979 */ | |
1980 syn_add_start_off(&pos, ®match, | |
1981 spp, SPO_MS_OFF, -1); | |
1982 if (pos.lnum > current_lnum) | |
1983 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1984 // must have used end of match in a next line, |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1985 // we can't handle that |
7 | 1986 spp->sp_startcol = MAXCOL; |
1987 continue; | |
1988 } | |
1989 startcol = pos.col; | |
1990 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1991 // remember the next column where this pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
1992 // matches in the current line |
7 | 1993 spp->sp_startcol = startcol; |
1994 | |
1995 /* | |
1996 * If a previously found match starts at a lower | |
1997 * column number, don't use this one. | |
1998 */ | |
1999 if (startcol >= next_match_col) | |
2000 continue; | |
2001 | |
2002 /* | |
2003 * If we matched this pattern at this position | |
2004 * before, skip it. Must retry in the next | |
2005 * column, because it may match from there. | |
2006 */ | |
2007 if (did_match_already(idx, &zero_width_next_ga)) | |
2008 { | |
2009 try_next_column = TRUE; | |
2010 continue; | |
2011 } | |
2012 | |
2013 endpos.lnum = regmatch.endpos[0].lnum; | |
2014 endpos.col = regmatch.endpos[0].col; | |
2015 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2016 // Compute the highlight start. |
7 | 2017 syn_add_start_off(&hl_startpos, ®match, |
2018 spp, SPO_HS_OFF, -1); | |
2019 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2020 // Compute the region start. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2021 // Default is to use the end of the match. |
7 | 2022 syn_add_end_off(&eos_pos, ®match, |
2023 spp, SPO_RS_OFF, 0); | |
2024 | |
2025 /* | |
2026 * Grab the external submatches before they get | |
2027 * overwritten. Reference count doesn't change. | |
2028 */ | |
2029 unref_extmatch(cur_extmatch); | |
2030 cur_extmatch = re_extmatch_out; | |
2031 re_extmatch_out = NULL; | |
2032 | |
2033 flags = 0; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2034 eoe_pos.lnum = 0; // avoid warning |
7 | 2035 eoe_pos.col = 0; |
2036 end_idx = 0; | |
2037 hl_endpos.lnum = 0; | |
2038 | |
2039 /* | |
2040 * For a "oneline" the end must be found in the | |
2041 * same line too. Search for it after the end of | |
2042 * the match with the start pattern. Set the | |
2043 * resulting end positions at the same time. | |
2044 */ | |
2045 if (spp->sp_type == SPTYPE_START | |
2046 && (spp->sp_flags & HL_ONELINE)) | |
2047 { | |
2048 lpos_T startpos; | |
2049 | |
2050 startpos = endpos; | |
2051 find_endpos(idx, &startpos, &endpos, &hl_endpos, | |
2052 &flags, &eoe_pos, &end_idx, cur_extmatch); | |
2053 if (endpos.lnum == 0) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2054 continue; // not found |
7 | 2055 } |
2056 | |
2057 /* | |
2058 * For a "match" the size must be > 0 after the | |
2059 * end offset needs has been added. Except when | |
2060 * syncing. | |
2061 */ | |
2062 else if (spp->sp_type == SPTYPE_MATCH) | |
2063 { | |
2064 syn_add_end_off(&hl_endpos, ®match, spp, | |
2065 SPO_HE_OFF, 0); | |
2066 syn_add_end_off(&endpos, ®match, spp, | |
2067 SPO_ME_OFF, 0); | |
2068 if (endpos.lnum == current_lnum | |
2069 && (int)endpos.col + syncing < startcol) | |
2070 { | |
2071 /* | |
2072 * If an empty string is matched, may need | |
2073 * to try matching again at next column. | |
2074 */ | |
2075 if (regmatch.startpos[0].col | |
2076 == regmatch.endpos[0].col) | |
2077 try_next_column = TRUE; | |
2078 continue; | |
2079 } | |
2080 } | |
2081 | |
2082 /* | |
2083 * keep the best match so far in next_match_* | |
2084 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2085 // Highlighting must start after startpos and end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2086 // before endpos. |
7 | 2087 if (hl_startpos.lnum == current_lnum |
2088 && (int)hl_startpos.col < startcol) | |
2089 hl_startpos.col = startcol; | |
2090 limit_pos_zero(&hl_endpos, &endpos); | |
2091 | |
2092 next_match_idx = idx; | |
2093 next_match_col = startcol; | |
2094 next_match_m_endpos = endpos; | |
2095 next_match_h_endpos = hl_endpos; | |
2096 next_match_h_startpos = hl_startpos; | |
2097 next_match_flags = flags; | |
2098 next_match_eos_pos = eos_pos; | |
2099 next_match_eoe_pos = eoe_pos; | |
2100 next_match_end_idx = end_idx; | |
2101 unref_extmatch(next_match_extmatch); | |
2102 next_match_extmatch = cur_extmatch; | |
2103 cur_extmatch = NULL; | |
2104 } | |
2105 } | |
2106 } | |
2107 | |
2108 /* | |
2109 * If we found a match at the current column, use it. | |
2110 */ | |
2111 if (next_match_idx >= 0 && next_match_col == (int)current_col) | |
2112 { | |
2113 synpat_T *lspp; | |
2114 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2115 // When a zero-width item matched which has a nextgroup, |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2116 // 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
|
2117 lspp = &(SYN_ITEMS(syn_block)[next_match_idx]); |
7 | 2118 if (next_match_m_endpos.lnum == current_lnum |
2119 && next_match_m_endpos.col == current_col | |
2120 && lspp->sp_next_list != NULL) | |
2121 { | |
2122 current_next_list = lspp->sp_next_list; | |
2123 current_next_flags = lspp->sp_flags; | |
2124 keep_next_list = TRUE; | |
2125 zero_width_next_list = TRUE; | |
2126 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2127 // Add the index to a list, so that we can check |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2128 // later that we don't match it again (and cause an |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2129 // endless loop). |
7 | 2130 if (ga_grow(&zero_width_next_ga, 1) == OK) |
2131 { | |
2132 ((int *)(zero_width_next_ga.ga_data)) | |
2133 [zero_width_next_ga.ga_len++] = next_match_idx; | |
2134 } | |
2135 next_match_idx = -1; | |
2136 } | |
2137 else | |
2138 cur_si = push_next_match(cur_si); | |
2139 found_match = TRUE; | |
2140 } | |
2141 } | |
2142 } | |
2143 | |
2144 /* | |
2145 * Handle searching for nextgroup match. | |
2146 */ | |
2147 if (current_next_list != NULL && !keep_next_list) | |
2148 { | |
2149 /* | |
2150 * If a nextgroup was not found, continue looking for one if: | |
2151 * - this is an empty line and the "skipempty" option was given | |
2152 * - we are on white space and the "skipwhite" option was given | |
2153 */ | |
2154 if (!found_match) | |
2155 { | |
2156 line = syn_getcurline(); | |
2157 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
|
2158 && VIM_ISWHITE(line[current_col])) |
7 | 2159 || ((current_next_flags & HL_SKIPEMPTY) |
2160 && *line == NUL)) | |
2161 break; | |
2162 } | |
2163 | |
2164 /* | |
2165 * If a nextgroup was found: Use it, and continue looking for | |
2166 * contained matches. | |
2167 * If a nextgroup was not found: Continue looking for a normal | |
2168 * match. | |
2169 * When did set current_next_list for a zero-width item and no | |
2170 * match was found don't loop (would get stuck). | |
2171 */ | |
2172 current_next_list = NULL; | |
2173 next_match_idx = -1; | |
2174 if (!zero_width_next_list) | |
2175 found_match = TRUE; | |
2176 } | |
2177 | |
2178 } while (found_match); | |
2179 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2180 restore_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2181 |
7 | 2182 /* |
2183 * Use attributes from the current state, if within its highlighting. | |
2184 * If not, use attributes from the current-but-one state, etc. | |
2185 */ | |
2186 current_attr = 0; | |
2187 #ifdef FEAT_EVAL | |
2188 current_id = 0; | |
2189 current_trans_id = 0; | |
2190 #endif | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2191 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2192 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
|
2193 current_seqnr = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2194 #endif |
7 | 2195 if (cur_si != NULL) |
2196 { | |
221 | 2197 #ifndef FEAT_EVAL |
2198 int current_trans_id = 0; | |
2199 #endif | |
7 | 2200 for (idx = current_state.ga_len - 1; idx >= 0; --idx) |
2201 { | |
2202 sip = &CUR_STATE(idx); | |
2203 if ((current_lnum > sip->si_h_startpos.lnum | |
2204 || (current_lnum == sip->si_h_startpos.lnum | |
2205 && current_col >= sip->si_h_startpos.col)) | |
2206 && (sip->si_h_endpos.lnum == 0 | |
2207 || current_lnum < sip->si_h_endpos.lnum | |
2208 || (current_lnum == sip->si_h_endpos.lnum | |
2209 && current_col < sip->si_h_endpos.col))) | |
2210 { | |
2211 current_attr = sip->si_attr; | |
2212 #ifdef FEAT_EVAL | |
2213 current_id = sip->si_id; | |
221 | 2214 #endif |
7 | 2215 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
|
2216 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2217 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
|
2218 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
|
2219 current_sub_char = sip->si_cchar; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2220 #endif |
7 | 2221 break; |
2222 } | |
2223 } | |
2224 | |
221 | 2225 if (can_spell != NULL) |
2226 { | |
2227 struct sp_syn sps; | |
2228 | |
2229 /* | |
2230 * set "can_spell" to TRUE if spell checking is supposed to be | |
2231 * done in the current item. | |
2232 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2233 if (syn_block->b_spell_cluster_id == 0) |
227 | 2234 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2235 // There is no @Spell cluster: Do spelling for items without |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2236 // @NoSpell cluster. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2237 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
|
2238 || current_trans_id == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2239 *can_spell = (syn_block->b_syn_spell != SYNSPL_NOTOP); |
227 | 2240 else |
2241 { | |
2242 sps.inc_tag = 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2243 sps.id = syn_block->b_nospell_cluster_id; |
227 | 2244 sps.cont_in_list = NULL; |
2245 *can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0); | |
2246 } | |
2247 } | |
221 | 2248 else |
2249 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2250 // The @Spell cluster is defined: Do spelling in items with |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2251 // the @Spell cluster. But not when @NoSpell is also there. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2252 // At the toplevel only spell check when ":syn spell toplevel" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2253 // was used. |
320 | 2254 if (current_trans_id == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2255 *can_spell = (syn_block->b_syn_spell == SYNSPL_TOP); |
320 | 2256 else |
2257 { | |
2258 sps.inc_tag = 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2259 sps.id = syn_block->b_spell_cluster_id; |
320 | 2260 sps.cont_in_list = NULL; |
2261 *can_spell = in_id_list(sip, sip->si_cont_list, &sps, 0); | |
2262 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2263 if (syn_block->b_nospell_cluster_id != 0) |
320 | 2264 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2265 sps.id = syn_block->b_nospell_cluster_id; |
320 | 2266 if (in_id_list(sip, sip->si_cont_list, &sps, 0)) |
2267 *can_spell = FALSE; | |
2268 } | |
2269 } | |
221 | 2270 } |
2271 } | |
2272 | |
2273 | |
7 | 2274 /* |
2275 * Check for end of current state (and the states before it) at the | |
2276 * next column. Don't do this for syncing, because we would miss a | |
2277 * single character match. | |
2278 * First check if the current state ends at the current column. It | |
2279 * may be for an empty match and a containing item might end in the | |
2280 * current column. | |
2281 */ | |
1504 | 2282 if (!syncing && !keep_state) |
7 | 2283 { |
2284 check_state_ends(); | |
442 | 2285 if (current_state.ga_len > 0 |
2286 && syn_getcurline()[current_col] != NUL) | |
7 | 2287 { |
2288 ++current_col; | |
2289 check_state_ends(); | |
2290 --current_col; | |
2291 } | |
2292 } | |
2293 } | |
221 | 2294 else if (can_spell != NULL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2295 // Default: Only do spelling when there is no @Spell cluster or when |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2296 // ":syn spell toplevel" was used. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2297 *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
|
2298 ? (syn_block->b_spell_cluster_id == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2299 : (syn_block->b_syn_spell == SYNSPL_TOP); |
7 | 2300 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2301 // nextgroup ends at end of line, unless "skipnl" or "skipempty" present |
7 | 2302 if (current_next_list != NULL |
13375
33f514c94943
patch 8.0.1561: crash with rust syntax highligting
Christian Brabandt <cb@256bit.org>
parents:
13339
diff
changeset
|
2303 && (line = syn_getcurline())[current_col] != NUL |
33f514c94943
patch 8.0.1561: crash with rust syntax highligting
Christian Brabandt <cb@256bit.org>
parents:
13339
diff
changeset
|
2304 && line[current_col + 1] == NUL |
7 | 2305 && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) |
2306 current_next_list = NULL; | |
2307 | |
2308 if (zero_width_next_ga.ga_len > 0) | |
2309 ga_clear(&zero_width_next_ga); | |
2310 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2311 // No longer need external matches. But keep next_match_extmatch. |
7 | 2312 unref_extmatch(re_extmatch_out); |
2313 re_extmatch_out = NULL; | |
2314 unref_extmatch(cur_extmatch); | |
2315 | |
2316 return current_attr; | |
2317 } | |
2318 | |
2319 | |
2320 /* | |
2321 * Check if we already matched pattern "idx" at the current column. | |
2322 */ | |
2323 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2324 did_match_already(int idx, garray_T *gap) |
7 | 2325 { |
2326 int i; | |
2327 | |
2328 for (i = current_state.ga_len; --i >= 0; ) | |
2329 if (CUR_STATE(i).si_m_startcol == (int)current_col | |
2330 && CUR_STATE(i).si_m_lnum == (int)current_lnum | |
2331 && CUR_STATE(i).si_idx == idx) | |
2332 return TRUE; | |
2333 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2334 // Zero-width matches with a nextgroup argument are not put on the syntax |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2335 // stack, and can only be matched once anyway. |
7 | 2336 for (i = gap->ga_len; --i >= 0; ) |
2337 if (((int *)(gap->ga_data))[i] == idx) | |
2338 return TRUE; | |
2339 | |
2340 return FALSE; | |
2341 } | |
2342 | |
2343 /* | |
2344 * Push the next match onto the stack. | |
2345 */ | |
2346 static stateitem_T * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2347 push_next_match(stateitem_T *cur_si) |
7 | 2348 { |
2349 synpat_T *spp; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2350 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2351 int save_flags; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2352 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2353 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2354 spp = &(SYN_ITEMS(syn_block)[next_match_idx]); |
7 | 2355 |
2356 /* | |
2357 * Push the item in current_state stack; | |
2358 */ | |
2359 if (push_current_state(next_match_idx) == OK) | |
2360 { | |
2361 /* | |
2362 * If it's a start-skip-end type that crosses lines, figure out how | |
2363 * much it continues in this line. Otherwise just fill in the length. | |
2364 */ | |
2365 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2366 cur_si->si_h_startpos = next_match_h_startpos; | |
2367 cur_si->si_m_startcol = current_col; | |
2368 cur_si->si_m_lnum = current_lnum; | |
2369 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
|
2370 #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
|
2371 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
|
2372 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
|
2373 if (current_state.ga_len > 1) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2374 cur_si->si_flags |= |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2375 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
|
2376 #endif |
7 | 2377 cur_si->si_next_list = spp->sp_next_list; |
2378 cur_si->si_extmatch = ref_extmatch(next_match_extmatch); | |
2379 if (spp->sp_type == SPTYPE_START && !(spp->sp_flags & HL_ONELINE)) | |
2380 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2381 // Try to find the end pattern in the current line |
7 | 2382 update_si_end(cur_si, (int)(next_match_m_endpos.col), TRUE); |
2383 check_keepend(); | |
2384 } | |
2385 else | |
2386 { | |
2387 cur_si->si_m_endpos = next_match_m_endpos; | |
2388 cur_si->si_h_endpos = next_match_h_endpos; | |
2389 cur_si->si_ends = TRUE; | |
2390 cur_si->si_flags |= next_match_flags; | |
2391 cur_si->si_eoe_pos = next_match_eoe_pos; | |
2392 cur_si->si_end_idx = next_match_end_idx; | |
2393 } | |
2394 if (keepend_level < 0 && (cur_si->si_flags & HL_KEEPEND)) | |
2395 keepend_level = current_state.ga_len - 1; | |
2396 check_keepend(); | |
2397 update_si_attr(current_state.ga_len - 1); | |
2398 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2399 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2400 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
|
2401 #endif |
7 | 2402 /* |
2403 * If the start pattern has another highlight group, push another item | |
2404 * on the stack for the start pattern. | |
2405 */ | |
2406 if ( spp->sp_type == SPTYPE_START | |
2407 && spp->sp_syn_match_id != 0 | |
2408 && push_current_state(next_match_idx) == OK) | |
2409 { | |
2410 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2411 cur_si->si_h_startpos = next_match_h_startpos; | |
2412 cur_si->si_m_startcol = current_col; | |
2413 cur_si->si_m_lnum = current_lnum; | |
2414 cur_si->si_m_endpos = next_match_eos_pos; | |
2415 cur_si->si_h_endpos = next_match_eos_pos; | |
2416 cur_si->si_ends = TRUE; | |
2417 cur_si->si_end_idx = 0; | |
2418 cur_si->si_flags = HL_MATCH; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2419 #ifdef FEAT_CONCEAL |
2418
da067045878f
Fix for "concealends". (Vince Negri)
Bram Moolenaar <bram@vim.org>
parents:
2401
diff
changeset
|
2420 cur_si->si_seqnr = next_seqnr++; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2421 cur_si->si_flags |= save_flags; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2422 if (cur_si->si_flags & HL_CONCEALENDS) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2423 cur_si->si_flags |= HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2424 #endif |
7 | 2425 cur_si->si_next_list = NULL; |
2426 check_keepend(); | |
2427 update_si_attr(current_state.ga_len - 1); | |
2428 } | |
2429 } | |
2430 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2431 next_match_idx = -1; // try other match next time |
7 | 2432 |
2433 return cur_si; | |
2434 } | |
2435 | |
2436 /* | |
2437 * Check for end of current state (and the states before it). | |
2438 */ | |
2439 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2440 check_state_ends(void) |
7 | 2441 { |
2442 stateitem_T *cur_si; | |
2863 | 2443 int had_extend; |
7 | 2444 |
2445 cur_si = &CUR_STATE(current_state.ga_len - 1); | |
2446 for (;;) | |
2447 { | |
2448 if (cur_si->si_ends | |
2449 && (cur_si->si_m_endpos.lnum < current_lnum | |
2450 || (cur_si->si_m_endpos.lnum == current_lnum | |
2451 && cur_si->si_m_endpos.col <= current_col))) | |
2452 { | |
2453 /* | |
2454 * If there is an end pattern group ID, highlight the end pattern | |
2455 * now. No need to pop the current item from the stack. | |
2456 * Only do this if the end pattern continues beyond the current | |
2457 * position. | |
2458 */ | |
2459 if (cur_si->si_end_idx | |
2460 && (cur_si->si_eoe_pos.lnum > current_lnum | |
2461 || (cur_si->si_eoe_pos.lnum == current_lnum | |
2462 && cur_si->si_eoe_pos.col > current_col))) | |
2463 { | |
2464 cur_si->si_idx = cur_si->si_end_idx; | |
2465 cur_si->si_end_idx = 0; | |
2466 cur_si->si_m_endpos = cur_si->si_eoe_pos; | |
2467 cur_si->si_h_endpos = cur_si->si_eoe_pos; | |
2468 cur_si->si_flags |= HL_MATCH; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2469 #ifdef FEAT_CONCEAL |
2418
da067045878f
Fix for "concealends". (Vince Negri)
Bram Moolenaar <bram@vim.org>
parents:
2401
diff
changeset
|
2470 cur_si->si_seqnr = next_seqnr++; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2471 if (cur_si->si_flags & HL_CONCEALENDS) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2472 cur_si->si_flags |= HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2473 #endif |
7 | 2474 update_si_attr(current_state.ga_len - 1); |
36 | 2475 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2476 // nextgroup= should not match in the end pattern |
2831 | 2477 current_next_list = NULL; |
2478 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2479 // what matches next may be different now, clear it |
36 | 2480 next_match_idx = 0; |
2481 next_match_col = MAXCOL; | |
7 | 2482 break; |
2483 } | |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2484 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2485 // handle next_list, unless at end of line and no "skipnl" or |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2486 // "skipempty" |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2487 current_next_list = cur_si->si_next_list; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2488 current_next_flags = cur_si->si_flags; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2489 if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2490 && syn_getcurline()[current_col] == NUL) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2491 current_next_list = NULL; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2492 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2493 // When the ended item has "extend", another item with |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2494 // "keepend" now needs to check for its end. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2495 had_extend = (cur_si->si_flags & HL_EXTEND); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2496 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2497 pop_current_state(); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2498 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2499 if (current_state.ga_len == 0) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2500 break; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2501 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2502 if (had_extend && keepend_level >= 0) |
7 | 2503 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2504 syn_update_ends(FALSE); |
7 | 2505 if (current_state.ga_len == 0) |
2506 break; | |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2507 } |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2508 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2509 cur_si = &CUR_STATE(current_state.ga_len - 1); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2510 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2511 /* |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2512 * Only for a region the search for the end continues after |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2513 * the end of the contained item. If the contained match |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2514 * included the end-of-line, break here, the region continues. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2515 * Don't do this when: |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2516 * - "keepend" is used for the contained item |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2517 * - not at the end of the line (could be end="x$"me=e-1). |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2518 * - "excludenl" is used (HL_HAS_EOL won't be set) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2519 */ |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2520 if (cur_si->si_idx >= 0 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2521 && SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2522 == SPTYPE_START |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2523 && !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2524 { |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2525 update_si_end(cur_si, (int)current_col, TRUE); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2526 check_keepend(); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2527 if ((current_next_flags & HL_HAS_EOL) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2528 && keepend_level < 0 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2529 && syn_getcurline()[current_col] == NUL) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28179
diff
changeset
|
2530 break; |
7 | 2531 } |
2532 } | |
2533 else | |
2534 break; | |
2535 } | |
2536 } | |
2537 | |
2538 /* | |
2539 * Update an entry in the current_state stack for a match or region. This | |
2540 * fills in si_attr, si_next_list and si_cont_list. | |
2541 */ | |
2542 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2543 update_si_attr(int idx) |
7 | 2544 { |
2545 stateitem_T *sip = &CUR_STATE(idx); | |
2546 synpat_T *spp; | |
2547 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2548 // This should not happen... |
1371 | 2549 if (sip->si_idx < 0) |
2550 return; | |
2551 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2552 spp = &(SYN_ITEMS(syn_block)[sip->si_idx]); |
7 | 2553 if (sip->si_flags & HL_MATCH) |
2554 sip->si_id = spp->sp_syn_match_id; | |
2555 else | |
2556 sip->si_id = spp->sp_syn.id; | |
2557 sip->si_attr = syn_id2attr(sip->si_id); | |
2558 sip->si_trans_id = sip->si_id; | |
2559 if (sip->si_flags & HL_MATCH) | |
2560 sip->si_cont_list = NULL; | |
2561 else | |
2562 sip->si_cont_list = spp->sp_cont_list; | |
2563 | |
2564 /* | |
2565 * For transparent items, take attr from outer item. | |
2566 * Also take cont_list, if there is none. | |
2567 * Don't do this for the matchgroup of a start or end pattern. | |
2568 */ | |
2569 if ((spp->sp_flags & HL_TRANSP) && !(sip->si_flags & HL_MATCH)) | |
2570 { | |
2571 if (idx == 0) | |
2572 { | |
2573 sip->si_attr = 0; | |
2574 sip->si_trans_id = 0; | |
2575 if (sip->si_cont_list == NULL) | |
2576 sip->si_cont_list = ID_LIST_ALL; | |
2577 } | |
2578 else | |
2579 { | |
2580 sip->si_attr = CUR_STATE(idx - 1).si_attr; | |
2581 sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id; | |
2582 if (sip->si_cont_list == NULL) | |
2583 { | |
2584 sip->si_flags |= HL_TRANS_CONT; | |
2585 sip->si_cont_list = CUR_STATE(idx - 1).si_cont_list; | |
2586 } | |
2587 } | |
2588 } | |
2589 } | |
2590 | |
2591 /* | |
2592 * Check the current stack for patterns with "keepend" flag. | |
2593 * Propagate the match-end to contained items, until a "skipend" item is found. | |
2594 */ | |
2595 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2596 check_keepend(void) |
7 | 2597 { |
2598 int i; | |
2599 lpos_T maxpos; | |
991 | 2600 lpos_T maxpos_h; |
7 | 2601 stateitem_T *sip; |
2602 | |
2603 /* | |
2604 * This check can consume a lot of time; only do it from the level where | |
2605 * there really is a keepend. | |
2606 */ | |
2607 if (keepend_level < 0) | |
2608 return; | |
2609 | |
2610 /* | |
2611 * Find the last index of an "extend" item. "keepend" items before that | |
2612 * won't do anything. If there is no "extend" item "i" will be | |
2613 * "keepend_level" and all "keepend" items will work normally. | |
2614 */ | |
2615 for (i = current_state.ga_len - 1; i > keepend_level; --i) | |
2616 if (CUR_STATE(i).si_flags & HL_EXTEND) | |
2617 break; | |
2618 | |
2619 maxpos.lnum = 0; | |
1702 | 2620 maxpos.col = 0; |
991 | 2621 maxpos_h.lnum = 0; |
1702 | 2622 maxpos_h.col = 0; |
7 | 2623 for ( ; i < current_state.ga_len; ++i) |
2624 { | |
2625 sip = &CUR_STATE(i); | |
2626 if (maxpos.lnum != 0) | |
2627 { | |
2628 limit_pos_zero(&sip->si_m_endpos, &maxpos); | |
991 | 2629 limit_pos_zero(&sip->si_h_endpos, &maxpos_h); |
7 | 2630 limit_pos_zero(&sip->si_eoe_pos, &maxpos); |
2631 sip->si_ends = TRUE; | |
2632 } | |
991 | 2633 if (sip->si_ends && (sip->si_flags & HL_KEEPEND)) |
2634 { | |
2635 if (maxpos.lnum == 0 | |
7 | 2636 || maxpos.lnum > sip->si_m_endpos.lnum |
2637 || (maxpos.lnum == sip->si_m_endpos.lnum | |
991 | 2638 && maxpos.col > sip->si_m_endpos.col)) |
2639 maxpos = sip->si_m_endpos; | |
2640 if (maxpos_h.lnum == 0 | |
2641 || maxpos_h.lnum > sip->si_h_endpos.lnum | |
2642 || (maxpos_h.lnum == sip->si_h_endpos.lnum | |
2643 && maxpos_h.col > sip->si_h_endpos.col)) | |
2644 maxpos_h = sip->si_h_endpos; | |
2645 } | |
7 | 2646 } |
2647 } | |
2648 | |
2649 /* | |
2650 * Update an entry in the current_state stack for a start-skip-end pattern. | |
2651 * This finds the end of the current item, if it's in the current line. | |
2652 * | |
2653 * Return the flags for the matched END. | |
2654 */ | |
2655 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2656 update_si_end( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2657 stateitem_T *sip, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2658 int startcol, // where to start searching for the end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2659 int force) // when TRUE overrule a previous end |
7 | 2660 { |
2661 lpos_T startpos; | |
2662 lpos_T endpos; | |
2663 lpos_T hl_endpos; | |
2664 lpos_T end_endpos; | |
2665 int end_idx; | |
2666 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2667 // return quickly for a keyword |
1371 | 2668 if (sip->si_idx < 0) |
2669 return; | |
2670 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2671 // Don't update when it's already done. Can be a match of an end pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2672 // that started in a previous line. Watch out: can also be a "keepend" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2673 // from a containing item. |
7 | 2674 if (!force && sip->si_m_endpos.lnum >= current_lnum) |
2675 return; | |
2676 | |
2677 /* | |
2678 * We need to find the end of the region. It may continue in the next | |
2679 * line. | |
2680 */ | |
2681 end_idx = 0; | |
2682 startpos.lnum = current_lnum; | |
2683 startpos.col = startcol; | |
2684 find_endpos(sip->si_idx, &startpos, &endpos, &hl_endpos, | |
2685 &(sip->si_flags), &end_endpos, &end_idx, sip->si_extmatch); | |
2686 | |
2687 if (endpos.lnum == 0) | |
2688 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2689 // No end pattern matched. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2690 if (SYN_ITEMS(syn_block)[sip->si_idx].sp_flags & HL_ONELINE) |
7 | 2691 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2692 // a "oneline" never continues in the next line |
7 | 2693 sip->si_ends = TRUE; |
2694 sip->si_m_endpos.lnum = current_lnum; | |
2695 sip->si_m_endpos.col = (colnr_T)STRLEN(syn_getcurline()); | |
2696 } | |
2697 else | |
2698 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2699 // continues in the next line |
7 | 2700 sip->si_ends = FALSE; |
2701 sip->si_m_endpos.lnum = 0; | |
2702 } | |
2703 sip->si_h_endpos = sip->si_m_endpos; | |
2704 } | |
2705 else | |
2706 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2707 // match within this line |
7 | 2708 sip->si_m_endpos = endpos; |
2709 sip->si_h_endpos = hl_endpos; | |
2710 sip->si_eoe_pos = end_endpos; | |
2711 sip->si_ends = TRUE; | |
2712 sip->si_end_idx = end_idx; | |
2713 } | |
2714 } | |
2715 | |
2716 /* | |
2717 * Add a new state to the current state stack. | |
2718 * It is cleared and the index set to "idx". | |
2719 * Return FAIL if it's not possible (out of memory). | |
2720 */ | |
2721 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2722 push_current_state(int idx) |
7 | 2723 { |
2724 if (ga_grow(¤t_state, 1) == FAIL) | |
2725 return FAIL; | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
2726 CLEAR_POINTER(&CUR_STATE(current_state.ga_len)); |
7 | 2727 CUR_STATE(current_state.ga_len).si_idx = idx; |
2728 ++current_state.ga_len; | |
2729 return OK; | |
2730 } | |
2731 | |
2732 /* | |
2733 * Remove a state from the current_state stack. | |
2734 */ | |
2735 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2736 pop_current_state(void) |
7 | 2737 { |
2738 if (current_state.ga_len) | |
2739 { | |
2740 unref_extmatch(CUR_STATE(current_state.ga_len - 1).si_extmatch); | |
2741 --current_state.ga_len; | |
2742 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2743 // after the end of a pattern, try matching a keyword or pattern |
7 | 2744 next_match_idx = -1; |
2745 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2746 // if first state with "keepend" is popped, reset keepend_level |
7 | 2747 if (keepend_level >= current_state.ga_len) |
2748 keepend_level = -1; | |
2749 } | |
2750 | |
2751 /* | |
2752 * Find the end of a start/skip/end syntax region after "startpos". | |
2753 * Only checks one line. | |
2754 * Also handles a match item that continued from a previous line. | |
2755 * If not found, the syntax item continues in the next line. m_endpos->lnum | |
2756 * will be 0. | |
2757 * If found, the end of the region and the end of the highlighting is | |
2758 * computed. | |
2759 */ | |
2760 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2761 find_endpos( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2762 int idx, // index of the pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2763 lpos_T *startpos, // where to start looking for an END match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2764 lpos_T *m_endpos, // return: end of match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2765 lpos_T *hl_endpos, // return: end of highlighting |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2766 long *flagsp, // return: flags of matching END |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2767 lpos_T *end_endpos, // return: end of end pattern match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2768 int *end_idx, // return: group ID for end pat. match, or 0 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2769 reg_extmatch_T *start_ext) // submatches from the start pattern |
7 | 2770 { |
2771 colnr_T matchcol; | |
2772 synpat_T *spp, *spp_skip; | |
2773 int start_idx; | |
2774 int best_idx; | |
2775 regmmatch_T regmatch; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2776 regmmatch_T best_regmatch; // startpos/endpos of best match |
7 | 2777 lpos_T pos; |
2778 int had_match = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2779 char_u buf_chartab[32]; // chartab array for syn option iskyeyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2780 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2781 // just in case we are invoked for a keyword |
1371 | 2782 if (idx < 0) |
2783 return; | |
2784 | |
7 | 2785 /* |
2786 * Check for being called with a START pattern. | |
2787 * Can happen with a match that continues to the next line, because it | |
2788 * contained a region. | |
2789 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2790 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 2791 if (spp->sp_type != SPTYPE_START) |
2792 { | |
2793 *hl_endpos = *startpos; | |
2794 return; | |
2795 } | |
2796 | |
2797 /* | |
2798 * Find the SKIP or first END pattern after the last START pattern. | |
2799 */ | |
2800 for (;;) | |
2801 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2802 spp = &(SYN_ITEMS(syn_block)[idx]); |
7 | 2803 if (spp->sp_type != SPTYPE_START) |
2804 break; | |
2805 ++idx; | |
2806 } | |
2807 | |
2808 /* | |
2809 * Lookup the SKIP pattern (if present) | |
2810 */ | |
2811 if (spp->sp_type == SPTYPE_SKIP) | |
2812 { | |
2813 spp_skip = spp; | |
2814 ++idx; | |
2815 } | |
2816 else | |
2817 spp_skip = NULL; | |
2818 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2819 // Setup external matches for syn_regexec(). |
7 | 2820 unref_extmatch(re_extmatch_in); |
2821 re_extmatch_in = ref_extmatch(start_ext); | |
2822 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2823 matchcol = startpos->col; // start looking for a match at sstart |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2824 start_idx = idx; // remember the first END pattern. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2825 best_regmatch.startpos[0].col = 0; // avoid compiler warning |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2826 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2827 // use syntax iskeyword option |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2828 save_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2829 |
7 | 2830 for (;;) |
2831 { | |
2832 /* | |
2833 * Find end pattern that matches first after "matchcol". | |
2834 */ | |
2835 best_idx = -1; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2836 for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx) |
7 | 2837 { |
2838 int lc_col = matchcol; | |
6375 | 2839 int r; |
7 | 2840 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2841 spp = &(SYN_ITEMS(syn_block)[idx]); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2842 if (spp->sp_type != SPTYPE_END) // past last END pattern |
7 | 2843 break; |
2844 lc_col -= spp->sp_offsets[SPO_LC_OFF]; | |
2845 if (lc_col < 0) | |
2846 lc_col = 0; | |
2847 | |
2848 regmatch.rmm_ic = spp->sp_ic; | |
2849 regmatch.regprog = spp->sp_prog; | |
6375 | 2850 r = syn_regexec(®match, startpos->lnum, lc_col, |
2851 IF_SYN_TIME(&spp->sp_time)); | |
2852 spp->sp_prog = regmatch.regprog; | |
2853 if (r) | |
7 | 2854 { |
2855 if (best_idx == -1 || regmatch.startpos[0].col | |
2856 < best_regmatch.startpos[0].col) | |
2857 { | |
2858 best_idx = idx; | |
2859 best_regmatch.startpos[0] = regmatch.startpos[0]; | |
2860 best_regmatch.endpos[0] = regmatch.endpos[0]; | |
2861 } | |
2862 } | |
2863 } | |
2864 | |
2865 /* | |
2866 * If all end patterns have been tried, and there is no match, the | |
2867 * item continues until end-of-line. | |
2868 */ | |
2869 if (best_idx == -1) | |
2870 break; | |
2871 | |
2872 /* | |
2873 * If the skip pattern matches before the end pattern, | |
2874 * continue searching after the skip pattern. | |
2875 */ | |
2876 if (spp_skip != NULL) | |
2877 { | |
2878 int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF]; | |
6375 | 2879 int r; |
7 | 2880 |
2881 if (lc_col < 0) | |
2882 lc_col = 0; | |
2883 regmatch.rmm_ic = spp_skip->sp_ic; | |
2884 regmatch.regprog = spp_skip->sp_prog; | |
6375 | 2885 r = syn_regexec(®match, startpos->lnum, lc_col, |
2886 IF_SYN_TIME(&spp_skip->sp_time)); | |
2887 spp_skip->sp_prog = regmatch.regprog; | |
2888 if (r && regmatch.startpos[0].col | |
7 | 2889 <= best_regmatch.startpos[0].col) |
2890 { | |
7500
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
2891 int line_len; |
ef568437e49a
commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents:
7467
diff
changeset
|
2892 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2893 // Add offset to skip pattern match |
7 | 2894 syn_add_end_off(&pos, ®match, spp_skip, SPO_ME_OFF, 1); |
2895 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2896 // If the skip pattern goes on to the next line, there is no |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2897 // match with an end pattern in this line. |
7 | 2898 if (pos.lnum > startpos->lnum) |
2899 break; | |
2900 | |
34540
9e093c96dff6
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Christian Brabandt <cb@256bit.org>
parents:
32120
diff
changeset
|
2901 line_len = ml_get_buf_len(syn_buf, startpos->lnum); |
7 | 2902 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2903 // take care of an empty match or negative offset |
7 | 2904 if (pos.col <= matchcol) |
2905 ++matchcol; | |
2906 else if (pos.col <= regmatch.endpos[0].col) | |
2907 matchcol = pos.col; | |
2908 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2909 // Be careful not to jump over the NUL at the end-of-line |
7 | 2910 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
|
2911 matchcol < line_len && matchcol < pos.col; |
7 | 2912 ++matchcol) |
2913 ; | |
2914 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2915 // 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
|
2916 if (matchcol >= line_len) |
7 | 2917 break; |
2918 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2919 continue; // start with first end pattern again |
7 | 2920 } |
2921 } | |
2922 | |
2923 /* | |
2924 * Match from start pattern to end pattern. | |
2925 * Correct for match and highlight offset of end pattern. | |
2926 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
2927 spp = &(SYN_ITEMS(syn_block)[best_idx]); |
7 | 2928 syn_add_end_off(m_endpos, &best_regmatch, spp, SPO_ME_OFF, 1); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2929 // can't end before the start |
7 | 2930 if (m_endpos->lnum == startpos->lnum && m_endpos->col < startpos->col) |
2931 m_endpos->col = startpos->col; | |
2932 | |
2933 syn_add_end_off(end_endpos, &best_regmatch, spp, SPO_HE_OFF, 1); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2934 // can't end before the start |
7 | 2935 if (end_endpos->lnum == startpos->lnum |
2936 && end_endpos->col < startpos->col) | |
2937 end_endpos->col = startpos->col; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2938 // can't end after the match |
7 | 2939 limit_pos(end_endpos, m_endpos); |
2940 | |
2941 /* | |
2942 * If the end group is highlighted differently, adjust the pointers. | |
2943 */ | |
2944 if (spp->sp_syn_match_id != spp->sp_syn.id && spp->sp_syn_match_id != 0) | |
2945 { | |
2946 *end_idx = best_idx; | |
2947 if (spp->sp_off_flags & (1 << (SPO_RE_OFF + SPO_COUNT))) | |
2948 { | |
2949 hl_endpos->lnum = best_regmatch.endpos[0].lnum; | |
2950 hl_endpos->col = best_regmatch.endpos[0].col; | |
2951 } | |
2952 else | |
2953 { | |
2954 hl_endpos->lnum = best_regmatch.startpos[0].lnum; | |
2955 hl_endpos->col = best_regmatch.startpos[0].col; | |
2956 } | |
2957 hl_endpos->col += spp->sp_offsets[SPO_RE_OFF]; | |
2958 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2959 // can't end before the start |
7 | 2960 if (hl_endpos->lnum == startpos->lnum |
2961 && hl_endpos->col < startpos->col) | |
2962 hl_endpos->col = startpos->col; | |
2963 limit_pos(hl_endpos, m_endpos); | |
2964 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2965 // now the match ends where the highlighting ends, it is turned |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2966 // into the matchgroup for the end |
7 | 2967 *m_endpos = *hl_endpos; |
2968 } | |
2969 else | |
2970 { | |
2971 *end_idx = 0; | |
2972 *hl_endpos = *end_endpos; | |
2973 } | |
2974 | |
2975 *flagsp = spp->sp_flags; | |
2976 | |
2977 had_match = TRUE; | |
2978 break; | |
2979 } | |
2980 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2981 // no match for an END pattern in this line |
7 | 2982 if (!had_match) |
2983 m_endpos->lnum = 0; | |
2984 | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2985 restore_chartab(buf_chartab); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
2986 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
2987 // Remove external matches. |
7 | 2988 unref_extmatch(re_extmatch_in); |
2989 re_extmatch_in = NULL; | |
2990 } | |
2991 | |
2992 /* | |
2993 * Limit "pos" not to be after "limit". | |
2994 */ | |
2995 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2996 limit_pos(lpos_T *pos, lpos_T *limit) |
7 | 2997 { |
2998 if (pos->lnum > limit->lnum) | |
2999 *pos = *limit; | |
3000 else if (pos->lnum == limit->lnum && pos->col > limit->col) | |
3001 pos->col = limit->col; | |
3002 } | |
3003 | |
3004 /* | |
3005 * Limit "pos" not to be after "limit", unless pos->lnum is zero. | |
3006 */ | |
3007 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3008 limit_pos_zero( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3009 lpos_T *pos, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3010 lpos_T *limit) |
7 | 3011 { |
3012 if (pos->lnum == 0) | |
3013 *pos = *limit; | |
3014 else | |
3015 limit_pos(pos, limit); | |
3016 } | |
3017 | |
3018 /* | |
3019 * Add offset to matched text for end of match or highlight. | |
3020 */ | |
3021 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3022 syn_add_end_off( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3023 lpos_T *result, // returned position |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3024 regmmatch_T *regmatch, // start/end of match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3025 synpat_T *spp, // matched pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3026 int idx, // index of offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3027 int extra) // extra chars for offset to start |
7 | 3028 { |
3029 int col; | |
1624 | 3030 int off; |
3031 char_u *base; | |
3032 char_u *p; | |
7 | 3033 |
3034 if (spp->sp_off_flags & (1 << idx)) | |
3035 { | |
3036 result->lnum = regmatch->startpos[0].lnum; | |
1624 | 3037 col = regmatch->startpos[0].col; |
3038 off = spp->sp_offsets[idx] + extra; | |
7 | 3039 } |
3040 else | |
3041 { | |
3042 result->lnum = regmatch->endpos[0].lnum; | |
3043 col = regmatch->endpos[0].col; | |
1624 | 3044 off = spp->sp_offsets[idx]; |
3045 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3046 // Don't go past the end of the line. Matters for "rs=e+2" when there |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3047 // is a matchgroup. Watch out for match with last NL in the buffer. |
1624 | 3048 if (result->lnum > syn_buf->b_ml.ml_line_count) |
3049 col = 0; | |
3050 else if (off != 0) | |
3051 { | |
3052 base = ml_get_buf(syn_buf, result->lnum, FALSE); | |
3053 p = base + col; | |
3054 if (off > 0) | |
3055 { | |
3056 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
|
3057 MB_PTR_ADV(p); |
1624 | 3058 } |
3059 else if (off < 0) | |
3060 { | |
3061 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
|
3062 MB_PTR_BACK(base, p); |
1624 | 3063 } |
3064 col = (int)(p - base); | |
3065 } | |
3066 result->col = col; | |
7 | 3067 } |
3068 | |
3069 /* | |
3070 * Add offset to matched text for start of match or highlight. | |
3071 * Avoid resulting column to become negative. | |
3072 */ | |
3073 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3074 syn_add_start_off( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3075 lpos_T *result, // returned position |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3076 regmmatch_T *regmatch, // start/end of match |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3077 synpat_T *spp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3078 int idx, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3079 int extra) // extra chars for offset to end |
7 | 3080 { |
3081 int col; | |
1624 | 3082 int off; |
3083 char_u *base; | |
3084 char_u *p; | |
7 | 3085 |
3086 if (spp->sp_off_flags & (1 << (idx + SPO_COUNT))) | |
3087 { | |
3088 result->lnum = regmatch->endpos[0].lnum; | |
1624 | 3089 col = regmatch->endpos[0].col; |
3090 off = spp->sp_offsets[idx] + extra; | |
7 | 3091 } |
3092 else | |
3093 { | |
3094 result->lnum = regmatch->startpos[0].lnum; | |
3095 col = regmatch->startpos[0].col; | |
1624 | 3096 off = spp->sp_offsets[idx]; |
3097 } | |
2092
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3098 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
|
3099 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3100 // a "\n" at the end of the pattern may take us below the last line |
2092
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3101 result->lnum = syn_buf->b_ml.ml_line_count; |
34540
9e093c96dff6
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Christian Brabandt <cb@256bit.org>
parents:
32120
diff
changeset
|
3102 col = ml_get_buf_len(syn_buf, result->lnum); |
2092
98cc757f7e3d
updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
3103 } |
1624 | 3104 if (off != 0) |
3105 { | |
3106 base = ml_get_buf(syn_buf, result->lnum, FALSE); | |
3107 p = base + col; | |
3108 if (off > 0) | |
3109 { | |
3110 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
|
3111 MB_PTR_ADV(p); |
1624 | 3112 } |
3113 else if (off < 0) | |
3114 { | |
3115 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
|
3116 MB_PTR_BACK(base, p); |
1624 | 3117 } |
3118 col = (int)(p - base); | |
3119 } | |
3120 result->col = col; | |
7 | 3121 } |
3122 | |
3123 /* | |
3124 * Get current line in syntax buffer. | |
3125 */ | |
3126 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3127 syn_getcurline(void) |
7 | 3128 { |
3129 return ml_get_buf(syn_buf, current_lnum, FALSE); | |
3130 } | |
3131 | |
3132 /* | |
410 | 3133 * Call vim_regexec() to find a match with "rmp" in "syn_buf". |
7 | 3134 * Returns TRUE when there is a match. |
3135 */ | |
3136 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3137 syn_regexec( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3138 regmmatch_T *rmp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3139 linenr_T lnum, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3140 colnr_T col, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3141 syn_time_T *st UNUSED) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3142 { |
29218
48b36959a4fc
patch 8.2.5128: syntax disabled when using synID() in searchpair() skip expr
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
3143 int r; |
48b36959a4fc
patch 8.2.5128: syntax disabled when using synID() in searchpair() skip expr
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
3144 int timed_out = FALSE; |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
3145 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3146 proftime_T pt; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3147 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3148 if (syn_time_on) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3149 profile_start(&pt); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3150 #endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3151 |
14161
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
13976
diff
changeset
|
3152 if (rmp->regprog == NULL) |
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
13976
diff
changeset
|
3153 // This can happen if a previous call to vim_regexec_multi() tried to |
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
13976
diff
changeset
|
3154 // use the NFA engine, which resulted in NFA_TOO_EXPENSIVE, and |
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
13976
diff
changeset
|
3155 // compiling the pattern with the other engine fails. |
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
13976
diff
changeset
|
3156 return FALSE; |
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
13976
diff
changeset
|
3157 |
410 | 3158 rmp->rmm_maxcol = syn_buf->b_p_smc; |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28475
diff
changeset
|
3159 r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, &timed_out); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3160 |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
3161 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3162 if (syn_time_on) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3163 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3164 profile_end(&pt); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3165 profile_add(&st->total, &pt); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3166 if (profile_cmp(&pt, &st->slowest) < 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3167 st->slowest = pt; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3168 ++st->count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3169 if (r > 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3170 ++st->match; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3171 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3172 #endif |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3173 #ifdef FEAT_RELTIME |
29218
48b36959a4fc
patch 8.2.5128: syntax disabled when using synID() in searchpair() skip expr
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
3174 if (timed_out && redrawtime_limit_set && !syn_win->w_s->b_syn_slow) |
14366
1c79c92a642e
patch 8.1.0198: there is no hint that syntax is disabled for 'redrawtime'
Christian Brabandt <cb@256bit.org>
parents:
14161
diff
changeset
|
3175 { |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3176 syn_win->w_s->b_syn_slow = TRUE; |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3177 msg(_("'redrawtime' exceeded, syntax highlighting disabled")); |
14366
1c79c92a642e
patch 8.1.0198: there is no hint that syntax is disabled for 'redrawtime'
Christian Brabandt <cb@256bit.org>
parents:
14161
diff
changeset
|
3178 } |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3179 #endif |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3180 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3181 if (r > 0) |
7 | 3182 { |
3183 rmp->startpos[0].lnum += lnum; | |
3184 rmp->endpos[0].lnum += lnum; | |
3185 return TRUE; | |
3186 } | |
3187 return FALSE; | |
3188 } | |
3189 | |
3190 /* | |
3191 * Check one position in a line for a matching keyword. | |
3192 * 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
|
3193 * Return its ID if found, 0 otherwise. |
7 | 3194 */ |
3195 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3196 check_keyword_id( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3197 char_u *line, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3198 int startcol, // position in line to check for keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3199 int *endcolp, // return: character after found keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3200 long *flagsp, // return: flags of matching keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3201 short **next_listp, // return: next_list of matching keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3202 stateitem_T *cur_si, // item at the top of the stack |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3203 int *ccharp UNUSED) // conceal substitution char |
7 | 3204 { |
134 | 3205 keyentry_T *kp; |
3206 char_u *kwp; | |
7 | 3207 int round; |
134 | 3208 int kwlen; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3209 char_u keyword[MAXKEYWLEN + 1]; // assume max. keyword len is 80 |
134 | 3210 hashtab_T *ht; |
3211 hashitem_T *hi; | |
7 | 3212 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3213 // Find first character after the keyword. First character was already |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3214 // checked. |
134 | 3215 kwp = line + startcol; |
3216 kwlen = 0; | |
7 | 3217 do |
3218 { | |
3219 if (has_mbyte) | |
474 | 3220 kwlen += (*mb_ptr2len)(kwp + kwlen); |
7 | 3221 else |
134 | 3222 ++kwlen; |
3223 } | |
4043 | 3224 while (vim_iswordp_buf(kwp + kwlen, syn_buf)); |
134 | 3225 |
3226 if (kwlen > MAXKEYWLEN) | |
7 | 3227 return 0; |
3228 | |
3229 /* | |
3230 * Must make a copy of the keyword, so we can add a NUL and make it | |
3231 * lowercase. | |
3232 */ | |
419 | 3233 vim_strncpy(keyword, kwp, kwlen); |
7 | 3234 |
3235 /* | |
3236 * Try twice: | |
3237 * 1. matching case | |
3238 * 2. ignoring case | |
3239 */ | |
3240 for (round = 1; round <= 2; ++round) | |
3241 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3242 ht = round == 1 ? &syn_block->b_keywtab : &syn_block->b_keywtab_ic; |
134 | 3243 if (ht->ht_used == 0) |
7 | 3244 continue; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3245 if (round == 2) // ignore case |
134 | 3246 (void)str_foldcase(kwp, kwlen, keyword, MAXKEYWLEN + 1); |
7 | 3247 |
3248 /* | |
134 | 3249 * Find keywords that match. There can be several with different |
3250 * attributes. | |
7 | 3251 * When current_next_list is non-zero accept only that group, otherwise: |
3252 * Accept a not-contained keyword at toplevel. | |
3253 * Accept a keyword at other levels only if it is in the contains list. | |
3254 */ | |
134 | 3255 hi = hash_find(ht, keyword); |
3256 if (!HASHITEM_EMPTY(hi)) | |
3257 for (kp = HI2KE(hi); kp != NULL; kp = kp->ke_next) | |
7 | 3258 { |
134 | 3259 if (current_next_list != 0 |
3260 ? in_id_list(NULL, current_next_list, &kp->k_syn, 0) | |
3261 : (cur_si == NULL | |
3262 ? !(kp->flags & HL_CONTAINED) | |
3263 : in_id_list(cur_si, cur_si->si_cont_list, | |
3264 &kp->k_syn, kp->flags & HL_CONTAINED))) | |
3265 { | |
3266 *endcolp = startcol + kwlen; | |
3267 *flagsp = kp->flags; | |
3268 *next_listp = kp->next_list; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3269 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3270 *ccharp = kp->k_char; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3271 #endif |
134 | 3272 return kp->k_syn.id; |
3273 } | |
7 | 3274 } |
3275 } | |
3276 return 0; | |
3277 } | |
3278 | |
3279 /* | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3280 * Handle ":syntax conceal" command. |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3281 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3282 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3283 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
|
3284 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3285 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3286 char_u *arg = eap->arg; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3287 char_u *next; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3288 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3289 eap->nextcmd = find_nextcmd(arg); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3290 if (eap->skip) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3291 return; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3292 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3293 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
|
3294 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
|
3295 { |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3296 if (curwin->w_s->b_syn_conceal) |
27561
c796016c6204
patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27553
diff
changeset
|
3297 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
|
3298 else |
27561
c796016c6204
patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27553
diff
changeset
|
3299 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
|
3300 } |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3301 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
|
3302 curwin->w_s->b_syn_conceal = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3303 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
|
3304 curwin->w_s->b_syn_conceal = FALSE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3305 else |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3306 semsg(_(e_illegal_argument_str_2), arg); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3307 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3308 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3309 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3310 /* |
7 | 3311 * Handle ":syntax case" command. |
3312 */ | |
3313 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3314 syn_cmd_case(exarg_T *eap, int syncing UNUSED) |
7 | 3315 { |
3316 char_u *arg = eap->arg; | |
3317 char_u *next; | |
3318 | |
3319 eap->nextcmd = find_nextcmd(arg); | |
3320 if (eap->skip) | |
3321 return; | |
3322 | |
3323 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
|
3324 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
|
3325 { |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3326 if (curwin->w_s->b_syn_ic) |
27561
c796016c6204
patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27553
diff
changeset
|
3327 msg("syntax case ignore"); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3328 else |
27561
c796016c6204
patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27553
diff
changeset
|
3329 msg("syntax case match"); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3330 } |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3331 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
|
3332 curwin->w_s->b_syn_ic = FALSE; |
7 | 3333 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
|
3334 curwin->w_s->b_syn_ic = TRUE; |
7 | 3335 else |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3336 semsg(_(e_illegal_argument_str_2), arg); |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3337 } |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3338 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3339 /* |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3340 * Handle ":syntax foldlevel" command. |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3341 */ |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3342 static void |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3343 syn_cmd_foldlevel(exarg_T *eap, int syncing UNUSED) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3344 { |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3345 char_u *arg = eap->arg; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3346 char_u *arg_end; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3347 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3348 eap->nextcmd = find_nextcmd(arg); |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3349 if (eap->skip) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3350 return; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3351 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3352 if (*arg == NUL) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3353 { |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3354 switch (curwin->w_s->b_syn_foldlevel) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3355 { |
27553
0ea5147a95f7
patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
3356 case SYNFLD_START: msg("syntax foldlevel start"); break; |
0ea5147a95f7
patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
3357 case SYNFLD_MINIMUM: msg("syntax foldlevel minimum"); break; |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3358 default: break; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3359 } |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3360 return; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3361 } |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3362 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3363 arg_end = skiptowhite(arg); |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3364 if (STRNICMP(arg, "start", 5) == 0 && arg_end - arg == 5) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3365 curwin->w_s->b_syn_foldlevel = SYNFLD_START; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3366 else if (STRNICMP(arg, "minimum", 7) == 0 && arg_end - arg == 7) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3367 curwin->w_s->b_syn_foldlevel = SYNFLD_MINIMUM; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3368 else |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3369 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3370 semsg(_(e_illegal_argument_str_2), arg); |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3371 return; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3372 } |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3373 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3374 arg = skipwhite(arg_end); |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3375 if (*arg != NUL) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3376 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3377 semsg(_(e_illegal_argument_str_2), arg); |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3378 } |
7 | 3379 } |
3380 | |
3381 /* | |
419 | 3382 * Handle ":syntax spell" command. |
3383 */ | |
3384 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3385 syn_cmd_spell(exarg_T *eap, int syncing UNUSED) |
419 | 3386 { |
3387 char_u *arg = eap->arg; | |
3388 char_u *next; | |
3389 | |
3390 eap->nextcmd = find_nextcmd(arg); | |
3391 if (eap->skip) | |
3392 return; | |
3393 | |
3394 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
|
3395 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
|
3396 { |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3397 if (curwin->w_s->b_syn_spell == SYNSPL_TOP) |
27553
0ea5147a95f7
patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
3398 msg("syntax spell toplevel"); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3399 else if (curwin->w_s->b_syn_spell == SYNSPL_NOTOP) |
27553
0ea5147a95f7
patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
3400 msg("syntax spell notoplevel"); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3401 else |
27553
0ea5147a95f7
patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
3402 msg("syntax spell default"); |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3403 } |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
3404 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
|
3405 curwin->w_s->b_syn_spell = SYNSPL_TOP; |
419 | 3406 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
|
3407 curwin->w_s->b_syn_spell = SYNSPL_NOTOP; |
1064 | 3408 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
|
3409 curwin->w_s->b_syn_spell = SYNSPL_DEFAULT; |
419 | 3410 else |
6880 | 3411 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3412 semsg(_(e_illegal_argument_str_2), arg); |
6880 | 3413 return; |
3414 } | |
3415 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3416 // assume spell checking changed, force a redraw |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
3417 redraw_win_later(curwin, UPD_NOT_VALID); |
419 | 3418 } |
3419 | |
3420 /* | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3421 * Handle ":syntax iskeyword" command. |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3422 */ |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3423 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3424 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
|
3425 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3426 char_u *arg = eap->arg; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3427 char_u save_chartab[32]; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3428 char_u *save_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3429 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3430 if (eap->skip) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3431 return; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3432 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3433 arg = skipwhite(arg); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3434 if (*arg == NUL) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3435 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3436 msg_puts("\n"); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3437 if (curwin->w_s->b_syn_isk != empty_option) |
14366
1c79c92a642e
patch 8.1.0198: there is no hint that syntax is disabled for 'redrawtime'
Christian Brabandt <cb@256bit.org>
parents:
14161
diff
changeset
|
3438 { |
27561
c796016c6204
patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents:
27553
diff
changeset
|
3439 msg_puts("syntax iskeyword "); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3440 msg_outtrans(curwin->w_s->b_syn_isk); |
14366
1c79c92a642e
patch 8.1.0198: there is no hint that syntax is disabled for 'redrawtime'
Christian Brabandt <cb@256bit.org>
parents:
14161
diff
changeset
|
3441 } |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3442 else |
14366
1c79c92a642e
patch 8.1.0198: there is no hint that syntax is disabled for 'redrawtime'
Christian Brabandt <cb@256bit.org>
parents:
14161
diff
changeset
|
3443 msg_outtrans((char_u *)_("syntax iskeyword not set")); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3444 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3445 else |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3446 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3447 if (STRNICMP(arg, "clear", 5) == 0) |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3448 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3449 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
|
3450 (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3451 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
|
3452 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3453 else |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3454 { |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3455 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
|
3456 save_isk = curbuf->b_p_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3457 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
|
3458 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3459 buf_init_chartab(curbuf, FALSE); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3460 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
|
3461 (size_t)32); |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3462 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
|
3463 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
|
3464 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
|
3465 curbuf->b_p_isk = save_isk; |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3466 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3467 } |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
3468 redraw_win_later(curwin, UPD_NOT_VALID); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3469 } |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3470 |
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3471 /* |
7 | 3472 * Clear all syntax info for one buffer. |
3473 */ | |
3474 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3475 syntax_clear(synblock_T *block) |
7 | 3476 { |
3477 int i; | |
3478 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3479 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
|
3480 #ifdef FEAT_RELTIME |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3481 block->b_syn_slow = FALSE; // clear previous timeout |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3482 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3483 block->b_syn_ic = FALSE; // Use case, by default |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3484 block->b_syn_foldlevel = SYNFLD_START; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3485 block->b_syn_spell = SYNSPL_DEFAULT; // default spell checking |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3486 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
|
3487 #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
|
3488 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
|
3489 #endif |
7 | 3490 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3491 // free the keywords |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3492 clear_keywtab(&block->b_keywtab); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3493 clear_keywtab(&block->b_keywtab_ic); |
7 | 3494 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3495 // free the syntax patterns |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3496 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
|
3497 syn_clear_pattern(block, i); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3498 ga_clear(&block->b_syn_patterns); |
7 | 3499 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3500 // free the syntax clusters |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3501 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
|
3502 syn_clear_cluster(block, i); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3503 ga_clear(&block->b_syn_clusters); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3504 block->b_spell_cluster_id = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3505 block->b_nospell_cluster_id = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3506 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3507 block->b_syn_sync_flags = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3508 block->b_syn_sync_minlines = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3509 block->b_syn_sync_maxlines = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3510 block->b_syn_sync_linebreaks = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3511 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
3512 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
|
3513 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
|
3514 VIM_CLEAR(block->b_syn_linecont_pat); |
7 | 3515 #ifdef FEAT_FOLDING |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3516 block->b_syn_folditems = 0; |
7 | 3517 #endif |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
3518 clear_string_option(&block->b_syn_isk); |
7 | 3519 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3520 // free the stored states |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3521 syn_stack_free_all(block); |
7 | 3522 invalidate_current_state(); |
2743 | 3523 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3524 // Reset the counter for ":syn include" |
2743 | 3525 running_syn_inc_tag = 0; |
7 | 3526 } |
3527 | |
3528 /* | |
2253
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3529 * 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
|
3530 */ |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3531 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3532 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
|
3533 { |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3534 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
|
3535 { |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3536 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
|
3537 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
|
3538 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
|
3539 } |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3540 } |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3541 |
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
3542 /* |
7 | 3543 * Clear syncing info for one buffer. |
3544 */ | |
3545 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3546 syntax_sync_clear(void) |
7 | 3547 { |
3548 int i; | |
3549 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3550 // free the syntax patterns |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3551 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
|
3552 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
|
3553 syn_remove_pattern(curwin->w_s, i); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3554 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3555 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
|
3556 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
|
3557 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
|
3558 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
|
3559 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
3560 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
|
3561 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
|
3562 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
|
3563 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
|
3564 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3565 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. |
7 | 3566 } |
3567 | |
3568 /* | |
3569 * Remove one pattern from the buffer's pattern list. | |
3570 */ | |
3571 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3572 syn_remove_pattern( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3573 synblock_T *block, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3574 int idx) |
7 | 3575 { |
3576 synpat_T *spp; | |
3577 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3578 spp = &(SYN_ITEMS(block)[idx]); |
7 | 3579 #ifdef FEAT_FOLDING |
3580 if (spp->sp_flags & HL_FOLD) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3581 --block->b_syn_folditems; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3582 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3583 syn_clear_pattern(block, idx); |
7 | 3584 mch_memmove(spp, spp + 1, |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3585 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
|
3586 --block->b_syn_patterns.ga_len; |
7 | 3587 } |
3588 | |
3589 /* | |
3590 * Clear and free one syntax pattern. When clearing all, must be called from | |
3591 * last to first! | |
3592 */ | |
3593 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3594 syn_clear_pattern(synblock_T *block, int i) |
7 | 3595 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3596 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
|
3597 vim_regfree(SYN_ITEMS(block)[i].sp_prog); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3598 // 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
|
3599 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
|
3600 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3601 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
|
3602 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
|
3603 vim_free(SYN_ITEMS(block)[i].sp_syn.cont_in_list); |
7 | 3604 } |
3605 } | |
3606 | |
3607 /* | |
3608 * Clear and free one syntax cluster. | |
3609 */ | |
3610 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3611 syn_clear_cluster(synblock_T *block, int i) |
7 | 3612 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3613 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
|
3614 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
|
3615 vim_free(SYN_CLSTR(block)[i].scl_list); |
7 | 3616 } |
3617 | |
3618 /* | |
3619 * Handle ":syntax clear" command. | |
3620 */ | |
3621 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3622 syn_cmd_clear(exarg_T *eap, int syncing) |
7 | 3623 { |
3624 char_u *arg = eap->arg; | |
3625 char_u *arg_end; | |
3626 int id; | |
3627 | |
3628 eap->nextcmd = find_nextcmd(arg); | |
3629 if (eap->skip) | |
3630 return; | |
3631 | |
3632 /* | |
3633 * We have to disable this within ":syn include @group filename", | |
3634 * because otherwise @group would get deleted. | |
3635 * Only required for Vim 5.x syntax files, 6.0 ones don't contain ":syn | |
3636 * clear". | |
3637 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3638 if (curwin->w_s->b_syn_topgrp != 0) |
7 | 3639 return; |
3640 | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3641 if (ends_excmd2(eap->cmd, arg)) |
7 | 3642 { |
3643 /* | |
3644 * No argument: Clear all syntax items. | |
3645 */ | |
3646 if (syncing) | |
3647 syntax_sync_clear(); | |
3648 else | |
3649 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3650 syntax_clear(curwin->w_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3651 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
|
3652 do_unlet((char_u *)"b:current_syntax", TRUE); |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
3653 do_unlet((char_u *)"w:current_syntax", TRUE); |
7 | 3654 } |
3655 } | |
3656 else | |
3657 { | |
3658 /* | |
3659 * Clear the group IDs that are in the argument. | |
3660 */ | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3661 while (!ends_excmd2(eap->cmd, arg)) |
7 | 3662 { |
3663 arg_end = skiptowhite(arg); | |
3664 if (*arg == '@') | |
3665 { | |
3666 id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1)); | |
3667 if (id == 0) | |
3668 { | |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31231
diff
changeset
|
3669 semsg(_(e_no_such_syntax_cluster_str_1), arg); |
7 | 3670 break; |
3671 } | |
3672 else | |
3673 { | |
3674 /* | |
3675 * We can't physically delete a cluster without changing | |
3676 * the IDs of other clusters, so we do the next best thing | |
3677 * and make it empty. | |
3678 */ | |
3679 short scl_id = id - SYNID_CLUSTER; | |
3680 | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
3681 VIM_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list); |
7 | 3682 } |
3683 } | |
3684 else | |
3685 { | |
3686 id = syn_namen2id(arg, (int)(arg_end - arg)); | |
3687 if (id == 0) | |
3688 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
3689 semsg(_(e_no_such_highlight_group_name_str), arg); |
7 | 3690 break; |
3691 } | |
3692 else | |
3693 syn_clear_one(id, syncing); | |
3694 } | |
3695 arg = skipwhite(arg_end); | |
3696 } | |
3697 } | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
3698 redraw_curbuf_later(UPD_SOME_VALID); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3699 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. |
7 | 3700 } |
3701 | |
3702 /* | |
3703 * Clear one syntax group for the current buffer. | |
3704 */ | |
3705 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3706 syn_clear_one(int id, int syncing) |
7 | 3707 { |
3708 synpat_T *spp; | |
3709 int idx; | |
3710 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3711 // Clear keywords only when not ":syn sync clear group-name" |
7 | 3712 if (!syncing) |
3713 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3714 (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
|
3715 (void)syn_clear_keyword(id, &curwin->w_s->b_keywtab_ic); |
7 | 3716 } |
3717 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3718 // clear the patterns for "id" |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3719 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
|
3720 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3721 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
7 | 3722 if (spp->sp_syn.id != id || spp->sp_syncing != syncing) |
3723 continue; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3724 syn_remove_pattern(curwin->w_s, idx); |
7 | 3725 } |
3726 } | |
3727 | |
3728 /* | |
3729 * Handle ":syntax on" command. | |
3730 */ | |
3731 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3732 syn_cmd_on(exarg_T *eap, int syncing UNUSED) |
7 | 3733 { |
3734 syn_cmd_onoff(eap, "syntax"); | |
3735 } | |
3736 | |
3737 /* | |
3738 * Handle ":syntax enable" command. | |
3739 */ | |
3740 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3741 syn_cmd_enable(exarg_T *eap, int syncing UNUSED) |
7 | 3742 { |
26199
eaa97adb0732
patch 8.2.3631: "syntax enable" does not work properly in Vim9 context
Bram Moolenaar <Bram@vim.org>
parents:
25521
diff
changeset
|
3743 set_internal_string_var((char_u *)"g:syntax_cmd", (char_u *)"enable"); |
7 | 3744 syn_cmd_onoff(eap, "syntax"); |
148 | 3745 do_unlet((char_u *)"g:syntax_cmd", TRUE); |
7 | 3746 } |
3747 | |
3748 /* | |
3749 * Handle ":syntax reset" command. | |
8815
50d9fb580ffe
commit https://github.com/vim/vim/commit/8bc189e81aa98ba4aebb03a9dc9527a210fce816
Christian Brabandt <cb@256bit.org>
parents:
8806
diff
changeset
|
3750 * It actually resets highlighting, not syntax. |
7 | 3751 */ |
3752 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3753 syn_cmd_reset(exarg_T *eap, int syncing UNUSED) |
7 | 3754 { |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
3755 set_nextcmd(eap, eap->arg); |
7 | 3756 if (!eap->skip) |
3757 { | |
26199
eaa97adb0732
patch 8.2.3631: "syntax enable" does not work properly in Vim9 context
Bram Moolenaar <Bram@vim.org>
parents:
25521
diff
changeset
|
3758 set_internal_string_var((char_u *)"g:syntax_cmd", (char_u *)"reset"); |
7 | 3759 do_cmdline_cmd((char_u *)"runtime! syntax/syncolor.vim"); |
148 | 3760 do_unlet((char_u *)"g:syntax_cmd", TRUE); |
7 | 3761 } |
3762 } | |
3763 | |
3764 /* | |
3765 * Handle ":syntax manual" command. | |
3766 */ | |
3767 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3768 syn_cmd_manual(exarg_T *eap, int syncing UNUSED) |
7 | 3769 { |
3770 syn_cmd_onoff(eap, "manual"); | |
3771 } | |
3772 | |
3773 /* | |
3774 * Handle ":syntax off" command. | |
3775 */ | |
3776 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3777 syn_cmd_off(exarg_T *eap, int syncing UNUSED) |
7 | 3778 { |
3779 syn_cmd_onoff(eap, "nosyntax"); | |
3780 } | |
3781 | |
3782 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3783 syn_cmd_onoff(exarg_T *eap, char *name) |
7 | 3784 { |
3785 char_u buf[100]; | |
3786 | |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
3787 set_nextcmd(eap, eap->arg); |
7 | 3788 if (!eap->skip) |
3789 { | |
3790 STRCPY(buf, "so "); | |
274 | 3791 vim_snprintf((char *)buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name); |
7 | 3792 do_cmdline_cmd(buf); |
3793 } | |
3794 } | |
3795 | |
3796 /* | |
3797 * Handle ":syntax [list]" command: list current syntax words. | |
3798 */ | |
3799 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3800 syn_cmd_list( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3801 exarg_T *eap, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3802 int syncing) // when TRUE: list syncing items |
7 | 3803 { |
3804 char_u *arg = eap->arg; | |
3805 int id; | |
3806 char_u *arg_end; | |
3807 | |
3808 eap->nextcmd = find_nextcmd(arg); | |
3809 if (eap->skip) | |
3810 return; | |
3811 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3812 if (!syntax_present(curwin)) |
7 | 3813 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3814 msg(_(msg_no_items)); |
7 | 3815 return; |
3816 } | |
3817 | |
3818 if (syncing) | |
3819 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3820 if (curwin->w_s->b_syn_sync_flags & SF_CCOMMENT) |
7 | 3821 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3822 msg_puts(_("syncing on C-style comments")); |
7 | 3823 syn_lines_msg(); |
3824 syn_match_msg(); | |
3825 return; | |
3826 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3827 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
|
3828 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3829 if (curwin->w_s->b_syn_sync_minlines == 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3830 msg_puts(_("no syncing")); |
7 | 3831 else |
3832 { | |
22928
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3833 if (curwin->w_s->b_syn_sync_minlines == MAXLNUM) |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3834 msg_puts(_("syncing starts at the first line")); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3835 else |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3836 { |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3837 msg_puts(_("syncing starts ")); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3838 msg_outnum(curwin->w_s->b_syn_sync_minlines); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3839 msg_puts(_(" lines before top line")); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3840 } |
7 | 3841 syn_match_msg(); |
3842 } | |
3843 return; | |
3844 } | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3845 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
|
3846 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
|
3847 || 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
|
3848 || curwin->w_s->b_syn_sync_linebreaks > 0) |
7 | 3849 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3850 msg_puts(_("\nsyncing on items")); |
7 | 3851 syn_lines_msg(); |
3852 syn_match_msg(); | |
3853 } | |
3854 } | |
3855 else | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3856 msg_puts_title(_("\n--- Syntax items ---")); |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3857 if (ends_excmd2(eap->cmd, arg)) |
7 | 3858 { |
3859 /* | |
3860 * No argument: List all group IDs and all syntax clusters. | |
3861 */ | |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
3862 for (id = 1; id <= highlight_num_groups() && !got_int; ++id) |
7 | 3863 syn_list_one(id, syncing, FALSE); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3864 for (id = 0; id < curwin->w_s->b_syn_clusters.ga_len && !got_int; ++id) |
7 | 3865 syn_list_cluster(id); |
3866 } | |
3867 else | |
3868 { | |
3869 /* | |
3870 * List the group IDs and syntax clusters that are in the argument. | |
3871 */ | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3872 while (!ends_excmd2(eap->cmd, arg) && !got_int) |
7 | 3873 { |
3874 arg_end = skiptowhite(arg); | |
3875 if (*arg == '@') | |
3876 { | |
3877 id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1)); | |
3878 if (id == 0) | |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31231
diff
changeset
|
3879 semsg(_(e_no_such_syntax_cluster_str_2), arg); |
7 | 3880 else |
3881 syn_list_cluster(id - SYNID_CLUSTER); | |
3882 } | |
3883 else | |
3884 { | |
3885 id = syn_namen2id(arg, (int)(arg_end - arg)); | |
3886 if (id == 0) | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
3887 semsg(_(e_no_such_highlight_group_name_str), arg); |
7 | 3888 else |
3889 syn_list_one(id, syncing, TRUE); | |
3890 } | |
3891 arg = skipwhite(arg_end); | |
3892 } | |
3893 } | |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
3894 set_nextcmd(eap, arg); |
7 | 3895 } |
3896 | |
3897 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3898 syn_lines_msg(void) |
7 | 3899 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3900 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
|
3901 || curwin->w_s->b_syn_sync_minlines > 0) |
7 | 3902 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3903 msg_puts("; "); |
22928
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3904 if (curwin->w_s->b_syn_sync_minlines == MAXLNUM) |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3905 msg_puts(_("from the first line")); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3906 else |
7 | 3907 { |
22928
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3908 if (curwin->w_s->b_syn_sync_minlines > 0) |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3909 { |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3910 msg_puts(_("minimal ")); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3911 msg_outnum(curwin->w_s->b_syn_sync_minlines); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3912 if (curwin->w_s->b_syn_sync_maxlines) |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3913 msg_puts(", "); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3914 } |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3915 if (curwin->w_s->b_syn_sync_maxlines > 0) |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3916 { |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3917 msg_puts(_("maximal ")); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3918 msg_outnum(curwin->w_s->b_syn_sync_maxlines); |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3919 } |
de6c242ec236
patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents:
22258
diff
changeset
|
3920 msg_puts(_(" lines before top line")); |
7 | 3921 } |
3922 } | |
3923 } | |
3924 | |
3925 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3926 syn_match_msg(void) |
7 | 3927 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3928 if (curwin->w_s->b_syn_sync_linebreaks > 0) |
7 | 3929 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3930 msg_puts(_("; match ")); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3931 msg_outnum(curwin->w_s->b_syn_sync_linebreaks); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3932 msg_puts(_(" line breaks")); |
7 | 3933 } |
3934 } | |
3935 | |
3936 static int last_matchgroup; | |
3937 | |
3938 struct name_list | |
3939 { | |
3940 int flag; | |
3941 char *name; | |
3942 }; | |
3943 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
3944 static void syn_list_flags(struct name_list *nl, int flags, int attr); |
7 | 3945 |
3946 /* | |
3947 * List one syntax item, for ":syntax" or "syntax list syntax_name". | |
3948 */ | |
3949 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3950 syn_list_one( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3951 int id, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3952 int syncing, // when TRUE: list syncing items |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3953 int link_only) // when TRUE; list link-only too |
7 | 3954 { |
3955 int attr; | |
3956 int idx; | |
3957 int did_header = FALSE; | |
3958 synpat_T *spp; | |
3959 static struct name_list namelist1[] = | |
3960 { | |
3961 {HL_DISPLAY, "display"}, | |
3962 {HL_CONTAINED, "contained"}, | |
3963 {HL_ONELINE, "oneline"}, | |
3964 {HL_KEEPEND, "keepend"}, | |
3965 {HL_EXTEND, "extend"}, | |
3966 {HL_EXCLUDENL, "excludenl"}, | |
3967 {HL_TRANSP, "transparent"}, | |
3968 {HL_FOLD, "fold"}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3969 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3970 {HL_CONCEAL, "conceal"}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3971 {HL_CONCEALENDS, "concealends"}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3972 #endif |
7 | 3973 {0, NULL} |
3974 }; | |
3975 static struct name_list namelist2[] = | |
3976 { | |
3977 {HL_SKIPWHITE, "skipwhite"}, | |
3978 {HL_SKIPNL, "skipnl"}, | |
3979 {HL_SKIPEMPTY, "skipempty"}, | |
3980 {0, NULL} | |
3981 }; | |
3982 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3983 attr = HL_ATTR(HLF_D); // highlight like directories |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3984 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3985 // list the keywords for "id" |
7 | 3986 if (!syncing) |
3987 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3988 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
|
3989 did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab_ic, |
7 | 3990 did_header, attr); |
3991 } | |
3992 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
3993 // list the patterns for "id" |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3994 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
|
3995 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
3996 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
7 | 3997 if (spp->sp_syn.id != id || spp->sp_syncing != syncing) |
3998 continue; | |
3999 | |
4000 (void)syn_list_header(did_header, 999, id); | |
4001 did_header = TRUE; | |
4002 last_matchgroup = 0; | |
4003 if (spp->sp_type == SPTYPE_MATCH) | |
4004 { | |
4005 put_pattern("match", ' ', spp, attr); | |
4006 msg_putchar(' '); | |
4007 } | |
4008 else if (spp->sp_type == SPTYPE_START) | |
4009 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4010 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
|
4011 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
|
4012 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
|
4013 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
|
4014 while (idx < curwin->w_s->b_syn_patterns.ga_len |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4015 && SYN_ITEMS(curwin->w_s)[idx].sp_type == SPTYPE_END) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4016 put_pattern("end", '=', &SYN_ITEMS(curwin->w_s)[idx++], attr); |
7 | 4017 --idx; |
4018 msg_putchar(' '); | |
4019 } | |
4020 syn_list_flags(namelist1, spp->sp_flags, attr); | |
4021 | |
4022 if (spp->sp_cont_list != NULL) | |
4023 put_id_list((char_u *)"contains", spp->sp_cont_list, attr); | |
4024 | |
4025 if (spp->sp_syn.cont_in_list != NULL) | |
4026 put_id_list((char_u *)"containedin", | |
4027 spp->sp_syn.cont_in_list, attr); | |
4028 | |
4029 if (spp->sp_next_list != NULL) | |
4030 { | |
4031 put_id_list((char_u *)"nextgroup", spp->sp_next_list, attr); | |
4032 syn_list_flags(namelist2, spp->sp_flags, attr); | |
4033 } | |
4034 if (spp->sp_flags & (HL_SYNC_HERE|HL_SYNC_THERE)) | |
4035 { | |
4036 if (spp->sp_flags & HL_SYNC_HERE) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4037 msg_puts_attr("grouphere", attr); |
7 | 4038 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4039 msg_puts_attr("groupthere", attr); |
7 | 4040 msg_putchar(' '); |
4041 if (spp->sp_sync_idx >= 0) | |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4042 msg_outtrans(highlight_group_name(SYN_ITEMS(curwin->w_s) |
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4043 [spp->sp_sync_idx].sp_syn.id - 1)); |
7 | 4044 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4045 msg_puts("NONE"); |
7 | 4046 msg_putchar(' '); |
4047 } | |
4048 } | |
4049 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4050 // list the link, if there is one |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4051 if (highlight_link_id(id - 1) && (did_header || link_only) && !got_int) |
7 | 4052 { |
4053 (void)syn_list_header(did_header, 999, id); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4054 msg_puts_attr("links to", attr); |
7 | 4055 msg_putchar(' '); |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4056 msg_outtrans(highlight_group_name(highlight_link_id(id - 1) - 1)); |
7 | 4057 } |
4058 } | |
4059 | |
4060 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4061 syn_list_flags(struct name_list *nlist, int flags, int attr) |
7 | 4062 { |
4063 int i; | |
4064 | |
3263 | 4065 for (i = 0; nlist[i].flag != 0; ++i) |
4066 if (flags & nlist[i].flag) | |
4067 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4068 msg_puts_attr(nlist[i].name, attr); |
7 | 4069 msg_putchar(' '); |
4070 } | |
4071 } | |
4072 | |
4073 /* | |
4074 * List one syntax cluster, for ":syntax" or "syntax list syntax_name". | |
4075 */ | |
4076 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4077 syn_list_cluster(int id) |
7 | 4078 { |
4079 int endcol = 15; | |
4080 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4081 // slight hack: roughly duplicate the guts of syn_list_header() |
7 | 4082 msg_putchar('\n'); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4083 msg_outtrans(SYN_CLSTR(curwin->w_s)[id].scl_name); |
7 | 4084 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4085 if (msg_col >= endcol) // output at least one space |
7 | 4086 endcol = msg_col + 1; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4087 if (Columns <= endcol) // avoid hang for tiny window |
7 | 4088 endcol = Columns - 1; |
4089 | |
4090 msg_advance(endcol); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4091 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
|
4092 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4093 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
|
4094 HL_ATTR(HLF_D)); |
7 | 4095 } |
4096 else | |
4097 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4098 msg_puts_attr("cluster", HL_ATTR(HLF_D)); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4099 msg_puts("=NONE"); |
7 | 4100 } |
4101 } | |
4102 | |
4103 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4104 put_id_list(char_u *name, short *list, int attr) |
7 | 4105 { |
4106 short *p; | |
4107 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4108 msg_puts_attr((char *)name, attr); |
7 | 4109 msg_putchar('='); |
4110 for (p = list; *p; ++p) | |
4111 { | |
4112 if (*p >= SYNID_ALLBUT && *p < SYNID_TOP) | |
4113 { | |
4114 if (p[1]) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4115 msg_puts("ALLBUT"); |
7 | 4116 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4117 msg_puts("ALL"); |
7 | 4118 } |
4119 else if (*p >= SYNID_TOP && *p < SYNID_CONTAINED) | |
4120 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4121 msg_puts("TOP"); |
7 | 4122 } |
4123 else if (*p >= SYNID_CONTAINED && *p < SYNID_CLUSTER) | |
4124 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4125 msg_puts("CONTAINED"); |
7 | 4126 } |
4127 else if (*p >= SYNID_CLUSTER) | |
4128 { | |
4129 short scl_id = *p - SYNID_CLUSTER; | |
4130 | |
4131 msg_putchar('@'); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4132 msg_outtrans(SYN_CLSTR(curwin->w_s)[scl_id].scl_name); |
7 | 4133 } |
4134 else | |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4135 msg_outtrans(highlight_group_name(*p - 1)); |
7 | 4136 if (p[1]) |
4137 msg_putchar(','); | |
4138 } | |
4139 msg_putchar(' '); | |
4140 } | |
4141 | |
4142 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4143 put_pattern( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4144 char *s, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4145 int c, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4146 synpat_T *spp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4147 int attr) |
7 | 4148 { |
4149 long n; | |
4150 int mask; | |
4151 int first; | |
4152 static char *sepchars = "/+=-#@\"|'^&"; | |
4153 int i; | |
4154 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4155 // May have to write "matchgroup=group" |
7 | 4156 if (last_matchgroup != spp->sp_syn_match_id) |
4157 { | |
4158 last_matchgroup = spp->sp_syn_match_id; | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4159 msg_puts_attr("matchgroup", attr); |
7 | 4160 msg_putchar('='); |
4161 if (last_matchgroup == 0) | |
4162 msg_outtrans((char_u *)"NONE"); | |
4163 else | |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
4164 msg_outtrans(highlight_group_name(last_matchgroup - 1)); |
7 | 4165 msg_putchar(' '); |
4166 } | |
4167 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4168 // output the name of the pattern and an '=' or ' ' |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4169 msg_puts_attr(s, attr); |
7 | 4170 msg_putchar(c); |
4171 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4172 // output the pattern, in between a char that is not in the pattern |
7 | 4173 for (i = 0; vim_strchr(spp->sp_pattern, sepchars[i]) != NULL; ) |
4174 if (sepchars[++i] == NUL) | |
4175 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4176 i = 0; // no good char found, just use the first one |
7 | 4177 break; |
4178 } | |
4179 msg_putchar(sepchars[i]); | |
4180 msg_outtrans(spp->sp_pattern); | |
4181 msg_putchar(sepchars[i]); | |
4182 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4183 // output any pattern options |
7 | 4184 first = TRUE; |
4185 for (i = 0; i < SPO_COUNT; ++i) | |
4186 { | |
4187 mask = (1 << i); | |
4188 if (spp->sp_off_flags & (mask + (mask << SPO_COUNT))) | |
4189 { | |
4190 if (!first) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4191 msg_putchar(','); // separate with commas |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4192 msg_puts(spo_name_tab[i]); |
7 | 4193 n = spp->sp_offsets[i]; |
4194 if (i != SPO_LC_OFF) | |
4195 { | |
4196 if (spp->sp_off_flags & mask) | |
4197 msg_putchar('s'); | |
4198 else | |
4199 msg_putchar('e'); | |
4200 if (n > 0) | |
4201 msg_putchar('+'); | |
4202 } | |
4203 if (n || i == SPO_LC_OFF) | |
4204 msg_outnum(n); | |
4205 first = FALSE; | |
4206 } | |
4207 } | |
4208 msg_putchar(' '); | |
4209 } | |
4210 | |
4211 /* | |
4212 * List or clear the keywords for one syntax group. | |
4213 * Return TRUE if the header has been printed. | |
4214 */ | |
4215 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4216 syn_list_keywords( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4217 int id, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4218 hashtab_T *ht, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4219 int did_header, // header has already been printed |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4220 int attr) |
7 | 4221 { |
4222 int outlen; | |
134 | 4223 hashitem_T *hi; |
4224 keyentry_T *kp; | |
4225 int todo; | |
7 | 4226 int prev_contained = 0; |
4227 short *prev_next_list = NULL; | |
4228 short *prev_cont_in_list = NULL; | |
4229 int prev_skipnl = 0; | |
4230 int prev_skipwhite = 0; | |
4231 int prev_skipempty = 0; | |
4232 | |
4233 /* | |
4234 * Unfortunately, this list of keywords is not sorted on alphabet but on | |
4235 * hash value... | |
4236 */ | |
835 | 4237 todo = (int)ht->ht_used; |
134 | 4238 for (hi = ht->ht_array; todo > 0 && !got_int; ++hi) |
4239 { | |
4240 if (!HASHITEM_EMPTY(hi)) | |
4241 { | |
4242 --todo; | |
4243 for (kp = HI2KE(hi); kp != NULL && !got_int; kp = kp->ke_next) | |
7 | 4244 { |
134 | 4245 if (kp->k_syn.id == id) |
7 | 4246 { |
134 | 4247 if (prev_contained != (kp->flags & HL_CONTAINED) |
4248 || prev_skipnl != (kp->flags & HL_SKIPNL) | |
4249 || prev_skipwhite != (kp->flags & HL_SKIPWHITE) | |
4250 || prev_skipempty != (kp->flags & HL_SKIPEMPTY) | |
4251 || prev_cont_in_list != kp->k_syn.cont_in_list | |
4252 || prev_next_list != kp->next_list) | |
4253 outlen = 9999; | |
4254 else | |
4255 outlen = (int)STRLEN(kp->keyword); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4256 // output "contained" and "nextgroup" on each line |
134 | 4257 if (syn_list_header(did_header, outlen, id)) |
4258 { | |
4259 prev_contained = 0; | |
4260 prev_next_list = NULL; | |
4261 prev_cont_in_list = NULL; | |
4262 prev_skipnl = 0; | |
4263 prev_skipwhite = 0; | |
4264 prev_skipempty = 0; | |
4265 } | |
4266 did_header = TRUE; | |
4267 if (prev_contained != (kp->flags & HL_CONTAINED)) | |
4268 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4269 msg_puts_attr("contained", attr); |
134 | 4270 msg_putchar(' '); |
4271 prev_contained = (kp->flags & HL_CONTAINED); | |
4272 } | |
4273 if (kp->k_syn.cont_in_list != prev_cont_in_list) | |
4274 { | |
4275 put_id_list((char_u *)"containedin", | |
4276 kp->k_syn.cont_in_list, attr); | |
4277 msg_putchar(' '); | |
4278 prev_cont_in_list = kp->k_syn.cont_in_list; | |
4279 } | |
4280 if (kp->next_list != prev_next_list) | |
4281 { | |
4282 put_id_list((char_u *)"nextgroup", kp->next_list, attr); | |
4283 msg_putchar(' '); | |
4284 prev_next_list = kp->next_list; | |
4285 if (kp->flags & HL_SKIPNL) | |
4286 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4287 msg_puts_attr("skipnl", attr); |
134 | 4288 msg_putchar(' '); |
4289 prev_skipnl = (kp->flags & HL_SKIPNL); | |
4290 } | |
4291 if (kp->flags & HL_SKIPWHITE) | |
4292 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4293 msg_puts_attr("skipwhite", attr); |
134 | 4294 msg_putchar(' '); |
4295 prev_skipwhite = (kp->flags & HL_SKIPWHITE); | |
4296 } | |
4297 if (kp->flags & HL_SKIPEMPTY) | |
4298 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4299 msg_puts_attr("skipempty", attr); |
134 | 4300 msg_putchar(' '); |
4301 prev_skipempty = (kp->flags & HL_SKIPEMPTY); | |
4302 } | |
4303 } | |
4304 msg_outtrans(kp->keyword); | |
7 | 4305 } |
4306 } | |
4307 } | |
4308 } | |
4309 | |
4310 return did_header; | |
4311 } | |
4312 | |
4313 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4314 syn_clear_keyword(int id, hashtab_T *ht) |
134 | 4315 { |
4316 hashitem_T *hi; | |
4317 keyentry_T *kp; | |
4318 keyentry_T *kp_prev; | |
4319 keyentry_T *kp_next; | |
4320 int todo; | |
4321 | |
4322 hash_lock(ht); | |
835 | 4323 todo = (int)ht->ht_used; |
32118
04d9dff67d99
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents:
31837
diff
changeset
|
4324 FOR_ALL_HASHTAB_ITEMS(ht, hi, todo) |
134 | 4325 { |
4326 if (!HASHITEM_EMPTY(hi)) | |
4327 { | |
4328 --todo; | |
4329 kp_prev = NULL; | |
4330 for (kp = HI2KE(hi); kp != NULL; ) | |
7 | 4331 { |
134 | 4332 if (kp->k_syn.id == id) |
4333 { | |
4334 kp_next = kp->ke_next; | |
4335 if (kp_prev == NULL) | |
4336 { | |
4337 if (kp_next == NULL) | |
31231
684e6dfa2fba
patch 9.0.0949: crash when unletting a variable while listing variables
Bram Moolenaar <Bram@vim.org>
parents:
30831
diff
changeset
|
4338 hash_remove(ht, hi, "syntax clear keyword"); |
134 | 4339 else |
4340 hi->hi_key = KE2HIKEY(kp_next); | |
4341 } | |
4342 else | |
4343 kp_prev->ke_next = kp_next; | |
4344 vim_free(kp->next_list); | |
4345 vim_free(kp->k_syn.cont_in_list); | |
4346 vim_free(kp); | |
4347 kp = kp_next; | |
4348 } | |
7 | 4349 else |
134 | 4350 { |
4351 kp_prev = kp; | |
4352 kp = kp->ke_next; | |
4353 } | |
7 | 4354 } |
134 | 4355 } |
4356 } | |
4357 hash_unlock(ht); | |
4358 } | |
4359 | |
4360 /* | |
4361 * Clear a whole keyword table. | |
7 | 4362 */ |
4363 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4364 clear_keywtab(hashtab_T *ht) |
134 | 4365 { |
4366 hashitem_T *hi; | |
4367 int todo; | |
4368 keyentry_T *kp; | |
4369 keyentry_T *kp_next; | |
4370 | |
835 | 4371 todo = (int)ht->ht_used; |
32118
04d9dff67d99
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents:
31837
diff
changeset
|
4372 FOR_ALL_HASHTAB_ITEMS(ht, hi, todo) |
134 | 4373 { |
4374 if (!HASHITEM_EMPTY(hi)) | |
4375 { | |
4376 --todo; | |
4377 for (kp = HI2KE(hi); kp != NULL; kp = kp_next) | |
7 | 4378 { |
134 | 4379 kp_next = kp->ke_next; |
4380 vim_free(kp->next_list); | |
4381 vim_free(kp->k_syn.cont_in_list); | |
4382 vim_free(kp); | |
7 | 4383 } |
134 | 4384 } |
4385 } | |
4386 hash_clear(ht); | |
4387 hash_init(ht); | |
7 | 4388 } |
4389 | |
4390 /* | |
4391 * Add a keyword to the list of keywords. | |
4392 */ | |
4393 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4394 add_keyword( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4395 char_u *name, // name of keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4396 int id, // group ID for this keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4397 int flags, // flags for this keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4398 short *cont_in_list, // containedin for this keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4399 short *next_list, // nextgroup for this keyword |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4400 int conceal_char) |
7 | 4401 { |
134 | 4402 keyentry_T *kp; |
4403 hashtab_T *ht; | |
4404 hashitem_T *hi; | |
154 | 4405 char_u *name_ic; |
134 | 4406 long_u hash; |
154 | 4407 char_u name_folded[MAXKEYWLEN + 1]; |
7 | 4408 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4409 if (curwin->w_s->b_syn_ic) |
154 | 4410 name_ic = str_foldcase(name, (int)STRLEN(name), |
4411 name_folded, MAXKEYWLEN + 1); | |
4412 else | |
4413 name_ic = name; | |
17659
121bdff812b4
patch 8.1.1827: allocating more memory than needed for extended structs
Bram Moolenaar <Bram@vim.org>
parents:
17401
diff
changeset
|
4414 kp = alloc(offsetof(keyentry_T, keyword) + STRLEN(name_ic) + 1); |
134 | 4415 if (kp == NULL) |
4416 return; | |
4417 STRCPY(kp->keyword, name_ic); | |
4418 kp->k_syn.id = id; | |
4419 kp->k_syn.inc_tag = current_syn_inc_tag; | |
4420 kp->flags = flags; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4421 kp->k_char = conceal_char; |
134 | 4422 kp->k_syn.cont_in_list = copy_id_list(cont_in_list); |
4423 if (cont_in_list != NULL) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4424 curwin->w_s->b_syn_containedin = TRUE; |
134 | 4425 kp->next_list = copy_id_list(next_list); |
4426 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4427 if (curwin->w_s->b_syn_ic) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4428 ht = &curwin->w_s->b_keywtab_ic; |
7 | 4429 else |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4430 ht = &curwin->w_s->b_keywtab; |
134 | 4431 |
4432 hash = hash_hash(kp->keyword); | |
4433 hi = hash_lookup(ht, kp->keyword, hash); | |
4434 if (HASHITEM_EMPTY(hi)) | |
4435 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4436 // new keyword, add to hashtable |
134 | 4437 kp->ke_next = NULL; |
4438 hash_add_item(ht, hi, kp->keyword, hash); | |
4439 } | |
4440 else | |
4441 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4442 // keyword already exists, prepend to list |
134 | 4443 kp->ke_next = HI2KE(hi); |
4444 hi->hi_key = KE2HIKEY(kp); | |
4445 } | |
7 | 4446 } |
4447 | |
4448 /* | |
4449 * Get the start and end of the group name argument. | |
4450 * Return a pointer to the first argument. | |
4451 * Return NULL if the end of the command was found instead of further args. | |
4452 */ | |
4453 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4454 get_group_name( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4455 char_u *arg, // start of the argument |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4456 char_u **name_end) // pointer to end of the name |
7 | 4457 { |
4458 char_u *rest; | |
4459 | |
4460 *name_end = skiptowhite(arg); | |
4461 rest = skipwhite(*name_end); | |
4462 | |
4463 /* | |
4464 * Check if there are enough arguments. The first argument may be a | |
4465 * pattern, where '|' is allowed, so only check for NUL. | |
4466 */ | |
4467 if (ends_excmd(*arg) || *rest == NUL) | |
4468 return NULL; | |
4469 return rest; | |
4470 } | |
4471 | |
4472 /* | |
4473 * Check for syntax command option arguments. | |
4474 * This can be called at any place in the list of arguments, and just picks | |
4475 * out the arguments that are known. Can be called several times in a row to | |
4476 * collect all options in between other arguments. | |
4477 * Return a pointer to the next argument (which isn't an option). | |
4478 * Return NULL for any error; | |
4479 */ | |
4480 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4481 get_syn_options( |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4482 char_u *start, // next argument to be checked |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4483 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
|
4484 int *conceal_char UNUSED, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4485 int skip) // TRUE if skipping over command |
154 | 4486 { |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4487 char_u *arg = start; |
7 | 4488 char_u *gname_start, *gname; |
4489 int syn_id; | |
4490 int len; | |
154 | 4491 char *p; |
7 | 4492 int i; |
4493 int fidx; | |
4494 static struct flag | |
4495 { | |
4496 char *name; | |
154 | 4497 int argtype; |
4498 int flags; | |
4499 } flagtab[] = { {"cCoOnNtTaAiInNeEdD", 0, HL_CONTAINED}, | |
4500 {"oOnNeElLiInNeE", 0, HL_ONELINE}, | |
4501 {"kKeEeEpPeEnNdD", 0, HL_KEEPEND}, | |
4502 {"eExXtTeEnNdD", 0, HL_EXTEND}, | |
4503 {"eExXcClLuUdDeEnNlL", 0, HL_EXCLUDENL}, | |
4504 {"tTrRaAnNsSpPaArReEnNtT", 0, HL_TRANSP}, | |
4505 {"sSkKiIpPnNlL", 0, HL_SKIPNL}, | |
4506 {"sSkKiIpPwWhHiItTeE", 0, HL_SKIPWHITE}, | |
4507 {"sSkKiIpPeEmMpPtTyY", 0, HL_SKIPEMPTY}, | |
4508 {"gGrRoOuUpPhHeErReE", 0, HL_SYNC_HERE}, | |
4509 {"gGrRoOuUpPtThHeErReE", 0, HL_SYNC_THERE}, | |
4510 {"dDiIsSpPlLaAyY", 0, HL_DISPLAY}, | |
4511 {"fFoOlLdD", 0, HL_FOLD}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4512 {"cCoOnNcCeEaAlL", 0, HL_CONCEAL}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4513 {"cCoOnNcCeEaAlLeEnNdDsS", 0, HL_CONCEALENDS}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4514 {"cCcChHaArR", 11, 0}, |
154 | 4515 {"cCoOnNtTaAiInNsS", 1, 0}, |
4516 {"cCoOnNtTaAiInNeEdDiInN", 2, 0}, | |
4517 {"nNeExXtTgGrRoOuUpP", 3, 0}, | |
7 | 4518 }; |
154 | 4519 static char *first_letters = "cCoOkKeEtTsSgGdDfFnN"; |
7 | 4520 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4521 if (arg == NULL) // already detected error |
7 | 4522 return NULL; |
4523 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4524 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4525 if (curwin->w_s->b_syn_conceal) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4526 opt->flags |= HL_CONCEAL; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4527 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4528 |
7 | 4529 for (;;) |
4530 { | |
154 | 4531 /* |
4532 * This is used very often when a large number of keywords is defined. | |
4533 * Need to skip quickly when no option name is found. | |
4534 * Also avoid tolower(), it's slow. | |
4535 */ | |
4536 if (strchr(first_letters, *arg) == NULL) | |
4537 break; | |
7 | 4538 |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24442
diff
changeset
|
4539 for (fidx = ARRAY_LENGTH(flagtab); --fidx >= 0; ) |
7 | 4540 { |
154 | 4541 p = flagtab[fidx].name; |
4542 for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) | |
4543 if (arg[len] != p[i] && arg[len] != p[i + 1]) | |
4544 break; | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
4545 if (p[i] == NUL && (VIM_ISWHITE(arg[len]) |
154 | 4546 || (flagtab[fidx].argtype > 0 |
4547 ? arg[len] == '=' | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4548 : ends_excmd2(start, arg + len)))) |
7 | 4549 { |
154 | 4550 if (opt->keyword |
4551 && (flagtab[fidx].flags == HL_DISPLAY | |
4552 || flagtab[fidx].flags == HL_FOLD | |
4553 || flagtab[fidx].flags == HL_EXTEND)) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4554 // treat "display", "fold" and "extend" as a keyword |
7 | 4555 fidx = -1; |
4556 break; | |
4557 } | |
4558 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4559 if (fidx < 0) // no match found |
154 | 4560 break; |
4561 | |
4562 if (flagtab[fidx].argtype == 1) | |
4563 { | |
4564 if (!opt->has_cont_list) | |
7 | 4565 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
4566 emsg(_(e_contains_argument_not_accepted_here)); |
7 | 4567 return NULL; |
4568 } | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4569 if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) |
7 | 4570 return NULL; |
4571 } | |
154 | 4572 else if (flagtab[fidx].argtype == 2) |
4573 { | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4574 if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) |
7 | 4575 return NULL; |
4576 } | |
154 | 4577 else if (flagtab[fidx].argtype == 3) |
4578 { | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4579 if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) |
7 | 4580 return NULL; |
4581 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4582 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
|
4583 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4584 // cchar=? |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4585 if (has_mbyte) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4586 { |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4587 #ifdef FEAT_CONCEAL |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4588 *conceal_char = mb_ptr2char(arg + 6); |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4589 #endif |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4590 arg += mb_ptr2len(arg + 6) - 1; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4591 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4592 else |
2251
646d34788036
Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4593 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4594 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4595 *conceal_char = arg[6]; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4596 #else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4597 ; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4598 #endif |
2251
646d34788036
Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4599 } |
2686 | 4600 #ifdef FEAT_CONCEAL |
4601 if (!vim_isprintc_strict(*conceal_char)) | |
4602 { | |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
4603 emsg(_(e_invalid_cchar_value)); |
2686 | 4604 return NULL; |
4605 } | |
4606 #endif | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4607 arg = skipwhite(arg + 7); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4608 } |
7 | 4609 else |
154 | 4610 { |
4611 opt->flags |= flagtab[fidx].flags; | |
4612 arg = skipwhite(arg + len); | |
4613 | |
4614 if (flagtab[fidx].flags == HL_SYNC_HERE | |
4615 || flagtab[fidx].flags == HL_SYNC_THERE) | |
4616 { | |
4617 if (opt->sync_idx == NULL) | |
4618 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
4619 emsg(_(e_groupthere_not_accepted_here)); |
154 | 4620 return NULL; |
4621 } | |
4622 gname_start = arg; | |
4623 arg = skiptowhite(arg); | |
4624 if (gname_start == arg) | |
4625 return NULL; | |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
4626 gname = vim_strnsave(gname_start, arg - gname_start); |
154 | 4627 if (gname == NULL) |
4628 return NULL; | |
4629 if (STRCMP(gname, "NONE") == 0) | |
4630 *opt->sync_idx = NONE_IDX; | |
4631 else | |
4632 { | |
4633 syn_id = syn_name2id(gname); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4634 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
|
4635 if (SYN_ITEMS(curwin->w_s)[i].sp_syn.id == syn_id |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
4636 && SYN_ITEMS(curwin->w_s)[i].sp_type |
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
4637 == SPTYPE_START) |
154 | 4638 { |
4639 *opt->sync_idx = i; | |
4640 break; | |
4641 } | |
4642 if (i < 0) | |
4643 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
4644 semsg(_(e_didnt_find_region_item_for_str), gname); |
154 | 4645 vim_free(gname); |
4646 return NULL; | |
4647 } | |
4648 } | |
4649 | |
4650 vim_free(gname); | |
4651 arg = skipwhite(arg); | |
4652 } | |
4653 #ifdef FEAT_FOLDING | |
4654 else if (flagtab[fidx].flags == HL_FOLD | |
4655 && foldmethodIsSyntax(curwin)) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4656 // Need to update folds later. |
154 | 4657 foldUpdateAll(curwin); |
4658 #endif | |
4659 } | |
4660 } | |
7 | 4661 |
4662 return arg; | |
4663 } | |
4664 | |
4665 /* | |
4666 * Adjustments to syntax item when declared in a ":syn include"'d file. | |
4667 * Set the contained flag, and if the item is not already contained, add it | |
4668 * to the specified top-level group, if any. | |
4669 */ | |
4670 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4671 syn_incl_toplevel(int id, int *flagsp) |
7 | 4672 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4673 if ((*flagsp & HL_CONTAINED) || curwin->w_s->b_syn_topgrp == 0) |
7 | 4674 return; |
4675 *flagsp |= HL_CONTAINED; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4676 if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER) |
7 | 4677 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4678 // We have to alloc this, because syn_combine_list() will free it. |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
4679 short *grp_list = ALLOC_MULT(short, 2); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4680 int tlg_id = curwin->w_s->b_syn_topgrp - SYNID_CLUSTER; |
7 | 4681 |
4682 if (grp_list != NULL) | |
4683 { | |
4684 grp_list[0] = id; | |
4685 grp_list[1] = 0; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
4686 syn_combine_list(&SYN_CLSTR(curwin->w_s)[tlg_id].scl_list, |
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
4687 &grp_list, CLUSTER_ADD); |
7 | 4688 } |
4689 } | |
4690 } | |
4691 | |
4692 /* | |
4693 * Handle ":syntax include [@{group-name}] filename" command. | |
4694 */ | |
4695 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4696 syn_cmd_include(exarg_T *eap, int syncing UNUSED) |
7 | 4697 { |
4698 char_u *arg = eap->arg; | |
4699 int sgl_id = 1; | |
4700 char_u *group_name_end; | |
4701 char_u *rest; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
4702 char *errormsg = NULL; |
7 | 4703 int prev_toplvl_grp; |
4704 int prev_syn_inc_tag; | |
4705 int source = FALSE; | |
4706 | |
4707 eap->nextcmd = find_nextcmd(arg); | |
4708 if (eap->skip) | |
4709 return; | |
4710 | |
4711 if (arg[0] == '@') | |
4712 { | |
4713 ++arg; | |
4714 rest = get_group_name(arg, &group_name_end); | |
4715 if (rest == NULL) | |
4716 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
4717 emsg(_(e_filename_required)); |
7 | 4718 return; |
4719 } | |
4720 sgl_id = syn_check_cluster(arg, (int)(group_name_end - arg)); | |
2743 | 4721 if (sgl_id == 0) |
4722 return; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4723 // separate_nextcmd() and expand_filename() depend on this |
7 | 4724 eap->arg = rest; |
4725 } | |
4726 | |
4727 /* | |
4728 * Everything that's left, up to the next command, should be the | |
4729 * filename to include. | |
4730 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17227
diff
changeset
|
4731 eap->argt |= (EX_XFILE | EX_NOSPC); |
28179
49631bf057d3
patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4732 separate_nextcmd(eap, FALSE); |
7 | 4733 if (*eap->arg == '<' || *eap->arg == '$' || mch_isFullName(eap->arg)) |
4734 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4735 // For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4736 // file. Need to expand the file name first. In other cases |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4737 // ":runtime!" is used. |
7 | 4738 source = TRUE; |
4739 if (expand_filename(eap, syn_cmdlinep, &errormsg) == FAIL) | |
4740 { | |
4741 if (errormsg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
4742 emsg(errormsg); |
7 | 4743 return; |
4744 } | |
4745 } | |
4746 | |
4747 /* | |
4748 * Save and restore the existing top-level grouplist id and ":syn | |
4749 * include" tag around the actual inclusion. | |
4750 */ | |
2743 | 4751 if (running_syn_inc_tag >= MAX_SYN_INC_TAG) |
4752 { | |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
4753 emsg(_(e_too_many_syntax_includes)); |
2743 | 4754 return; |
4755 } | |
7 | 4756 prev_syn_inc_tag = current_syn_inc_tag; |
4757 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
|
4758 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
|
4759 curwin->w_s->b_syn_topgrp = sgl_id; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4760 if (source ? do_source(eap->arg, FALSE, DOSO_NONE, NULL) == FAIL |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8514
diff
changeset
|
4761 : source_runtime(eap->arg, DIP_ALL) == FAIL) |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4762 semsg(_(e_cant_open_file_str), eap->arg); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4763 curwin->w_s->b_syn_topgrp = prev_toplvl_grp; |
7 | 4764 current_syn_inc_tag = prev_syn_inc_tag; |
4765 } | |
4766 | |
4767 /* | |
4768 * Handle ":syntax keyword {group-name} [{option}] keyword .." command. | |
4769 */ | |
4770 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4771 syn_cmd_keyword(exarg_T *eap, int syncing UNUSED) |
7 | 4772 { |
4773 char_u *arg = eap->arg; | |
4774 char_u *group_name_end; | |
4775 int syn_id; | |
4776 char_u *rest; | |
2743 | 4777 char_u *keyword_copy = NULL; |
7 | 4778 char_u *p; |
154 | 4779 char_u *kw; |
4780 syn_opt_arg_T syn_opt_arg; | |
4781 int cnt; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4782 int conceal_char = NUL; |
7 | 4783 |
4784 rest = get_group_name(arg, &group_name_end); | |
4785 | |
4786 if (rest != NULL) | |
4787 { | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4788 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
|
4789 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
|
4790 else |
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4791 syn_id = syn_check_group(arg, (int)(group_name_end - arg)); |
2743 | 4792 if (syn_id != 0) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4793 // allocate a buffer, for removing backslashes in the keyword |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16611
diff
changeset
|
4794 keyword_copy = alloc(STRLEN(rest) + 1); |
7 | 4795 if (keyword_copy != NULL) |
4796 { | |
154 | 4797 syn_opt_arg.flags = 0; |
4798 syn_opt_arg.keyword = TRUE; | |
4799 syn_opt_arg.sync_idx = NULL; | |
4800 syn_opt_arg.has_cont_list = FALSE; | |
4801 syn_opt_arg.cont_in_list = NULL; | |
4802 syn_opt_arg.next_list = NULL; | |
4803 | |
7 | 4804 /* |
4805 * The options given apply to ALL keywords, so all options must be | |
4806 * found before keywords can be created. | |
154 | 4807 * 1: collect the options and copy the keywords to keyword_copy. |
7 | 4808 */ |
154 | 4809 cnt = 0; |
4810 p = keyword_copy; | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4811 for ( ; rest != NULL && !ends_excmd2(eap->arg, rest); |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4812 rest = skipwhite(rest)) |
7 | 4813 { |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
4814 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
|
4815 eap->skip); |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4816 if (rest == NULL || ends_excmd2(eap->arg, rest)) |
154 | 4817 break; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4818 // 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
|
4819 while (*rest != NUL && !VIM_ISWHITE(*rest)) |
154 | 4820 { |
4821 if (*rest == '\\' && rest[1] != NUL) | |
4822 ++rest; | |
4823 *p++ = *rest++; | |
4824 } | |
4825 *p++ = NUL; | |
4826 ++cnt; | |
4827 } | |
4828 | |
4829 if (!eap->skip) | |
4830 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4831 // Adjust flags for use of ":syn include". |
154 | 4832 syn_incl_toplevel(syn_id, &syn_opt_arg.flags); |
4833 | |
7 | 4834 /* |
154 | 4835 * 2: Add an entry for each keyword. |
7 | 4836 */ |
154 | 4837 for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) |
7 | 4838 { |
154 | 4839 for (p = vim_strchr(kw, '['); ; ) |
7 | 4840 { |
154 | 4841 if (p != NULL) |
4842 *p = NUL; | |
4843 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
|
4844 syn_opt_arg.cont_in_list, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4845 syn_opt_arg.next_list, conceal_char); |
168 | 4846 if (p == NULL) |
4847 break; | |
4848 if (p[1] == NUL) | |
4849 { | |
26958
d92e0d85923f
patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
4850 semsg(_(e_error_missing_rsb_str), kw); |
7017 | 4851 goto error; |
168 | 4852 } |
4853 if (p[1] == ']') | |
4854 { | |
7017 | 4855 if (p[2] != NUL) |
4856 { | |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
4857 semsg(_(e_trailing_char_after_rsb_str_str), |
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
4858 kw, &p[2]); |
7017 | 4859 goto error; |
4860 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4861 kw = p + 1; // skip over the "]" |
168 | 4862 break; |
4863 } | |
154 | 4864 if (has_mbyte) |
7 | 4865 { |
474 | 4866 int l = (*mb_ptr2len)(p + 1); |
154 | 4867 |
4868 mch_memmove(p, p + 1, l); | |
4869 p += l; | |
4870 } | |
4871 else | |
4872 { | |
4873 p[0] = p[1]; | |
4874 ++p; | |
7 | 4875 } |
4876 } | |
4877 } | |
4878 } | |
7017 | 4879 error: |
7 | 4880 vim_free(keyword_copy); |
168 | 4881 vim_free(syn_opt_arg.cont_in_list); |
4882 vim_free(syn_opt_arg.next_list); | |
7 | 4883 } |
4884 } | |
4885 | |
4886 if (rest != NULL) | |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4887 set_nextcmd(eap, rest); |
7 | 4888 else |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26199
diff
changeset
|
4889 semsg(_(e_invalid_argument_str), arg); |
7 | 4890 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4891 redraw_curbuf_later(UPD_SOME_VALID); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4892 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. |
7 | 4893 } |
4894 | |
4895 /* | |
4896 * Handle ":syntax match {name} [{options}] {pattern} [{options}]". | |
4897 * | |
4898 * Also ":syntax sync match {name} [[grouphere | groupthere] {group-name}] .." | |
4899 */ | |
4900 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4901 syn_cmd_match( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4902 exarg_T *eap, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4903 int syncing) // TRUE for ":syntax sync match .. " |
7 | 4904 { |
4905 char_u *arg = eap->arg; | |
4906 char_u *group_name_end; | |
4907 char_u *rest; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4908 synpat_T item; // the item found in the line |
7 | 4909 int syn_id; |
4910 int idx; | |
154 | 4911 syn_opt_arg_T syn_opt_arg; |
7 | 4912 int sync_idx = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4913 int conceal_char = NUL; |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4914 int orig_called_emsg = called_emsg; |
7 | 4915 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4916 // Isolate the group name, check for validity |
7 | 4917 rest = get_group_name(arg, &group_name_end); |
4918 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4919 // Get options before the pattern |
154 | 4920 syn_opt_arg.flags = 0; |
4921 syn_opt_arg.keyword = FALSE; | |
4922 syn_opt_arg.sync_idx = syncing ? &sync_idx : NULL; | |
4923 syn_opt_arg.has_cont_list = TRUE; | |
4924 syn_opt_arg.cont_list = NULL; | |
4925 syn_opt_arg.cont_in_list = NULL; | |
4926 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
|
4927 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); |
7 | 4928 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4929 // get the pattern. |
7 | 4930 init_syn_patterns(); |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
4931 CLEAR_FIELD(item); |
7 | 4932 rest = get_syn_pattern(rest, &item); |
154 | 4933 if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) |
4934 syn_opt_arg.flags |= HL_HAS_EOL; | |
7 | 4935 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4936 // 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
|
4937 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); |
7 | 4938 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4939 if (rest != NULL) // all arguments are valid |
7 | 4940 { |
4941 /* | |
4942 * Check for trailing command and illegal trailing arguments. | |
4943 */ | |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4944 set_nextcmd(eap, rest); |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4945 if (!ends_excmd2(eap->cmd, rest) || eap->skip) |
7 | 4946 rest = NULL; |
31837
e16361210675
patch 9.0.1251: checking returned value of ga_grow() is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
31809
diff
changeset
|
4947 else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) == OK |
7 | 4948 && (syn_id = syn_check_group(arg, |
4949 (int)(group_name_end - arg))) != 0) | |
4950 { | |
154 | 4951 syn_incl_toplevel(syn_id, &syn_opt_arg.flags); |
7 | 4952 /* |
4953 * Store the pattern in the syn_items list | |
4954 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4955 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
|
4956 SYN_ITEMS(curwin->w_s)[idx] = item; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4957 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
|
4958 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
|
4959 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
|
4960 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
|
4961 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
|
4962 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
|
4963 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
|
4964 SYN_ITEMS(curwin->w_s)[idx].sp_syn.cont_in_list = |
154 | 4965 syn_opt_arg.cont_in_list; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4966 #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
|
4967 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
|
4968 #endif |
154 | 4969 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
|
4970 curwin->w_s->b_syn_containedin = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
4971 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
|
4972 ++curwin->w_s->b_syn_patterns.ga_len; |
7 | 4973 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4974 // remember that we found a match for syncing on |
154 | 4975 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
|
4976 curwin->w_s->b_syn_sync_flags |= SF_MATCH; |
7 | 4977 #ifdef FEAT_FOLDING |
154 | 4978 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
|
4979 ++curwin->w_s->b_syn_folditems; |
7 | 4980 #endif |
4981 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4982 redraw_curbuf_later(UPD_SOME_VALID); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4983 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
4984 return; // don't free the progs and patterns now |
7 | 4985 } |
4986 } | |
4987 | |
4988 /* | |
4989 * Something failed, free the allocated memory. | |
4990 */ | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
4991 vim_regfree(item.sp_prog); |
7 | 4992 vim_free(item.sp_pattern); |
154 | 4993 vim_free(syn_opt_arg.cont_list); |
4994 vim_free(syn_opt_arg.cont_in_list); | |
4995 vim_free(syn_opt_arg.next_list); | |
7 | 4996 |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4997 if (rest == NULL && called_emsg == orig_called_emsg) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26199
diff
changeset
|
4998 semsg(_(e_invalid_argument_str), arg); |
7 | 4999 } |
5000 | |
5001 /* | |
5002 * Handle ":syntax region {group-name} [matchgroup={group-name}] | |
5003 * start {start} .. [skip {skip}] end {end} .. [{options}]". | |
5004 */ | |
5005 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5006 syn_cmd_region( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5007 exarg_T *eap, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5008 int syncing) // TRUE for ":syntax sync region .." |
7 | 5009 { |
5010 char_u *arg = eap->arg; | |
5011 char_u *group_name_end; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5012 char_u *rest; // next arg, NULL on error |
7 | 5013 char_u *key_end; |
5014 char_u *key = NULL; | |
5015 char_u *p; | |
5016 int item; | |
5017 #define ITEM_START 0 | |
5018 #define ITEM_SKIP 1 | |
5019 #define ITEM_END 2 | |
5020 #define ITEM_MATCHGROUP 3 | |
5021 struct pat_ptr | |
5022 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5023 synpat_T *pp_synp; // pointer to syn_pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5024 int pp_matchgroup_id; // matchgroup ID |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5025 struct pat_ptr *pp_next; // pointer to next pat_ptr |
7 | 5026 } *(pat_ptrs[3]); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5027 // patterns found in the line |
7 | 5028 struct pat_ptr *ppp; |
5029 struct pat_ptr *ppp_next; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5030 int pat_count = 0; // nr of syn_patterns found |
7 | 5031 int syn_id; |
5032 int matchgroup_id = 0; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5033 int not_enough = FALSE; // not enough arguments |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5034 int illegal = FALSE; // illegal arguments |
7 | 5035 int success = FALSE; |
5036 int idx; | |
154 | 5037 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
|
5038 int conceal_char = NUL; |
7 | 5039 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5040 // Isolate the group name, check for validity |
7 | 5041 rest = get_group_name(arg, &group_name_end); |
5042 | |
5043 pat_ptrs[0] = NULL; | |
5044 pat_ptrs[1] = NULL; | |
5045 pat_ptrs[2] = NULL; | |
5046 | |
5047 init_syn_patterns(); | |
5048 | |
154 | 5049 syn_opt_arg.flags = 0; |
5050 syn_opt_arg.keyword = FALSE; | |
5051 syn_opt_arg.sync_idx = NULL; | |
5052 syn_opt_arg.has_cont_list = TRUE; | |
5053 syn_opt_arg.cont_list = NULL; | |
5054 syn_opt_arg.cont_in_list = NULL; | |
5055 syn_opt_arg.next_list = NULL; | |
5056 | |
7 | 5057 /* |
5058 * get the options, patterns and matchgroup. | |
5059 */ | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5060 while (rest != NULL && !ends_excmd2(eap->cmd, rest)) |
7 | 5061 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5062 // 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
|
5063 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5064 if (rest == NULL || ends_excmd2(eap->cmd, rest)) |
7 | 5065 break; |
5066 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5067 // must be a pattern or matchgroup then |
7 | 5068 key_end = rest; |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5069 while (*key_end && !VIM_ISWHITE(*key_end) && *key_end != '=') |
7 | 5070 ++key_end; |
5071 vim_free(key); | |
20751
d9a2e5dcfd9f
patch 8.2.0928: many type casts are used for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20623
diff
changeset
|
5072 key = vim_strnsave_up(rest, key_end - rest); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5073 if (key == NULL) // out of memory |
7 | 5074 { |
5075 rest = NULL; | |
5076 break; | |
5077 } | |
5078 if (STRCMP(key, "MATCHGROUP") == 0) | |
5079 item = ITEM_MATCHGROUP; | |
5080 else if (STRCMP(key, "START") == 0) | |
5081 item = ITEM_START; | |
5082 else if (STRCMP(key, "END") == 0) | |
5083 item = ITEM_END; | |
5084 else if (STRCMP(key, "SKIP") == 0) | |
5085 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5086 if (pat_ptrs[ITEM_SKIP] != NULL) // one skip pattern allowed |
7 | 5087 { |
5088 illegal = TRUE; | |
5089 break; | |
5090 } | |
5091 item = ITEM_SKIP; | |
5092 } | |
5093 else | |
5094 break; | |
5095 rest = skipwhite(key_end); | |
5096 if (*rest != '=') | |
5097 { | |
5098 rest = NULL; | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5099 semsg(_(e_missing_equal_str), arg); |
7 | 5100 break; |
5101 } | |
5102 rest = skipwhite(rest + 1); | |
5103 if (*rest == NUL) | |
5104 { | |
5105 not_enough = TRUE; | |
5106 break; | |
5107 } | |
5108 | |
5109 if (item == ITEM_MATCHGROUP) | |
5110 { | |
5111 p = skiptowhite(rest); | |
5112 if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip) | |
5113 matchgroup_id = 0; | |
5114 else | |
5115 { | |
5116 matchgroup_id = syn_check_group(rest, (int)(p - rest)); | |
5117 if (matchgroup_id == 0) | |
5118 { | |
5119 illegal = TRUE; | |
5120 break; | |
5121 } | |
5122 } | |
5123 rest = skipwhite(p); | |
5124 } | |
5125 else | |
5126 { | |
5127 /* | |
5128 * Allocate room for a syn_pattern, and link it in the list of | |
5129 * syn_patterns for this item, at the start (because the list is | |
5130 * used from end to start). | |
5131 */ | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
5132 ppp = ALLOC_ONE(struct pat_ptr); |
7 | 5133 if (ppp == NULL) |
5134 { | |
5135 rest = NULL; | |
5136 break; | |
5137 } | |
5138 ppp->pp_next = pat_ptrs[item]; | |
5139 pat_ptrs[item] = ppp; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
5140 ppp->pp_synp = ALLOC_CLEAR_ONE(synpat_T); |
7 | 5141 if (ppp->pp_synp == NULL) |
5142 { | |
5143 rest = NULL; | |
5144 break; | |
5145 } | |
5146 | |
5147 /* | |
5148 * Get the syntax pattern and the following offset(s). | |
5149 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5150 // Enable the appropriate \z specials. |
7 | 5151 if (item == ITEM_START) |
5152 reg_do_extmatch = REX_SET; | |
5153 else if (item == ITEM_SKIP || item == ITEM_END) | |
5154 reg_do_extmatch = REX_USE; | |
5155 rest = get_syn_pattern(rest, ppp->pp_synp); | |
5156 reg_do_extmatch = 0; | |
5157 if (item == ITEM_END && vim_regcomp_had_eol() | |
154 | 5158 && !(syn_opt_arg.flags & HL_EXCLUDENL)) |
7 | 5159 ppp->pp_synp->sp_flags |= HL_HAS_EOL; |
5160 ppp->pp_matchgroup_id = matchgroup_id; | |
5161 ++pat_count; | |
5162 } | |
5163 } | |
5164 vim_free(key); | |
5165 if (illegal || not_enough) | |
5166 rest = NULL; | |
5167 | |
5168 /* | |
5169 * Must have a "start" and "end" pattern. | |
5170 */ | |
5171 if (rest != NULL && (pat_ptrs[ITEM_START] == NULL || | |
5172 pat_ptrs[ITEM_END] == NULL)) | |
5173 { | |
5174 not_enough = TRUE; | |
5175 rest = NULL; | |
5176 } | |
5177 | |
5178 if (rest != NULL) | |
5179 { | |
5180 /* | |
5181 * Check for trailing garbage or command. | |
5182 * If OK, add the item. | |
5183 */ | |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
5184 set_nextcmd(eap, rest); |
7 | 5185 if (!ends_excmd(*rest) || eap->skip) |
5186 rest = NULL; | |
31837
e16361210675
patch 9.0.1251: checking returned value of ga_grow() is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
31809
diff
changeset
|
5187 else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) == OK |
7 | 5188 && (syn_id = syn_check_group(arg, |
5189 (int)(group_name_end - arg))) != 0) | |
5190 { | |
154 | 5191 syn_incl_toplevel(syn_id, &syn_opt_arg.flags); |
7 | 5192 /* |
5193 * Store the start/skip/end in the syn_items list | |
5194 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5195 idx = curwin->w_s->b_syn_patterns.ga_len; |
7 | 5196 for (item = ITEM_START; item <= ITEM_END; ++item) |
5197 { | |
5198 for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp->pp_next) | |
5199 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5200 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
|
5201 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
|
5202 SYN_ITEMS(curwin->w_s)[idx].sp_type = |
7 | 5203 (item == ITEM_START) ? SPTYPE_START : |
5204 (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
|
5205 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
|
5206 SYN_ITEMS(curwin->w_s)[idx].sp_syn.id = syn_id; |
2743 | 5207 SYN_ITEMS(curwin->w_s)[idx].sp_syn.inc_tag = |
5208 current_syn_inc_tag; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5209 SYN_ITEMS(curwin->w_s)[idx].sp_syn_match_id = |
7 | 5210 ppp->pp_matchgroup_id; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5211 #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
|
5212 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
|
5213 #endif |
7 | 5214 if (item == ITEM_START) |
5215 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5216 SYN_ITEMS(curwin->w_s)[idx].sp_cont_list = |
154 | 5217 syn_opt_arg.cont_list; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5218 SYN_ITEMS(curwin->w_s)[idx].sp_syn.cont_in_list = |
154 | 5219 syn_opt_arg.cont_in_list; |
5220 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
|
5221 curwin->w_s->b_syn_containedin = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5222 SYN_ITEMS(curwin->w_s)[idx].sp_next_list = |
154 | 5223 syn_opt_arg.next_list; |
7 | 5224 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5225 ++curwin->w_s->b_syn_patterns.ga_len; |
7 | 5226 ++idx; |
5227 #ifdef FEAT_FOLDING | |
154 | 5228 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
|
5229 ++curwin->w_s->b_syn_folditems; |
7 | 5230 #endif |
5231 } | |
5232 } | |
5233 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5234 redraw_curbuf_later(UPD_SOME_VALID); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5235 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5236 success = TRUE; // don't free the progs and patterns now |
7 | 5237 } |
5238 } | |
5239 | |
5240 /* | |
5241 * Free the allocated memory. | |
5242 */ | |
5243 for (item = ITEM_START; item <= ITEM_END; ++item) | |
5244 for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp_next) | |
5245 { | |
17907
4cf69f8d1ec6
patch 8.1.1950: using NULL pointer after an out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5246 if (!success && ppp->pp_synp != NULL) |
7 | 5247 { |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
5248 vim_regfree(ppp->pp_synp->sp_prog); |
7 | 5249 vim_free(ppp->pp_synp->sp_pattern); |
5250 } | |
5251 vim_free(ppp->pp_synp); | |
5252 ppp_next = ppp->pp_next; | |
5253 vim_free(ppp); | |
5254 } | |
5255 | |
5256 if (!success) | |
5257 { | |
154 | 5258 vim_free(syn_opt_arg.cont_list); |
5259 vim_free(syn_opt_arg.cont_in_list); | |
5260 vim_free(syn_opt_arg.next_list); | |
7 | 5261 if (not_enough) |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5262 semsg(_(e_not_enough_arguments_syntax_region_str), arg); |
7 | 5263 else if (illegal || rest == NULL) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26199
diff
changeset
|
5264 semsg(_(e_invalid_argument_str), arg); |
7 | 5265 } |
5266 } | |
5267 | |
5268 /* | |
5269 * A simple syntax group ID comparison function suitable for use in qsort() | |
5270 */ | |
5271 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5272 syn_compare_stub(const void *v1, const void *v2) |
7 | 5273 { |
5274 const short *s1 = v1; | |
5275 const short *s2 = v2; | |
5276 | |
5277 return (*s1 > *s2 ? 1 : *s1 < *s2 ? -1 : 0); | |
5278 } | |
5279 | |
5280 /* | |
5281 * Combines lists of syntax clusters. | |
5282 * *clstr1 and *clstr2 must both be allocated memory; they will be consumed. | |
5283 */ | |
5284 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5285 syn_combine_list(short **clstr1, short **clstr2, int list_op) |
7 | 5286 { |
5287 int count1 = 0; | |
5288 int count2 = 0; | |
5289 short *g1; | |
5290 short *g2; | |
5291 short *clstr = NULL; | |
5292 int count; | |
5293 int round; | |
5294 | |
5295 /* | |
5296 * Handle degenerate cases. | |
5297 */ | |
5298 if (*clstr2 == NULL) | |
5299 return; | |
5300 if (*clstr1 == NULL || list_op == CLUSTER_REPLACE) | |
5301 { | |
5302 if (list_op == CLUSTER_REPLACE) | |
5303 vim_free(*clstr1); | |
5304 if (list_op == CLUSTER_REPLACE || list_op == CLUSTER_ADD) | |
5305 *clstr1 = *clstr2; | |
5306 else | |
5307 vim_free(*clstr2); | |
5308 return; | |
5309 } | |
5310 | |
5311 for (g1 = *clstr1; *g1; g1++) | |
5312 ++count1; | |
5313 for (g2 = *clstr2; *g2; g2++) | |
5314 ++count2; | |
5315 | |
5316 /* | |
5317 * For speed purposes, sort both lists. | |
5318 */ | |
5319 qsort(*clstr1, (size_t)count1, sizeof(short), syn_compare_stub); | |
5320 qsort(*clstr2, (size_t)count2, sizeof(short), syn_compare_stub); | |
5321 | |
5322 /* | |
5323 * We proceed in two passes; in round 1, we count the elements to place | |
5324 * in the new list, and in round 2, we allocate and populate the new | |
5325 * list. For speed, we use a mergesort-like method, adding the smaller | |
5326 * of the current elements in each list to the new list. | |
5327 */ | |
5328 for (round = 1; round <= 2; round++) | |
5329 { | |
5330 g1 = *clstr1; | |
5331 g2 = *clstr2; | |
5332 count = 0; | |
5333 | |
5334 /* | |
5335 * First, loop through the lists until one of them is empty. | |
5336 */ | |
5337 while (*g1 && *g2) | |
5338 { | |
5339 /* | |
5340 * We always want to add from the first list. | |
5341 */ | |
5342 if (*g1 < *g2) | |
5343 { | |
5344 if (round == 2) | |
5345 clstr[count] = *g1; | |
5346 count++; | |
5347 g1++; | |
5348 continue; | |
5349 } | |
5350 /* | |
5351 * We only want to add from the second list if we're adding the | |
5352 * lists. | |
5353 */ | |
5354 if (list_op == CLUSTER_ADD) | |
5355 { | |
5356 if (round == 2) | |
5357 clstr[count] = *g2; | |
5358 count++; | |
5359 } | |
5360 if (*g1 == *g2) | |
5361 g1++; | |
5362 g2++; | |
5363 } | |
5364 | |
5365 /* | |
5366 * Now add the leftovers from whichever list didn't get finished | |
5367 * first. As before, we only want to add from the second list if | |
5368 * we're adding the lists. | |
5369 */ | |
5370 for (; *g1; g1++, count++) | |
5371 if (round == 2) | |
5372 clstr[count] = *g1; | |
5373 if (list_op == CLUSTER_ADD) | |
5374 for (; *g2; g2++, count++) | |
5375 if (round == 2) | |
5376 clstr[count] = *g2; | |
5377 | |
5378 if (round == 1) | |
5379 { | |
5380 /* | |
5381 * If the group ended up empty, we don't need to allocate any | |
5382 * space for it. | |
5383 */ | |
5384 if (count == 0) | |
5385 { | |
5386 clstr = NULL; | |
5387 break; | |
5388 } | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
5389 clstr = ALLOC_MULT(short, count + 1); |
7 | 5390 if (clstr == NULL) |
5391 break; | |
5392 clstr[count] = 0; | |
5393 } | |
5394 } | |
5395 | |
5396 /* | |
5397 * Finally, put the new list in place. | |
5398 */ | |
5399 vim_free(*clstr1); | |
5400 vim_free(*clstr2); | |
5401 *clstr1 = clstr; | |
5402 } | |
5403 | |
5404 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5405 * Lookup a syntax cluster name and return its ID. |
7 | 5406 * If it is not found, 0 is returned. |
5407 */ | |
5408 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5409 syn_scl_name2id(char_u *name) |
7 | 5410 { |
5411 int i; | |
5412 char_u *name_u; | |
5413 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5414 // Avoid using stricmp() too much, it's slow on some systems |
7 | 5415 name_u = vim_strsave_up(name); |
5416 if (name_u == NULL) | |
5417 return 0; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5418 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
|
5419 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
|
5420 && STRCMP(name_u, SYN_CLSTR(curwin->w_s)[i].scl_name_u) == 0) |
7 | 5421 break; |
5422 vim_free(name_u); | |
5423 return (i < 0 ? 0 : i + SYNID_CLUSTER); | |
5424 } | |
5425 | |
5426 /* | |
5427 * Like syn_scl_name2id(), but take a pointer + length argument. | |
5428 */ | |
5429 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5430 syn_scl_namen2id(char_u *linep, int len) |
7 | 5431 { |
5432 char_u *name; | |
5433 int id = 0; | |
5434 | |
5435 name = vim_strnsave(linep, len); | |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
5436 if (name == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
5437 return 0; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
5438 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
5439 id = syn_scl_name2id(name); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
5440 vim_free(name); |
7 | 5441 return id; |
5442 } | |
5443 | |
5444 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5445 * Find syntax cluster name in the table and return its ID. |
7 | 5446 * The argument is a pointer to the name and the length of the name. |
5447 * If it doesn't exist yet, a new entry is created. | |
5448 * Return 0 for failure. | |
5449 */ | |
5450 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5451 syn_check_cluster(char_u *pp, int len) |
7 | 5452 { |
5453 int id; | |
5454 char_u *name; | |
5455 | |
5456 name = vim_strnsave(pp, len); | |
5457 if (name == NULL) | |
5458 return 0; | |
5459 | |
5460 id = syn_scl_name2id(name); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5461 if (id == 0) // doesn't exist yet |
7 | 5462 id = syn_add_cluster(name); |
5463 else | |
5464 vim_free(name); | |
5465 return id; | |
5466 } | |
5467 | |
5468 /* | |
11189
e74af2aca96e
patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5469 * Add new syntax cluster and return its ID. |
7 | 5470 * "name" must be an allocated string, it will be consumed. |
5471 * Return 0 for failure. | |
5472 */ | |
5473 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5474 syn_add_cluster(char_u *name) |
221 | 5475 { |
5476 int len; | |
7 | 5477 |
5478 /* | |
5479 * First call for this growarray: init growing array. | |
5480 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5481 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
|
5482 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5483 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
|
5484 curwin->w_s->b_syn_clusters.ga_growsize = 10; |
7 | 5485 } |
5486 | |
2743 | 5487 len = curwin->w_s->b_syn_clusters.ga_len; |
5488 if (len >= MAX_CLUSTER_ID) | |
5489 { | |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
5490 emsg(_(e_too_many_syntax_clusters)); |
2743 | 5491 vim_free(name); |
5492 return 0; | |
5493 } | |
5494 | |
7 | 5495 /* |
5496 * Make room for at least one other cluster entry. | |
5497 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5498 if (ga_grow(&curwin->w_s->b_syn_clusters, 1) == FAIL) |
7 | 5499 { |
5500 vim_free(name); | |
5501 return 0; | |
5502 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5503 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
5504 CLEAR_POINTER(&(SYN_CLSTR(curwin->w_s)[len])); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5505 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
|
5506 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
|
5507 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
|
5508 ++curwin->w_s->b_syn_clusters.ga_len; |
7 | 5509 |
221 | 5510 if (STRICMP(name, "Spell") == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5511 curwin->w_s->b_spell_cluster_id = len + SYNID_CLUSTER; |
227 | 5512 if (STRICMP(name, "NoSpell") == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5513 curwin->w_s->b_nospell_cluster_id = len + SYNID_CLUSTER; |
221 | 5514 |
7 | 5515 return len + SYNID_CLUSTER; |
5516 } | |
5517 | |
5518 /* | |
5519 * Handle ":syntax cluster {cluster-name} [contains={groupname},..] | |
5520 * [add={groupname},..] [remove={groupname},..]". | |
5521 */ | |
5522 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5523 syn_cmd_cluster(exarg_T *eap, int syncing UNUSED) |
7 | 5524 { |
5525 char_u *arg = eap->arg; | |
5526 char_u *group_name_end; | |
5527 char_u *rest; | |
5528 int scl_id; | |
5529 short *clstr_list; | |
5530 int got_clstr = FALSE; | |
5531 int opt_len; | |
5532 int list_op; | |
5533 | |
5534 eap->nextcmd = find_nextcmd(arg); | |
5535 if (eap->skip) | |
5536 return; | |
5537 | |
5538 rest = get_group_name(arg, &group_name_end); | |
5539 | |
5540 if (rest != NULL) | |
5541 { | |
2743 | 5542 scl_id = syn_check_cluster(arg, (int)(group_name_end - arg)); |
5543 if (scl_id == 0) | |
5544 return; | |
5545 scl_id -= SYNID_CLUSTER; | |
7 | 5546 |
5547 for (;;) | |
5548 { | |
5549 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
|
5550 && (VIM_ISWHITE(rest[3]) || rest[3] == '=')) |
7 | 5551 { |
5552 opt_len = 3; | |
5553 list_op = CLUSTER_ADD; | |
5554 } | |
5555 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
|
5556 && (VIM_ISWHITE(rest[6]) || rest[6] == '=')) |
7 | 5557 { |
5558 opt_len = 6; | |
5559 list_op = CLUSTER_SUBTRACT; | |
5560 } | |
5561 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
|
5562 && (VIM_ISWHITE(rest[8]) || rest[8] == '=')) |
7 | 5563 { |
5564 opt_len = 8; | |
5565 list_op = CLUSTER_REPLACE; | |
5566 } | |
5567 else | |
5568 break; | |
5569 | |
5570 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
|
5571 if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL) |
7 | 5572 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26199
diff
changeset
|
5573 semsg(_(e_invalid_argument_str), rest); |
7 | 5574 break; |
5575 } | |
10618
4ee16e5e2e26
patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents:
10534
diff
changeset
|
5576 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
|
5577 syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, |
7 | 5578 &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
|
5579 else |
4f3decf25b7d
patch 8.0.0214: leaking memory when syntax cluster id is unknown
Christian Brabandt <cb@256bit.org>
parents:
10629
diff
changeset
|
5580 vim_free(clstr_list); |
7 | 5581 got_clstr = TRUE; |
5582 } | |
5583 | |
5584 if (got_clstr) | |
5585 { | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5586 redraw_curbuf_later(UPD_SOME_VALID); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5587 syn_stack_free_all(curwin->w_s); // Need to recompute all. |
7 | 5588 } |
5589 } | |
5590 | |
5591 if (!got_clstr) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5592 emsg(_(e_no_cluster_specified)); |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5593 if (rest == NULL || !ends_excmd2(eap->cmd, rest)) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26199
diff
changeset
|
5594 semsg(_(e_invalid_argument_str), arg); |
7 | 5595 } |
5596 | |
5597 /* | |
5598 * On first call for current buffer: Init growing array. | |
5599 */ | |
5600 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5601 init_syn_patterns(void) |
7 | 5602 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5603 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
|
5604 curwin->w_s->b_syn_patterns.ga_growsize = 10; |
7 | 5605 } |
5606 | |
5607 /* | |
5608 * Get one pattern for a ":syntax match" or ":syntax region" command. | |
5609 * Stores the pattern and program in a synpat_T. | |
5610 * Returns a pointer to the next argument, or NULL in case of an error. | |
5611 */ | |
5612 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5613 get_syn_pattern(char_u *arg, synpat_T *ci) |
7 | 5614 { |
5615 char_u *end; | |
5616 int *p; | |
5617 int idx; | |
5618 char_u *cpo_save; | |
5619 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5620 // need at least three chars |
6993 | 5621 if (arg == NULL || arg[0] == NUL || arg[1] == NUL || arg[2] == NUL) |
7 | 5622 return NULL; |
5623 | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
5624 end = skip_regexp(arg + 1, *arg, TRUE); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5625 if (*end != *arg) // end delimiter not found |
7 | 5626 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5627 semsg(_(e_pattern_delimiter_not_found_str), arg); |
7 | 5628 return NULL; |
5629 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5630 // store the pattern and compiled regexp program |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
5631 if ((ci->sp_pattern = vim_strnsave(arg + 1, end - arg - 1)) == NULL) |
7 | 5632 return NULL; |
5633 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5634 // Make 'cpoptions' empty, to avoid the 'l' flag |
7 | 5635 cpo_save = p_cpo; |
23493
f8382c4e6551
patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents:
23043
diff
changeset
|
5636 p_cpo = empty_option; |
7 | 5637 ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC); |
5638 p_cpo = cpo_save; | |
5639 | |
5640 if (ci->sp_prog == NULL) | |
5641 return NULL; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5642 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
|
5643 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5644 syn_clear_time(&ci->sp_time); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5645 #endif |
7 | 5646 |
5647 /* | |
5648 * Check for a match, highlight or region offset. | |
5649 */ | |
5650 ++end; | |
5651 do | |
5652 { | |
5653 for (idx = SPO_COUNT; --idx >= 0; ) | |
5654 if (STRNCMP(end, spo_name_tab[idx], 3) == 0) | |
5655 break; | |
5656 if (idx >= 0) | |
5657 { | |
5658 p = &(ci->sp_offsets[idx]); | |
5659 if (idx != SPO_LC_OFF) | |
5660 switch (end[3]) | |
5661 { | |
5662 case 's': break; | |
5663 case 'b': break; | |
5664 case 'e': idx += SPO_COUNT; break; | |
5665 default: idx = -1; break; | |
5666 } | |
5667 if (idx >= 0) | |
5668 { | |
5669 ci->sp_off_flags |= (1 << idx); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5670 if (idx == SPO_LC_OFF) // lc=99 |
7 | 5671 { |
5672 end += 3; | |
5673 *p = getdigits(&end); | |
5674 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5675 // "lc=" offset automatically sets "ms=" offset |
7 | 5676 if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) |
5677 { | |
5678 ci->sp_off_flags |= (1 << SPO_MS_OFF); | |
5679 ci->sp_offsets[SPO_MS_OFF] = *p; | |
5680 } | |
5681 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5682 else // yy=x+99 |
7 | 5683 { |
5684 end += 4; | |
5685 if (*end == '+') | |
5686 { | |
5687 ++end; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5688 *p = getdigits(&end); // positive offset |
7 | 5689 } |
5690 else if (*end == '-') | |
5691 { | |
5692 ++end; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5693 *p = -getdigits(&end); // negative offset |
7 | 5694 } |
5695 } | |
5696 if (*end != ',') | |
5697 break; | |
5698 ++end; | |
5699 } | |
5700 } | |
5701 } while (idx >= 0); | |
5702 | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5703 if (!ends_excmd2(arg, end) && !VIM_ISWHITE(*end)) |
7 | 5704 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5705 semsg(_(e_garbage_after_pattern_str), arg); |
7 | 5706 return NULL; |
5707 } | |
5708 return skipwhite(end); | |
5709 } | |
5710 | |
5711 /* | |
5712 * Handle ":syntax sync .." command. | |
5713 */ | |
5714 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5715 syn_cmd_sync(exarg_T *eap, int syncing UNUSED) |
7 | 5716 { |
5717 char_u *arg_start = eap->arg; | |
5718 char_u *arg_end; | |
5719 char_u *key = NULL; | |
5720 char_u *next_arg; | |
5721 int illegal = FALSE; | |
5722 int finished = FALSE; | |
5723 long n; | |
5724 char_u *cpo_save; | |
5725 | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5726 if (ends_excmd2(eap->cmd, arg_start)) |
7 | 5727 { |
5728 syn_cmd_list(eap, TRUE); | |
5729 return; | |
5730 } | |
5731 | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5732 while (!ends_excmd2(eap->cmd, arg_start)) |
7 | 5733 { |
5734 arg_end = skiptowhite(arg_start); | |
5735 next_arg = skipwhite(arg_end); | |
5736 vim_free(key); | |
20751
d9a2e5dcfd9f
patch 8.2.0928: many type casts are used for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20623
diff
changeset
|
5737 key = vim_strnsave_up(arg_start, arg_end - arg_start); |
21240
e35955a787a8
patch 8.2.1171: possible crash when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
5738 if (key == NULL) |
e35955a787a8
patch 8.2.1171: possible crash when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
5739 break; |
7 | 5740 if (STRCMP(key, "CCOMMENT") == 0) |
5741 { | |
5742 if (!eap->skip) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5743 curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT; |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5744 if (!ends_excmd2(eap->cmd, next_arg)) |
7 | 5745 { |
5746 arg_end = skiptowhite(next_arg); | |
5747 if (!eap->skip) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5748 curwin->w_s->b_syn_sync_id = syn_check_group(next_arg, |
7 | 5749 (int)(arg_end - next_arg)); |
5750 next_arg = skipwhite(arg_end); | |
5751 } | |
5752 else if (!eap->skip) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5753 curwin->w_s->b_syn_sync_id = syn_name2id((char_u *)"Comment"); |
7 | 5754 } |
5755 else if ( STRNCMP(key, "LINES", 5) == 0 | |
5756 || STRNCMP(key, "MINLINES", 8) == 0 | |
5757 || STRNCMP(key, "MAXLINES", 8) == 0 | |
5758 || STRNCMP(key, "LINEBREAKS", 10) == 0) | |
5759 { | |
5760 if (key[4] == 'S') | |
5761 arg_end = key + 6; | |
5762 else if (key[0] == 'L') | |
5763 arg_end = key + 11; | |
5764 else | |
5765 arg_end = key + 9; | |
5766 if (arg_end[-1] != '=' || !VIM_ISDIGIT(*arg_end)) | |
5767 { | |
5768 illegal = TRUE; | |
5769 break; | |
5770 } | |
5771 n = getdigits(&arg_end); | |
5772 if (!eap->skip) | |
5773 { | |
5774 if (key[4] == 'B') | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5775 curwin->w_s->b_syn_sync_linebreaks = n; |
7 | 5776 else if (key[1] == 'A') |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5777 curwin->w_s->b_syn_sync_maxlines = n; |
7 | 5778 else |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5779 curwin->w_s->b_syn_sync_minlines = n; |
7 | 5780 } |
5781 } | |
5782 else if (STRCMP(key, "FROMSTART") == 0) | |
5783 { | |
5784 if (!eap->skip) | |
5785 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5786 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
|
5787 curwin->w_s->b_syn_sync_maxlines = 0; |
7 | 5788 } |
5789 } | |
5790 else if (STRCMP(key, "LINECONT") == 0) | |
5791 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5792 if (*next_arg == NUL) // missing pattern |
7504
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5793 { |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5794 illegal = TRUE; |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5795 break; |
013f285f31a6
commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents:
7500
diff
changeset
|
5796 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5797 if (curwin->w_s->b_syn_linecont_pat != NULL) |
7 | 5798 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5799 emsg(_(e_syntax_sync_line_continuations_pattern_specified_twice)); |
7 | 5800 finished = TRUE; |
5801 break; | |
5802 } | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
5803 arg_end = skip_regexp(next_arg + 1, *next_arg, TRUE); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5804 if (*arg_end != *next_arg) // end delimiter not found |
7 | 5805 { |
5806 illegal = TRUE; | |
5807 break; | |
5808 } | |
5809 | |
5810 if (!eap->skip) | |
5811 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5812 // store the pattern and compiled regexp program |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
5813 if ((curwin->w_s->b_syn_linecont_pat = |
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
5814 vim_strnsave(next_arg + 1, |
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
5815 arg_end - next_arg - 1)) == NULL) |
7 | 5816 { |
5817 finished = TRUE; | |
5818 break; | |
5819 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5820 curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic; |
7 | 5821 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5822 // Make 'cpoptions' empty, to avoid the 'l' flag |
7 | 5823 cpo_save = p_cpo; |
23493
f8382c4e6551
patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents:
23043
diff
changeset
|
5824 p_cpo = empty_option; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5825 curwin->w_s->b_syn_linecont_prog = |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5826 vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC); |
7 | 5827 p_cpo = cpo_save; |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
5828 #ifdef FEAT_PROFILE |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5829 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
|
5830 #endif |
7 | 5831 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
5832 if (curwin->w_s->b_syn_linecont_prog == NULL) |
7 | 5833 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12973
diff
changeset
|
5834 VIM_CLEAR(curwin->w_s->b_syn_linecont_pat); |
7 | 5835 finished = TRUE; |
5836 break; | |
5837 } | |
5838 } | |
5839 next_arg = skipwhite(arg_end + 1); | |
5840 } | |
5841 else | |
5842 { | |
5843 eap->arg = next_arg; | |
5844 if (STRCMP(key, "MATCH") == 0) | |
5845 syn_cmd_match(eap, TRUE); | |
5846 else if (STRCMP(key, "REGION") == 0) | |
5847 syn_cmd_region(eap, TRUE); | |
5848 else if (STRCMP(key, "CLEAR") == 0) | |
5849 syn_cmd_clear(eap, TRUE); | |
5850 else | |
5851 illegal = TRUE; | |
5852 finished = TRUE; | |
5853 break; | |
5854 } | |
5855 arg_start = next_arg; | |
5856 } | |
5857 vim_free(key); | |
5858 if (illegal) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5859 semsg(_(e_illegal_arguments_str), arg_start); |
7 | 5860 else if (!finished) |
5861 { | |
25521
2063b858cad9
patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
5862 set_nextcmd(eap, arg_start); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5863 redraw_curbuf_later(UPD_SOME_VALID); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5864 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. |
7 | 5865 } |
5866 } | |
5867 | |
5868 /* | |
5869 * Convert a line of highlight group names into a list of group ID numbers. | |
5870 * "arg" should point to the "contains" or "nextgroup" keyword. | |
5871 * "arg" is advanced to after the last group name. | |
5872 * Careful: the argument is modified (NULs added). | |
5873 * returns FAIL for some error, OK for success. | |
5874 */ | |
5875 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5876 get_id_list( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
5877 char_u **arg, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5878 int keylen, // length of keyword |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5879 short **list, // where to store the resulting list, if not |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5880 // 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
|
5881 int skip) |
7 | 5882 { |
5883 char_u *p = NULL; | |
5884 char_u *end; | |
5885 int round; | |
5886 int count; | |
5887 int total_count = 0; | |
5888 short *retval = NULL; | |
5889 char_u *name; | |
5890 regmatch_T regmatch; | |
5891 int id; | |
5892 int i; | |
5893 int failed = FALSE; | |
5894 | |
5895 /* | |
5896 * We parse the list twice: | |
5897 * round == 1: count the number of items, allocate the array. | |
5898 * round == 2: fill the array with the items. | |
5899 * In round 1 new groups may be added, causing the number of items to | |
5900 * grow when a regexp is used. In that case round 1 is done once again. | |
5901 */ | |
5902 for (round = 1; round <= 2; ++round) | |
5903 { | |
5904 /* | |
5905 * skip "contains" | |
5906 */ | |
5907 p = skipwhite(*arg + keylen); | |
5908 if (*p != '=') | |
5909 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5910 semsg(_(e_missing_equal_sign_str), *arg); |
7 | 5911 break; |
5912 } | |
5913 p = skipwhite(p + 1); | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5914 if (ends_excmd2(*arg, p)) |
7 | 5915 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5916 semsg(_(e_empty_argument_str), *arg); |
7 | 5917 break; |
5918 } | |
5919 | |
5920 /* | |
5921 * parse the arguments after "contains" | |
5922 */ | |
5923 count = 0; | |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
5924 while (!ends_excmd2(*arg, p)) |
7 | 5925 { |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
5926 for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end) |
7 | 5927 ; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
5928 name = alloc(end - p + 3); // leave room for "^$" |
7 | 5929 if (name == NULL) |
5930 { | |
5931 failed = TRUE; | |
5932 break; | |
5933 } | |
419 | 5934 vim_strncpy(name + 1, p, end - p); |
7 | 5935 if ( STRCMP(name + 1, "ALLBUT") == 0 |
5936 || STRCMP(name + 1, "ALL") == 0 | |
5937 || STRCMP(name + 1, "TOP") == 0 | |
5938 || STRCMP(name + 1, "CONTAINED") == 0) | |
5939 { | |
5940 if (TOUPPER_ASC(**arg) != 'C') | |
5941 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5942 semsg(_(e_str_not_allowed_here), name + 1); |
7 | 5943 failed = TRUE; |
5944 vim_free(name); | |
5945 break; | |
5946 } | |
5947 if (count != 0) | |
5948 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
5949 semsg(_(e_str_must_be_first_in_contains_list), name + 1); |
7 | 5950 failed = TRUE; |
5951 vim_free(name); | |
5952 break; | |
5953 } | |
5954 if (name[1] == 'A') | |
24442
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5955 id = SYNID_ALLBUT + current_syn_inc_tag; |
7 | 5956 else if (name[1] == 'T') |
24442
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5957 { |
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5958 if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER) |
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5959 id = curwin->w_s->b_syn_topgrp; |
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5960 else |
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5961 id = SYNID_TOP + current_syn_inc_tag; |
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5962 } |
7 | 5963 else |
24442
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5964 id = SYNID_CONTAINED + current_syn_inc_tag; |
d16a69f718b5
patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
5965 |
7 | 5966 } |
5967 else if (name[1] == '@') | |
5968 { | |
10629
16fc46021e51
patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10624
diff
changeset
|
5969 if (skip) |
16fc46021e51
patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10624
diff
changeset
|
5970 id = -1; |
16fc46021e51
patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10624
diff
changeset
|
5971 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
|
5972 id = syn_check_cluster(name + 2, (int)(end - p - 1)); |
7 | 5973 } |
5974 else | |
5975 { | |
5976 /* | |
5977 * Handle full group name. | |
5978 */ | |
5979 if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL) | |
5980 id = syn_check_group(name + 1, (int)(end - p)); | |
5981 else | |
5982 { | |
5983 /* | |
5984 * Handle match of regexp with group names. | |
5985 */ | |
5986 *name = '^'; | |
5987 STRCAT(name, "$"); | |
5988 regmatch.regprog = vim_regcomp(name, RE_MAGIC); | |
5989 if (regmatch.regprog == NULL) | |
5990 { | |
5991 failed = TRUE; | |
5992 vim_free(name); | |
5993 break; | |
5994 } | |
5995 | |
5996 regmatch.rm_ic = TRUE; | |
5997 id = 0; | |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
5998 for (i = highlight_num_groups(); --i >= 0; ) |
7 | 5999 { |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
6000 if (vim_regexec(®match, highlight_group_name(i), |
7 | 6001 (colnr_T)0)) |
6002 { | |
6003 if (round == 2) | |
6004 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6005 // Got more items than expected; can happen |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6006 // when adding items that match: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6007 // "contains=a.*b,axb". |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6008 // Go back to first round |
7 | 6009 if (count >= total_count) |
6010 { | |
6011 vim_free(retval); | |
6012 round = 1; | |
6013 } | |
6014 else | |
6015 retval[count] = i + 1; | |
6016 } | |
6017 ++count; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6018 id = -1; // remember that we found one |
7 | 6019 } |
6020 } | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6021 vim_regfree(regmatch.regprog); |
7 | 6022 } |
6023 } | |
6024 vim_free(name); | |
6025 if (id == 0) | |
6026 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
6027 semsg(_(e_unknown_group_name_str), p); |
7 | 6028 failed = TRUE; |
6029 break; | |
6030 } | |
6031 if (id > 0) | |
6032 { | |
6033 if (round == 2) | |
6034 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6035 // Got more items than expected, go back to first round |
7 | 6036 if (count >= total_count) |
6037 { | |
6038 vim_free(retval); | |
6039 round = 1; | |
6040 } | |
6041 else | |
6042 retval[count] = id; | |
6043 } | |
6044 ++count; | |
6045 } | |
6046 p = skipwhite(end); | |
6047 if (*p != ',') | |
6048 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6049 p = skipwhite(p + 1); // skip comma in between arguments |
7 | 6050 } |
6051 if (failed) | |
6052 break; | |
6053 if (round == 1) | |
6054 { | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
6055 retval = ALLOC_MULT(short, count + 1); |
7 | 6056 if (retval == NULL) |
6057 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6058 retval[count] = 0; // zero means end of the list |
7 | 6059 total_count = count; |
6060 } | |
6061 } | |
6062 | |
6063 *arg = p; | |
6064 if (failed || retval == NULL) | |
6065 { | |
6066 vim_free(retval); | |
6067 return FAIL; | |
6068 } | |
6069 | |
6070 if (*list == NULL) | |
6071 *list = retval; | |
6072 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6073 vim_free(retval); // list already found, don't overwrite it |
7 | 6074 |
6075 return OK; | |
6076 } | |
6077 | |
6078 /* | |
6079 * Make a copy of an ID list. | |
6080 */ | |
6081 static short * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6082 copy_id_list(short *list) |
7 | 6083 { |
6084 int len; | |
6085 int count; | |
6086 short *retval; | |
6087 | |
6088 if (list == NULL) | |
6089 return NULL; | |
6090 | |
6091 for (count = 0; list[count]; ++count) | |
6092 ; | |
6093 len = (count + 1) * sizeof(short); | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
6094 retval = alloc(len); |
7 | 6095 if (retval != NULL) |
6096 mch_memmove(retval, list, (size_t)len); | |
6097 | |
6098 return retval; | |
6099 } | |
6100 | |
6101 /* | |
6102 * Check if syntax group "ssp" is in the ID list "list" of "cur_si". | |
6103 * "cur_si" can be NULL if not checking the "containedin" list. | |
6104 * Used to check if a syntax item is in the "contains" or "nextgroup" list of | |
6105 * the current item. | |
6106 * This function is called very often, keep it fast!! | |
6107 */ | |
6108 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6109 in_id_list( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6110 stateitem_T *cur_si, // current item or NULL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6111 short *list, // id list |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6112 struct sp_syn *ssp, // group id and ":syn include" tag of group |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6113 int contained) // group id is contained |
7 | 6114 { |
6115 int retval; | |
6116 short *scl_list; | |
6117 short item; | |
6118 short id = ssp->id; | |
6119 static int depth = 0; | |
6120 int r; | |
6121 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6122 // If ssp has a "containedin" list and "cur_si" is in it, return TRUE. |
36 | 6123 if (cur_si != NULL && ssp->cont_in_list != NULL |
6124 && !(cur_si->si_flags & HL_MATCH)) | |
7 | 6125 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6126 // Ignore transparent items without a contains argument. Double check |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6127 // that we don't go back past the first one. |
7 | 6128 while ((cur_si->si_flags & HL_TRANS_CONT) |
6129 && cur_si > (stateitem_T *)(current_state.ga_data)) | |
6130 --cur_si; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6131 // cur_si->si_idx is -1 for keywords, these never contain anything. |
7 | 6132 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
|
6133 &(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
|
6134 SYN_ITEMS(syn_block)[cur_si->si_idx].sp_flags & HL_CONTAINED)) |
7 | 6135 return TRUE; |
6136 } | |
6137 | |
6138 if (list == NULL) | |
6139 return FALSE; | |
6140 | |
6141 /* | |
6142 * If list is ID_LIST_ALL, we are in a transparent item that isn't | |
6143 * inside anything. Only allow not-contained groups. | |
6144 */ | |
6145 if (list == ID_LIST_ALL) | |
6146 return !contained; | |
6147 | |
6148 /* | |
6149 * If the first item is "ALLBUT", return TRUE if "id" is NOT in the | |
6150 * contains list. We also require that "id" is at the same ":syn include" | |
6151 * level as the list. | |
6152 */ | |
6153 item = *list; | |
6154 if (item >= SYNID_ALLBUT && item < SYNID_CLUSTER) | |
6155 { | |
6156 if (item < SYNID_TOP) | |
6157 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6158 // ALL or ALLBUT: accept all groups in the same file |
7 | 6159 if (item - SYNID_ALLBUT != ssp->inc_tag) |
6160 return FALSE; | |
6161 } | |
6162 else if (item < SYNID_CONTAINED) | |
6163 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6164 // TOP: accept all not-contained groups in the same file |
7 | 6165 if (item - SYNID_TOP != ssp->inc_tag || contained) |
6166 return FALSE; | |
6167 } | |
6168 else | |
6169 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6170 // CONTAINED: accept all contained groups in the same file |
7 | 6171 if (item - SYNID_CONTAINED != ssp->inc_tag || !contained) |
6172 return FALSE; | |
6173 } | |
6174 item = *++list; | |
6175 retval = FALSE; | |
6176 } | |
6177 else | |
6178 retval = TRUE; | |
6179 | |
6180 /* | |
6181 * Return "retval" if id is in the contains list. | |
6182 */ | |
6183 while (item != 0) | |
6184 { | |
6185 if (item == id) | |
6186 return retval; | |
6187 if (item >= SYNID_CLUSTER) | |
6188 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6189 scl_list = SYN_CLSTR(syn_block)[item - SYNID_CLUSTER].scl_list; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6190 // restrict recursiveness to 30 to avoid an endless loop for a |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6191 // cluster that includes itself (indirectly) |
7 | 6192 if (scl_list != NULL && depth < 30) |
6193 { | |
6194 ++depth; | |
6195 r = in_id_list(NULL, scl_list, ssp, contained); | |
6196 --depth; | |
6197 if (r) | |
6198 return retval; | |
6199 } | |
6200 } | |
6201 item = *++list; | |
6202 } | |
6203 return !retval; | |
6204 } | |
6205 | |
6206 struct subcommand | |
6207 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6208 char *name; // subcommand name |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6209 void (*func)(exarg_T *, int); // function to call |
7 | 6210 }; |
6211 | |
6212 static struct subcommand subcommands[] = | |
6213 { | |
6214 {"case", syn_cmd_case}, | |
6215 {"clear", syn_cmd_clear}, | |
6216 {"cluster", syn_cmd_cluster}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6217 {"conceal", syn_cmd_conceal}, |
7 | 6218 {"enable", syn_cmd_enable}, |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6219 {"foldlevel", syn_cmd_foldlevel}, |
7 | 6220 {"include", syn_cmd_include}, |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
6221 {"iskeyword", syn_cmd_iskeyword}, |
7 | 6222 {"keyword", syn_cmd_keyword}, |
6223 {"list", syn_cmd_list}, | |
6224 {"manual", syn_cmd_manual}, | |
6225 {"match", syn_cmd_match}, | |
6226 {"on", syn_cmd_on}, | |
6227 {"off", syn_cmd_off}, | |
6228 {"region", syn_cmd_region}, | |
6229 {"reset", syn_cmd_reset}, | |
419 | 6230 {"spell", syn_cmd_spell}, |
7 | 6231 {"sync", syn_cmd_sync}, |
6232 {"", syn_cmd_list}, | |
6233 {NULL, NULL} | |
6234 }; | |
6235 | |
6236 /* | |
6237 * ":syntax". | |
6238 * This searches the subcommands[] table for the subcommand name, and calls a | |
6239 * syntax_subcommand() function to do the rest. | |
6240 */ | |
6241 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6242 ex_syntax(exarg_T *eap) |
7 | 6243 { |
6244 char_u *arg = eap->arg; | |
6245 char_u *subcmd_end; | |
6246 char_u *subcmd_name; | |
6247 int i; | |
6248 | |
6249 syn_cmdlinep = eap->cmdlinep; | |
6250 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6251 // isolate subcommand name |
7 | 6252 for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end) |
6253 ; | |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
6254 subcmd_name = vim_strnsave(arg, subcmd_end - arg); |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6255 if (subcmd_name == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6256 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6257 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6258 if (eap->skip) // skip error messages for all subcommands |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6259 ++emsg_skip; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6260 for (i = 0; ; ++i) |
7 | 6261 { |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6262 if (subcommands[i].name == NULL) |
7 | 6263 { |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6264 semsg(_(e_invalid_syntax_subcommand_str), subcmd_name); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6265 break; |
7 | 6266 } |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6267 if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6268 { |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6269 eap->arg = skipwhite(subcmd_end); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6270 (subcommands[i].func)(eap, FALSE); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6271 break; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6272 } |
7 | 6273 } |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6274 vim_free(subcmd_name); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6275 if (eap->skip) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6276 --emsg_skip; |
7 | 6277 } |
6278 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6279 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6280 ex_ownsyntax(exarg_T *eap) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6281 { |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6282 char_u *old_value; |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6283 char_u *new_value; |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6284 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6285 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
|
6286 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16790
diff
changeset
|
6287 curwin->w_s = ALLOC_ONE(synblock_T); |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
32118
diff
changeset
|
6288 CLEAR_POINTER(curwin->w_s); |
7030
8d513ddfe3ec
commit https://github.com/vim/vim/commit/670acbc70f371409b46b722bd9a1166e53574f42
Christian Brabandt <cb@256bit.org>
parents:
7017
diff
changeset
|
6289 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
|
6290 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
|
6291 #ifdef FEAT_SPELL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6292 // TODO: keep the spell checking as it was. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6293 curwin->w_p_spell = FALSE; // No spell checking |
22258
a6af570dad75
patch 8.2.1678: crash when using ":set" after ":ownsyntax"
Bram Moolenaar <Bram@vim.org>
parents:
21240
diff
changeset
|
6294 // make sure option values are "empty_option" instead of NULL |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6295 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
|
6296 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
|
6297 clear_string_option(&curwin->w_s->b_p_spl); |
22258
a6af570dad75
patch 8.2.1678: crash when using ":set" after ":ownsyntax"
Bram Moolenaar <Bram@vim.org>
parents:
21240
diff
changeset
|
6298 clear_string_option(&curwin->w_s->b_p_spo); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6299 #endif |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7685
diff
changeset
|
6300 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
|
6301 } |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6302 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6303 // save value of b:current_syntax |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6304 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
|
6305 if (old_value != NULL) |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6306 old_value = vim_strsave(old_value); |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6307 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6308 // Apply the "syntax" autocommand event, this finds and loads the syntax |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6309 // file. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6310 apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, TRUE, curbuf); |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6311 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6312 // move value of b:current_syntax to w:current_syntax |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6313 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
|
6314 if (new_value != NULL) |
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6315 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
|
6316 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6317 // restore value of b:current_syntax |
2256
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6318 if (old_value == NULL) |
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6319 do_unlet((char_u *)"b:current_syntax", TRUE); |
8b3203df361f
Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2253
diff
changeset
|
6320 else |
2252
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6321 { |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6322 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
|
6323 vim_free(old_value); |
a0b5918c33cc
Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
6324 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6325 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6326 |
7 | 6327 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6328 syntax_present(win_T *win) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6329 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6330 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
|
6331 || 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
|
6332 || 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
|
6333 || win->w_s->b_keywtab_ic.ht_used > 0); |
7 | 6334 } |
6335 | |
6336 | |
6337 static enum | |
6338 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6339 EXP_SUBCMD, // expand ":syn" sub-commands |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6340 EXP_CASE, // expand ":syn case" arguments |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6341 EXP_SPELL, // expand ":syn spell" arguments |
29890
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6342 EXP_SYNC, // expand ":syn sync" arguments |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6343 EXP_CLUSTER // expand ":syn list @cluster" arguments |
7 | 6344 } expand_what; |
6345 | |
1322 | 6346 /* |
6347 * Reset include_link, include_default, include_none to 0. | |
6348 * Called when we are done expanding. | |
6349 */ | |
6350 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6351 reset_expand_highlight(void) |
1322 | 6352 { |
6353 include_link = include_default = include_none = 0; | |
6354 } | |
6355 | |
6356 /* | |
6357 * Handle command line completion for :match and :echohl command: Add "None" | |
6358 * as highlight group. | |
6359 */ | |
6360 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6361 set_context_in_echohl_cmd(expand_T *xp, char_u *arg) |
1322 | 6362 { |
6363 xp->xp_context = EXPAND_HIGHLIGHT; | |
6364 xp->xp_pattern = arg; | |
6365 include_none = 1; | |
6366 } | |
7 | 6367 |
6368 /* | |
6369 * Handle command line completion for :syntax command. | |
6370 */ | |
6371 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6372 set_context_in_syntax_cmd(expand_T *xp, char_u *arg) |
7 | 6373 { |
6374 char_u *p; | |
6375 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6376 // Default: expand subcommands |
7 | 6377 xp->xp_context = EXPAND_SYNTAX; |
6378 expand_what = EXP_SUBCMD; | |
6379 xp->xp_pattern = arg; | |
1322 | 6380 include_link = 0; |
6381 include_default = 0; | |
7 | 6382 |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6383 if (*arg == NUL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6384 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6385 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6386 // (part of) subcommand already typed |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6387 p = skiptowhite(arg); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6388 if (*p == NUL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6389 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6390 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6391 // past first word |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6392 xp->xp_pattern = skipwhite(p); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6393 if (*skiptowhite(xp->xp_pattern) != NUL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6394 xp->xp_context = EXPAND_NOTHING; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6395 else if (STRNICMP(arg, "case", p - arg) == 0) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6396 expand_what = EXP_CASE; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6397 else if (STRNICMP(arg, "spell", p - arg) == 0) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6398 expand_what = EXP_SPELL; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6399 else if (STRNICMP(arg, "sync", p - arg) == 0) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6400 expand_what = EXP_SYNC; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6401 else if (STRNICMP(arg, "list", p - arg) == 0) |
7 | 6402 { |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6403 p = skipwhite(p); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6404 if (*p == '@') |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6405 expand_what = EXP_CLUSTER; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6406 else |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6407 xp->xp_context = EXPAND_HIGHLIGHT; |
7 | 6408 } |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6409 else if (STRNICMP(arg, "keyword", p - arg) == 0 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6410 || STRNICMP(arg, "region", p - arg) == 0 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6411 || STRNICMP(arg, "match", p - arg) == 0) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6412 xp->xp_context = EXPAND_HIGHLIGHT; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6413 else |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31602
diff
changeset
|
6414 xp->xp_context = EXPAND_NOTHING; |
7 | 6415 } |
6416 | |
6417 /* | |
6418 * Function given to ExpandGeneric() to obtain the list syntax names for | |
6419 * expansion. | |
6420 */ | |
6421 char_u * | |
29892
db0939444c96
patch 9.0.0284: using static buffer for multiple completion functions
Bram Moolenaar <Bram@vim.org>
parents:
29890
diff
changeset
|
6422 get_syntax_name(expand_T *xp, int idx) |
7 | 6423 { |
10534
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6424 switch (expand_what) |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6425 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6426 case EXP_SUBCMD: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6427 return (char_u *)subcommands[idx].name; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6428 case EXP_CASE: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6429 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6430 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
|
6431 return (char_u *)case_args[idx]; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6432 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6433 case EXP_SPELL: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6434 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6435 static char *spell_args[] = |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6436 {"toplevel", "notoplevel", "default", NULL}; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6437 return (char_u *)spell_args[idx]; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6438 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6439 case EXP_SYNC: |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6440 { |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6441 static char *sync_args[] = |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6442 {"ccomment", "clear", "fromstart", |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6443 "linebreaks=", "linecont", "lines=", "match", |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6444 "maxlines=", "minlines=", "region", NULL}; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6445 return (char_u *)sync_args[idx]; |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6446 } |
29890
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6447 case EXP_CLUSTER: |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6448 { |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6449 if (idx < curwin->w_s->b_syn_clusters.ga_len) |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6450 { |
29892
db0939444c96
patch 9.0.0284: using static buffer for multiple completion functions
Bram Moolenaar <Bram@vim.org>
parents:
29890
diff
changeset
|
6451 vim_snprintf((char *)xp->xp_buf, EXPAND_BUF_LEN, "@%s", |
29890
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6452 SYN_CLSTR(curwin->w_s)[idx].scl_name); |
29892
db0939444c96
patch 9.0.0284: using static buffer for multiple completion functions
Bram Moolenaar <Bram@vim.org>
parents:
29890
diff
changeset
|
6453 return xp->xp_buf; |
29890
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6454 } |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6455 else |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6456 return NULL; |
80929331a836
patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
6457 } |
10534
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6458 } |
1c6db35e3527
commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents:
10530
diff
changeset
|
6459 return NULL; |
7 | 6460 } |
6461 | |
6462 | |
6463 /* | |
6464 * Function called for expression evaluation: get syntax ID at file position. | |
6465 */ | |
6466 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6467 syn_get_id( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6468 win_T *wp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6469 long lnum, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6470 colnr_T col, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6471 int trans, // remove transparency |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6472 int *spellp, // return: can do spell checking |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6473 int keep_state) // keep state of char at "col" |
7 | 6474 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6475 // When the position is not after the current position and in the same |
28475
a7556b47ff09
patch 8.2.4762: using freed memory using synstack() and synID() in WinEnter
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
6476 // line of the same window with the same buffer, need to restart parsing. |
a7556b47ff09
patch 8.2.4762: using freed memory using synstack() and synID() in WinEnter
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
6477 if (wp != syn_win |
a7556b47ff09
patch 8.2.4762: using freed memory using synstack() and synID() in WinEnter
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
6478 || wp->w_buffer != syn_buf |
7 | 6479 || lnum != current_lnum |
253 | 6480 || col < current_col) |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6481 syntax_start(wp, lnum); |
7685
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6482 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
|
6483 && lnum == current_lnum |
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6484 && col > current_col) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6485 // next_match may not be correct when moving around, e.g. with the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6486 // "skip" expression in searchpair() |
7685
616460b73ee3
commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents:
7504
diff
changeset
|
6487 next_match_idx = -1; |
7 | 6488 |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6489 (void)get_syntax_attr(col, spellp, keep_state); |
7 | 6490 |
6491 return (trans ? current_trans_id : current_id); | |
6492 } | |
6493 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6494 #if defined(FEAT_CONCEAL) || defined(PROTO) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6495 /* |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6496 * 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
|
6497 * 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
|
6498 * 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
|
6499 * 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
|
6500 */ |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6501 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6502 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
|
6503 { |
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
|
6504 *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
|
6505 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
|
6506 } |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6507 |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2318
diff
changeset
|
6508 /* |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6509 * Return conceal substitution character |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6510 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6511 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6512 syn_get_sub_char(void) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6513 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6514 return current_sub_char; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6515 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6516 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
6517 |
1500 | 6518 #if defined(FEAT_EVAL) || defined(PROTO) |
6519 /* | |
6520 * Return the syntax ID at position "i" in the current stack. | |
6521 * The caller must have called syn_get_id() before to fill the stack. | |
6522 * Returns -1 when "i" is out of range. | |
6523 */ | |
6524 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6525 syn_get_stack_item(int i) |
1500 | 6526 { |
1504 | 6527 if (i >= current_state.ga_len) |
6528 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6529 // Need to invalidate the state, because we didn't properly finish it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6530 // for the last character, "keep_state" was TRUE. |
1504 | 6531 invalidate_current_state(); |
6532 current_col = MAXCOL; | |
1500 | 6533 return -1; |
1504 | 6534 } |
1500 | 6535 return CUR_STATE(i).si_id; |
6536 } | |
6537 #endif | |
6538 | |
7 | 6539 #if defined(FEAT_FOLDING) || defined(PROTO) |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6540 static int |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6541 syn_cur_foldlevel(void) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6542 { |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6543 int level = 0; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6544 int i; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6545 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6546 for (i = 0; i < current_state.ga_len; ++i) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6547 if (CUR_STATE(i).si_flags & HL_FOLD) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6548 ++level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6549 return level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6550 } |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6551 |
7 | 6552 /* |
6553 * Function called to get folding level for line "lnum" in window "wp". | |
6554 */ | |
6555 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6556 syn_get_foldlevel(win_T *wp, long lnum) |
7 | 6557 { |
6558 int level = 0; | |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6559 int low_level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6560 int cur_level; |
7 | 6561 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6562 // 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
|
6563 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
|
6564 && !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
|
6565 # 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
|
6566 && !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
|
6567 # endif |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6568 ) |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
6569 { |
12510
7a887dccd13a
patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6570 syntax_start(wp, lnum); |
7 | 6571 |
20623
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6572 // Start with the fold level at the start of the line. |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6573 level = syn_cur_foldlevel(); |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6574 |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6575 if (wp->w_s->b_syn_foldlevel == SYNFLD_MINIMUM) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6576 { |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6577 // Find the lowest fold level that is followed by a higher one. |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6578 cur_level = level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6579 low_level = cur_level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6580 while (!current_finished) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6581 { |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6582 (void)syn_current_attr(FALSE, FALSE, NULL, FALSE); |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6583 cur_level = syn_cur_foldlevel(); |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6584 if (cur_level < low_level) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6585 low_level = cur_level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6586 else if (cur_level > low_level) |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6587 level = low_level; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6588 ++current_col; |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6589 } |
99b6e6bf48bf
patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
6590 } |
7 | 6591 } |
6592 if (level > wp->w_p_fdn) | |
1028 | 6593 { |
7 | 6594 level = wp->w_p_fdn; |
1028 | 6595 if (level < 0) |
6596 level = 0; | |
6597 } | |
7 | 6598 return level; |
6599 } | |
6600 #endif | |
6601 | |
6567 | 6602 #if defined(FEAT_PROFILE) || defined(PROTO) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6603 /* |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6604 * ":syntime". |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6605 */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6606 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6607 ex_syntime(exarg_T *eap) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6608 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6609 if (STRCMP(eap->arg, "on") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6610 syn_time_on = TRUE; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6611 else if (STRCMP(eap->arg, "off") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6612 syn_time_on = FALSE; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6613 else if (STRCMP(eap->arg, "clear") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6614 syntime_clear(); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6615 else if (STRCMP(eap->arg, "report") == 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6616 syntime_report(); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6617 else |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26199
diff
changeset
|
6618 semsg(_(e_invalid_argument_str), eap->arg); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6619 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6620 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6621 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6622 syn_clear_time(syn_time_T *st) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6623 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6624 profile_zero(&st->total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6625 profile_zero(&st->slowest); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6626 st->count = 0; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6627 st->match = 0; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6628 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6629 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6630 /* |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6631 * Clear the syntax timing for the current buffer. |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6632 */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6633 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6634 syntime_clear(void) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6635 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6636 int idx; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6637 synpat_T *spp; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6638 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6639 if (!syntax_present(curwin)) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6640 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6641 msg(_(msg_no_items)); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6642 return; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6643 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6644 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
|
6645 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6646 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6647 syn_clear_time(&spp->sp_time); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6648 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6649 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6650 |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6651 /* |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6652 * 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
|
6653 * ":syntime {on,off,clear,report}" command. |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6654 */ |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6655 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6656 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
|
6657 { |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6658 switch (idx) |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6659 { |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6660 case 0: return (char_u *)"on"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6661 case 1: return (char_u *)"off"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6662 case 2: return (char_u *)"clear"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6663 case 3: return (char_u *)"report"; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6664 } |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6665 return NULL; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6666 } |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6667 |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6668 typedef struct |
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 proftime_T total; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6671 int count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6672 int match; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6673 proftime_T slowest; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6674 proftime_T average; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6675 int id; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6676 char_u *pattern; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6677 } time_entry_T; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6678 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6679 static int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6680 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
|
6681 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6682 const time_entry_T *s1 = v1; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6683 const time_entry_T *s2 = v2; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6684 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6685 return profile_cmp(&s1->total, &s2->total); |
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 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6688 /* |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6689 * Clear the syntax timing for the current buffer. |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6690 */ |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6691 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
6692 syntime_report(void) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6693 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6694 int idx; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6695 synpat_T *spp; |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
29892
diff
changeset
|
6696 # if defined(FEAT_RELTIME) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6697 proftime_T tm; |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4791
diff
changeset
|
6698 # endif |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6699 int len; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6700 proftime_T total_total; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6701 int total_count = 0; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6702 garray_T ga; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6703 time_entry_T *p; |
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 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6707 msg(_(msg_no_items)); |
4764
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 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6711 ga_init2(&ga, sizeof(time_entry_T), 50); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6712 profile_zero(&total_total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6713 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
|
6714 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6715 spp = &(SYN_ITEMS(curwin->w_s)[idx]); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6716 if (spp->sp_time.count > 0) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6717 { |
7009 | 6718 (void)ga_grow(&ga, 1); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6719 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
|
6720 p->total = spp->sp_time.total; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6721 profile_add(&total_total, &spp->sp_time.total); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6722 p->count = spp->sp_time.count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6723 p->match = spp->sp_time.match; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6724 total_count += spp->sp_time.count; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6725 p->slowest = spp->sp_time.slowest; |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
29892
diff
changeset
|
6726 # if defined(FEAT_RELTIME) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6727 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
|
6728 p->average = tm; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6729 # endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6730 p->id = spp->sp_syn.id; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6731 p->pattern = spp->sp_pattern; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6732 ++ga.ga_len; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6733 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6734 } |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6735 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6736 // Sort on total time. Skip if there are no items to avoid passing NULL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6737 // pointer to qsort(). |
10530
ea5adbeccfc1
commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents:
10499
diff
changeset
|
6738 if (ga.ga_len > 1) |
ea5adbeccfc1
commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents:
10499
diff
changeset
|
6739 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
|
6740 syn_compare_syntime); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6741 |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6742 msg_puts_title(_(" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN")); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6743 msg_puts("\n"); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6744 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
|
6745 { |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6746 p = ((time_entry_T *)ga.ga_data) + idx; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6747 |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6748 msg_puts(profile_msg(&p->total)); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6749 msg_puts(" "); // make sure there is always a separating space |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6750 msg_advance(13); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6751 msg_outnum(p->count); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6752 msg_puts(" "); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6753 msg_advance(20); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6754 msg_outnum(p->match); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6755 msg_puts(" "); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6756 msg_advance(26); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6757 msg_puts(profile_msg(&p->slowest)); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6758 msg_puts(" "); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6759 msg_advance(38); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6760 msg_puts(profile_msg(&p->average)); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6761 msg_puts(" "); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6762 msg_advance(50); |
17401
5462bb963075
patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents:
17389
diff
changeset
|
6763 msg_outtrans(highlight_group_name(p->id - 1)); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6764 msg_puts(" "); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6765 |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6766 msg_advance(69); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6767 if (Columns < 80) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6768 len = 20; // will wrap anyway |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6769 else |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6770 len = Columns - 70; |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6771 if (len > (int)STRLEN(p->pattern)) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6772 len = (int)STRLEN(p->pattern); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6773 msg_outtrans_len(p->pattern, len); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6774 msg_puts("\n"); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6775 } |
4791
65cef998f860
updated for version 7.3.1142
Bram Moolenaar <bram@vim.org>
parents:
4776
diff
changeset
|
6776 ga_clear(&ga); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6777 if (!got_int) |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6778 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6779 msg_puts("\n"); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6780 msg_puts(profile_msg(&total_total)); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6781 msg_advance(13); |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6782 msg_outnum(total_count); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6783 msg_puts("\n"); |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6784 } |
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 #endif |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
6787 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17907
diff
changeset
|
6788 #endif // FEAT_SYN_HL |