annotate src/syntax.c @ 31750:13cecb002fe6 v9.0.1207

patch 9.0.1207: error when object type is expected but getting "any" Commit: https://github.com/vim/vim/commit/450c7a97d1a28f715acaf562298112b9b932adc3 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 16 16:39:37 2023 +0000 patch 9.0.1207: error when object type is expected but getting "any" Problem: Error when object type is expected but getting "any". Solution: When actual type is "any" use a runtime type check. (closes #11826)
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 Jan 2023 17:45:02 +0100
parents 53c3df37a2b0
children 543153d582d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * syntax.c: code for syntax highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #if defined(FEAT_SYN_HL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #define SPO_COUNT 7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 static char *(spo_name_tab[SPO_COUNT]) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 {"ms=", "me=", "hs=", "he=", "rs=", "re=", "lc="};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 * The patterns that are being searched for are stored in a syn_pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 * A match item consists of one pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 * A start/end item consists of n start patterns and m end patterns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 * A start/skip/end item consists of n start patterns, one skip pattern and m
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 * end patterns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 * For the latter two, the patterns are always consecutive: start-skip-end.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 * A character offset can be given for the matched text (_m_start and _m_end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 typedef struct syn_pattern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 } synpat_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 #define SYN_ITEMS(buf) ((synpat_T *)((buf)->b_syn_patterns.ga_data))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 * Flags for b_syn_sync_flags:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 #define SYN_STATE_P(ssp) ((bufstate_T *)((ssp)->ga_data))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 * The attributes of the syntax item that has been recognized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
110 typedef struct syn_cluster_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
115 } syn_cluster_T;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 * Methods of combining two clusters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
124 #define SYN_CLSTR(buf) ((syn_cluster_T *)((buf)->b_syn_clusters.ga_data))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 * Syntax group IDs have different types:
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
128 * 0 - 19999 normal syntax groups
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
129 * 20000 - 20999 ALLBUT indicator (current_syn_inc_tag added)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
130 * 21000 - 21999 TOP indicator (current_syn_inc_tag added)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
131 * 22000 - 22999 CONTAINED indicator (current_syn_inc_tag added)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
132 * 23000 - 32767 cluster IDs (subtract SYNID_CLUSTER for the cluster ID)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
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
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
140 #define MAX_CLUSTER_ID (32767 - SYNID_CLUSTER)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 * Annoying Hack(TM): ":syn include" needs this pointer to pass to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 * expand_filename(). Most of the other syntax commands don't need it, so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 * instead of passing it to them, we stow it here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 static char_u **syn_cmdlinep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 * rules in each ":syn include"'d file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 static int current_syn_inc_tag = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 static int running_syn_inc_tag = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 /*
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
158 * In a hashtable item "hi_key" points to "keyword" in a keyentry.
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
159 * This avoids adding a pointer to the hashtable item.
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
160 * KE2HIKEY() converts a var pointer to a hashitem key pointer.
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
161 * HIKEY2KE() converts a hashitem key pointer to a var pointer.
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
162 * HI2KE() converts a hashitem pointer to a var pointer.
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
163 */
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
164 static keyentry_T dumkey;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
165 #define KE2HIKEY(kp) ((kp)->keyword)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
166 #define HIKEY2KE(p) ((keyentry_T *)((p) - (dumkey.keyword - (char_u *)&dumkey)))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
167 #define HI2KE(hi) HIKEY2KE((hi)->hi_key)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
168
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
169 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 * To reduce the time spent in keepend(), remember at which level in the state
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 * stack the first item with "keepend" is present. When "-1", there is no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 * "keepend" on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 static int keepend_level = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 * For the current state we need to remember more than just the idx.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 * When si_m_endpos.lnum is 0, the items other than si_idx are unknown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 * (The end positions have the column number of the next char)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 typedef struct state_item
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 } stateitem_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 /*
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
219 * Struct to reduce the number of arguments to get_syn_options(), it's used
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
220 * very often.
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
221 */
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
222 typedef struct
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
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
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
232 } syn_opt_arg_T;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
233
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
234 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 * The next possible match in the current line for any pattern is remembered,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 * to avoid having to try for a match in each column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 * If next_match_idx == -1, not tried (in this line) yet.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 * If next_match_col == MAXCOL, no match found in this line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 * (All end positions have the column of the char after the end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 static reg_extmatch_T *next_match_extmatch = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 #define INVALID_STATE(ssp) ((ssp)->ga_itemsize == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 #define VALID_STATE(ssp) ((ssp)->ga_itemsize != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 * The current state (within the line) of the recognition engine.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 * When current_state.ga_itemsize is 0 the current state is invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 #define CUR_STATE(idx) ((stateitem_T *)(current_state.ga_data))[idx]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 * Start the syntax recognition for a line. This function is normally called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 * from the screen updating, once for each displayed line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 * it. Careful: curbuf and curwin are likely to point to another buffer and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 * window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 synstate_T *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 synstate_T *last_valid = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 synstate_T *last_min_valid = NULL;
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
363 synstate_T *sp, *prev = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 linenr_T parsed_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 linenr_T first_stored;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 * After switching buffers, invalidate current_state.
26
404aac550f35 updated for version 7.0017
vimboss
parents: 24
diff changeset
375 * Also do this when a change was made, the current state may be invalid
404aac550f35 updated for version 7.0017
vimboss
parents: 24
diff changeset
376 * then.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 syn_win = wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 * Allocate syntax stack when needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 * If the state of the end of the previous line is useful, store it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 if (VALID_STATE(&current_state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 && current_lnum < lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 && current_lnum < syn_buf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 (void)syn_finish_line(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 if (!current_state_stored)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 ++current_lnum;
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
408 (void)store_current_state();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 * If the current_lnum is now the same as "lnum", keep the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 * state (this happens very often!). Otherwise invalidate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 * current_state and figure it out below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 if (current_lnum != lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 * Try to synchronize from a saved state in b_sst_array[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 * Only do this if lnum is not before and not to far beyond a saved state.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
426 if (INVALID_STATE(&current_state) && syn_block->b_sst_array != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 if (p->sst_lnum > lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 if (p->sst_lnum <= lnum && p->sst_change_lnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 last_min_valid = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 if (last_min_valid != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 load_current_state(last_min_valid);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 * If "lnum" is before or far beyond a line with a saved state, need to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 * re-synchronize.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 if (INVALID_STATE(&current_state))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 syn_sync(wp, lnum, last_valid);
2906
8477b2cc2b81 updated for version 7.3.226
Bram Moolenaar <bram@vim.org>
parents: 2863
diff changeset
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
8477b2cc2b81 updated for version 7.3.226
Bram Moolenaar <bram@vim.org>
parents: 2863
diff changeset
453 first_stored = 1;
8477b2cc2b81 updated for version 7.3.226
Bram Moolenaar <bram@vim.org>
parents: 2863
diff changeset
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
8477b2cc2b81 updated for version 7.3.226
Bram Moolenaar <bram@vim.org>
parents: 2863
diff changeset
457 first_stored = current_lnum + syn_block->b_syn_sync_minlines;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 first_stored = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 * Advance from the sync point or saved state until the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 * Save some entries for syncing with later on.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
467 dist = 999999;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 while (current_lnum < lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 syn_start_line();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 (void)syn_finish_line(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 ++current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 if (current_lnum >= first_stored)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 if (prev == NULL)
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
484 prev = syn_stack_find_entry(current_lnum - 1);
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 else
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
488 sp = prev;
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
489 while (sp != NULL && sp->sst_lnum < current_lnum)
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
490 sp = sp->sst_next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 if (sp != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 && sp->sst_lnum == current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 && syn_stack_equal(sp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 parsed_lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 prev = sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 while (sp != NULL && sp->sst_change_lnum <= parsed_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 prev = sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 sp->sst_change_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 sp = sp->sst_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 load_current_state(prev);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 else if (prev == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 || current_lnum == lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 || current_lnum >= prev->sst_lnum + dist)
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
516 prev = store_current_state();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 current_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 syn_start_line();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 * We cannot simply discard growarrays full of state_items or buf_states; we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 * have to manually release their extmatch pointers first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 garray_T *gap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 if (p->sst_stacksize > SST_FIX_STATES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 gap = &(p->sst_union.sst_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 for (i = 0; i < gap->ga_len; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 unref_extmatch(SYN_STATE_P(gap)[i].bs_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 ga_clear(gap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 for (i = 0; i < p->sst_stacksize; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 unref_extmatch(p->sst_union.sst_stack[i].bs_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 * Cleanup the current_state stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 stateitem_T *sip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 sip = (stateitem_T *)(current_state.ga_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 for (i = 0; i < current_state.ga_len; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 unref_extmatch(sip[i].si_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 ga_clear(&current_state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 * Try to find a synchronisation point for line "lnum".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 * This sets current_lnum and the current state. One of three methods is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 * used:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 * 1. Search backwards for the end of a C-comment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 * 2. Search backwards for given sync patterns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 * 3. Simply start on a given number of lines above "lnum".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 buf_T *curbuf_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 win_T *curwin_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 pos_T cursor_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 linenr_T end_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 linenr_T break_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 int had_sync_point;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 stateitem_T *cur_si;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 synpat_T *spp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 int found_flags = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 int found_match_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 linenr_T found_current_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 int found_current_col= 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 lpos_T found_m_endpos;
442
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
602 colnr_T prev_current_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 * Clear any current state that might be hanging around.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 * Start at least "minlines" back. Default starting point for parsing is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 * there.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 * Start further back, to avoid that scrolling backwards will result in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 * resyncing for every line. Now it resyncs only one out of N lines,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 * where N is minlines * 1.5, or minlines * 2 if minlines is small.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 * Watch out for overflow when minlines is MAXLNUM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
617 if (syn_block->b_syn_sync_minlines > start_lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 start_lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
621 if (syn_block->b_syn_sync_minlines == 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 lnum = 1;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
623 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
624 lnum = syn_block->b_syn_sync_minlines * 2;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 else
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
626 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
627 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
628 && lnum > syn_block->b_syn_sync_maxlines)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
629 lnum = syn_block->b_syn_sync_maxlines;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 if (lnum >= start_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 start_lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 start_lnum -= lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 current_lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 * 1. Search backwards for the end of a C-style comment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
640 if (syn_block->b_syn_sync_flags & SF_CCOMMENT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
642 // 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
643 // use find_start_comment().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 curwin_save = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 curwin = wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 curbuf_save = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 curbuf = syn_buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 * Skip lines that end in a backslash.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 for ( ; start_lnum > 1; --start_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 line = ml_get(start_lnum - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 if (*line == NUL || *(line + STRLEN(line) - 1) != '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 current_lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 cursor_save = wp->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 wp->w_cursor.lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 wp->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 * If the line is inside a comment, need to find the syntax item that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 * defines the comment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 * Restrict the search for the end of a comment to b_syn_sync_maxlines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 validate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 if (push_current_state(idx) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 update_si_attr(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 wp->w_cursor = cursor_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 curwin = curwin_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 curbuf = curbuf_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 * 2. Search backwards for given sync patterns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 break_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700
699
2af8de31a3a8 updated for version 7.0211
vimboss
parents: 697
diff changeset
701 found_m_endpos.lnum = 0;
2af8de31a3a8 updated for version 7.0211
vimboss
parents: 697
diff changeset
702 found_m_endpos.col = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 end_lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 while (--lnum > break_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 current_lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 if (last_valid != NULL && lnum == last_valid->sst_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 load_current_state(last_valid);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 * Check if the previous line has the line-continuation pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 if (lnum > 1 && syn_match_linecont(lnum - 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 * Start with nothing on the state stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 validate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 for (current_lnum = lnum; current_lnum < end_lnum; ++current_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 syn_start_line();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 had_sync_point = syn_finish_line(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 * When a sync point has been found, remember where, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 * continue to look for another one, further on in the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 if (had_sync_point && current_state.ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 if (cur_si->si_m_endpos.lnum > start_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 current_lnum = end_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 }
1371
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
753 if (cur_si->si_idx < 0)
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
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
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
756 found_flags = 0;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
757 found_match_idx = KEYWORD_IDX;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
758 }
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
759 else
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
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
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
762 found_flags = spp->sp_flags;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
763 found_match_idx = spp->sp_sync_idx;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
764 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 found_current_lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 found_current_col = current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 found_m_endpos = cur_si->si_m_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 * Continue after the match (be aware of a zero-length
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 * match).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 if (found_m_endpos.lnum > current_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 current_lnum = found_m_endpos.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 current_col = found_m_endpos.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 if (current_lnum >= end_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 else if (found_m_endpos.col > current_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 current_col = found_m_endpos.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 ++current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
787 prev_current_col = current_col;
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
788 if (syn_getcurline()[current_col] != NUL)
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
789 ++current_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 check_state_ends();
442
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
791 current_col = prev_current_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 * If a sync point was encountered, break here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 if (found_flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 * Put the item that was specified by the sync point on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 * state stack. If there was no item specified, make the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 * state stack empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 clear_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 if (found_match_idx >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 && push_current_state(found_match_idx) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 update_si_attr(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 * When using "grouphere", continue from the sync point
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 * match, until the end of the line. Parsing starts at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 * the next line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 * For "groupthere" the parsing starts at start_lnum.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 if (found_flags & HL_SYNC_HERE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 if (current_state.ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 cur_si->si_h_startpos.lnum = found_current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 cur_si->si_h_startpos.col = found_current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 update_si_end(cur_si, (int)current_col, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 check_keepend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 current_col = found_m_endpos.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 current_lnum = found_m_endpos.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 (void)syn_finish_line(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 ++current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 current_lnum = start_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 end_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 if (lnum <= break_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 invalidate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 current_lnum = break_lnum + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 validate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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 {
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
858 if (syn_block->b_syn_isk != empty_option)
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
859 {
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
860 mch_memmove(chartab, syn_buf->b_chartab, (size_t)32);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
861 mch_memmove(syn_buf->b_chartab, syn_win->w_s->b_syn_chartab,
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
862 (size_t)32);
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
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
866 static void
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
867 restore_chartab(char_u *chartab)
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
868 {
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
869 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
870 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
871 }
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
872
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 * Return TRUE if the line-continuation pattern matches in line "lnum".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
877 syn_match_linecont(linenr_T lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 regmmatch_T regmatch;
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
880 int r;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
881 char_u buf_chartab[32]; // chartab array for syn iskyeyword
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
883 if (syn_block->b_syn_linecont_prog != NULL)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
884 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
885 // use syntax iskeyword option
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
886 save_chartab(buf_chartab);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
887 regmatch.rmm_ic = syn_block->b_syn_linecont_ic;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
888 regmatch.regprog = syn_block->b_syn_linecont_prog;
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
889 r = syn_regexec(&regmatch, lnum, (colnr_T)0,
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
890 IF_SYN_TIME(&syn_block->b_syn_linecont_time));
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
891 syn_block->b_syn_linecont_prog = regmatch.regprog;
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
892 restore_chartab(buf_chartab);
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
893 return r;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 * Prepare the current state for the start of a line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
902 syn_start_line(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 current_finished = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 current_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 * Need to update the end of a start/skip/end that continues from the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 * previous line and regions that have "keepend".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 if (current_state.ga_len > 0)
2863
8d8bd6307b1a updated for version 7.3.205
Bram Moolenaar <bram@vim.org>
parents: 2831
diff changeset
912 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 syn_update_ends(TRUE);
2863
8d8bd6307b1a updated for version 7.3.205
Bram Moolenaar <bram@vim.org>
parents: 2831
diff changeset
914 check_state_ends();
8d8bd6307b1a updated for version 7.3.205
Bram Moolenaar <bram@vim.org>
parents: 2831
diff changeset
915 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 next_match_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 ++current_line_id;
11581
2298fda621d3 patch 8.0.0673: build failure without conceal feature
Christian Brabandt <cb@256bit.org>
parents: 11579
diff changeset
919 #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
920 next_seqnr = 1;
11581
2298fda621d3 patch 8.0.0673: build failure without conceal feature
Christian Brabandt <cb@256bit.org>
parents: 11579
diff changeset
921 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 * Check for items in the stack that need their end updated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 * When "startofline" is TRUE the last item is always updated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 * When "startofline" is FALSE the item with "keepend" is forcefully updated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
930 syn_update_ends(int startofline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 stateitem_T *cur_si;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 int i;
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
934 int seen_keepend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 if (startofline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
938 // 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
939 // contained region. The match ends as soon as the region ends.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 for (i = 0; i < current_state.ga_len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 cur_si = &CUR_STATE(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 if (cur_si->si_idx >= 0
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
944 && (SYN_ITEMS(syn_block)[cur_si->si_idx]).sp_type
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 == SPTYPE_MATCH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 && cur_si->si_m_endpos.lnum < current_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 cur_si->si_flags |= HL_MATCHCONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 cur_si->si_m_endpos.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 cur_si->si_m_endpos.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 cur_si->si_h_endpos = cur_si->si_m_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 cur_si->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 * Need to update the end of a start/skip/end that continues from the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 * previous line. And regions that have "keepend", because they may
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
960 * influence contained items. If we've just removed "extend"
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
961 * (startofline == 0) then we should update ends of normal regions
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
962 * contained inside "keepend" because "extend" could have extended
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
963 * these "keepend" regions as well as contained normal regions.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 * Then check for items ending in column 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 i = current_state.ga_len - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 if (keepend_level >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 for ( ; i > keepend_level; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 if (CUR_STATE(i).si_flags & HL_EXTEND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 break;
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
971
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
972 seen_keepend = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 for ( ; i < current_state.ga_len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 cur_si = &CUR_STATE(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 if ((cur_si->si_flags & HL_KEEPEND)
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
977 || (seen_keepend && !startofline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 || (i == current_state.ga_len - 1 && startofline))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
980 cur_si->si_h_startpos.col = 0; // start highl. in col 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 cur_si->si_h_startpos.lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 if (!(cur_si->si_flags & HL_MATCHCONT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 update_si_end(cur_si, (int)current_col, !startofline);
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
985
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
986 if (!startofline && (cur_si->si_flags & HL_KEEPEND))
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
987 seen_keepend = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 check_keepend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
993 /////////////////////////////////////////
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
994 // Handling of the state stack cache.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 * EXPLANATION OF THE SYNTAX STATE STACK CACHE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 * To speed up syntax highlighting, the state stack for the start of some
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 * lines is cached. These entries can be used to start parsing at that point.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 * The stack is kept in b_sst_array[] for each buffer. There is a list of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 * valid entries. b_sst_first points to the first one, then follow sst_next.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 * The entries are sorted on line number. The first entry is often for line 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 * (line 1 always starts with an empty stack).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 * There is also a list for free entries. This construction is used to avoid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 * having to allocate and free memory blocks too often.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 * When making changes to the buffer, this is logged in b_mod_*. When calling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 * update_screen() to update the display, it will call
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 * syn_stack_apply_changes() for each displayed buffer to adjust the cached
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 * entries. The entries which are inside the changed area are removed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 * because they must be recomputed. Entries below the changed have their line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 * number adjusted for deleted/inserted lines, and have their sst_change_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 * set to indicate that a check must be made if the changed lines would change
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 * the cached entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 * When later displaying lines, an entry is stored for each line. Displayed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 * lines are likely to be displayed again, in which case the state at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 * start of the line is needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 * For not displayed lines, an entry is stored for every so many lines. These
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 * entries will be used e.g., when scrolling backwards. The distance between
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 * entries depends on the number of lines in the buffer. For small buffers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 * the distance is fixed at SST_DIST, for large buffers there is a fixed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 * number of entries SST_MAX_ENTRIES, and the distance is computed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1028 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1029 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
1030 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1031 synstate_T *p;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1032
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1033 if (block->b_sst_array != NULL)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1034 {
19934
3ff714d765ba patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1035 FOR_ALL_SYNSTATES(block, p)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1036 clear_syn_state(p);
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
1037 VIM_CLEAR(block->b_sst_array);
14850
85ef79b16181 patch 8.1.0437: may access freed memory when syntax HL times out
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
1038 block->b_sst_first = NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1039 block->b_sst_len = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1040 }
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1041 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 * Free b_sst_array[] for buffer "buf".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 * Used when syntax items changed to force resyncing everywhere.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1047 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
1048 {
11073
d2178a6cc9f3 patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents: 10952
diff changeset
1049 #ifdef FEAT_FOLDING
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 win_T *wp;
11073
d2178a6cc9f3 patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents: 10952
diff changeset
1051 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1053 syn_stack_free_block(block);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1054
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 #ifdef FEAT_FOLDING
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1056 // When using "syntax" fold method, must update all folds.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1059 if (wp->w_s == block && foldmethodIsSyntax(wp))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 foldUpdateAll(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 * Allocate the syntax state stack for syn_buf when needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 * If the number of entries in b_sst_array[] is much too big or a bit too
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 * small, reallocate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 * Also used to allocate b_sst_array[] for the first time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1072 syn_stack_alloc(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 long len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 synstate_T *to, *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 synstate_T *sstp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 len = syn_buf->b_ml.ml_line_count / SST_DIST + Rows * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 if (len < SST_MIN_ENTRIES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 len = SST_MIN_ENTRIES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 else if (len > SST_MAX_ENTRIES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 len = SST_MAX_ENTRIES;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1083 if (syn_block->b_sst_len > len * 2 || syn_block->b_sst_len < len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1085 // Allocate 50% too much, to avoid reallocating too often.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 len = syn_buf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 len = (len + len / 2) / SST_DIST + Rows * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 if (len < SST_MIN_ENTRIES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 len = SST_MIN_ENTRIES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 else if (len > SST_MAX_ENTRIES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 len = SST_MAX_ENTRIES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1093 if (syn_block->b_sst_array != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1095 // 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
1096 // 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
1097 while (syn_block->b_sst_len - syn_block->b_sst_freecount + 2 > len
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 && syn_stack_cleanup())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 ;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1100 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
1101 len = syn_block->b_sst_len - syn_block->b_sst_freecount + 2;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103
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
1104 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
1105 if (sstp == NULL) // out of memory!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 to = sstp - 1;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1109 if (syn_block->b_sst_array != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1111 // 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
1112 for (from = syn_block->b_sst_first; from != NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 from = from->sst_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 ++to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 *to = *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 to->sst_next = to + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 if (to != sstp - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 to->sst_next = NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1123 syn_block->b_sst_first = sstp;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1124 syn_block->b_sst_freecount = len - (int)(to - sstp) - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1128 syn_block->b_sst_first = NULL;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1129 syn_block->b_sst_freecount = len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1132 // Create the list of free entries.
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1133 syn_block->b_sst_firstfree = to + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 while (++to < sstp + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 to->sst_next = to + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 (sstp + len - 1)->sst_next = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1138 vim_free(syn_block->b_sst_array);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1139 syn_block->b_sst_array = sstp;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1140 syn_block->b_sst_len = len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 * Check for changes in a buffer to affect stored syntax states. Uses the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 * b_mod_* fields.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 * Called from update_screen(), before screen is being updated, once for each
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 * displayed buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1151 syn_stack_apply_changes(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1153 win_T *wp;
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 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
1156
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1157 FOR_ALL_WINDOWS(wp)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1158 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1159 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
1160 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
1161 }
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1162 }
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1163
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1164 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1165 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
1166 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 synstate_T *p, *prev, *np;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 linenr_T n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 prev = NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1171 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
1172 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1173 if (p->sst_lnum + block->b_syn_sync_linebreaks > buf->b_mod_top)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 n = p->sst_lnum + buf->b_mod_xlines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 if (n <= buf->b_mod_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1178 // this state is inside the changed area, remove it
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 np = p->sst_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 if (prev == NULL)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1181 block->b_sst_first = np;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 prev->sst_next = np;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1184 syn_stack_free_entry(block, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 p = np;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1188 // 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
1189 // 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
1190 // again.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 if (p->sst_change_lnum != 0 && p->sst_change_lnum > buf->b_mod_top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 if (p->sst_change_lnum + buf->b_mod_xlines > buf->b_mod_top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 p->sst_change_lnum += buf->b_mod_xlines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 p->sst_change_lnum = buf->b_mod_top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 if (p->sst_change_lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 || p->sst_change_lnum < buf->b_mod_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 p->sst_change_lnum = buf->b_mod_bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 p->sst_lnum = n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 prev = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 p = p->sst_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 * Reduce the number of entries in the state stack for syn_buf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 * Returns TRUE if at least one entry was freed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1214 syn_stack_cleanup(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 synstate_T *p, *prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 disptick_T tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 int above;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 int dist;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 int retval = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221
14850
85ef79b16181 patch 8.1.0437: may access freed memory when syntax HL times out
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
1222 if (syn_block->b_sst_first == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1225 // 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
1226 if (syn_block->b_sst_len <= Rows)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
1227 dist = 999999;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
1228 else
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1229 dist = syn_buf->b_ml.ml_line_count / (syn_block->b_sst_len - Rows) + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 /*
2020
710da9abc3c1 updated for version 7.2-317
vimboss
parents: 1883
diff changeset
1232 * Go through the list to find the "tick" for the oldest entry that can
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 * be removed. Set "above" when the "tick" for the oldest entry is above
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 * "b_sst_lasttick" (the display tick wraps around).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1236 tick = syn_block->b_sst_lasttick;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 above = FALSE;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1238 prev = syn_block->b_sst_first;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 if (prev->sst_lnum + dist > p->sst_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1243 if (p->sst_tick > syn_block->b_sst_lasttick)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 if (!above || p->sst_tick < tick)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 tick = p->sst_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 above = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 else if (!above && p->sst_tick < tick)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 tick = p->sst_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 * Go through the list to make the entries for the oldest tick at an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 * interval of several lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1258 prev = syn_block->b_sst_first;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 if (p->sst_tick == tick && prev->sst_lnum + dist > p->sst_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1263 // Move this entry from used list to free list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 prev->sst_next = p->sst_next;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1265 syn_stack_free_entry(syn_block, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 p = prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 retval = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 * Free the allocated memory for a syn_state item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 * Move the entry into the free list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1278 syn_stack_free_entry(synblock_T *block, synstate_T *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 clear_syn_state(p);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1281 p->sst_next = block->b_sst_firstfree;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1282 block->b_sst_firstfree = p;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1283 ++block->b_sst_freecount;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 * Find an entry in the list of state stacks at or before "lnum".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 * Returns NULL when there is no entry or the first entry is after "lnum".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 static synstate_T *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1291 syn_stack_find_entry(linenr_T lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 synstate_T *p, *prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 prev = NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1296 for (p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 if (p->sst_lnum == lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 if (p->sst_lnum > lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 return prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 * Try saving the current state in b_sst_array[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 * The current state must be valid for the start of the current_lnum line!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 static synstate_T *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1311 store_current_state(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 synstate_T *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 bufstate_T *bp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 stateitem_T *cur_si;
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
1317 synstate_T *sp = syn_stack_find_entry(current_lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 * If the current state contains a start or end pattern that continues
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 * from the previous line, we can't use it. Don't store it then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 for (i = current_state.ga_len - 1; i >= 0; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 cur_si = &CUR_STATE(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 if (cur_si->si_h_startpos.lnum >= current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 || cur_si->si_m_endpos.lnum >= current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 || cur_si->si_h_endpos.lnum >= current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 || (cur_si->si_end_idx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 && cur_si->si_eoe_pos.lnum >= current_lnum))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 if (i >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 if (sp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1337 // 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
1338 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
1339 // it's the first entry
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1340 syn_block->b_sst_first = sp->sst_next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1343 // 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
1344 FOR_ALL_SYNSTATES(syn_block, p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 if (p->sst_next == sp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 break;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1347 if (p != NULL) // just in case
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
1348 p->sst_next = sp->sst_next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1350 syn_stack_free_entry(syn_block, sp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 sp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 else if (sp == NULL || sp->sst_lnum != current_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 * Add a new entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1359 // 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
1360 if (syn_block->b_sst_freecount == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 (void)syn_stack_cleanup();
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1363 // "sp" may have been moved to the freelist now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 sp = syn_stack_find_entry(current_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1366 // 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
1367 if (syn_block->b_sst_freecount == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 sp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1371 // 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
1372 // list, after *sp
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1373 p = syn_block->b_sst_firstfree;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1374 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
1375 --syn_block->b_sst_freecount;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 if (sp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1378 // Insert in front of the list
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1379 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
1380 syn_block->b_sst_first = p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1384 // insert in list after *sp
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 p->sst_next = sp->sst_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 sp->sst_next = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 sp = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 sp->sst_stacksize = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 sp->sst_lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 if (sp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1395 // When overwriting an existing state stack, clear it first
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 clear_syn_state(sp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 sp->sst_stacksize = current_state.ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 if (current_state.ga_len > SST_FIX_STATES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1400 // 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
1401 // 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
1402 ga_init2(&sp->sst_union.sst_ga, sizeof(bufstate_T), 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 if (ga_grow(&sp->sst_union.sst_ga, current_state.ga_len) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 sp->sst_stacksize = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 sp->sst_union.sst_ga.ga_len = current_state.ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 bp = SYN_STATE_P(&(sp->sst_union.sst_ga));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 bp = sp->sst_union.sst_stack;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 for (i = 0; i < sp->sst_stacksize; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 bp[i].bs_idx = CUR_STATE(i).si_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 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
1415 #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
1416 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
1417 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
1418 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 bp[i].bs_extmatch = ref_extmatch(CUR_STATE(i).si_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 sp->sst_next_flags = current_next_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 sp->sst_next_list = current_next_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 sp->sst_tick = display_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 sp->sst_change_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 current_state_stored = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 return sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 * Copy a state stack from "from" in b_sst_array[] to current_state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1434 load_current_state(synstate_T *from)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 bufstate_T *bp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 clear_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 validate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 keepend_level = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 if (from->sst_stacksize
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 && ga_grow(&current_state, from->sst_stacksize) != FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 if (from->sst_stacksize > SST_FIX_STATES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 bp = SYN_STATE_P(&(from->sst_union.sst_ga));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 bp = from->sst_union.sst_stack;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 for (i = 0; i < from->sst_stacksize; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 CUR_STATE(i).si_idx = bp[i].bs_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 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
1453 #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
1454 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
1455 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
1456 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 CUR_STATE(i).si_extmatch = ref_extmatch(bp[i].bs_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 if (keepend_level < 0 && (CUR_STATE(i).si_flags & HL_KEEPEND))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 keepend_level = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 CUR_STATE(i).si_ends = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 CUR_STATE(i).si_m_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 if (CUR_STATE(i).si_idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 CUR_STATE(i).si_next_list =
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1464 (SYN_ITEMS(syn_block)[CUR_STATE(i).si_idx]).sp_next_list;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 CUR_STATE(i).si_next_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 update_si_attr(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 current_state.ga_len = from->sst_stacksize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 current_next_list = from->sst_next_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 current_next_flags = from->sst_next_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 current_lnum = from->sst_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 * Compare saved state stack "*sp" with the current state.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 * Return TRUE when they are equal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1481 syn_stack_equal(synstate_T *sp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 int i, j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 bufstate_T *bp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 reg_extmatch_T *six, *bsx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1487 // 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
1488 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
1489 || 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
1490 return FALSE;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1491
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1492 // 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
1493 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
1494 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
1495 else
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1496 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
1497
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1498 for (i = current_state.ga_len; --i >= 0; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 {
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1500 // 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
1501 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
1502 break;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1503 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
1504 continue;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1505 // 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
1506 // 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
1507 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
1508 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
1509 // 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
1510 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
1511 break;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1512 for (j = 0; j < NSUBEXP; ++j)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 {
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1514 // 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
1515 if (bsx->matches[j] != six->matches[j])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 {
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1517 // 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
1518 // 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
1519 // sp_ic flag set.
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1520 if (bsx->matches[j] == NULL || six->matches[j] == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 break;
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1522 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
1523 ? 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
1524 : STRCMP(bsx->matches[j], six->matches[j]) != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 }
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1528 if (j != NSUBEXP)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1529 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 }
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29218
diff changeset
1531 return i < 0 ? TRUE : FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 * We stop parsing syntax above line "lnum". If the stored state at or below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 * this line depended on a change before it, it now depends on the line below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 * the last parsed line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 * The window looks like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 * line which changed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 * displayed line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 * displayed line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 * lnum -> line below window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 void
30831
fbeebe308514 patch 9.0.0750: crash when popup closed in callback
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
1545 syntax_end_parsing(win_T *wp, linenr_T lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 synstate_T *sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548
30831
fbeebe308514 patch 9.0.0750: crash when popup closed in callback
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
1549 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
1550 return; // not the right window
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 sp = syn_stack_find_entry(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 if (sp != NULL && sp->sst_lnum < lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 sp = sp->sst_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 if (sp != NULL && sp->sst_change_lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 sp->sst_change_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 * End of handling of the state stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 ****************************************/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1564 invalidate_current_state(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 clear_current_state();
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1567 current_state.ga_itemsize = 0; // mark current_state invalid
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 current_next_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 keepend_level = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1573 validate_current_state(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 current_state.ga_itemsize = sizeof(stateitem_T);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 current_state.ga_growsize = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 * Return TRUE if the syntax at start of lnum changed since last time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 * This will only be called just after get_syntax_attr() for the previous
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 * line, to check if the next line needs to be redrawn too.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1585 syntax_check_changed(linenr_T lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 int retval = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 synstate_T *sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 * Check the state stack when:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 * - lnum is just below the previously syntaxed line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 * - lnum is not before the lines with saved states.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 * - lnum is not past the lines with saved states.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 * - lnum is at or before the last changed line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 if (VALID_STATE(&current_state) && lnum == current_lnum + 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 sp = syn_stack_find_entry(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 if (sp != NULL && sp->sst_lnum == lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 * finish the previous line (needed when not all of the line was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 * drawn)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 (void)syn_finish_line(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 * Compare the current state with the previously saved state of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 * the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 if (syn_stack_equal(sp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 retval = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 * Store the current state in b_sst_array[] for later use.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 ++current_lnum;
1512
aa7c51f81f46 updated for version 7.1-227
vimboss
parents: 1504
diff changeset
1619 (void)store_current_state();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 * Finish the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 * This doesn't return any attributes, it only gets the state at the end of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 * the line. It can start anywhere in the line, as long as the current state
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 * is valid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1633 syn_finish_line(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1634 int syncing) // called for syncing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 stateitem_T *cur_si;
442
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
1637 colnr_T prev_current_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1639 while (!current_finished)
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 (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
1642 /*
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1643 * 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
1644 */
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1645 if (syncing && current_state.ga_len)
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1646 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 /*
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1648 * Check for match with sync item.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 */
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1650 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
1651 if (cur_si->si_idx >= 0
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1652 && (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
1653 & (HL_SYNC_HERE|HL_SYNC_THERE)))
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1654 return TRUE;
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1655
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1656 // 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
1657 // 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
1658 // past the NUL.
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1659 prev_current_col = current_col;
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1660 if (syn_getcurline()[current_col] != NUL)
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1661 ++current_col;
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1662 check_state_ends();
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1663 current_col = prev_current_col;
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1664 }
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
1665 ++current_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 * Return highlight attributes for next character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 * Must first call syntax_start() once for the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 * "col" is normally 0 for the first use in a line, and increments by one each
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 * time. It's allowed to skip characters and to stop before the end of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 * line. But only a "col" after a previously used column is allowed.
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
1676 * When "can_spell" is not NULL set it to TRUE when spell-checking should be
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
1677 * done.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1680 get_syntax_attr(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1681 colnr_T col,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1682 int *can_spell,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1683 int keep_state) // keep state of char at "col"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 int attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686
1363
3328b87305ef updated for version 7.1-077
vimboss
parents: 1326
diff changeset
1687 if (can_spell != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1688 // 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
1689 // ":syn spell toplevel" was used.
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1690 *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
1691 ? (syn_block->b_spell_cluster_id == 0)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1692 : (syn_block->b_syn_spell == SYNSPL_TOP);
1363
3328b87305ef updated for version 7.1-077
vimboss
parents: 1326
diff changeset
1693
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1694 // check for out of memory situation
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1695 if (syn_block->b_sst_array == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1698 // After 'synmaxcol' the attribute is always zero.
431
8b77f61b399b updated for version 7.0111
vimboss
parents: 419
diff changeset
1699 if (syn_buf->b_p_smc > 0 && col >= (colnr_T)syn_buf->b_p_smc)
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1700 {
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1701 clear_current_state();
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1702 #ifdef FEAT_EVAL
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1703 current_id = 0;
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1704 current_trans_id = 0;
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1705 #endif
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2392
diff changeset
1706 #ifdef FEAT_CONCEAL
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2392
diff changeset
1707 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
1708 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
1709 #endif
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1710 return 0;
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1711 }
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
1712
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1713 // Make sure current_state is valid
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 if (INVALID_STATE(&current_state))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 validate_current_state();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 * Skip from the current column to "col", get the attributes for "col".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 while (current_col <= col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 {
1504
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
1722 attr = syn_current_attr(FALSE, TRUE, can_spell,
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
1723 current_col == col ? keep_state : FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 ++current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 return attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 * Get syntax attributes for current_lnum, current_col.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1734 syn_current_attr(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1735 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
1736 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
1737 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
1738 int keep_state) // keep syntax stack afterwards
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 int syn_id;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1741 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
1742 lpos_T hl_startpos; // was: int hl_startcol;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 lpos_T hl_endpos;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1744 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
1745 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
1746 int end_idx; // group ID for end pattern
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 synpat_T *spp;
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
1749 stateitem_T *cur_si, *sip = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 int startcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 int endcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 long flags;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1753 int cchar;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 short *next_list;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1755 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
1756 static int try_next_column = FALSE; // must try in next col
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 int do_keywords;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 regmmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 lpos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 int lc_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 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
1762 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
1763 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
1764 // looking for a pattern match!
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1765
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1766 // variables for zero-width matches that have a "nextgroup" argument
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 int keep_next_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 int zero_width_next_list = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 garray_T zero_width_next_ga;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 * No character, no attributes! Past end of line?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 * Do try matching with an empty line (could be the start of a region).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 line = syn_getcurline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 if (line[current_col] == NUL && current_col != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 * If we found a match after the last column, use it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 if (next_match_idx >= 0 && next_match_col >= (int)current_col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 && next_match_col != MAXCOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 (void)push_next_match(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 current_finished = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 current_state_stored = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1790 // if the current or next character is NUL, we will finish the line now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 if (line[current_col] == NUL || line[current_col + 1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 current_finished = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 current_state_stored = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 * When in the previous column there was a match but it could not be used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 * (empty match or already matched in this column) need to try again in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 * the next column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 if (try_next_column)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 next_match_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 try_next_column = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1808 // Only check for keywords when not syncing and there are some.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 do_keywords = !syncing
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1810 && (syn_block->b_keywtab.ht_used > 0
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1811 || syn_block->b_keywtab_ic.ht_used > 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1813 // 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
1814 // 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
1815 ga_init2(&zero_width_next_ga, sizeof(int), 10);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1817 // use syntax iskeyword option
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
1818 save_chartab(buf_chartab);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
1819
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 * Repeat matching keywords and patterns, to find contained items at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 * same column. This stops when there are no extra matches at the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 * column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 found_match = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 keep_next_list = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 syn_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
1831
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 * 1. Check for a current state.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 * Only when there is no current state, or if the current state may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 * contain other things, we need to check for keywords and patterns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 * Always need to check for contained items if some item has the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 * "containedin" argument (takes extra time!).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 if (current_state.ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 cur_si = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1844 if (syn_block->b_syn_containedin || cur_si == NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 || cur_si->si_cont_list != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 * 2. Check for keywords, if on a keyword char after a non-keyword
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 * char. Don't do this when syncing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 if (do_keywords)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 line = syn_getcurline();
4043
80b041b994d1 updated for version 7.3.776
Bram Moolenaar <bram@vim.org>
parents: 3900
diff changeset
1854 if (vim_iswordp_buf(line + current_col, syn_buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 && (current_col == 0
4043
80b041b994d1 updated for version 7.3.776
Bram Moolenaar <bram@vim.org>
parents: 3900
diff changeset
1856 || !vim_iswordp_buf(line + current_col - 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 - (has_mbyte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 ? (*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
1859 : 0) , syn_buf)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 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
1862 &endcol, &flags, &next_list, cur_si,
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1863 &cchar);
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 168
diff changeset
1864 if (syn_id != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 if (push_current_state(KEYWORD_IDX) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 cur_si->si_m_startcol = current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 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
1871 cur_si->si_h_startpos.col = 0; // starts right away
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 cur_si->si_m_endpos.lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 cur_si->si_m_endpos.col = endcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 cur_si->si_h_endpos.lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 cur_si->si_h_endpos.col = endcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 cur_si->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 cur_si->si_end_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 cur_si->si_flags = flags;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1879 #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
1880 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
1881 cur_si->si_cchar = cchar;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1882 if (current_state.ga_len > 1)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1883 cur_si->si_flags |=
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1884 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
1885 & HL_CONCEAL;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1886 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 cur_si->si_id = syn_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 cur_si->si_trans_id = syn_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 if (flags & HL_TRANSP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 if (current_state.ga_len < 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 cur_si->si_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 cur_si->si_trans_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 cur_si->si_attr = CUR_STATE(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 current_state.ga_len - 2).si_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 cur_si->si_trans_id = CUR_STATE(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 current_state.ga_len - 2).si_trans_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 cur_si->si_attr = syn_id2attr(syn_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 cur_si->si_cont_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 cur_si->si_next_list = next_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 check_keepend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 vim_free(next_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 /*
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 168
diff changeset
1917 * 3. Check for patterns (only if no keyword found).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1919 if (syn_id == 0 && syn_block->b_syn_patterns.ga_len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 * If we didn't check for a match yet, or we are past it, check
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 * for any match with a pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 if (next_match_idx < 0 || next_match_col < (int)current_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 * Check all relevant patterns for a match at this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 * position. This is complicated, because matching with a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 * pattern takes quite a bit of time, thus we want to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 * avoid doing it when it's not needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1933 next_match_idx = 0; // no match in this line yet
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 next_match_col = MAXCOL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1935 for (idx = syn_block->b_syn_patterns.ga_len; --idx >= 0; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
1937 spp = &(SYN_ITEMS(syn_block)[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 if ( spp->sp_syncing == syncing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 && (displaying || !(spp->sp_flags & HL_DISPLAY))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 && (spp->sp_type == SPTYPE_MATCH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 || spp->sp_type == SPTYPE_START)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 && (current_next_list != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 ? in_id_list(NULL, current_next_list,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 &spp->sp_syn, 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 : (cur_si == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 ? !(spp->sp_flags & HL_CONTAINED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 : in_id_list(cur_si,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 cur_si->si_cont_list, &spp->sp_syn,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 spp->sp_flags & HL_CONTAINED))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 {
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
1951 int r;
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
1952
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1953 // 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
1954 // 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
1955 // this item.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 if (spp->sp_line_id == current_line_id
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 && spp->sp_startcol >= next_match_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 spp->sp_line_id = current_line_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 lc_col = current_col - spp->sp_offsets[SPO_LC_OFF];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 if (lc_col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 lc_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 regmatch.rmm_ic = spp->sp_ic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 regmatch.regprog = spp->sp_prog;
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
1967 r = syn_regexec(&regmatch,
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1968 current_lnum,
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1969 (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
1970 IF_SYN_TIME(&spp->sp_time));
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
1971 spp->sp_prog = regmatch.regprog;
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
1972 if (!r)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1974 // no match in this line, try another one
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 spp->sp_startcol = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 * Compute the first column of the match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 syn_add_start_off(&pos, &regmatch,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 spp, SPO_MS_OFF, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 if (pos.lnum > current_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1986 // 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
1987 // we can't handle that
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 spp->sp_startcol = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 startcol = pos.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
1993 // 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
1994 // matches in the current line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 spp->sp_startcol = startcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 * If a previously found match starts at a lower
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 * column number, don't use this one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 if (startcol >= next_match_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 * If we matched this pattern at this position
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 * before, skip it. Must retry in the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 * column, because it may match from there.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 if (did_match_already(idx, &zero_width_next_ga))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 try_next_column = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 endpos.lnum = regmatch.endpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 endpos.col = regmatch.endpos[0].col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2018 // Compute the highlight start.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 syn_add_start_off(&hl_startpos, &regmatch,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 spp, SPO_HS_OFF, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2022 // Compute the region start.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2023 // Default is to use the end of the match.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 syn_add_end_off(&eos_pos, &regmatch,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 spp, SPO_RS_OFF, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 * Grab the external submatches before they get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 * overwritten. Reference count doesn't change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 unref_extmatch(cur_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 cur_extmatch = re_extmatch_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 re_extmatch_out = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 flags = 0;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2036 eoe_pos.lnum = 0; // avoid warning
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 eoe_pos.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 end_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 hl_endpos.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 * For a "oneline" the end must be found in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 * same line too. Search for it after the end of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 * the match with the start pattern. Set the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 * resulting end positions at the same time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 if (spp->sp_type == SPTYPE_START
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 && (spp->sp_flags & HL_ONELINE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 lpos_T startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 startpos = endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 find_endpos(idx, &startpos, &endpos, &hl_endpos,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 &flags, &eoe_pos, &end_idx, cur_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 if (endpos.lnum == 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2056 continue; // not found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 * For a "match" the size must be > 0 after the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 * end offset needs has been added. Except when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 * syncing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 else if (spp->sp_type == SPTYPE_MATCH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 syn_add_end_off(&hl_endpos, &regmatch, spp,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 SPO_HE_OFF, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 syn_add_end_off(&endpos, &regmatch, spp,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 SPO_ME_OFF, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 if (endpos.lnum == current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 && (int)endpos.col + syncing < startcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 * If an empty string is matched, may need
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 * to try matching again at next column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 if (regmatch.startpos[0].col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 == regmatch.endpos[0].col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 try_next_column = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 * keep the best match so far in next_match_*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2087 // 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
2088 // before endpos.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 if (hl_startpos.lnum == current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 && (int)hl_startpos.col < startcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 hl_startpos.col = startcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 limit_pos_zero(&hl_endpos, &endpos);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 next_match_idx = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 next_match_col = startcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 next_match_m_endpos = endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 next_match_h_endpos = hl_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 next_match_h_startpos = hl_startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 next_match_flags = flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 next_match_eos_pos = eos_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 next_match_eoe_pos = eoe_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 next_match_end_idx = end_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 unref_extmatch(next_match_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 next_match_extmatch = cur_extmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105 cur_extmatch = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 * If we found a match at the current column, use it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 if (next_match_idx >= 0 && next_match_col == (int)current_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 synpat_T *lspp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2117 // 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
2118 // 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
2119 lspp = &(SYN_ITEMS(syn_block)[next_match_idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 if (next_match_m_endpos.lnum == current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 && next_match_m_endpos.col == current_col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 && lspp->sp_next_list != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 current_next_list = lspp->sp_next_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 current_next_flags = lspp->sp_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 keep_next_list = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 zero_width_next_list = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2129 // 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
2130 // 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
2131 // endless loop).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 if (ga_grow(&zero_width_next_ga, 1) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 ((int *)(zero_width_next_ga.ga_data))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 [zero_width_next_ga.ga_len++] = next_match_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 next_match_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 cur_si = push_next_match(cur_si);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 found_match = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 * Handle searching for nextgroup match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 if (current_next_list != NULL && !keep_next_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 * If a nextgroup was not found, continue looking for one if:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 * - this is an empty line and the "skipempty" option was given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 * - we are on white space and the "skipwhite" option was given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 if (!found_match)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 line = syn_getcurline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 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
2160 && VIM_ISWHITE(line[current_col]))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 || ((current_next_flags & HL_SKIPEMPTY)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162 && *line == NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167 * If a nextgroup was found: Use it, and continue looking for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 * contained matches.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 * If a nextgroup was not found: Continue looking for a normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 * match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 * When did set current_next_list for a zero-width item and no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 * match was found don't loop (would get stuck).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 current_next_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 next_match_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 if (!zero_width_next_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 found_match = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 } while (found_match);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
2182 restore_chartab(buf_chartab);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
2183
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 * Use attributes from the current state, if within its highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 * If not, use attributes from the current-but-one state, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 current_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2190 current_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 current_trans_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 #endif
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2193 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2194 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
2195 current_seqnr = 0;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2196 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 if (cur_si != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 {
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2199 #ifndef FEAT_EVAL
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2200 int current_trans_id = 0;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2201 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 for (idx = current_state.ga_len - 1; idx >= 0; --idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 sip = &CUR_STATE(idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205 if ((current_lnum > sip->si_h_startpos.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2206 || (current_lnum == sip->si_h_startpos.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 && current_col >= sip->si_h_startpos.col))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 && (sip->si_h_endpos.lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 || current_lnum < sip->si_h_endpos.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 || (current_lnum == sip->si_h_endpos.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 && current_col < sip->si_h_endpos.col)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 current_attr = sip->si_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 current_id = sip->si_id;
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2216 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 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
2218 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2219 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
2220 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
2221 current_sub_char = sip->si_cchar;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2222 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2227 if (can_spell != NULL)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2228 {
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2229 struct sp_syn sps;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2230
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2231 /*
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2232 * set "can_spell" to TRUE if spell checking is supposed to be
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2233 * done in the current item.
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2234 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2235 if (syn_block->b_spell_cluster_id == 0)
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2236 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2237 // 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
2238 // @NoSpell cluster.
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2239 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
2240 || current_trans_id == 0)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2241 *can_spell = (syn_block->b_syn_spell != SYNSPL_NOTOP);
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2242 else
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2243 {
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2244 sps.inc_tag = 0;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2245 sps.id = syn_block->b_nospell_cluster_id;
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2246 sps.cont_in_list = NULL;
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2247 *can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0);
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2248 }
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
2249 }
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2250 else
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2251 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2252 // 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
2253 // 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
2254 // 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
2255 // was used.
320
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2256 if (current_trans_id == 0)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2257 *can_spell = (syn_block->b_syn_spell == SYNSPL_TOP);
320
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2258 else
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2259 {
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2260 sps.inc_tag = 0;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2261 sps.id = syn_block->b_spell_cluster_id;
320
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2262 sps.cont_in_list = NULL;
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2263 *can_spell = in_id_list(sip, sip->si_cont_list, &sps, 0);
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2264
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2265 if (syn_block->b_nospell_cluster_id != 0)
320
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2266 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2267 sps.id = syn_block->b_nospell_cluster_id;
320
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2268 if (in_id_list(sip, sip->si_cont_list, &sps, 0))
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2269 *can_spell = FALSE;
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2270 }
bb9041b0ad81 updated for version 7.0083
vimboss
parents: 308
diff changeset
2271 }
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2272 }
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2273 }
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2274
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2275
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 * Check for end of current state (and the states before it) at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 * next column. Don't do this for syncing, because we would miss a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 * single character match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 * First check if the current state ends at the current column. It
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 * may be for an empty match and a containing item might end in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 * current column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 */
1504
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
2284 if (!syncing && !keep_state)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 check_state_ends();
442
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
2287 if (current_state.ga_len > 0
c36697964844 updated for version 7.0115
vimboss
parents: 431
diff changeset
2288 && syn_getcurline()[current_col] != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 ++current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 check_state_ends();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 --current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 }
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
2296 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
2297 // 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
2298 // ":syn spell toplevel" was used.
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2299 *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
2300 ? (syn_block->b_spell_cluster_id == 0)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2301 : (syn_block->b_syn_spell == SYNSPL_TOP);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2303 // nextgroup ends at end of line, unless "skipnl" or "skipempty" present
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 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
2305 && (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
2306 && line[current_col + 1] == NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 current_next_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 if (zero_width_next_ga.ga_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 ga_clear(&zero_width_next_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2313 // No longer need external matches. But keep next_match_extmatch.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 unref_extmatch(re_extmatch_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 re_extmatch_out = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 unref_extmatch(cur_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 return current_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 * Check if we already matched pattern "idx" at the current column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2326 did_match_already(int idx, garray_T *gap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 for (i = current_state.ga_len; --i >= 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 if (CUR_STATE(i).si_m_startcol == (int)current_col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 && CUR_STATE(i).si_m_lnum == (int)current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 && CUR_STATE(i).si_idx == idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2336 // 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
2337 // stack, and can only be matched once anyway.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 for (i = gap->ga_len; --i >= 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 if (((int *)(gap->ga_data))[i] == idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 * Push the next match onto the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 static stateitem_T *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2349 push_next_match(stateitem_T *cur_si)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 synpat_T *spp;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2352 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2353 int save_flags;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2354 #endif
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2355
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2356 spp = &(SYN_ITEMS(syn_block)[next_match_idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 * Push the item in current_state stack;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 if (push_current_state(next_match_idx) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 * If it's a start-skip-end type that crosses lines, figure out how
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 * much it continues in this line. Otherwise just fill in the length.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 cur_si->si_h_startpos = next_match_h_startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 cur_si->si_m_startcol = current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 cur_si->si_m_lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 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
2372 #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
2373 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
2374 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
2375 if (current_state.ga_len > 1)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2376 cur_si->si_flags |=
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2377 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
2378 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 cur_si->si_next_list = spp->sp_next_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 cur_si->si_extmatch = ref_extmatch(next_match_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 if (spp->sp_type == SPTYPE_START && !(spp->sp_flags & HL_ONELINE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2383 // Try to find the end pattern in the current line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 update_si_end(cur_si, (int)(next_match_m_endpos.col), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 check_keepend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 cur_si->si_m_endpos = next_match_m_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 cur_si->si_h_endpos = next_match_h_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 cur_si->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 cur_si->si_flags |= next_match_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 cur_si->si_eoe_pos = next_match_eoe_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 cur_si->si_end_idx = next_match_end_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 if (keepend_level < 0 && (cur_si->si_flags & HL_KEEPEND))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 keepend_level = current_state.ga_len - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 check_keepend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 update_si_attr(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2401 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2402 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
2403 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405 * If the start pattern has another highlight group, push another item
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406 * on the stack for the start pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408 if ( spp->sp_type == SPTYPE_START
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 && spp->sp_syn_match_id != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 && push_current_state(next_match_idx) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 cur_si->si_h_startpos = next_match_h_startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 cur_si->si_m_startcol = current_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 cur_si->si_m_lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 cur_si->si_m_endpos = next_match_eos_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 cur_si->si_h_endpos = next_match_eos_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 cur_si->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 cur_si->si_end_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 cur_si->si_flags = HL_MATCH;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2421 #ifdef FEAT_CONCEAL
2418
da067045878f Fix for "concealends". (Vince Negri)
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
2422 cur_si->si_seqnr = next_seqnr++;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2423 cur_si->si_flags |= save_flags;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2424 if (cur_si->si_flags & HL_CONCEALENDS)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2425 cur_si->si_flags |= HL_CONCEAL;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2426 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 cur_si->si_next_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 check_keepend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 update_si_attr(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2433 next_match_idx = -1; // try other match next time
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 return cur_si;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 * Check for end of current state (and the states before it).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2442 check_state_ends(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444 stateitem_T *cur_si;
2863
8d8bd6307b1a updated for version 7.3.205
Bram Moolenaar <bram@vim.org>
parents: 2831
diff changeset
2445 int had_extend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 cur_si = &CUR_STATE(current_state.ga_len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 if (cur_si->si_ends
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 && (cur_si->si_m_endpos.lnum < current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 || (cur_si->si_m_endpos.lnum == current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 && cur_si->si_m_endpos.col <= current_col)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 * If there is an end pattern group ID, highlight the end pattern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 * now. No need to pop the current item from the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 * Only do this if the end pattern continues beyond the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 * position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 if (cur_si->si_end_idx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 && (cur_si->si_eoe_pos.lnum > current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 || (cur_si->si_eoe_pos.lnum == current_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 && cur_si->si_eoe_pos.col > current_col)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 cur_si->si_idx = cur_si->si_end_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 cur_si->si_end_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 cur_si->si_m_endpos = cur_si->si_eoe_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 cur_si->si_h_endpos = cur_si->si_eoe_pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 cur_si->si_flags |= HL_MATCH;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2471 #ifdef FEAT_CONCEAL
2418
da067045878f Fix for "concealends". (Vince Negri)
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
2472 cur_si->si_seqnr = next_seqnr++;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2473 if (cur_si->si_flags & HL_CONCEALENDS)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2474 cur_si->si_flags |= HL_CONCEAL;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2475 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 update_si_attr(current_state.ga_len - 1);
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2477
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2478 // nextgroup= should not match in the end pattern
2831
30b7cde21940 updated for version 7.3.190
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2479 current_next_list = NULL;
30b7cde21940 updated for version 7.3.190
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2480
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2481 // what matches next may be different now, clear it
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2482 next_match_idx = 0;
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2483 next_match_col = MAXCOL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 }
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2486
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2487 // 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
2488 // "skipempty"
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2489 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
2490 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
2491 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
2492 && 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
2493 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
2494
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2495 // 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
2496 // "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
2497 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
2498
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2499 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
2500
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2501 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
2502 break;
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2503
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2504 if (had_extend && keepend_level >= 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 {
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2506 syn_update_ends(FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 if (current_state.ga_len == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 break;
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2509 }
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 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
2512
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2513 /*
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2514 * 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
2515 * 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
2516 * 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
2517 * 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
2518 * - "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
2519 * - 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
2520 * - "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
2521 */
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2522 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
2523 && 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
2524 == SPTYPE_START
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2525 && !(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
2526 {
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2527 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
2528 check_keepend();
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
2529 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
2530 && 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
2531 && 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
2532 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 * Update an entry in the current_state stack for a match or region. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 * fills in si_attr, si_next_list and si_cont_list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2545 update_si_attr(int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 stateitem_T *sip = &CUR_STATE(idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 synpat_T *spp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2550 // This should not happen...
1371
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2551 if (sip->si_idx < 0)
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2552 return;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2553
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2554 spp = &(SYN_ITEMS(syn_block)[sip->si_idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 if (sip->si_flags & HL_MATCH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 sip->si_id = spp->sp_syn_match_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 sip->si_id = spp->sp_syn.id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 sip->si_attr = syn_id2attr(sip->si_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 sip->si_trans_id = sip->si_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 if (sip->si_flags & HL_MATCH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 sip->si_cont_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 sip->si_cont_list = spp->sp_cont_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 * For transparent items, take attr from outer item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 * Also take cont_list, if there is none.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 * Don't do this for the matchgroup of a start or end pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 if ((spp->sp_flags & HL_TRANSP) && !(sip->si_flags & HL_MATCH))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 if (idx == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 sip->si_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 sip->si_trans_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 if (sip->si_cont_list == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 sip->si_cont_list = ID_LIST_ALL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 sip->si_attr = CUR_STATE(idx - 1).si_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 if (sip->si_cont_list == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 sip->si_flags |= HL_TRANS_CONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 sip->si_cont_list = CUR_STATE(idx - 1).si_cont_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 * Check the current stack for patterns with "keepend" flag.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 * Propagate the match-end to contained items, until a "skipend" item is found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2598 check_keepend(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601 lpos_T maxpos;
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2602 lpos_T maxpos_h;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 stateitem_T *sip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 * This check can consume a lot of time; only do it from the level where
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 * there really is a keepend.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 if (keepend_level < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 * Find the last index of an "extend" item. "keepend" items before that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 * won't do anything. If there is no "extend" item "i" will be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 * "keepend_level" and all "keepend" items will work normally.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 for (i = current_state.ga_len - 1; i > keepend_level; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 if (CUR_STATE(i).si_flags & HL_EXTEND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 maxpos.lnum = 0;
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1697
diff changeset
2622 maxpos.col = 0;
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2623 maxpos_h.lnum = 0;
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1697
diff changeset
2624 maxpos_h.col = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 for ( ; i < current_state.ga_len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 sip = &CUR_STATE(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 if (maxpos.lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 limit_pos_zero(&sip->si_m_endpos, &maxpos);
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2631 limit_pos_zero(&sip->si_h_endpos, &maxpos_h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 limit_pos_zero(&sip->si_eoe_pos, &maxpos);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 sip->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 }
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2635 if (sip->si_ends && (sip->si_flags & HL_KEEPEND))
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2636 {
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2637 if (maxpos.lnum == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 || maxpos.lnum > sip->si_m_endpos.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 || (maxpos.lnum == sip->si_m_endpos.lnum
991
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2640 && maxpos.col > sip->si_m_endpos.col))
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2641 maxpos = sip->si_m_endpos;
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2642 if (maxpos_h.lnum == 0
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2643 || maxpos_h.lnum > sip->si_h_endpos.lnum
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2644 || (maxpos_h.lnum == sip->si_h_endpos.lnum
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2645 && maxpos_h.col > sip->si_h_endpos.col))
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2646 maxpos_h = sip->si_h_endpos;
ddafd2ba3a86 updated for version 7.0-117
vimboss
parents: 844
diff changeset
2647 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 * Update an entry in the current_state stack for a start-skip-end pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 * This finds the end of the current item, if it's in the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 * Return the flags for the matched END.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2658 update_si_end(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2659 stateitem_T *sip,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2660 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
2661 int force) // when TRUE overrule a previous end
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 lpos_T startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 lpos_T endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 lpos_T hl_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 lpos_T end_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 int end_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2669 // return quickly for a keyword
1371
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2670 if (sip->si_idx < 0)
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2671 return;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2672
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2673 // 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
2674 // 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
2675 // from a containing item.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 if (!force && sip->si_m_endpos.lnum >= current_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 * We need to find the end of the region. It may continue in the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 * line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 end_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 startpos.lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 startpos.col = startcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 find_endpos(sip->si_idx, &startpos, &endpos, &hl_endpos,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 &(sip->si_flags), &end_endpos, &end_idx, sip->si_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 if (endpos.lnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2691 // No end pattern matched.
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2692 if (SYN_ITEMS(syn_block)[sip->si_idx].sp_flags & HL_ONELINE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2694 // a "oneline" never continues in the next line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 sip->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 sip->si_m_endpos.lnum = current_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 sip->si_m_endpos.col = (colnr_T)STRLEN(syn_getcurline());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2701 // continues in the next line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 sip->si_ends = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 sip->si_m_endpos.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 sip->si_h_endpos = sip->si_m_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2709 // match within this line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 sip->si_m_endpos = endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 sip->si_h_endpos = hl_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 sip->si_eoe_pos = end_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 sip->si_ends = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 sip->si_end_idx = end_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 * Add a new state to the current state stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 * It is cleared and the index set to "idx".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 * Return FAIL if it's not possible (out of memory).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2724 push_current_state(int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 if (ga_grow(&current_state, 1) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 return FAIL;
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
2728 CLEAR_POINTER(&CUR_STATE(current_state.ga_len));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 CUR_STATE(current_state.ga_len).si_idx = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 ++current_state.ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 * Remove a state from the current_state stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2738 pop_current_state(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 if (current_state.ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742 unref_extmatch(CUR_STATE(current_state.ga_len - 1).si_extmatch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 --current_state.ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2745 // after the end of a pattern, try matching a keyword or pattern
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 next_match_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2748 // if first state with "keepend" is popped, reset keepend_level
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 if (keepend_level >= current_state.ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 keepend_level = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 * Find the end of a start/skip/end syntax region after "startpos".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 * Only checks one line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 * Also handles a match item that continued from a previous line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 * If not found, the syntax item continues in the next line. m_endpos->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 * will be 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 * If found, the end of the region and the end of the highlighting is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 * computed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
2763 find_endpos(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2764 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
2765 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
2766 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
2767 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
2768 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
2769 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
2770 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
2771 reg_extmatch_T *start_ext) // submatches from the start pattern
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 colnr_T matchcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774 synpat_T *spp, *spp_skip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 int start_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 int best_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 regmmatch_T regmatch;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2778 regmmatch_T best_regmatch; // startpos/endpos of best match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 lpos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 int had_match = FALSE;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2782 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
2783
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2784 // just in case we are invoked for a keyword
1371
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2785 if (idx < 0)
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2786 return;
e8450dbf6f03 updated for version 7.1-086
vimboss
parents: 1363
diff changeset
2787
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 * Check for being called with a START pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 * Can happen with a match that continues to the next line, because it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 * contained a region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2793 spp = &(SYN_ITEMS(syn_block)[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 if (spp->sp_type != SPTYPE_START)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 *hl_endpos = *startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 * Find the SKIP or first END pattern after the last START pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2805 spp = &(SYN_ITEMS(syn_block)[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 if (spp->sp_type != SPTYPE_START)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2812 * Lookup the SKIP pattern (if present)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 if (spp->sp_type == SPTYPE_SKIP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 spp_skip = spp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 spp_skip = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2822 // Setup external matches for syn_regexec().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823 unref_extmatch(re_extmatch_in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 re_extmatch_in = ref_extmatch(start_ext);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2826 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
2827 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
2828 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
2829
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2830 // use syntax iskeyword option
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
2831 save_chartab(buf_chartab);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
2832
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 * Find end pattern that matches first after "matchcol".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 best_idx = -1;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2839 for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 int lc_col = matchcol;
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2842 int r;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2844 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
2845 if (spp->sp_type != SPTYPE_END) // past last END pattern
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 lc_col -= spp->sp_offsets[SPO_LC_OFF];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 if (lc_col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 lc_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851 regmatch.rmm_ic = spp->sp_ic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852 regmatch.regprog = spp->sp_prog;
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2853 r = syn_regexec(&regmatch, startpos->lnum, lc_col,
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2854 IF_SYN_TIME(&spp->sp_time));
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2855 spp->sp_prog = regmatch.regprog;
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2856 if (r)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 if (best_idx == -1 || regmatch.startpos[0].col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 < best_regmatch.startpos[0].col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 best_idx = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 best_regmatch.startpos[0] = regmatch.startpos[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 best_regmatch.endpos[0] = regmatch.endpos[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 * If all end patterns have been tried, and there is no match, the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 * item continues until end-of-line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 if (best_idx == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2873 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 * If the skip pattern matches before the end pattern,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 * continue searching after the skip pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 if (spp_skip != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF];
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2882 int r;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 if (lc_col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 lc_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 regmatch.rmm_ic = spp_skip->sp_ic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 regmatch.regprog = spp_skip->sp_prog;
6375
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2888 r = syn_regexec(&regmatch, startpos->lnum, lc_col,
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2889 IF_SYN_TIME(&spp_skip->sp_time));
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2890 spp_skip->sp_prog = regmatch.regprog;
27a36d1013a6 updated for version 7.4.519
Bram Moolenaar <bram@vim.org>
parents: 5954
diff changeset
2891 if (r && regmatch.startpos[0].col
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892 <= best_regmatch.startpos[0].col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 {
7500
ef568437e49a commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents: 7467
diff changeset
2894 int line_len;
ef568437e49a commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents: 7467
diff changeset
2895
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2896 // Add offset to skip pattern match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897 syn_add_end_off(&pos, &regmatch, spp_skip, SPO_ME_OFF, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2899 // 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
2900 // match with an end pattern in this line.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901 if (pos.lnum > startpos->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 line = ml_get_buf(syn_buf, startpos->lnum, FALSE);
7500
ef568437e49a commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16
Christian Brabandt <cb@256bit.org>
parents: 7467
diff changeset
2905 line_len = (int)STRLEN(line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2907 // take care of an empty match or negative offset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 if (pos.col <= matchcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909 ++matchcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 else if (pos.col <= regmatch.endpos[0].col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911 matchcol = pos.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2913 // Be careful not to jump over the NUL at the end-of-line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 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
2915 matchcol < line_len && matchcol < pos.col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 ++matchcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2919 // 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
2920 if (matchcol >= line_len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2923 continue; // start with first end pattern again
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 * Match from start pattern to end pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 * Correct for match and highlight offset of end pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
2931 spp = &(SYN_ITEMS(syn_block)[best_idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 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
2933 // can't end before the start
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 if (m_endpos->lnum == startpos->lnum && m_endpos->col < startpos->col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 m_endpos->col = startpos->col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937 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
2938 // can't end before the start
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 if (end_endpos->lnum == startpos->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 && end_endpos->col < startpos->col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 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
2942 // can't end after the match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 limit_pos(end_endpos, m_endpos);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2946 * If the end group is highlighted differently, adjust the pointers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 if (spp->sp_syn_match_id != spp->sp_syn.id && spp->sp_syn_match_id != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950 *end_idx = best_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 if (spp->sp_off_flags & (1 << (SPO_RE_OFF + SPO_COUNT)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953 hl_endpos->lnum = best_regmatch.endpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 hl_endpos->col = best_regmatch.endpos[0].col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958 hl_endpos->lnum = best_regmatch.startpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 hl_endpos->col = best_regmatch.startpos[0].col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 hl_endpos->col += spp->sp_offsets[SPO_RE_OFF];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2963 // can't end before the start
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 if (hl_endpos->lnum == startpos->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 && hl_endpos->col < startpos->col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 hl_endpos->col = startpos->col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 limit_pos(hl_endpos, m_endpos);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2969 // 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
2970 // into the matchgroup for the end
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 *m_endpos = *hl_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 *end_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 *hl_endpos = *end_endpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 *flagsp = spp->sp_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981 had_match = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2985 // no match for an END pattern in this line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 if (!had_match)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987 m_endpos->lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
2989 restore_chartab(buf_chartab);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
2990
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
2991 // Remove external matches.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 unref_extmatch(re_extmatch_in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993 re_extmatch_in = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2996 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2997 * Limit "pos" not to be after "limit".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2998 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2999 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3000 limit_pos(lpos_T *pos, lpos_T *limit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3002 if (pos->lnum > limit->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003 *pos = *limit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3004 else if (pos->lnum == limit->lnum && pos->col > limit->col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 pos->col = limit->col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 * Limit "pos" not to be after "limit", unless pos->lnum is zero.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3010 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3012 limit_pos_zero(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3013 lpos_T *pos,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3014 lpos_T *limit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016 if (pos->lnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 *pos = *limit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3018 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3019 limit_pos(pos, limit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 * Add offset to matched text for end of match or highlight.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3025 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3026 syn_add_end_off(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3027 lpos_T *result, // returned position
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3028 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
3029 synpat_T *spp, // matched pattern
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3030 int idx, // index of offset
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3031 int extra) // extra chars for offset to start
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3032 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3033 int col;
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3034 int off;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3035 char_u *base;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3036 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038 if (spp->sp_off_flags & (1 << idx))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3040 result->lnum = regmatch->startpos[0].lnum;
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3041 col = regmatch->startpos[0].col;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3042 off = spp->sp_offsets[idx] + extra;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3043 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3044 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046 result->lnum = regmatch->endpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 col = regmatch->endpos[0].col;
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3048 off = spp->sp_offsets[idx];
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3049 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3050 // 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
3051 // is a matchgroup. Watch out for match with last NL in the buffer.
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3052 if (result->lnum > syn_buf->b_ml.ml_line_count)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3053 col = 0;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3054 else if (off != 0)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3055 {
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3056 base = ml_get_buf(syn_buf, result->lnum, FALSE);
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3057 p = base + col;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3058 if (off > 0)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3059 {
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3060 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
3061 MB_PTR_ADV(p);
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3062 }
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3063 else if (off < 0)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3064 {
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3065 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
3066 MB_PTR_BACK(base, p);
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3067 }
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3068 col = (int)(p - base);
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3069 }
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3070 result->col = col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3071 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 * Add offset to matched text for start of match or highlight.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3075 * Avoid resulting column to become negative.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3078 syn_add_start_off(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3079 lpos_T *result, // returned position
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3080 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
3081 synpat_T *spp,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3082 int idx,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3083 int extra) // extra chars for offset to end
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085 int col;
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3086 int off;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3087 char_u *base;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3088 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3090 if (spp->sp_off_flags & (1 << (idx + SPO_COUNT)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3091 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3092 result->lnum = regmatch->endpos[0].lnum;
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3093 col = regmatch->endpos[0].col;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3094 off = spp->sp_offsets[idx] + extra;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 result->lnum = regmatch->startpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 col = regmatch->startpos[0].col;
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3100 off = spp->sp_offsets[idx];
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3101 }
2092
98cc757f7e3d updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
3102 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
3103 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3104 // 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
3105 result->lnum = syn_buf->b_ml.ml_line_count;
2100
7d121c69f540 updated for version 7.2.383
Bram Moolenaar <bram@zimbu.org>
parents: 2092
diff changeset
3106 col = (int)STRLEN(ml_get_buf(syn_buf, result->lnum, FALSE));
2092
98cc757f7e3d updated for version 7.2.376
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
3107 }
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3108 if (off != 0)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3109 {
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3110 base = ml_get_buf(syn_buf, result->lnum, FALSE);
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3111 p = base + col;
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3112 if (off > 0)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3113 {
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3114 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
3115 MB_PTR_ADV(p);
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3116 }
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3117 else if (off < 0)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3118 {
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3119 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
3120 MB_PTR_BACK(base, p);
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3121 }
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3122 col = (int)(p - base);
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3123 }
18ee39301b82 updated for version 7.2a
vimboss
parents: 1521
diff changeset
3124 result->col = col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 * Get current line in syntax buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130 static char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3131 syn_getcurline(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 return ml_get_buf(syn_buf, current_lnum, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3134 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3136 /*
410
c60ba877860b updated for version 7.0107
vimboss
parents: 386
diff changeset
3137 * Call vim_regexec() to find a match with "rmp" in "syn_buf".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 * Returns TRUE when there is a match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3140 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3141 syn_regexec(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3142 regmmatch_T *rmp,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3143 linenr_T lnum,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3144 colnr_T col,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3145 syn_time_T *st UNUSED)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3146 {
29218
48b36959a4fc patch 8.2.5128: syntax disabled when using synID() in searchpair() skip expr
Bram Moolenaar <Bram@vim.org>
parents: 29071
diff changeset
3147 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
3148 int timed_out = FALSE;
4766
ec24ff78a79c updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents: 4764
diff changeset
3149 #ifdef FEAT_PROFILE
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3150 proftime_T pt;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3151
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3152 if (syn_time_on)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3153 profile_start(&pt);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3154 #endif
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3155
14161
7cac4646c552 patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents: 13976
diff changeset
3156 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
3157 // 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
3158 // 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
3159 // 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
3160 return FALSE;
7cac4646c552 patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents: 13976
diff changeset
3161
410
c60ba877860b updated for version 7.0107
vimboss
parents: 386
diff changeset
3162 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
3163 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
3164
4766
ec24ff78a79c updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents: 4764
diff changeset
3165 #ifdef FEAT_PROFILE
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3166 if (syn_time_on)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3167 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3168 profile_end(&pt);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3169 profile_add(&st->total, &pt);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3170 if (profile_cmp(&pt, &st->slowest) < 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3171 st->slowest = pt;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3172 ++st->count;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3173 if (r > 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3174 ++st->match;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3175 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3176 #endif
11529
998d2cf59caa patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3177 #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
3178 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
3179 {
11529
998d2cf59caa patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3180 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
3181 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
3182 }
11529
998d2cf59caa patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3183 #endif
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3184
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3185 if (r > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3186 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3187 rmp->startpos[0].lnum += lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3188 rmp->endpos[0].lnum += lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3189 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3190 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3191 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3192 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3194 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195 * Check one position in a line for a matching keyword.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3196 * 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
3197 * Return its ID if found, 0 otherwise.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3198 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3199 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3200 check_keyword_id(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3201 char_u *line,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3202 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
3203 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
3204 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
3205 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
3206 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
3207 int *ccharp UNUSED) // conceal substitution char
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3208 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3209 keyentry_T *kp;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3210 char_u *kwp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3211 int round;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3212 int kwlen;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3213 char_u keyword[MAXKEYWLEN + 1]; // assume max. keyword len is 80
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3214 hashtab_T *ht;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3215 hashitem_T *hi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3216
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3217 // 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
3218 // checked.
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3219 kwp = line + startcol;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3220 kwlen = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3221 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3223 if (has_mbyte)
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 448
diff changeset
3224 kwlen += (*mb_ptr2len)(kwp + kwlen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3225 else
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3226 ++kwlen;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3227 }
4043
80b041b994d1 updated for version 7.3.776
Bram Moolenaar <bram@vim.org>
parents: 3900
diff changeset
3228 while (vim_iswordp_buf(kwp + kwlen, syn_buf));
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3229
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3230 if (kwlen > MAXKEYWLEN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3231 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3233 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 * Must make a copy of the keyword, so we can add a NUL and make it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3235 * lowercase.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3236 */
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3237 vim_strncpy(keyword, kwp, kwlen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3239 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 * Try twice:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241 * 1. matching case
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 * 2. ignoring case
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3243 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244 for (round = 1; round <= 2; ++round)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3245 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3246 ht = round == 1 ? &syn_block->b_keywtab : &syn_block->b_keywtab_ic;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3247 if (ht->ht_used == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3248 continue;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3249 if (round == 2) // ignore case
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3250 (void)str_foldcase(kwp, kwlen, keyword, MAXKEYWLEN + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3252 /*
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3253 * Find keywords that match. There can be several with different
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3254 * attributes.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3255 * When current_next_list is non-zero accept only that group, otherwise:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3256 * Accept a not-contained keyword at toplevel.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3257 * Accept a keyword at other levels only if it is in the contains list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3258 */
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3259 hi = hash_find(ht, keyword);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3260 if (!HASHITEM_EMPTY(hi))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3261 for (kp = HI2KE(hi); kp != NULL; kp = kp->ke_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3262 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3263 if (current_next_list != 0
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3264 ? in_id_list(NULL, current_next_list, &kp->k_syn, 0)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3265 : (cur_si == NULL
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3266 ? !(kp->flags & HL_CONTAINED)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3267 : in_id_list(cur_si, cur_si->si_cont_list,
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3268 &kp->k_syn, kp->flags & HL_CONTAINED)))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3269 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3270 *endcolp = startcol + kwlen;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3271 *flagsp = kp->flags;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3272 *next_listp = kp->next_list;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3273 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3274 *ccharp = kp->k_char;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3275 #endif
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3276 return kp->k_syn.id;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
3277 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3278 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3280 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283 /*
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3284 * Handle ":syntax conceal" command.
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3285 */
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3286 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3287 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
3288 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3289 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3290 char_u *arg = eap->arg;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3291 char_u *next;
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 eap->nextcmd = find_nextcmd(arg);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3294 if (eap->skip)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3295 return;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3296
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3297 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
3298 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
3299 {
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
3300 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
3301 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
3302 else
27561
c796016c6204 patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents: 27553
diff changeset
3303 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
3304 }
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
3305 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
3306 curwin->w_s->b_syn_conceal = TRUE;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3307 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
3308 curwin->w_s->b_syn_conceal = FALSE;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3309 else
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
3310 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
3311 #endif
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3312 }
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3313
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3314 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3315 * Handle ":syntax case" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3316 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3318 syn_cmd_case(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 char_u *next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 eap->nextcmd = find_nextcmd(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3324 if (eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3325 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 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
3328 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
3329 {
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
3330 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
3331 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
3332 else
27561
c796016c6204 patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents: 27553
diff changeset
3333 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
3334 }
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
3335 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
3336 curwin->w_s->b_syn_ic = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 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
3338 curwin->w_s->b_syn_ic = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 else
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
3340 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
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
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 /*
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 * 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
3345 */
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 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
3347 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
3348 {
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 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
3350 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
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 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
3353 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
3354 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
3355
99b6e6bf48bf patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
3356 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
3357 {
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 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
3359 {
27553
0ea5147a95f7 patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
3360 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
3361 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
3362 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
3363 }
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 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
3365 }
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
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 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
3368 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
3369 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
3370 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
3371 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
3372 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
3373 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
3374 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
3375 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
3376 }
99b6e6bf48bf patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
3377
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 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
3379 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
3380 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
3381 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
3382 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385 /*
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3386 * Handle ":syntax spell" command.
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3387 */
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3388 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3389 syn_cmd_spell(exarg_T *eap, int syncing UNUSED)
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3390 {
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3391 char_u *arg = eap->arg;
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3392 char_u *next;
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3393
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3394 eap->nextcmd = find_nextcmd(arg);
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3395 if (eap->skip)
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3396 return;
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3397
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3398 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
3399 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
3400 {
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
3401 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
3402 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
3403 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
3404 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
3405 else
27553
0ea5147a95f7 patch 8.2.4303: a few messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
3406 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
3407 }
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
3408 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
3409 curwin->w_s->b_syn_spell = SYNSPL_TOP;
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3410 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
3411 curwin->w_s->b_syn_spell = SYNSPL_NOTOP;
1064
a8bcc7553263 updated for version 7.0-190
vimboss
parents: 1028
diff changeset
3412 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
3413 curwin->w_s->b_syn_spell = SYNSPL_DEFAULT;
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3414 else
6880
bcc0909b379e patch 7.4.760
Bram Moolenaar <bram@vim.org>
parents: 6698
diff changeset
3415 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
3416 semsg(_(e_illegal_argument_str_2), arg);
6880
bcc0909b379e patch 7.4.760
Bram Moolenaar <bram@vim.org>
parents: 6698
diff changeset
3417 return;
bcc0909b379e patch 7.4.760
Bram Moolenaar <bram@vim.org>
parents: 6698
diff changeset
3418 }
bcc0909b379e patch 7.4.760
Bram Moolenaar <bram@vim.org>
parents: 6698
diff changeset
3419
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3420 // 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
3421 redraw_win_later(curwin, UPD_NOT_VALID);
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3422 }
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3423
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
3424 /*
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3425 * Handle ":syntax iskeyword" command.
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3426 */
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3427 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3428 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
3429 {
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3430 char_u *arg = eap->arg;
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3431 char_u save_chartab[32];
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3432 char_u *save_isk;
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3433
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3434 if (eap->skip)
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3435 return;
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3436
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3437 arg = skipwhite(arg);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3438 if (*arg == NUL)
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3439 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3440 msg_puts("\n");
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3441 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
3442 {
27561
c796016c6204 patch 8.2.4307: a few more messages should not be translated
Bram Moolenaar <Bram@vim.org>
parents: 27553
diff changeset
3443 msg_puts("syntax iskeyword ");
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3444 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
3445 }
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3446 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
3447 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
3448 }
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3449 else
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3450 {
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3451 if (STRNICMP(arg, "clear", 5) == 0)
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 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
3454 (size_t)32);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3455 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
3456 }
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3457 else
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 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
3460 save_isk = curbuf->b_p_isk;
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3461 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
3462
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3463 buf_init_chartab(curbuf, FALSE);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3464 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
3465 (size_t)32);
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3466 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
3467 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
3468 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
3469 curbuf->b_p_isk = save_isk;
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 }
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
3472 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
3473 }
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3474
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3475 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3476 * Clear all syntax info for one buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3477 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3478 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3479 syntax_clear(synblock_T *block)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3481 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3482
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3483 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
3484 #ifdef FEAT_RELTIME
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3485 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
3486 #endif
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3487 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
3488 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
3489 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
3490 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
3491 #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
3492 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
3493 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3494
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3495 // free the keywords
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3496 clear_keywtab(&block->b_keywtab);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3497 clear_keywtab(&block->b_keywtab_ic);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3498
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3499 // free the syntax patterns
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3500 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
3501 syn_clear_pattern(block, i);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3502 ga_clear(&block->b_syn_patterns);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3503
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3504 // free the syntax clusters
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3505 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
3506 syn_clear_cluster(block, i);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3507 ga_clear(&block->b_syn_clusters);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3508 block->b_spell_cluster_id = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3509 block->b_nospell_cluster_id = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3510
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3511 block->b_syn_sync_flags = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3512 block->b_syn_sync_minlines = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3513 block->b_syn_sync_maxlines = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3514 block->b_syn_sync_linebreaks = 0;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3515
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
3516 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
3517 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
3518 VIM_CLEAR(block->b_syn_linecont_pat);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3519 #ifdef FEAT_FOLDING
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3520 block->b_syn_folditems = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3521 #endif
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
3522 clear_string_option(&block->b_syn_isk);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3524 // free the stored states
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3525 syn_stack_free_all(block);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3526 invalidate_current_state();
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
3527
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3528 // Reset the counter for ":syn include"
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
3529 running_syn_inc_tag = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3532 /*
2253
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3533 * 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
3534 */
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3535 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3536 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
3537 {
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3538 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
3539 {
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3540 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
3541 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
3542 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
3543 }
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3544 }
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3545
12ebd6f6dfce Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents: 2252
diff changeset
3546 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3547 * Clear syncing info for one buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3548 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3549 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3550 syntax_sync_clear(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3551 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3553
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3554 // free the syntax patterns
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3555 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
3556 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
3557 syn_remove_pattern(curwin->w_s, i);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3558
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3559 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
3560 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
3561 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
3562 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
3563
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
3564 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
3565 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
3566 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
3567 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
3568
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3569 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3572 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3573 * Remove one pattern from the buffer's pattern list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3574 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3575 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3576 syn_remove_pattern(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3577 synblock_T *block,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3578 int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3579 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3580 synpat_T *spp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3582 spp = &(SYN_ITEMS(block)[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3583 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3584 if (spp->sp_flags & HL_FOLD)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3585 --block->b_syn_folditems;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3586 #endif
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3587 syn_clear_pattern(block, idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3588 mch_memmove(spp, spp + 1,
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3589 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
3590 --block->b_syn_patterns.ga_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3593 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3594 * Clear and free one syntax pattern. When clearing all, must be called from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3595 * last to first!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3596 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3597 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3598 syn_clear_pattern(synblock_T *block, int i)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3599 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3600 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
3601 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
3602 // 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
3603 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
3604 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3605 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
3606 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
3607 vim_free(SYN_ITEMS(block)[i].sp_syn.cont_in_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3611 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3612 * Clear and free one syntax cluster.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3613 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3614 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3615 syn_clear_cluster(synblock_T *block, int i)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3616 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3617 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
3618 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
3619 vim_free(SYN_CLSTR(block)[i].scl_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3622 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3623 * Handle ":syntax clear" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3624 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3625 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3626 syn_cmd_clear(exarg_T *eap, int syncing)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3628 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3629 char_u *arg_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3630 int id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 eap->nextcmd = find_nextcmd(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 if (eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3634 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3636 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3637 * We have to disable this within ":syn include @group filename",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638 * because otherwise @group would get deleted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 * Only required for Vim 5.x syntax files, 6.0 ones don't contain ":syn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3640 * clear".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3641 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3642 if (curwin->w_s->b_syn_topgrp != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3643 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3644
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
3645 if (ends_excmd2(eap->cmd, arg))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3648 * No argument: Clear all syntax items.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3649 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3650 if (syncing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3651 syntax_sync_clear();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3652 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3653 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3654 syntax_clear(curwin->w_s);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3655 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
3656 do_unlet((char_u *)"b:current_syntax", TRUE);
2252
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
3657 do_unlet((char_u *)"w:current_syntax", TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3658 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3660 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3662 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3663 * Clear the group IDs that are in the argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3664 */
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
3665 while (!ends_excmd2(eap->cmd, arg))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3666 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3667 arg_end = skiptowhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3668 if (*arg == '@')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3670 id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3671 if (id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3672 {
31602
53c3df37a2b0 patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
3673 semsg(_(e_no_such_syntax_cluster_str_1), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3674 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3676 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3677 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3678 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3679 * We can't physically delete a cluster without changing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3680 * the IDs of other clusters, so we do the next best thing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3681 * and make it empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3682 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3683 short scl_id = id - SYNID_CLUSTER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3684
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
3685 VIM_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3687 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3688 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3690 id = syn_namen2id(arg, (int)(arg_end - arg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3691 if (id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 {
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3693 semsg(_(e_no_such_highlight_group_name_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 syn_clear_one(id, syncing);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3699 arg = skipwhite(arg_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 }
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
3702 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
3703 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3706 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3707 * Clear one syntax group for the current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3709 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3710 syn_clear_one(int id, int syncing)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3712 synpat_T *spp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3713 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3714
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3715 // Clear keywords only when not ":syn sync clear group-name"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3716 if (!syncing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3717 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3718 (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
3719 (void)syn_clear_keyword(id, &curwin->w_s->b_keywtab_ic);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3720 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3721
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3722 // clear the patterns for "id"
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3723 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
3724 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3725 spp = &(SYN_ITEMS(curwin->w_s)[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3726 if (spp->sp_syn.id != id || spp->sp_syncing != syncing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3727 continue;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3728 syn_remove_pattern(curwin->w_s, idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3729 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3732 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3733 * Handle ":syntax on" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3734 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3736 syn_cmd_on(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3737 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3738 syn_cmd_onoff(eap, "syntax");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3739 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3741 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3742 * Handle ":syntax enable" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3743 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3744 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3745 syn_cmd_enable(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3746 {
26199
eaa97adb0732 patch 8.2.3631: "syntax enable" does not work properly in Vim9 context
Bram Moolenaar <Bram@vim.org>
parents: 25521
diff changeset
3747 set_internal_string_var((char_u *)"g:syntax_cmd", (char_u *)"enable");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3748 syn_cmd_onoff(eap, "syntax");
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 134
diff changeset
3749 do_unlet((char_u *)"g:syntax_cmd", TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3752 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3753 * Handle ":syntax reset" command.
8815
50d9fb580ffe commit https://github.com/vim/vim/commit/8bc189e81aa98ba4aebb03a9dc9527a210fce816
Christian Brabandt <cb@256bit.org>
parents: 8806
diff changeset
3754 * It actually resets highlighting, not syntax.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3755 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3756 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3757 syn_cmd_reset(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3758 {
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
3759 set_nextcmd(eap, eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3760 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3761 {
26199
eaa97adb0732 patch 8.2.3631: "syntax enable" does not work properly in Vim9 context
Bram Moolenaar <Bram@vim.org>
parents: 25521
diff changeset
3762 set_internal_string_var((char_u *)"g:syntax_cmd", (char_u *)"reset");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3763 do_cmdline_cmd((char_u *)"runtime! syntax/syncolor.vim");
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 134
diff changeset
3764 do_unlet((char_u *)"g:syntax_cmd", TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3768 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3769 * Handle ":syntax manual" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3770 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3771 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3772 syn_cmd_manual(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3774 syn_cmd_onoff(eap, "manual");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3777 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3778 * Handle ":syntax off" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3779 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3780 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3781 syn_cmd_off(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3783 syn_cmd_onoff(eap, "nosyntax");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3785
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3786 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3787 syn_cmd_onoff(exarg_T *eap, char *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3788 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3789 char_u buf[100];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3790
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
3791 set_nextcmd(eap, eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3792 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3794 STRCPY(buf, "so ");
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 271
diff changeset
3795 vim_snprintf((char *)buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 do_cmdline_cmd(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3799
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3800 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801 * Handle ":syntax [list]" command: list current syntax words.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3804 syn_cmd_list(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3805 exarg_T *eap,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3806 int syncing) // when TRUE: list syncing items
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3807 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3808 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3809 int id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3810 char_u *arg_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3812 eap->nextcmd = find_nextcmd(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3813 if (eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3814 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3815
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3816 if (!syntax_present(curwin))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3817 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3818 msg(_(msg_no_items));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3819 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3822 if (syncing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3823 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3824 if (curwin->w_s->b_syn_sync_flags & SF_CCOMMENT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3825 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3826 msg_puts(_("syncing on C-style comments"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3827 syn_lines_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3828 syn_match_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3829 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3830 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3831 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
3832 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3833 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
3834 msg_puts(_("no syncing"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3835 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3836 {
22928
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3837 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
3838 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
3839 else
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3840 {
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3841 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
3842 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
3843 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
3844 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3845 syn_match_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3847 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3848 }
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3849 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
3850 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
3851 || 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
3852 || curwin->w_s->b_syn_sync_linebreaks > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3853 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3854 msg_puts(_("\nsyncing on items"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3855 syn_lines_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3856 syn_match_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3857 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3858 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3859 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3860 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
3861 if (ends_excmd2(eap->cmd, arg))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3863 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3864 * No argument: List all group IDs and all syntax clusters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865 */
17401
5462bb963075 patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents: 17389
diff changeset
3866 for (id = 1; id <= highlight_num_groups() && !got_int; ++id)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3867 syn_list_one(id, syncing, FALSE);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3868 for (id = 0; id < curwin->w_s->b_syn_clusters.ga_len && !got_int; ++id)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3869 syn_list_cluster(id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3871 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3872 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3873 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3874 * List the group IDs and syntax clusters that are in the argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3875 */
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
3876 while (!ends_excmd2(eap->cmd, arg) && !got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3877 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3878 arg_end = skiptowhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3879 if (*arg == '@')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3881 id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3882 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
3883 semsg(_(e_no_such_syntax_cluster_str_2), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3884 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3885 syn_list_cluster(id - SYNID_CLUSTER);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3886 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3887 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3888 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3889 id = syn_namen2id(arg, (int)(arg_end - arg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3890 if (id == 0)
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3891 semsg(_(e_no_such_highlight_group_name_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3892 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3893 syn_list_one(id, syncing, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3895 arg = skipwhite(arg_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3897 }
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
3898 set_nextcmd(eap, arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3901 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3902 syn_lines_msg(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3903 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3904 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
3905 || curwin->w_s->b_syn_sync_minlines > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3906 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3907 msg_puts("; ");
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 == MAXLNUM)
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3909 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
3910 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3911 {
22928
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_minlines > 0)
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3913 {
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3914 msg_puts(_("minimal "));
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3915 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
3916 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
3917 msg_puts(", ");
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3918 }
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3919 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
3920 {
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3921 msg_puts(_("maximal "));
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3922 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
3923 }
de6c242ec236 patch 8.2.2011: "syn sync" reports a very large number
Bram Moolenaar <Bram@vim.org>
parents: 22258
diff changeset
3924 msg_puts(_(" lines before top line"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3926 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3928
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3929 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3930 syn_match_msg(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3931 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3932 if (curwin->w_s->b_syn_sync_linebreaks > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3933 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
3934 msg_puts(_("; match "));
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3935 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
3936 msg_puts(_(" line breaks"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3937 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3938 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3939
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3940 static int last_matchgroup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3941
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3942 struct name_list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3944 int flag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3945 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3946 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3947
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7687
diff changeset
3948 static void syn_list_flags(struct name_list *nl, int flags, int attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3949
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3950 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3951 * List one syntax item, for ":syntax" or "syntax list syntax_name".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3952 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3953 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3954 syn_list_one(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
3955 int id,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3956 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
3957 int link_only) // when TRUE; list link-only too
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3958 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3959 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3960 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3961 int did_header = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3962 synpat_T *spp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3963 static struct name_list namelist1[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3964 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3965 {HL_DISPLAY, "display"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3966 {HL_CONTAINED, "contained"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3967 {HL_ONELINE, "oneline"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3968 {HL_KEEPEND, "keepend"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3969 {HL_EXTEND, "extend"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3970 {HL_EXCLUDENL, "excludenl"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3971 {HL_TRANSP, "transparent"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3972 {HL_FOLD, "fold"},
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3973 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3974 {HL_CONCEAL, "conceal"},
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3975 {HL_CONCEALENDS, "concealends"},
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3976 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3977 {0, NULL}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3978 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3979 static struct name_list namelist2[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3980 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3981 {HL_SKIPWHITE, "skipwhite"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3982 {HL_SKIPNL, "skipnl"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3983 {HL_SKIPEMPTY, "skipempty"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3984 {0, NULL}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3985 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3986
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3987 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
3988
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3989 // list the keywords for "id"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3990 if (!syncing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3991 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3992 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
3993 did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab_ic,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3994 did_header, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3995 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3996
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
3997 // list the patterns for "id"
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
3998 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
3999 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4000 spp = &(SYN_ITEMS(curwin->w_s)[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4001 if (spp->sp_syn.id != id || spp->sp_syncing != syncing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4002 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4004 (void)syn_list_header(did_header, 999, id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4005 did_header = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4006 last_matchgroup = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007 if (spp->sp_type == SPTYPE_MATCH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4009 put_pattern("match", ' ', spp, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4010 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4011 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012 else if (spp->sp_type == SPTYPE_START)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4013 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4014 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
4015 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
4016 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
4017 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
4018 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
4019 && 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
4020 put_pattern("end", '=', &SYN_ITEMS(curwin->w_s)[idx++], attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4021 --idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4022 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4024 syn_list_flags(namelist1, spp->sp_flags, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026 if (spp->sp_cont_list != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4027 put_id_list((char_u *)"contains", spp->sp_cont_list, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4028
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4029 if (spp->sp_syn.cont_in_list != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4030 put_id_list((char_u *)"containedin",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4031 spp->sp_syn.cont_in_list, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4032
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4033 if (spp->sp_next_list != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4034 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4035 put_id_list((char_u *)"nextgroup", spp->sp_next_list, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4036 syn_list_flags(namelist2, spp->sp_flags, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4037 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4038 if (spp->sp_flags & (HL_SYNC_HERE|HL_SYNC_THERE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4040 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
4041 msg_puts_attr("grouphere", attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4042 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4043 msg_puts_attr("groupthere", attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4044 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4045 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
4046 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
4047 [spp->sp_sync_idx].sp_syn.id - 1));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4048 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4049 msg_puts("NONE");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4050 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4051 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4053
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4054 // 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
4055 if (highlight_link_id(id - 1) && (did_header || link_only) && !got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4057 (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
4058 msg_puts_attr("links to", attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4059 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
4060 msg_outtrans(highlight_group_name(highlight_link_id(id - 1) - 1));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4062 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4064 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4065 syn_list_flags(struct name_list *nlist, int flags, int attr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4066 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4067 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4068
3263
320cc46d0eb0 updated for version 7.3.400
Bram Moolenaar <bram@vim.org>
parents: 2906
diff changeset
4069 for (i = 0; nlist[i].flag != 0; ++i)
320cc46d0eb0 updated for version 7.3.400
Bram Moolenaar <bram@vim.org>
parents: 2906
diff changeset
4070 if (flags & nlist[i].flag)
320cc46d0eb0 updated for version 7.3.400
Bram Moolenaar <bram@vim.org>
parents: 2906
diff changeset
4071 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4072 msg_puts_attr(nlist[i].name, attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4073 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4074 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4076
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4077 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4078 * List one syntax cluster, for ":syntax" or "syntax list syntax_name".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4079 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4080 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4081 syn_list_cluster(int id)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4083 int endcol = 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4084
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4085 // slight hack: roughly duplicate the guts of syn_list_header()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4086 msg_putchar('\n');
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4087 msg_outtrans(SYN_CLSTR(curwin->w_s)[id].scl_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4088
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4089 if (msg_col >= endcol) // output at least one space
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4090 endcol = msg_col + 1;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4091 if (Columns <= endcol) // avoid hang for tiny window
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4092 endcol = Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4093
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4094 msg_advance(endcol);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4095 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
4096 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4097 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
4098 HL_ATTR(HLF_D));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4102 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
4103 msg_puts("=NONE");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4107 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4108 put_id_list(char_u *name, short *list, int attr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 short *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4111
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4112 msg_puts_attr((char *)name, attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4113 msg_putchar('=');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4114 for (p = list; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4115 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4116 if (*p >= SYNID_ALLBUT && *p < SYNID_TOP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4118 if (p[1])
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4119 msg_puts("ALLBUT");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4120 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4121 msg_puts("ALL");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4122 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4123 else if (*p >= SYNID_TOP && *p < SYNID_CONTAINED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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("TOP");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4127 else if (*p >= SYNID_CONTAINED && *p < SYNID_CLUSTER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4128 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4129 msg_puts("CONTAINED");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4131 else if (*p >= SYNID_CLUSTER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4133 short scl_id = *p - SYNID_CLUSTER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4135 msg_putchar('@');
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4136 msg_outtrans(SYN_CLSTR(curwin->w_s)[scl_id].scl_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 else
17401
5462bb963075 patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents: 17389
diff changeset
4139 msg_outtrans(highlight_group_name(*p - 1));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140 if (p[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 msg_putchar(',');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4146 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4147 put_pattern(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4148 char *s,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4149 int c,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4150 synpat_T *spp,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4151 int attr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4152 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4153 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4154 int mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4155 int first;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4156 static char *sepchars = "/+=-#@\"|'^&";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4157 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4158
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4159 // May have to write "matchgroup=group"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 if (last_matchgroup != spp->sp_syn_match_id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4161 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4162 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
4163 msg_puts_attr("matchgroup", attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4164 msg_putchar('=');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4165 if (last_matchgroup == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4166 msg_outtrans((char_u *)"NONE");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4167 else
17401
5462bb963075 patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents: 17389
diff changeset
4168 msg_outtrans(highlight_group_name(last_matchgroup - 1));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4169 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4170 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4171
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4172 // 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
4173 msg_puts_attr(s, attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4174 msg_putchar(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4175
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4176 // output the pattern, in between a char that is not in the pattern
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4177 for (i = 0; vim_strchr(spp->sp_pattern, sepchars[i]) != NULL; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4178 if (sepchars[++i] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4179 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4180 i = 0; // no good char found, just use the first one
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4181 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4183 msg_putchar(sepchars[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4184 msg_outtrans(spp->sp_pattern);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4185 msg_putchar(sepchars[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4186
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4187 // output any pattern options
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4188 first = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4189 for (i = 0; i < SPO_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4190 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4191 mask = (1 << i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4192 if (spp->sp_off_flags & (mask + (mask << SPO_COUNT)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4193 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4194 if (!first)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4195 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
4196 msg_puts(spo_name_tab[i]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4197 n = spp->sp_offsets[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4198 if (i != SPO_LC_OFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4199 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4200 if (spp->sp_off_flags & mask)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4201 msg_putchar('s');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4202 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4203 msg_putchar('e');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4204 if (n > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4205 msg_putchar('+');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4207 if (n || i == SPO_LC_OFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4208 msg_outnum(n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4209 first = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4210 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4211 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4212 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4213 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4215 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4216 * List or clear the keywords for one syntax group.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4217 * Return TRUE if the header has been printed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4218 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4219 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4220 syn_list_keywords(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4221 int id,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4222 hashtab_T *ht,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4223 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
4224 int attr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4226 int outlen;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4227 hashitem_T *hi;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4228 keyentry_T *kp;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4229 int todo;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4230 int prev_contained = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4231 short *prev_next_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4232 short *prev_cont_in_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4233 int prev_skipnl = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4234 int prev_skipwhite = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4235 int prev_skipempty = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4237 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4238 * Unfortunately, this list of keywords is not sorted on alphabet but on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4239 * hash value...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4240 */
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 834
diff changeset
4241 todo = (int)ht->ht_used;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4242 for (hi = ht->ht_array; todo > 0 && !got_int; ++hi)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4243 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4244 if (!HASHITEM_EMPTY(hi))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4245 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4246 --todo;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4247 for (kp = HI2KE(hi); kp != NULL && !got_int; kp = kp->ke_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4248 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4249 if (kp->k_syn.id == id)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4250 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4251 if (prev_contained != (kp->flags & HL_CONTAINED)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4252 || prev_skipnl != (kp->flags & HL_SKIPNL)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4253 || prev_skipwhite != (kp->flags & HL_SKIPWHITE)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4254 || prev_skipempty != (kp->flags & HL_SKIPEMPTY)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4255 || prev_cont_in_list != kp->k_syn.cont_in_list
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4256 || prev_next_list != kp->next_list)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4257 outlen = 9999;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4258 else
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4259 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
4260 // output "contained" and "nextgroup" on each line
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4261 if (syn_list_header(did_header, outlen, id))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4262 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4263 prev_contained = 0;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4264 prev_next_list = NULL;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4265 prev_cont_in_list = NULL;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4266 prev_skipnl = 0;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4267 prev_skipwhite = 0;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4268 prev_skipempty = 0;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4269 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4270 did_header = TRUE;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4271 if (prev_contained != (kp->flags & HL_CONTAINED))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4272 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4273 msg_puts_attr("contained", attr);
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4274 msg_putchar(' ');
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4275 prev_contained = (kp->flags & HL_CONTAINED);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4276 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4277 if (kp->k_syn.cont_in_list != prev_cont_in_list)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4278 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4279 put_id_list((char_u *)"containedin",
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4280 kp->k_syn.cont_in_list, attr);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4281 msg_putchar(' ');
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4282 prev_cont_in_list = kp->k_syn.cont_in_list;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4283 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4284 if (kp->next_list != prev_next_list)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4285 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4286 put_id_list((char_u *)"nextgroup", kp->next_list, attr);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4287 msg_putchar(' ');
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4288 prev_next_list = kp->next_list;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4289 if (kp->flags & HL_SKIPNL)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4290 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4291 msg_puts_attr("skipnl", attr);
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4292 msg_putchar(' ');
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4293 prev_skipnl = (kp->flags & HL_SKIPNL);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4294 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4295 if (kp->flags & HL_SKIPWHITE)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4296 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4297 msg_puts_attr("skipwhite", attr);
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4298 msg_putchar(' ');
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4299 prev_skipwhite = (kp->flags & HL_SKIPWHITE);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4300 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4301 if (kp->flags & HL_SKIPEMPTY)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4302 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
4303 msg_puts_attr("skipempty", attr);
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4304 msg_putchar(' ');
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4305 prev_skipempty = (kp->flags & HL_SKIPEMPTY);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4306 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4307 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4308 msg_outtrans(kp->keyword);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4310 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4314 return did_header;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4317 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4318 syn_clear_keyword(int id, hashtab_T *ht)
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4319 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4320 hashitem_T *hi;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4321 keyentry_T *kp;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4322 keyentry_T *kp_prev;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4323 keyentry_T *kp_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4324 int todo;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4325
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4326 hash_lock(ht);
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 834
diff changeset
4327 todo = (int)ht->ht_used;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4328 for (hi = ht->ht_array; todo > 0; ++hi)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4329 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4330 if (!HASHITEM_EMPTY(hi))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4331 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4332 --todo;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4333 kp_prev = NULL;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4334 for (kp = HI2KE(hi); kp != NULL; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4335 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4336 if (kp->k_syn.id == id)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4337 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4338 kp_next = kp->ke_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4339 if (kp_prev == NULL)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4340 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4341 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
4342 hash_remove(ht, hi, "syntax clear keyword");
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4343 else
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4344 hi->hi_key = KE2HIKEY(kp_next);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4345 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4346 else
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4347 kp_prev->ke_next = kp_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4348 vim_free(kp->next_list);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4349 vim_free(kp->k_syn.cont_in_list);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4350 vim_free(kp);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4351 kp = kp_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4352 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4353 else
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4354 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4355 kp_prev = kp;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4356 kp = kp->ke_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4357 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4358 }
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4359 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4360 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4361 hash_unlock(ht);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4362 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4363
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4364 /*
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4365 * Clear a whole keyword table.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4366 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4368 clear_keywtab(hashtab_T *ht)
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4369 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4370 hashitem_T *hi;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4371 int todo;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4372 keyentry_T *kp;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4373 keyentry_T *kp_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4374
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 834
diff changeset
4375 todo = (int)ht->ht_used;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4376 for (hi = ht->ht_array; todo > 0; ++hi)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4377 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4378 if (!HASHITEM_EMPTY(hi))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4379 {
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4380 --todo;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4381 for (kp = HI2KE(hi); kp != NULL; kp = kp_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4382 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4383 kp_next = kp->ke_next;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4384 vim_free(kp->next_list);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4385 vim_free(kp->k_syn.cont_in_list);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4386 vim_free(kp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4387 }
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4388 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4389 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4390 hash_clear(ht);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4391 hash_init(ht);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4394 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4395 * Add a keyword to the list of keywords.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4396 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4397 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4398 add_keyword(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4399 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
4400 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
4401 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
4402 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
4403 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
4404 int conceal_char)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4405 {
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4406 keyentry_T *kp;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4407 hashtab_T *ht;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4408 hashitem_T *hi;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4409 char_u *name_ic;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4410 long_u hash;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4411 char_u name_folded[MAXKEYWLEN + 1];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4412
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4413 if (curwin->w_s->b_syn_ic)
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4414 name_ic = str_foldcase(name, (int)STRLEN(name),
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4415 name_folded, MAXKEYWLEN + 1);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4416 else
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4417 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
4418 kp = alloc(offsetof(keyentry_T, keyword) + STRLEN(name_ic) + 1);
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4419 if (kp == NULL)
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4420 return;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4421 STRCPY(kp->keyword, name_ic);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4422 kp->k_syn.id = id;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4423 kp->k_syn.inc_tag = current_syn_inc_tag;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4424 kp->flags = flags;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4425 kp->k_char = conceal_char;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4426 kp->k_syn.cont_in_list = copy_id_list(cont_in_list);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4427 if (cont_in_list != NULL)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4428 curwin->w_s->b_syn_containedin = TRUE;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4429 kp->next_list = copy_id_list(next_list);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4430
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4431 if (curwin->w_s->b_syn_ic)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4432 ht = &curwin->w_s->b_keywtab_ic;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4433 else
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4434 ht = &curwin->w_s->b_keywtab;
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4435
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4436 hash = hash_hash(kp->keyword);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4437 hi = hash_lookup(ht, kp->keyword, hash);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4438 if (HASHITEM_EMPTY(hi))
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4439 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4440 // new keyword, add to hashtable
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4441 kp->ke_next = NULL;
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4442 hash_add_item(ht, hi, kp->keyword, hash);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4443 }
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4444 else
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4445 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4446 // keyword already exists, prepend to list
134
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4447 kp->ke_next = HI2KE(hi);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4448 hi->hi_key = KE2HIKEY(kp);
9322cb10d72e updated for version 7.0044
vimboss
parents: 41
diff changeset
4449 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453 * Get the start and end of the group name argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 * Return a pointer to the first argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4455 * Return NULL if the end of the command was found instead of further args.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4456 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457 static char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4458 get_group_name(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4459 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
4460 char_u **name_end) // pointer to end of the name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4461 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462 char_u *rest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 *name_end = skiptowhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4465 rest = skipwhite(*name_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468 * Check if there are enough arguments. The first argument may be a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 * pattern, where '|' is allowed, so only check for NUL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4470 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 if (ends_excmd(*arg) || *rest == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4473 return rest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4476 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4477 * Check for syntax command option arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4478 * This can be called at any place in the list of arguments, and just picks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4479 * out the arguments that are known. Can be called several times in a row to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4480 * collect all options in between other arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4481 * Return a pointer to the next argument (which isn't an option).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4482 * Return NULL for any error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4483 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4484 static char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4485 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
4486 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
4487 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
4488 int *conceal_char UNUSED,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4489 int skip) // TRUE if skipping over command
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4490 {
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
4491 char_u *arg = start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4492 char_u *gname_start, *gname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4493 int syn_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4494 int len;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4495 char *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4496 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4497 int fidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4498 static struct flag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500 char *name;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4501 int argtype;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4502 int flags;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4503 } flagtab[] = { {"cCoOnNtTaAiInNeEdD", 0, HL_CONTAINED},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4504 {"oOnNeElLiInNeE", 0, HL_ONELINE},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4505 {"kKeEeEpPeEnNdD", 0, HL_KEEPEND},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4506 {"eExXtTeEnNdD", 0, HL_EXTEND},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4507 {"eExXcClLuUdDeEnNlL", 0, HL_EXCLUDENL},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4508 {"tTrRaAnNsSpPaArReEnNtT", 0, HL_TRANSP},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4509 {"sSkKiIpPnNlL", 0, HL_SKIPNL},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4510 {"sSkKiIpPwWhHiItTeE", 0, HL_SKIPWHITE},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4511 {"sSkKiIpPeEmMpPtTyY", 0, HL_SKIPEMPTY},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4512 {"gGrRoOuUpPhHeErReE", 0, HL_SYNC_HERE},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4513 {"gGrRoOuUpPtThHeErReE", 0, HL_SYNC_THERE},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4514 {"dDiIsSpPlLaAyY", 0, HL_DISPLAY},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4515 {"fFoOlLdD", 0, HL_FOLD},
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4516 {"cCoOnNcCeEaAlL", 0, HL_CONCEAL},
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4517 {"cCoOnNcCeEaAlLeEnNdDsS", 0, HL_CONCEALENDS},
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4518 {"cCcChHaArR", 11, 0},
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4519 {"cCoOnNtTaAiInNsS", 1, 0},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4520 {"cCoOnNtTaAiInNeEdDiInN", 2, 0},
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4521 {"nNeExXtTgGrRoOuUpP", 3, 0},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4522 };
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4523 static char *first_letters = "cCoOkKeEtTsSgGdDfFnN";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4524
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4525 if (arg == NULL) // already detected error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4526 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4527
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4528 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4529 if (curwin->w_s->b_syn_conceal)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4530 opt->flags |= HL_CONCEAL;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4531 #endif
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4532
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4533 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4534 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4535 /*
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4536 * This is used very often when a large number of keywords is defined.
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4537 * Need to skip quickly when no option name is found.
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4538 * Also avoid tolower(), it's slow.
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4539 */
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4540 if (strchr(first_letters, *arg) == NULL)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4541 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4542
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24442
diff changeset
4543 for (fidx = ARRAY_LENGTH(flagtab); --fidx >= 0; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4545 p = flagtab[fidx].name;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4546 for (i = 0, len = 0; p[i] != NUL; i += 2, ++len)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4547 if (arg[len] != p[i] && arg[len] != p[i + 1])
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4548 break;
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
4549 if (p[i] == NUL && (VIM_ISWHITE(arg[len])
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4550 || (flagtab[fidx].argtype > 0
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4551 ? arg[len] == '='
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
4552 : ends_excmd2(start, arg + len))))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4553 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4554 if (opt->keyword
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4555 && (flagtab[fidx].flags == HL_DISPLAY
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4556 || flagtab[fidx].flags == HL_FOLD
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4557 || 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
4558 // treat "display", "fold" and "extend" as a keyword
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4559 fidx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4560 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4562 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4563 if (fidx < 0) // no match found
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4564 break;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4565
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4566 if (flagtab[fidx].argtype == 1)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4567 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4568 if (!opt->has_cont_list)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4569 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
4570 emsg(_(e_contains_argument_not_accepted_here));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4571 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4572 }
10618
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
4573 if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4574 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575 }
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4576 else if (flagtab[fidx].argtype == 2)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4577 {
10618
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
4578 if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4579 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4580 }
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4581 else if (flagtab[fidx].argtype == 3)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4582 {
10618
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
4583 if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4584 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4585 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4586 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
4587 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4588 // cchar=?
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4589 if (has_mbyte)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4590 {
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15555
diff changeset
4591 #ifdef FEAT_CONCEAL
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4592 *conceal_char = mb_ptr2char(arg + 6);
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15555
diff changeset
4593 #endif
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4594 arg += mb_ptr2len(arg + 6) - 1;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4595 }
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4596 else
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
4597 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4598 #ifdef FEAT_CONCEAL
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4599 *conceal_char = arg[6];
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4600 #else
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4601 ;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4602 #endif
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
4603 }
2686
7b44c70ee8ab updated for version 7.3.104
Bram Moolenaar <bram@vim.org>
parents: 2593
diff changeset
4604 #ifdef FEAT_CONCEAL
7b44c70ee8ab updated for version 7.3.104
Bram Moolenaar <bram@vim.org>
parents: 2593
diff changeset
4605 if (!vim_isprintc_strict(*conceal_char))
7b44c70ee8ab updated for version 7.3.104
Bram Moolenaar <bram@vim.org>
parents: 2593
diff changeset
4606 {
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
4607 emsg(_(e_invalid_cchar_value));
2686
7b44c70ee8ab updated for version 7.3.104
Bram Moolenaar <bram@vim.org>
parents: 2593
diff changeset
4608 return NULL;
7b44c70ee8ab updated for version 7.3.104
Bram Moolenaar <bram@vim.org>
parents: 2593
diff changeset
4609 }
7b44c70ee8ab updated for version 7.3.104
Bram Moolenaar <bram@vim.org>
parents: 2593
diff changeset
4610 #endif
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4611 arg = skipwhite(arg + 7);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4612 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4613 else
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4614 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4615 opt->flags |= flagtab[fidx].flags;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4616 arg = skipwhite(arg + len);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4617
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4618 if (flagtab[fidx].flags == HL_SYNC_HERE
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4619 || flagtab[fidx].flags == HL_SYNC_THERE)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4620 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4621 if (opt->sync_idx == NULL)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4622 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
4623 emsg(_(e_groupthere_not_accepted_here));
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4624 return NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4625 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4626 gname_start = arg;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4627 arg = skiptowhite(arg);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4628 if (gname_start == arg)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4629 return NULL;
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20751
diff changeset
4630 gname = vim_strnsave(gname_start, arg - gname_start);
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4631 if (gname == NULL)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4632 return NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4633 if (STRCMP(gname, "NONE") == 0)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4634 *opt->sync_idx = NONE_IDX;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4635 else
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4636 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4637 syn_id = syn_name2id(gname);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4638 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
4639 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
4640 && 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
4641 == SPTYPE_START)
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4642 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4643 *opt->sync_idx = i;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4644 break;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4645 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4646 if (i < 0)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4647 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
4648 semsg(_(e_didnt_find_region_item_for_str), gname);
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4649 vim_free(gname);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4650 return NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4651 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4652 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4653
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4654 vim_free(gname);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4655 arg = skipwhite(arg);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4656 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4657 #ifdef FEAT_FOLDING
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4658 else if (flagtab[fidx].flags == HL_FOLD
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4659 && foldmethodIsSyntax(curwin))
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4660 // Need to update folds later.
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4661 foldUpdateAll(curwin);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4662 #endif
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4663 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4664 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4666 return arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4669 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4670 * Adjustments to syntax item when declared in a ":syn include"'d file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4671 * Set the contained flag, and if the item is not already contained, add it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4672 * to the specified top-level group, if any.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4673 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4674 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4675 syn_incl_toplevel(int id, int *flagsp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4676 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4677 if ((*flagsp & HL_CONTAINED) || curwin->w_s->b_syn_topgrp == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4678 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4679 *flagsp |= HL_CONTAINED;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4680 if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4681 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4682 // 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
4683 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
4684 int tlg_id = curwin->w_s->b_syn_topgrp - SYNID_CLUSTER;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4685
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4686 if (grp_list != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4688 grp_list[0] = id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4689 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
4690 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
4691 &grp_list, CLUSTER_ADD);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4693 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4697 * Handle ":syntax include [@{group-name}] filename" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4699 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4700 syn_cmd_include(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4703 int sgl_id = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 char_u *group_name_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705 char_u *rest;
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14968
diff changeset
4706 char *errormsg = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 int prev_toplvl_grp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 int prev_syn_inc_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4709 int source = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711 eap->nextcmd = find_nextcmd(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 if (eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4715 if (arg[0] == '@')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 ++arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718 rest = get_group_name(arg, &group_name_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719 if (rest == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
4721 emsg(_(e_filename_required));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4724 sgl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4725 if (sgl_id == 0)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4726 return;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4727 // separate_nextcmd() and expand_filename() depend on this
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 eap->arg = rest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732 * Everything that's left, up to the next command, should be the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 * filename to include.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4734 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17227
diff changeset
4735 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
4736 separate_nextcmd(eap, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4737 if (*eap->arg == '<' || *eap->arg == '$' || mch_isFullName(eap->arg))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4739 // 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
4740 // 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
4741 // ":runtime!" is used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742 source = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743 if (expand_filename(eap, syn_cmdlinep, &errormsg) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4744 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745 if (errormsg != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14968
diff changeset
4746 emsg(errormsg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4747 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4748 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4752 * Save and restore the existing top-level grouplist id and ":syn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4753 * include" tag around the actual inclusion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 */
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4755 if (running_syn_inc_tag >= MAX_SYN_INC_TAG)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4756 {
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
4757 emsg(_(e_too_many_syntax_includes));
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4758 return;
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4759 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4760 prev_syn_inc_tag = current_syn_inc_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4761 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
4762 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
4763 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
4764 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
4765 : 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
4766 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
4767 curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4768 current_syn_inc_tag = prev_syn_inc_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4769 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4770
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4771 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4772 * Handle ":syntax keyword {group-name} [{option}] keyword .." command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4773 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4774 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4775 syn_cmd_keyword(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4776 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4777 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4778 char_u *group_name_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4779 int syn_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4780 char_u *rest;
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4781 char_u *keyword_copy = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4782 char_u *p;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4783 char_u *kw;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4784 syn_opt_arg_T syn_opt_arg;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4785 int cnt;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4786 int conceal_char = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4788 rest = get_group_name(arg, &group_name_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4790 if (rest != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4791 {
10618
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
4792 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
4793 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
4794 else
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
4795 syn_id = syn_check_group(arg, (int)(group_name_end - arg));
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
4796 if (syn_id != 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4797 // 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
4798 keyword_copy = alloc(STRLEN(rest) + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4799 if (keyword_copy != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4801 syn_opt_arg.flags = 0;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4802 syn_opt_arg.keyword = TRUE;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4803 syn_opt_arg.sync_idx = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4804 syn_opt_arg.has_cont_list = FALSE;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4805 syn_opt_arg.cont_in_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4806 syn_opt_arg.next_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4807
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4808 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 * The options given apply to ALL keywords, so all options must be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4810 * found before keywords can be created.
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4811 * 1: collect the options and copy the keywords to keyword_copy.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4812 */
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4813 cnt = 0;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4814 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
4815 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
4816 rest = skipwhite(rest))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 {
10618
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
4818 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
4819 eap->skip);
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
4820 if (rest == NULL || ends_excmd2(eap->arg, rest))
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4821 break;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4822 // 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
4823 while (*rest != NUL && !VIM_ISWHITE(*rest))
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4824 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4825 if (*rest == '\\' && rest[1] != NUL)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4826 ++rest;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4827 *p++ = *rest++;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4828 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4829 *p++ = NUL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4830 ++cnt;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4831 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4832
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4833 if (!eap->skip)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4834 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4835 // Adjust flags for use of ":syn include".
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4836 syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4837
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4838 /*
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4839 * 2: Add an entry for each keyword.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4840 */
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4841 for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4842 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4843 for (p = vim_strchr(kw, '['); ; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4844 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4845 if (p != NULL)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4846 *p = NUL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4847 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
4848 syn_opt_arg.cont_in_list,
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4849 syn_opt_arg.next_list, conceal_char);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4850 if (p == NULL)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4851 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4852 if (p[1] == NUL)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4853 {
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
4854 semsg(_(e_error_missing_rsb_str), kw);
7017
0dbbdcf13e03 patch 7.4.825
Bram Moolenaar <bram@vim.org>
parents: 7009
diff changeset
4855 goto error;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4856 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4857 if (p[1] == ']')
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4858 {
7017
0dbbdcf13e03 patch 7.4.825
Bram Moolenaar <bram@vim.org>
parents: 7009
diff changeset
4859 if (p[2] != NUL)
0dbbdcf13e03 patch 7.4.825
Bram Moolenaar <bram@vim.org>
parents: 7009
diff changeset
4860 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
4861 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
4862 kw, &p[2]);
7017
0dbbdcf13e03 patch 7.4.825
Bram Moolenaar <bram@vim.org>
parents: 7009
diff changeset
4863 goto error;
0dbbdcf13e03 patch 7.4.825
Bram Moolenaar <bram@vim.org>
parents: 7009
diff changeset
4864 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4865 kw = p + 1; // skip over the "]"
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4866 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4867 }
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4868 if (has_mbyte)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4869 {
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 448
diff changeset
4870 int l = (*mb_ptr2len)(p + 1);
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4871
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4872 mch_memmove(p, p + 1, l);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4873 p += l;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4874 }
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4875 else
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4876 {
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4877 p[0] = p[1];
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4878 ++p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4879 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4880 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4881 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4882 }
7017
0dbbdcf13e03 patch 7.4.825
Bram Moolenaar <bram@vim.org>
parents: 7009
diff changeset
4883 error:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4884 vim_free(keyword_copy);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4885 vim_free(syn_opt_arg.cont_in_list);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 154
diff changeset
4886 vim_free(syn_opt_arg.next_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4888 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4889
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4890 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
4891 set_nextcmd(eap, rest);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4892 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26199
diff changeset
4893 semsg(_(e_invalid_argument_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4894
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
4895 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
4896 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4899 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4900 * Handle ":syntax match {name} [{options}] {pattern} [{options}]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4901 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4902 * Also ":syntax sync match {name} [[grouphere | groupthere] {group-name}] .."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4905 syn_cmd_match(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
4906 exarg_T *eap,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4907 int syncing) // TRUE for ":syntax sync match .. "
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4908 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4909 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4910 char_u *group_name_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4911 char_u *rest;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4912 synpat_T item; // the item found in the line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4913 int syn_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4914 int idx;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4915 syn_opt_arg_T syn_opt_arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4916 int sync_idx = 0;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4917 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
4918 int orig_called_emsg = called_emsg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4919
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4920 // Isolate the group name, check for validity
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4921 rest = get_group_name(arg, &group_name_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4922
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4923 // Get options before the pattern
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4924 syn_opt_arg.flags = 0;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4925 syn_opt_arg.keyword = FALSE;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4926 syn_opt_arg.sync_idx = syncing ? &sync_idx : NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4927 syn_opt_arg.has_cont_list = TRUE;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4928 syn_opt_arg.cont_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4929 syn_opt_arg.cont_in_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4930 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
4931 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4932
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4933 // get the pattern.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4934 init_syn_patterns();
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
4935 CLEAR_FIELD(item);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4936 rest = get_syn_pattern(rest, &item);
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4937 if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL))
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4938 syn_opt_arg.flags |= HL_HAS_EOL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4939
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4940 // 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
4941 rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4942
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4943 if (rest != NULL) // all arguments are valid
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4945 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4946 * Check for trailing command and illegal trailing arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4947 */
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
4948 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
4949 if (!ends_excmd2(eap->cmd, rest) || eap->skip)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4950 rest = NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4951 else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4952 && (syn_id = syn_check_group(arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4953 (int)(group_name_end - arg))) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4954 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4955 syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4956 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4957 * Store the pattern in the syn_items list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4958 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4959 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
4960 SYN_ITEMS(curwin->w_s)[idx] = item;
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_syncing = syncing;
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_type = SPTYPE_MATCH;
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_syn.id = syn_id;
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.inc_tag = current_syn_inc_tag;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4965 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
4966 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
4967 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
4968 SYN_ITEMS(curwin->w_s)[idx].sp_syn.cont_in_list =
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4969 syn_opt_arg.cont_in_list;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4970 #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
4971 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
4972 #endif
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4973 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
4974 curwin->w_s->b_syn_containedin = TRUE;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4975 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
4976 ++curwin->w_s->b_syn_patterns.ga_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4977
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
4978 // remember that we found a match for syncing on
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4979 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
4980 curwin->w_s->b_syn_sync_flags |= SF_MATCH;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4981 #ifdef FEAT_FOLDING
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4982 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
4983 ++curwin->w_s->b_syn_folditems;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4984 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4985
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
4986 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
4987 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
4988 return; // don't free the progs and patterns now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4993 * Something failed, free the allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4994 */
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
4995 vim_regfree(item.sp_prog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 vim_free(item.sp_pattern);
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4997 vim_free(syn_opt_arg.cont_list);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4998 vim_free(syn_opt_arg.cont_in_list);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
4999 vim_free(syn_opt_arg.next_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
5001 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
5002 semsg(_(e_invalid_argument_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5005 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006 * Handle ":syntax region {group-name} [matchgroup={group-name}]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007 * start {start} .. [skip {skip}] end {end} .. [{options}]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5009 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5010 syn_cmd_region(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5011 exarg_T *eap,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5012 int syncing) // TRUE for ":syntax sync region .."
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5013 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5014 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5015 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
5016 char_u *rest; // next arg, NULL on error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5017 char_u *key_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5018 char_u *key = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5020 int item;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5021 #define ITEM_START 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5022 #define ITEM_SKIP 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 #define ITEM_END 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 #define ITEM_MATCHGROUP 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025 struct pat_ptr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5026 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5027 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
5028 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
5029 struct pat_ptr *pp_next; // pointer to next pat_ptr
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5030 } *(pat_ptrs[3]);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5031 // patterns found in the line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5032 struct pat_ptr *ppp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5033 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
5034 int pat_count = 0; // nr of syn_patterns found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5035 int syn_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5036 int matchgroup_id = 0;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5037 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
5038 int illegal = FALSE; // illegal arguments
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5039 int success = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5040 int idx;
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5041 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
5042 int conceal_char = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5043
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5044 // Isolate the group name, check for validity
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5045 rest = get_group_name(arg, &group_name_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5047 pat_ptrs[0] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5048 pat_ptrs[1] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5049 pat_ptrs[2] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5051 init_syn_patterns();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5052
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5053 syn_opt_arg.flags = 0;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5054 syn_opt_arg.keyword = FALSE;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5055 syn_opt_arg.sync_idx = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5056 syn_opt_arg.has_cont_list = TRUE;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5057 syn_opt_arg.cont_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5058 syn_opt_arg.cont_in_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5059 syn_opt_arg.next_list = NULL;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5060
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5061 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5062 * get the options, patterns and matchgroup.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 */
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
5064 while (rest != NULL && !ends_excmd2(eap->cmd, rest))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5065 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5066 // 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
5067 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
5068 if (rest == NULL || ends_excmd2(eap->cmd, rest))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5069 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5070
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5071 // must be a pattern or matchgroup then
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5072 key_end = rest;
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
5073 while (*key_end && !VIM_ISWHITE(*key_end) && *key_end != '=')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5074 ++key_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5075 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
5076 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
5077 if (key == NULL) // out of memory
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5079 rest = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5080 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5081 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5082 if (STRCMP(key, "MATCHGROUP") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5083 item = ITEM_MATCHGROUP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5084 else if (STRCMP(key, "START") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5085 item = ITEM_START;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086 else if (STRCMP(key, "END") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 item = ITEM_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088 else if (STRCMP(key, "SKIP") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5090 if (pat_ptrs[ITEM_SKIP] != NULL) // one skip pattern allowed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 illegal = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 item = ITEM_SKIP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5097 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 rest = skipwhite(key_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5100 if (*rest != '=')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 rest = NULL;
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5103 semsg(_(e_missing_equal_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5105 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 rest = skipwhite(rest + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 if (*rest == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5109 not_enough = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 if (item == ITEM_MATCHGROUP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5115 p = skiptowhite(rest);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5116 if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 matchgroup_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 matchgroup_id = syn_check_group(rest, (int)(p - rest));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 if (matchgroup_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5123 illegal = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5124 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5127 rest = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5131 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 * Allocate room for a syn_pattern, and link it in the list of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5133 * syn_patterns for this item, at the start (because the list is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134 * used from end to start).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5135 */
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
5136 ppp = ALLOC_ONE(struct pat_ptr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5137 if (ppp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5139 rest = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 ppp->pp_next = pat_ptrs[item];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143 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
5144 ppp->pp_synp = ALLOC_CLEAR_ONE(synpat_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145 if (ppp->pp_synp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147 rest = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5152 * Get the syntax pattern and the following offset(s).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5153 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5154 // Enable the appropriate \z specials.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5155 if (item == ITEM_START)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5156 reg_do_extmatch = REX_SET;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5157 else if (item == ITEM_SKIP || item == ITEM_END)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5158 reg_do_extmatch = REX_USE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5159 rest = get_syn_pattern(rest, ppp->pp_synp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5160 reg_do_extmatch = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5161 if (item == ITEM_END && vim_regcomp_had_eol()
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5162 && !(syn_opt_arg.flags & HL_EXCLUDENL))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5163 ppp->pp_synp->sp_flags |= HL_HAS_EOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5164 ppp->pp_matchgroup_id = matchgroup_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5165 ++pat_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 vim_free(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5169 if (illegal || not_enough)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5170 rest = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5172 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5173 * Must have a "start" and "end" pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5174 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175 if (rest != NULL && (pat_ptrs[ITEM_START] == NULL ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176 pat_ptrs[ITEM_END] == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5178 not_enough = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5179 rest = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5182 if (rest != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5184 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 * Check for trailing garbage or command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5186 * If OK, add the item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5187 */
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
5188 set_nextcmd(eap, rest);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5189 if (!ends_excmd(*rest) || eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5190 rest = NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5191 else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) != FAIL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192 && (syn_id = syn_check_group(arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 (int)(group_name_end - arg))) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5194 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5195 syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5196 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5197 * Store the start/skip/end in the syn_items list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5198 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5199 idx = curwin->w_s->b_syn_patterns.ga_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200 for (item = ITEM_START; item <= ITEM_END; ++item)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5202 for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp->pp_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5203 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5204 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
5205 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
5206 SYN_ITEMS(curwin->w_s)[idx].sp_type =
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5207 (item == ITEM_START) ? SPTYPE_START :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5208 (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
5209 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
5210 SYN_ITEMS(curwin->w_s)[idx].sp_syn.id = syn_id;
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5211 SYN_ITEMS(curwin->w_s)[idx].sp_syn.inc_tag =
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5212 current_syn_inc_tag;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5213 SYN_ITEMS(curwin->w_s)[idx].sp_syn_match_id =
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5214 ppp->pp_matchgroup_id;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5215 #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
5216 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
5217 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5218 if (item == ITEM_START)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5219 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5220 SYN_ITEMS(curwin->w_s)[idx].sp_cont_list =
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5221 syn_opt_arg.cont_list;
2250
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_syn.cont_in_list =
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5223 syn_opt_arg.cont_in_list;
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5224 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
5225 curwin->w_s->b_syn_containedin = TRUE;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5226 SYN_ITEMS(curwin->w_s)[idx].sp_next_list =
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5227 syn_opt_arg.next_list;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5228 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5229 ++curwin->w_s->b_syn_patterns.ga_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5230 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5231 #ifdef FEAT_FOLDING
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5232 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
5233 ++curwin->w_s->b_syn_folditems;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5234 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5237
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
5238 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
5239 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
5240 success = TRUE; // don't free the progs and patterns now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 * Free the allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5246 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5247 for (item = ITEM_START; item <= ITEM_END; ++item)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5248 for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5249 {
17907
4cf69f8d1ec6 patch 8.1.1950: using NULL pointer after an out-of-memory
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
5250 if (!success && ppp->pp_synp != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 {
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
5252 vim_regfree(ppp->pp_synp->sp_prog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5253 vim_free(ppp->pp_synp->sp_pattern);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5255 vim_free(ppp->pp_synp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5256 ppp_next = ppp->pp_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5257 vim_free(ppp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5258 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5260 if (!success)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5261 {
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5262 vim_free(syn_opt_arg.cont_list);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5263 vim_free(syn_opt_arg.cont_in_list);
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
5264 vim_free(syn_opt_arg.next_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5265 if (not_enough)
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5266 semsg(_(e_not_enough_arguments_syntax_region_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267 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
5268 semsg(_(e_invalid_argument_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5273 * A simple syntax group ID comparison function suitable for use in qsort()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5276 syn_compare_stub(const void *v1, const void *v2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278 const short *s1 = v1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 const short *s2 = v2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5281 return (*s1 > *s2 ? 1 : *s1 < *s2 ? -1 : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5285 * Combines lists of syntax clusters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5286 * *clstr1 and *clstr2 must both be allocated memory; they will be consumed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5287 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5289 syn_combine_list(short **clstr1, short **clstr2, int list_op)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5291 int count1 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5292 int count2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5293 short *g1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294 short *g2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5295 short *clstr = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5296 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5297 int round;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5299 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5300 * Handle degenerate cases.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 if (*clstr2 == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5303 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5304 if (*clstr1 == NULL || list_op == CLUSTER_REPLACE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 if (list_op == CLUSTER_REPLACE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 vim_free(*clstr1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 if (list_op == CLUSTER_REPLACE || list_op == CLUSTER_ADD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 *clstr1 = *clstr2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 vim_free(*clstr2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5312 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315 for (g1 = *clstr1; *g1; g1++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 ++count1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317 for (g2 = *clstr2; *g2; g2++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 ++count2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 * For speed purposes, sort both lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5322 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 qsort(*clstr1, (size_t)count1, sizeof(short), syn_compare_stub);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5324 qsort(*clstr2, (size_t)count2, sizeof(short), syn_compare_stub);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 * We proceed in two passes; in round 1, we count the elements to place
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5328 * in the new list, and in round 2, we allocate and populate the new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 * list. For speed, we use a mergesort-like method, adding the smaller
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 * of the current elements in each list to the new list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 for (round = 1; round <= 2; round++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 g1 = *clstr1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335 g2 = *clstr2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5336 count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 * First, loop through the lists until one of them is empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341 while (*g1 && *g2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5342 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5343 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5344 * We always want to add from the first list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5345 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5346 if (*g1 < *g2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5348 if (round == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 clstr[count] = *g1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350 count++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 g1++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5353 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5354 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5355 * We only want to add from the second list if we're adding the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 * lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 if (list_op == CLUSTER_ADD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5360 if (round == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5361 clstr[count] = *g2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5362 count++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5363 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5364 if (*g1 == *g2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5365 g1++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5366 g2++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5369 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5370 * Now add the leftovers from whichever list didn't get finished
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5371 * first. As before, we only want to add from the second list if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5372 * we're adding the lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5373 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5374 for (; *g1; g1++, count++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5375 if (round == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5376 clstr[count] = *g1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5377 if (list_op == CLUSTER_ADD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5378 for (; *g2; g2++, count++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5379 if (round == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5380 clstr[count] = *g2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5382 if (round == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5383 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5384 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5385 * If the group ended up empty, we don't need to allocate any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5386 * space for it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5388 if (count == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5390 clstr = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5391 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5392 }
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
5393 clstr = ALLOC_MULT(short, count + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394 if (clstr == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396 clstr[count] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5400 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5401 * Finally, put the new list in place.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5402 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5403 vim_free(*clstr1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5404 vim_free(*clstr2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5405 *clstr1 = clstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5408 /*
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5409 * Lookup a syntax cluster name and return its ID.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5410 * If it is not found, 0 is returned.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5411 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5412 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5413 syn_scl_name2id(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 char_u *name_u;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5418 // Avoid using stricmp() too much, it's slow on some systems
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 name_u = vim_strsave_up(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 if (name_u == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 return 0;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5422 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
5423 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
5424 && STRCMP(name_u, SYN_CLSTR(curwin->w_s)[i].scl_name_u) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 vim_free(name_u);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 return (i < 0 ? 0 : i + SYNID_CLUSTER);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 * Like syn_scl_name2id(), but take a pointer + length argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5434 syn_scl_namen2id(char_u *linep, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 int id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 name = vim_strnsave(linep, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 if (name != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5441 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442 id = syn_scl_name2id(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 return id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5448 /*
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5449 * Find syntax cluster name in the table and return its ID.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450 * The argument is a pointer to the name and the length of the name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5451 * If it doesn't exist yet, a new entry is created.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5452 * Return 0 for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5453 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5454 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5455 syn_check_cluster(char_u *pp, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5456 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5457 int id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5458 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460 name = vim_strnsave(pp, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5461 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5464 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
5465 if (id == 0) // doesn't exist yet
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5466 id = syn_add_cluster(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5467 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5468 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5469 return id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5472 /*
11189
e74af2aca96e patch 8.0.0481: unnecessary if statement
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5473 * Add new syntax cluster and return its ID.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5474 * "name" must be an allocated string, it will be consumed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5475 * Return 0 for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5476 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5477 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5478 syn_add_cluster(char_u *name)
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
5479 {
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
5480 int len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5483 * First call for this growarray: init growing array.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5485 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
5486 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5487 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
5488 curwin->w_s->b_syn_clusters.ga_growsize = 10;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5489 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5490
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5491 len = curwin->w_s->b_syn_clusters.ga_len;
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5492 if (len >= MAX_CLUSTER_ID)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5493 {
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
5494 emsg(_(e_too_many_syntax_clusters));
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5495 vim_free(name);
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5496 return 0;
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5497 }
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5498
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5499 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 * Make room for at least one other cluster entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 */
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5502 if (ga_grow(&curwin->w_s->b_syn_clusters, 1) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5504 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5506 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5507
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
5508 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
5509 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
5510 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
5511 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
5512 ++curwin->w_s->b_syn_clusters.ga_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
5514 if (STRICMP(name, "Spell") == 0)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5515 curwin->w_s->b_spell_cluster_id = len + SYNID_CLUSTER;
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
5516 if (STRICMP(name, "NoSpell") == 0)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5517 curwin->w_s->b_nospell_cluster_id = len + SYNID_CLUSTER;
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 205
diff changeset
5518
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 return len + SYNID_CLUSTER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5523 * Handle ":syntax cluster {cluster-name} [contains={groupname},..]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 * [add={groupname},..] [remove={groupname},..]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5525 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5527 syn_cmd_cluster(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5528 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5529 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5530 char_u *group_name_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5531 char_u *rest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5532 int scl_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5533 short *clstr_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5534 int got_clstr = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5535 int opt_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5536 int list_op;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5538 eap->nextcmd = find_nextcmd(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5539 if (eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5540 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5542 rest = get_group_name(arg, &group_name_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5543
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5544 if (rest != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5545 {
2743
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5546 scl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5547 if (scl_id == 0)
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5548 return;
d67916de812a updated for version 7.3.148
Bram Moolenaar <bram@vim.org>
parents: 2686
diff changeset
5549 scl_id -= SYNID_CLUSTER;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5551 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5552 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5553 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
5554 && (VIM_ISWHITE(rest[3]) || rest[3] == '='))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5555 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5556 opt_len = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5557 list_op = CLUSTER_ADD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5559 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
5560 && (VIM_ISWHITE(rest[6]) || rest[6] == '='))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5562 opt_len = 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5563 list_op = CLUSTER_SUBTRACT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5565 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
5566 && (VIM_ISWHITE(rest[8]) || rest[8] == '='))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568 opt_len = 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5569 list_op = CLUSTER_REPLACE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5571 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5572 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5574 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
5575 if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5576 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26199
diff changeset
5577 semsg(_(e_invalid_argument_str), rest);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5578 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5579 }
10618
4ee16e5e2e26 patch 8.0.0198: some syntax arguments take effect even after "if 0"
Christian Brabandt <cb@256bit.org>
parents: 10534
diff changeset
5580 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
5581 syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5582 &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
5583 else
4f3decf25b7d patch 8.0.0214: leaking memory when syntax cluster id is unknown
Christian Brabandt <cb@256bit.org>
parents: 10629
diff changeset
5584 vim_free(clstr_list);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 got_clstr = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 if (got_clstr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 {
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
5590 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
5591 syn_stack_free_all(curwin->w_s); // Need to recompute all.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595 if (!got_clstr)
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5596 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
5597 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
5598 semsg(_(e_invalid_argument_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5599 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5602 * On first call for current buffer: Init growing array.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5604 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5605 init_syn_patterns(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5606 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5607 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
5608 curwin->w_s->b_syn_patterns.ga_growsize = 10;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5611 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 * Get one pattern for a ":syntax match" or ":syntax region" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613 * Stores the pattern and program in a synpat_T.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5614 * Returns a pointer to the next argument, or NULL in case of an error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 static char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5617 get_syn_pattern(char_u *arg, synpat_T *ci)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 char_u *end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 int *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 char_u *cpo_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5623
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5624 // need at least three chars
6993
dcc108222d70 patch 7.4.814
Bram Moolenaar <bram@vim.org>
parents: 6880
diff changeset
5625 if (arg == NULL || arg[0] == NUL || arg[1] == NUL || arg[2] == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5626 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5627
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
5628 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
5629 if (*end != *arg) // end delimiter not found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5631 semsg(_(e_pattern_delimiter_not_found_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5634 // 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
5635 if ((ci->sp_pattern = vim_strnsave(arg + 1, end - arg - 1)) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5636 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5637
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5638 // Make 'cpoptions' empty, to avoid the 'l' flag
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5639 cpo_save = p_cpo;
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23043
diff changeset
5640 p_cpo = empty_option;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5641 ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5642 p_cpo = cpo_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644 if (ci->sp_prog == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645 return NULL;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5646 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
5647 #ifdef FEAT_PROFILE
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
5648 syn_clear_time(&ci->sp_time);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
5649 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5651 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652 * Check for a match, highlight or region offset.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5653 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5654 ++end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5655 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5656 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5657 for (idx = SPO_COUNT; --idx >= 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5658 if (STRNCMP(end, spo_name_tab[idx], 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5659 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5660 if (idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662 p = &(ci->sp_offsets[idx]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5663 if (idx != SPO_LC_OFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 switch (end[3])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666 case 's': break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667 case 'b': break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5668 case 'e': idx += SPO_COUNT; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5669 default: idx = -1; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5670 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5671 if (idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5672 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 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
5674 if (idx == SPO_LC_OFF) // lc=99
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5675 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5676 end += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677 *p = getdigits(&end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5679 // "lc=" offset automatically sets "ms=" offset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5680 if (!(ci->sp_off_flags & (1 << SPO_MS_OFF)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5681 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 ci->sp_off_flags |= (1 << SPO_MS_OFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683 ci->sp_offsets[SPO_MS_OFF] = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5686 else // yy=x+99
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 end += 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 if (*end == '+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 ++end;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5692 *p = getdigits(&end); // positive offset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5693 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 else if (*end == '-')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696 ++end;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5697 *p = -getdigits(&end); // negative offset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 if (*end != ',')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 ++end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 } while (idx >= 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
5707 if (!ends_excmd2(arg, end) && !VIM_ISWHITE(*end))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5708 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5709 semsg(_(e_garbage_after_pattern_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5710 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 return skipwhite(end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5715 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716 * Handle ":syntax sync .." command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5718 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5719 syn_cmd_sync(exarg_T *eap, int syncing UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 char_u *arg_start = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 char_u *arg_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5723 char_u *key = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5724 char_u *next_arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 int illegal = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5726 int finished = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5727 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5728 char_u *cpo_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5729
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
5730 if (ends_excmd2(eap->cmd, arg_start))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 syn_cmd_list(eap, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
5736 while (!ends_excmd2(eap->cmd, arg_start))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5737 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5738 arg_end = skiptowhite(arg_start);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5739 next_arg = skipwhite(arg_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5740 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
5741 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
5742 if (key == NULL)
e35955a787a8 patch 8.2.1171: possible crash when out of memory
Bram Moolenaar <Bram@vim.org>
parents: 20830
diff changeset
5743 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5744 if (STRCMP(key, "CCOMMENT") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5745 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5746 if (!eap->skip)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5747 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
5748 if (!ends_excmd2(eap->cmd, next_arg))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5749 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5750 arg_end = skiptowhite(next_arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5751 if (!eap->skip)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5752 curwin->w_s->b_syn_sync_id = syn_check_group(next_arg,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5753 (int)(arg_end - next_arg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5754 next_arg = skipwhite(arg_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5756 else if (!eap->skip)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5757 curwin->w_s->b_syn_sync_id = syn_name2id((char_u *)"Comment");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5759 else if ( STRNCMP(key, "LINES", 5) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5760 || STRNCMP(key, "MINLINES", 8) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5761 || STRNCMP(key, "MAXLINES", 8) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 || STRNCMP(key, "LINEBREAKS", 10) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764 if (key[4] == 'S')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765 arg_end = key + 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5766 else if (key[0] == 'L')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5767 arg_end = key + 11;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 arg_end = key + 9;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 if (arg_end[-1] != '=' || !VIM_ISDIGIT(*arg_end))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 illegal = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 n = getdigits(&arg_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 if (key[4] == 'B')
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_linebreaks = n;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 else if (key[1] == 'A')
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5781 curwin->w_s->b_syn_sync_maxlines = n;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 else
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5783 curwin->w_s->b_syn_sync_minlines = n;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 else if (STRCMP(key, "FROMSTART") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5790 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
5791 curwin->w_s->b_syn_sync_maxlines = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 else if (STRCMP(key, "LINECONT") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5796 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
5797 {
013f285f31a6 commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents: 7500
diff changeset
5798 illegal = TRUE;
013f285f31a6 commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents: 7500
diff changeset
5799 break;
013f285f31a6 commit https://github.com/vim/vim/commit/2795e21eaafaeaf95a91667fd411023280d0f902
Christian Brabandt <cb@256bit.org>
parents: 7500
diff changeset
5800 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5801 if (curwin->w_s->b_syn_linecont_pat != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5803 emsg(_(e_syntax_sync_line_continuations_pattern_specified_twice));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 finished = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 }
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
5807 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
5808 if (*arg_end != *next_arg) // end delimiter not found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5809 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 illegal = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5811 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5816 // 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
5817 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
5818 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
5819 arg_end - next_arg - 1)) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5821 finished = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 }
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5824 curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5826 // Make 'cpoptions' empty, to avoid the 'l' flag
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 cpo_save = p_cpo;
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23043
diff changeset
5828 p_cpo = empty_option;
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5829 curwin->w_s->b_syn_linecont_prog =
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
5830 vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 p_cpo = cpo_save;
4766
ec24ff78a79c updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents: 4764
diff changeset
5832 #ifdef FEAT_PROFILE
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
5833 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
5834 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
5836 if (curwin->w_s->b_syn_linecont_prog == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
5838 VIM_CLEAR(curwin->w_s->b_syn_linecont_pat);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 finished = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 next_arg = skipwhite(arg_end + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 eap->arg = next_arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 if (STRCMP(key, "MATCH") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 syn_cmd_match(eap, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5850 else if (STRCMP(key, "REGION") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5851 syn_cmd_region(eap, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5852 else if (STRCMP(key, "CLEAR") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5853 syn_cmd_clear(eap, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5854 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5855 illegal = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5856 finished = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5857 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 arg_start = next_arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5860 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5861 vim_free(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5862 if (illegal)
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5863 semsg(_(e_illegal_arguments_str), arg_start);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864 else if (!finished)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 {
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
5866 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
5867 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
5868 syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 * Convert a line of highlight group names into a list of group ID numbers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874 * "arg" should point to the "contains" or "nextgroup" keyword.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 * "arg" is advanced to after the last group name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876 * Careful: the argument is modified (NULs added).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 * returns FAIL for some error, OK for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5880 get_id_list(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5881 char_u **arg,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5882 int keylen, // length of keyword
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5883 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
5884 // 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
5885 int skip)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5886 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5887 char_u *p = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5888 char_u *end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889 int round;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5891 int total_count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 short *retval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5893 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 int id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5896 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5897 int failed = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5899 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900 * We parse the list twice:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901 * round == 1: count the number of items, allocate the array.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5902 * round == 2: fill the array with the items.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903 * In round 1 new groups may be added, causing the number of items to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904 * grow when a regexp is used. In that case round 1 is done once again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5905 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5906 for (round = 1; round <= 2; ++round)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5909 * skip "contains"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5911 p = skipwhite(*arg + keylen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912 if (*p != '=')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5914 semsg(_(e_missing_equal_sign_str), *arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5915 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 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
5918 if (ends_excmd2(*arg, p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5919 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5920 semsg(_(e_empty_argument_str), *arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5924 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5925 * parse the arguments after "contains"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 count = 0;
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
5928 while (!ends_excmd2(*arg, p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929 {
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
5930 for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5931 ;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
5932 name = alloc(end - p + 3); // leave room for "^$"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5933 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5934 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935 failed = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 }
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
5938 vim_strncpy(name + 1, p, end - p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5939 if ( STRCMP(name + 1, "ALLBUT") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5940 || STRCMP(name + 1, "ALL") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 || STRCMP(name + 1, "TOP") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 || STRCMP(name + 1, "CONTAINED") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944 if (TOUPPER_ASC(**arg) != 'C')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5946 semsg(_(e_str_not_allowed_here), name + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 failed = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 if (count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5953 semsg(_(e_str_must_be_first_in_contains_list), name + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 failed = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 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
5959 id = SYNID_ALLBUT + current_syn_inc_tag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5960 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
5961 {
d16a69f718b5 patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 23493
diff changeset
5962 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
5963 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
5964 else
d16a69f718b5 patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 23493
diff changeset
5965 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
5966 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5967 else
24442
d16a69f718b5 patch 8.2.2761: using "syn include" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 23493
diff changeset
5968 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
5969
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5971 else if (name[1] == '@')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5972 {
10629
16fc46021e51 patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10624
diff changeset
5973 if (skip)
16fc46021e51 patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10624
diff changeset
5974 id = -1;
16fc46021e51 patch 8.0.0204: compiler warns for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10624
diff changeset
5975 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
5976 id = syn_check_cluster(name + 2, (int)(end - p - 1));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5977 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5978 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5980 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5981 * Handle full group name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5982 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5983 if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5984 id = syn_check_group(name + 1, (int)(end - p));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5985 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5987 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5988 * Handle match of regexp with group names.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5989 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5990 *name = '^';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5991 STRCAT(name, "$");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5992 regmatch.regprog = vim_regcomp(name, RE_MAGIC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5993 if (regmatch.regprog == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5994 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5995 failed = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5996 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5997 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5998 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5999
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6000 regmatch.rm_ic = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6001 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
6002 for (i = highlight_num_groups(); --i >= 0; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6003 {
17401
5462bb963075 patch 8.1.1699: highlight_ga can be local instead of global
Bram Moolenaar <Bram@vim.org>
parents: 17389
diff changeset
6004 if (vim_regexec(&regmatch, highlight_group_name(i),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6005 (colnr_T)0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6006 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6007 if (round == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6008 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6009 // 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
6010 // when adding items that match:
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6011 // "contains=a.*b,axb".
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6012 // Go back to first round
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6013 if (count >= total_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6015 vim_free(retval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6016 round = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6017 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6018 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6019 retval[count] = i + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6021 ++count;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6022 id = -1; // remember that we found one
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6024 }
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
6025 vim_regfree(regmatch.regprog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6026 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6027 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6028 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 if (id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6030 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
6031 semsg(_(e_unknown_group_name_str), p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032 failed = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6035 if (id > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 if (round == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6039 // Got more items than expected, go back to first round
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 if (count >= total_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6042 vim_free(retval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 round = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6046 retval[count] = id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 ++count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6049 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6050 p = skipwhite(end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6051 if (*p != ',')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6052 break;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6053 p = skipwhite(p + 1); // skip comma in between arguments
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 if (failed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 if (round == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058 {
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
6059 retval = ALLOC_MULT(short, count + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 if (retval == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6061 break;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6062 retval[count] = 0; // zero means end of the list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6063 total_count = count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6064 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 *arg = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068 if (failed || retval == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6070 vim_free(retval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6071 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6074 if (*list == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6075 *list = retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6076 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6077 vim_free(retval); // list already found, don't overwrite it
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6078
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6079 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6080 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6081
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6082 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6083 * Make a copy of an ID list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6084 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6085 static short *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6086 copy_id_list(short *list)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6087 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6088 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6089 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6090 short *retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6091
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6092 if (list == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6093 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6094
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6095 for (count = 0; list[count]; ++count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6096 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6097 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
6098 retval = alloc(len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6099 if (retval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6100 mch_memmove(retval, list, (size_t)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6103 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6106 * Check if syntax group "ssp" is in the ID list "list" of "cur_si".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6107 * "cur_si" can be NULL if not checking the "containedin" list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6108 * Used to check if a syntax item is in the "contains" or "nextgroup" list of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6109 * the current item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6110 * This function is called very often, keep it fast!!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6111 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6113 in_id_list(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6114 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
6115 short *list, // id list
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6116 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
6117 int contained) // group id is contained
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6119 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 short *scl_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121 short item;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6122 short id = ssp->id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6123 static int depth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6124 int r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6125
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6126 // If ssp has a "containedin" list and "cur_si" is in it, return TRUE.
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
6127 if (cur_si != NULL && ssp->cont_in_list != NULL
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
6128 && !(cur_si->si_flags & HL_MATCH))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6129 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6130 // 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
6131 // that we don't go back past the first one.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6132 while ((cur_si->si_flags & HL_TRANS_CONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6133 && cur_si > (stateitem_T *)(current_state.ga_data))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6134 --cur_si;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6135 // cur_si->si_idx is -1 for keywords, these never contain anything.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6136 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
6137 &(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
6138 SYN_ITEMS(syn_block)[cur_si->si_idx].sp_flags & HL_CONTAINED))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6139 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6142 if (list == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6143 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6145 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6146 * If list is ID_LIST_ALL, we are in a transparent item that isn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6147 * inside anything. Only allow not-contained groups.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6148 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 if (list == ID_LIST_ALL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6150 return !contained;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6152 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6153 * If the first item is "ALLBUT", return TRUE if "id" is NOT in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6154 * contains list. We also require that "id" is at the same ":syn include"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6155 * level as the list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6156 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6157 item = *list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6158 if (item >= SYNID_ALLBUT && item < SYNID_CLUSTER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6159 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6160 if (item < SYNID_TOP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6161 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6162 // ALL or ALLBUT: accept all groups in the same file
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6163 if (item - SYNID_ALLBUT != ssp->inc_tag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6164 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6166 else if (item < SYNID_CONTAINED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6167 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6168 // TOP: accept all not-contained groups in the same file
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6169 if (item - SYNID_TOP != ssp->inc_tag || contained)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6170 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6171 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6172 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6174 // CONTAINED: accept all contained groups in the same file
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6175 if (item - SYNID_CONTAINED != ssp->inc_tag || !contained)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6176 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6178 item = *++list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6179 retval = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6181 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6182 retval = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6185 * Return "retval" if id is in the contains list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6186 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6187 while (item != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6188 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6189 if (item == id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6190 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6191 if (item >= SYNID_CLUSTER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6192 {
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6193 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
6194 // 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
6195 // cluster that includes itself (indirectly)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6196 if (scl_list != NULL && depth < 30)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6197 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6198 ++depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6199 r = in_id_list(NULL, scl_list, ssp, contained);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6200 --depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6201 if (r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6202 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6203 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6204 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6205 item = *++list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6207 return !retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6210 struct subcommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6211 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6212 char *name; // subcommand name
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6213 void (*func)(exarg_T *, int); // function to call
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6214 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6216 static struct subcommand subcommands[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6218 {"case", syn_cmd_case},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6219 {"clear", syn_cmd_clear},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6220 {"cluster", syn_cmd_cluster},
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6221 {"conceal", syn_cmd_conceal},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 {"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
6223 {"foldlevel", syn_cmd_foldlevel},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6224 {"include", syn_cmd_include},
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
6225 {"iskeyword", syn_cmd_iskeyword},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6226 {"keyword", syn_cmd_keyword},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6227 {"list", syn_cmd_list},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6228 {"manual", syn_cmd_manual},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6229 {"match", syn_cmd_match},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6230 {"on", syn_cmd_on},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6231 {"off", syn_cmd_off},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6232 {"region", syn_cmd_region},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6233 {"reset", syn_cmd_reset},
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
6234 {"spell", syn_cmd_spell},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6235 {"sync", syn_cmd_sync},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6236 {"", syn_cmd_list},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6237 {NULL, NULL}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6238 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6240 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6241 * ":syntax".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6242 * This searches the subcommands[] table for the subcommand name, and calls a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6243 * syntax_subcommand() function to do the rest.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6244 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6245 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6246 ex_syntax(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6248 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6249 char_u *subcmd_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6250 char_u *subcmd_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6251 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6253 syn_cmdlinep = eap->cmdlinep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6254
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6255 // isolate subcommand name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6256 for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6257 ;
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20751
diff changeset
6258 subcmd_name = vim_strnsave(arg, subcmd_end - arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6259 if (subcmd_name != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6260 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6261 if (eap->skip) // skip error messages for all subcommands
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6262 ++emsg_skip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6263 for (i = 0; ; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6264 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6265 if (subcommands[i].name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6266 {
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
6267 semsg(_(e_invalid_syntax_subcommand_str), subcmd_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6268 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6270 if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6272 eap->arg = skipwhite(subcmd_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6273 (subcommands[i].func)(eap, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6274 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6277 vim_free(subcmd_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6278 if (eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6279 --emsg_skip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6282
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6283 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6284 ex_ownsyntax(exarg_T *eap)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6285 {
2252
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6286 char_u *old_value;
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6287 char_u *new_value;
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6288
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6289 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
6290 {
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
6291 curwin->w_s = ALLOC_ONE(synblock_T);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6292 memset(curwin->w_s, 0, sizeof(synblock_T));
7030
8d513ddfe3ec commit https://github.com/vim/vim/commit/670acbc70f371409b46b722bd9a1166e53574f42
Christian Brabandt <cb@256bit.org>
parents: 7017
diff changeset
6293 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
6294 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
6295 #ifdef FEAT_SPELL
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6296 // 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
6297 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
6298 // 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
6299 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
6300 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
6301 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
6302 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
6303 #endif
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7685
diff changeset
6304 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
6305 }
2252
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6306
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6307 // save value of b:current_syntax
2252
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6308 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
6309 if (old_value != NULL)
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6310 old_value = vim_strsave(old_value);
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 // 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
6313 // file.
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6314 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
6315
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6316 // 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
6317 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
6318 if (new_value != NULL)
8b3203df361f Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2253
diff changeset
6319 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
6320
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6321 // restore value of b:current_syntax
2256
8b3203df361f Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2253
diff changeset
6322 if (old_value == NULL)
8b3203df361f Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2253
diff changeset
6323 do_unlet((char_u *)"b:current_syntax", TRUE);
8b3203df361f Fix crash for ":ownsyntax". (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2253
diff changeset
6324 else
2252
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6325 {
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6326 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
6327 vim_free(old_value);
a0b5918c33cc Fixed memory leak in ":ownsyntax".
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
6328 }
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
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6332 syntax_present(win_T *win)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6333 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6334 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
6335 || 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
6336 || 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
6337 || win->w_s->b_keywtab_ic.ht_used > 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6338 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6341 static enum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6342 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6343 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
6344 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
6345 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
6346 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
6347 EXP_CLUSTER // expand ":syn list @cluster" arguments
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6348 } expand_what;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349
1322
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6350 /*
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6351 * Reset include_link, include_default, include_none to 0.
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6352 * Called when we are done expanding.
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6353 */
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6354 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6355 reset_expand_highlight(void)
1322
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6356 {
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6357 include_link = include_default = include_none = 0;
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6358 }
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6359
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6360 /*
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6361 * Handle command line completion for :match and :echohl command: Add "None"
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6362 * as highlight group.
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6363 */
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6364 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6365 set_context_in_echohl_cmd(expand_T *xp, char_u *arg)
1322
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6366 {
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6367 xp->xp_context = EXPAND_HIGHLIGHT;
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6368 xp->xp_pattern = arg;
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6369 include_none = 1;
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6370 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6372 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6373 * Handle command line completion for :syntax command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6374 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6375 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6376 set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6377 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6378 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6379
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6380 // Default: expand subcommands
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6381 xp->xp_context = EXPAND_SYNTAX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6382 expand_what = EXP_SUBCMD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6383 xp->xp_pattern = arg;
1322
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6384 include_link = 0;
4ce0a7e4c6b3 updated for version 7.1-036
vimboss
parents: 1299
diff changeset
6385 include_default = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6386
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6387 // (part of) subcommand already typed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6388 if (*arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6390 p = skiptowhite(arg);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6391 if (*p != NUL) // past first word
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 xp->xp_pattern = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6394 if (*skiptowhite(xp->xp_pattern) != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6395 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396 else if (STRNICMP(arg, "case", p - arg) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 expand_what = EXP_CASE;
10534
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6398 else if (STRNICMP(arg, "spell", p - arg) == 0)
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6399 expand_what = EXP_SPELL;
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6400 else if (STRNICMP(arg, "sync", p - arg) == 0)
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6401 expand_what = EXP_SYNC;
29890
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6402 else if (STRNICMP(arg, "list", p - arg) == 0)
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6403 {
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6404 p = skipwhite(p);
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6405 if (*p == '@')
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6406 expand_what = EXP_CLUSTER;
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6407 else
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6408 xp->xp_context = EXPAND_HIGHLIGHT;
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6409 }
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6410 else if (STRNICMP(arg, "keyword", p - arg) == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6411 || STRNICMP(arg, "region", p - arg) == 0
29890
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6412 || STRNICMP(arg, "match", p - arg) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6413 xp->xp_context = EXPAND_HIGHLIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6414 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6415 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6420 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6421 * Function given to ExpandGeneric() to obtain the list syntax names for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 * expansion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6424 char_u *
29892
db0939444c96 patch 9.0.0284: using static buffer for multiple completion functions
Bram Moolenaar <Bram@vim.org>
parents: 29890
diff changeset
6425 get_syntax_name(expand_T *xp, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6426 {
10534
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6427 switch (expand_what)
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6428 {
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6429 case EXP_SUBCMD:
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6430 return (char_u *)subcommands[idx].name;
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6431 case EXP_CASE:
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 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
6434 return (char_u *)case_args[idx];
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6435 }
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6436 case EXP_SPELL:
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6437 {
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6438 static char *spell_args[] =
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6439 {"toplevel", "notoplevel", "default", NULL};
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6440 return (char_u *)spell_args[idx];
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6441 }
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6442 case EXP_SYNC:
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6443 {
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6444 static char *sync_args[] =
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6445 {"ccomment", "clear", "fromstart",
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6446 "linebreaks=", "linecont", "lines=", "match",
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6447 "maxlines=", "minlines=", "region", NULL};
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6448 return (char_u *)sync_args[idx];
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6449 }
29890
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6450 case EXP_CLUSTER:
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6451 {
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6452 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
6453 {
29892
db0939444c96 patch 9.0.0284: using static buffer for multiple completion functions
Bram Moolenaar <Bram@vim.org>
parents: 29890
diff changeset
6454 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
6455 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
6456 return xp->xp_buf;
29890
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6457 }
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6458 else
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6459 return NULL;
80929331a836 patch 9.0.0283: cannot complete "syn list @cluster"
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
6460 }
10534
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6461 }
1c6db35e3527 commit https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1
Christian Brabandt <cb@256bit.org>
parents: 10530
diff changeset
6462 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6466 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6467 * Function called for expression evaluation: get syntax ID at file position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6468 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6470 syn_get_id(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6471 win_T *wp,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6472 long lnum,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6473 colnr_T col,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6474 int trans, // remove transparency
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6475 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
6476 int keep_state) // keep state of char at "col"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6478 // 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
6479 // 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
6480 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
6481 || wp->w_buffer != syn_buf
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6482 || lnum != current_lnum
253
62a331864307 updated for version 7.0069
vimboss
parents: 227
diff changeset
6483 || col < current_col)
12510
7a887dccd13a patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
6484 syntax_start(wp, lnum);
7685
616460b73ee3 commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents: 7504
diff changeset
6485 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
6486 && lnum == current_lnum
616460b73ee3 commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents: 7504
diff changeset
6487 && col > current_col)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6488 // 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
6489 // "skip" expression in searchpair()
7685
616460b73ee3 commit https://github.com/vim/vim/commit/6773a348da0dcf45df3c6c6649880655ec0d2042
Christian Brabandt <cb@256bit.org>
parents: 7504
diff changeset
6490 next_match_idx = -1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6491
2375
a96dd77ce213 For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents: 2318
diff changeset
6492 (void)get_syntax_attr(col, spellp, keep_state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494 return (trans ? current_trans_id : current_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6497 #if defined(FEAT_CONCEAL) || defined(PROTO)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6498 /*
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 * 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
6500 * 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
6501 * 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
6502 * 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
6503 */
a96dd77ce213 For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents: 2318
diff changeset
6504 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6505 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
6506 {
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
6507 *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
6508 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
6509 }
a96dd77ce213 For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents: 2318
diff changeset
6510
a96dd77ce213 For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents: 2318
diff changeset
6511 /*
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6512 * Return conceal substitution character
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 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6515 syn_get_sub_char(void)
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6516 {
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6517 return current_sub_char;
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6518 }
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6519 #endif
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
6520
1500
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6521 #if defined(FEAT_EVAL) || defined(PROTO)
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6522 /*
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6523 * Return the syntax ID at position "i" in the current stack.
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6524 * The caller must have called syn_get_id() before to fill the stack.
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6525 * Returns -1 when "i" is out of range.
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6526 */
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6527 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6528 syn_get_stack_item(int i)
1500
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6529 {
1504
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
6530 if (i >= current_state.ga_len)
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
6531 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6532 // 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
6533 // for the last character, "keep_state" was TRUE.
1504
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
6534 invalidate_current_state();
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
6535 current_col = MAXCOL;
1500
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6536 return -1;
1504
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1503
diff changeset
6537 }
1500
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6538 return CUR_STATE(i).si_id;
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6539 }
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6540 #endif
ea9f418ed072 updated for version 7.1-215
vimboss
parents: 1421
diff changeset
6541
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6542 #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
6543 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
6544 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
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 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
6547 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
6548
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 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
6550 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
6551 ++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
6552 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
6553 }
99b6e6bf48bf patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
6554
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6555 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6556 * Function called to get folding level for line "lnum" in window "wp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6557 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6558 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6559 syn_get_foldlevel(win_T *wp, long lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6561 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
6562 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
6563 int cur_level;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6564
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6565 // 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
6566 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
6567 && !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
6568 # 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
6569 && !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
6570 # endif
998d2cf59caa patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
6571 )
998d2cf59caa patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
6572 {
12510
7a887dccd13a patch 8.0.1133: syntax timeout not used correctly
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
6573 syntax_start(wp, lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6574
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
6575 // 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
6576 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
6577
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 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
6579 {
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 // 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
6581 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
6582 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
6583 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
6584 {
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 (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
6586 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
6587 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
6588 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
6589 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
6590 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
6591 ++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
6592 }
99b6e6bf48bf patch 8.2.0865: syntax foldlevel is taken from the start of the line
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
6593 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6594 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6595 if (level > wp->w_p_fdn)
1028
5044d9d784ed updated for version 7.0-154
vimboss
parents: 991
diff changeset
6596 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6597 level = wp->w_p_fdn;
1028
5044d9d784ed updated for version 7.0-154
vimboss
parents: 991
diff changeset
6598 if (level < 0)
5044d9d784ed updated for version 7.0-154
vimboss
parents: 991
diff changeset
6599 level = 0;
5044d9d784ed updated for version 7.0-154
vimboss
parents: 991
diff changeset
6600 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6601 return level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6603 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6604
6567
d6473d6501fd updated for version 7.4.610
Bram Moolenaar <bram@vim.org>
parents: 6386
diff changeset
6605 #if defined(FEAT_PROFILE) || defined(PROTO)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6606 /*
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6607 * ":syntime".
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 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6610 ex_syntime(exarg_T *eap)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6611 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6612 if (STRCMP(eap->arg, "on") == 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6613 syn_time_on = TRUE;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6614 else if (STRCMP(eap->arg, "off") == 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6615 syn_time_on = FALSE;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6616 else if (STRCMP(eap->arg, "clear") == 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6617 syntime_clear();
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6618 else if (STRCMP(eap->arg, "report") == 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6619 syntime_report();
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6620 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26199
diff changeset
6621 semsg(_(e_invalid_argument_str), eap->arg);
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6622 }
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 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6625 syn_clear_time(syn_time_T *st)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6626 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6627 profile_zero(&st->total);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6628 profile_zero(&st->slowest);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6629 st->count = 0;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6630 st->match = 0;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6631 }
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 /*
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6634 * Clear the syntax timing for the current buffer.
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 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6637 syntime_clear(void)
4764
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 int idx;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6640 synpat_T *spp;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6641
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6642 if (!syntax_present(curwin))
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6643 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6644 msg(_(msg_no_items));
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6645 return;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6646 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6647 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
6648 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6649 spp = &(SYN_ITEMS(curwin->w_s)[idx]);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6650 syn_clear_time(&spp->sp_time);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6651 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6652 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6653
4803
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 * 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
6656 * ":syntime {on,off,clear,report}" command.
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 char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6659 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
6660 {
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6661 switch (idx)
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6662 {
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6663 case 0: return (char_u *)"on";
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6664 case 1: return (char_u *)"off";
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6665 case 2: return (char_u *)"clear";
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6666 case 3: return (char_u *)"report";
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6667 }
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6668 return NULL;
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6669 }
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6670
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6671 typedef struct
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6672 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6673 proftime_T total;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6674 int count;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6675 int match;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6676 proftime_T slowest;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6677 proftime_T average;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6678 int id;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6679 char_u *pattern;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6680 } time_entry_T;
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 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6683 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
6684 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6685 const time_entry_T *s1 = v1;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6686 const time_entry_T *s2 = v2;
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 return profile_cmp(&s1->total, &s2->total);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6689 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6690
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6691 /*
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6692 * Clear the syntax timing for the current buffer.
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 static void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6695 syntime_report(void)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6696 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6697 int idx;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6698 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
6699 # if defined(FEAT_RELTIME)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6700 proftime_T tm;
4803
220bdea4f579 updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents: 4791
diff changeset
6701 # endif
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6702 int len;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6703 proftime_T total_total;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6704 int total_count = 0;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6705 garray_T ga;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6706 time_entry_T *p;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6707
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6708 if (!syntax_present(curwin))
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6709 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6710 msg(_(msg_no_items));
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6711 return;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6712 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6713
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6714 ga_init2(&ga, sizeof(time_entry_T), 50);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6715 profile_zero(&total_total);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6716 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
6717 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6718 spp = &(SYN_ITEMS(curwin->w_s)[idx]);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6719 if (spp->sp_time.count > 0)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6720 {
7009
286fd54c7ae3 patch 7.4.822
Bram Moolenaar <bram@vim.org>
parents: 6993
diff changeset
6721 (void)ga_grow(&ga, 1);
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6722 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
6723 p->total = spp->sp_time.total;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6724 profile_add(&total_total, &spp->sp_time.total);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6725 p->count = spp->sp_time.count;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6726 p->match = spp->sp_time.match;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6727 total_count += spp->sp_time.count;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6728 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
6729 # if defined(FEAT_RELTIME)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6730 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
6731 p->average = tm;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6732 # endif
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6733 p->id = spp->sp_syn.id;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6734 p->pattern = spp->sp_pattern;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6735 ++ga.ga_len;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6736 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6737 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6738
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6739 // 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
6740 // pointer to qsort().
10530
ea5adbeccfc1 commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents: 10499
diff changeset
6741 if (ga.ga_len > 1)
ea5adbeccfc1 commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e
Christian Brabandt <cb@256bit.org>
parents: 10499
diff changeset
6742 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
6743 syn_compare_syntime);
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6744
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6745 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
6746 msg_puts("\n");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6747 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
6748 {
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6749 p = ((time_entry_T *)ga.ga_data) + idx;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6750
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6751 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
6752 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
6753 msg_advance(13);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6754 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
6755 msg_puts(" ");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6756 msg_advance(20);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6757 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
6758 msg_puts(" ");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6759 msg_advance(26);
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->slowest));
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(38);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6763 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
6764 msg_puts(" ");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6765 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
6766 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
6767 msg_puts(" ");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6768
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6769 msg_advance(69);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6770 if (Columns < 80)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6771 len = 20; // will wrap anyway
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6772 else
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6773 len = Columns - 70;
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6774 if (len > (int)STRLEN(p->pattern))
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6775 len = (int)STRLEN(p->pattern);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6776 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
6777 msg_puts("\n");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6778 }
4791
65cef998f860 updated for version 7.3.1142
Bram Moolenaar <bram@vim.org>
parents: 4776
diff changeset
6779 ga_clear(&ga);
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6780 if (!got_int)
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6781 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6782 msg_puts("\n");
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6783 msg_puts(profile_msg(&total_total));
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6784 msg_advance(13);
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6785 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
6786 msg_puts("\n");
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6787 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6788 }
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6789 #endif
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6790
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 17907
diff changeset
6791 #endif // FEAT_SYN_HL