Mercurial > vim
annotate src/option.c @ 4242:edd0bc1f26bd v7.3.872
updated for version 7.3.872
Problem: On some systems case of file names is always ignored, on others
never.
Solution: Add the 'fileignorecase' option to control this at runtime.
Implies 'wildignorecase'.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 19 Mar 2013 16:49:16 +0100 |
parents | 6fe728bf165e |
children | 7eaccdaa5304 |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle user-settable options. This is all pretty much table- | |
12 * driven. Checklist for adding a new option: | |
13 * - Put it in the options array below (copy an existing entry). | |
14 * - For a global option: Add a variable for it in option.h. | |
15 * - For a buffer or window local option: | |
16 * - Add a PV_XX entry to the enum below. | |
17 * - Add a variable to the window or buffer struct in structs.h. | |
18 * - For a window option, add some code to copy_winopt(). | |
19 * - For a buffer option, add some code to buf_copy_options(). | |
20 * - For a buffer string option, add code to check_buf_options(). | |
21 * - If it's a numeric option, add any necessary bounds checks to do_set(). | |
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL. | |
23 * - When adding an option with expansion (P_EXPAND), but with a different | |
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. | |
25 * - Add documentation! One line in doc/help.txt, full description in | |
26 * options.txt, and any other related places. | |
27 * - Add an entry in runtime/optwin.vim. | |
28 * When making changes: | |
29 * - Adjust the help for the option in doc/option.txt. | |
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a | |
31 * comment at the help for the 'compatible' option. | |
32 */ | |
33 | |
34 #define IN_OPTION_C | |
35 #include "vim.h" | |
36 | |
37 /* | |
38 * The options that are local to a window or buffer have "indir" set to one of | |
39 * these values. Special values: | |
40 * PV_NONE: global option. | |
692 | 41 * PV_WIN is added: window-local option |
42 * PV_BUF is added: buffer-local option | |
7 | 43 * PV_BOTH is added: global option which also has a local value. |
44 */ | |
45 #define PV_BOTH 0x1000 | |
692 | 46 #define PV_WIN 0x2000 |
47 #define PV_BUF 0x4000 | |
694 | 48 #define PV_MASK 0x0fff |
692 | 49 #define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x)) |
50 #define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x)) | |
7 | 51 #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) |
52 | |
692 | 53 /* |
694 | 54 * Definition of the PV_ values for buffer-local options. |
55 * The BV_ values are defined in option.h. | |
692 | 56 */ |
57 #define PV_AI OPT_BUF(BV_AI) | |
58 #define PV_AR OPT_BOTH(OPT_BUF(BV_AR)) | |
694 | 59 #ifdef FEAT_QUICKFIX |
692 | 60 # define PV_BH OPT_BUF(BV_BH) |
694 | 61 # define PV_BT OPT_BUF(BV_BT) |
62 # define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM)) | |
63 # define PV_GP OPT_BOTH(OPT_BUF(BV_GP)) | |
64 # define PV_MP OPT_BOTH(OPT_BUF(BV_MP)) | |
692 | 65 #endif |
66 #define PV_BIN OPT_BUF(BV_BIN) | |
67 #define PV_BL OPT_BUF(BV_BL) | |
694 | 68 #ifdef FEAT_MBYTE |
69 # define PV_BOMB OPT_BUF(BV_BOMB) | |
70 #endif | |
71 #define PV_CI OPT_BUF(BV_CI) | |
72 #ifdef FEAT_CINDENT | |
73 # define PV_CIN OPT_BUF(BV_CIN) | |
74 # define PV_CINK OPT_BUF(BV_CINK) | |
75 # define PV_CINO OPT_BUF(BV_CINO) | |
76 #endif | |
77 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
78 # define PV_CINW OPT_BUF(BV_CINW) | |
79 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
80 #define PV_CM OPT_BOTH(OPT_BUF(BV_CM)) |
694 | 81 #ifdef FEAT_FOLDING |
82 # define PV_CMS OPT_BUF(BV_CMS) | |
83 #endif | |
84 #ifdef FEAT_COMMENTS | |
85 # define PV_COM OPT_BUF(BV_COM) | |
86 #endif | |
87 #ifdef FEAT_INS_EXPAND | |
88 # define PV_CPT OPT_BUF(BV_CPT) | |
89 # define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT)) | |
90 # define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR)) | |
91 #endif | |
92 #ifdef FEAT_COMPL_FUNC | |
93 # define PV_CFU OPT_BUF(BV_CFU) | |
94 #endif | |
95 #ifdef FEAT_FIND_ID | |
96 # define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF)) | |
97 # define PV_INC OPT_BOTH(OPT_BUF(BV_INC)) | |
98 #endif | |
99 #define PV_EOL OPT_BUF(BV_EOL) | |
100 #define PV_EP OPT_BOTH(OPT_BUF(BV_EP)) | |
101 #define PV_ET OPT_BUF(BV_ET) | |
102 #ifdef FEAT_MBYTE | |
103 # define PV_FENC OPT_BUF(BV_FENC) | |
104 #endif | |
790 | 105 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
106 # define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR)) | |
107 #endif | |
694 | 108 #ifdef FEAT_EVAL |
109 # define PV_FEX OPT_BUF(BV_FEX) | |
110 #endif | |
111 #define PV_FF OPT_BUF(BV_FF) | |
112 #define PV_FLP OPT_BUF(BV_FLP) | |
113 #define PV_FO OPT_BUF(BV_FO) | |
114 #ifdef FEAT_AUTOCMD | |
115 # define PV_FT OPT_BUF(BV_FT) | |
116 #endif | |
117 #define PV_IMI OPT_BUF(BV_IMI) | |
118 #define PV_IMS OPT_BUF(BV_IMS) | |
119 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
120 # define PV_INDE OPT_BUF(BV_INDE) | |
121 # define PV_INDK OPT_BUF(BV_INDK) | |
122 #endif | |
123 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) | |
124 # define PV_INEX OPT_BUF(BV_INEX) | |
125 #endif | |
126 #define PV_INF OPT_BUF(BV_INF) | |
127 #define PV_ISK OPT_BUF(BV_ISK) | |
128 #ifdef FEAT_CRYPT | |
129 # define PV_KEY OPT_BUF(BV_KEY) | |
130 #endif | |
131 #ifdef FEAT_KEYMAP | |
132 # define PV_KMAP OPT_BUF(BV_KMAP) | |
133 #endif | |
134 #define PV_KP OPT_BOTH(OPT_BUF(BV_KP)) | |
135 #ifdef FEAT_LISP | |
136 # define PV_LISP OPT_BUF(BV_LISP) | |
137 #endif | |
138 #define PV_MA OPT_BUF(BV_MA) | |
139 #define PV_ML OPT_BUF(BV_ML) | |
140 #define PV_MOD OPT_BUF(BV_MOD) | |
141 #define PV_MPS OPT_BUF(BV_MPS) | |
142 #define PV_NF OPT_BUF(BV_NF) | |
143 #ifdef FEAT_COMPL_FUNC | |
144 # define PV_OFU OPT_BUF(BV_OFU) | |
145 #endif | |
146 #define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH)) | |
147 #define PV_PI OPT_BUF(BV_PI) | |
148 #ifdef FEAT_TEXTOBJ | |
149 # define PV_QE OPT_BUF(BV_QE) | |
150 #endif | |
151 #define PV_RO OPT_BUF(BV_RO) | |
152 #ifdef FEAT_SMARTINDENT | |
153 # define PV_SI OPT_BUF(BV_SI) | |
154 #endif | |
155 #ifndef SHORT_FNAME | |
156 # define PV_SN OPT_BUF(BV_SN) | |
157 #endif | |
158 #ifdef FEAT_SYN_HL | |
159 # define PV_SMC OPT_BUF(BV_SMC) | |
744 | 160 # define PV_SYN OPT_BUF(BV_SYN) |
161 #endif | |
162 #ifdef FEAT_SPELL | |
694 | 163 # define PV_SPC OPT_BUF(BV_SPC) |
164 # define PV_SPF OPT_BUF(BV_SPF) | |
165 # define PV_SPL OPT_BUF(BV_SPL) | |
166 #endif | |
167 #define PV_STS OPT_BUF(BV_STS) | |
168 #ifdef FEAT_SEARCHPATH | |
169 # define PV_SUA OPT_BUF(BV_SUA) | |
170 #endif | |
171 #define PV_SW OPT_BUF(BV_SW) | |
172 #define PV_SWF OPT_BUF(BV_SWF) | |
173 #define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS)) | |
174 #define PV_TS OPT_BUF(BV_TS) | |
175 #define PV_TW OPT_BUF(BV_TW) | |
176 #define PV_TX OPT_BUF(BV_TX) | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
177 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
178 # define PV_UDF OPT_BUF(BV_UDF) |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
179 #endif |
694 | 180 #define PV_WM OPT_BUF(BV_WM) |
692 | 181 |
182 /* | |
694 | 183 * Definition of the PV_ values for window-local options. |
184 * The WV_ values are defined in option.h. | |
692 | 185 */ |
186 #define PV_LIST OPT_WIN(WV_LIST) | |
187 #ifdef FEAT_ARABIC | |
188 # define PV_ARAB OPT_WIN(WV_ARAB) | |
189 #endif | |
694 | 190 #ifdef FEAT_DIFF |
191 # define PV_DIFF OPT_WIN(WV_DIFF) | |
192 #endif | |
193 #ifdef FEAT_FOLDING | |
194 # define PV_FDC OPT_WIN(WV_FDC) | |
195 # define PV_FEN OPT_WIN(WV_FEN) | |
196 # define PV_FDI OPT_WIN(WV_FDI) | |
197 # define PV_FDL OPT_WIN(WV_FDL) | |
198 # define PV_FDM OPT_WIN(WV_FDM) | |
199 # define PV_FML OPT_WIN(WV_FML) | |
200 # define PV_FDN OPT_WIN(WV_FDN) | |
201 # ifdef FEAT_EVAL | |
202 # define PV_FDE OPT_WIN(WV_FDE) | |
203 # define PV_FDT OPT_WIN(WV_FDT) | |
204 # endif | |
205 # define PV_FMR OPT_WIN(WV_FMR) | |
206 #endif | |
207 #ifdef FEAT_LINEBREAK | |
208 # define PV_LBR OPT_WIN(WV_LBR) | |
209 #endif | |
210 #define PV_NU OPT_WIN(WV_NU) | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
211 #define PV_RNU OPT_WIN(WV_RNU) |
694 | 212 #ifdef FEAT_LINEBREAK |
213 # define PV_NUW OPT_WIN(WV_NUW) | |
214 #endif | |
215 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | |
216 # define PV_PVW OPT_WIN(WV_PVW) | |
217 #endif | |
218 #ifdef FEAT_RIGHTLEFT | |
219 # define PV_RL OPT_WIN(WV_RL) | |
220 # define PV_RLC OPT_WIN(WV_RLC) | |
221 #endif | |
222 #ifdef FEAT_SCROLLBIND | |
223 # define PV_SCBIND OPT_WIN(WV_SCBIND) | |
224 #endif | |
225 #define PV_SCROLL OPT_WIN(WV_SCROLL) | |
744 | 226 #ifdef FEAT_SPELL |
227 # define PV_SPELL OPT_WIN(WV_SPELL) | |
228 #endif | |
694 | 229 #ifdef FEAT_SYN_HL |
744 | 230 # define PV_CUC OPT_WIN(WV_CUC) |
231 # define PV_CUL OPT_WIN(WV_CUL) | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
232 # define PV_CC OPT_WIN(WV_CC) |
694 | 233 #endif |
234 #ifdef FEAT_STL_OPT | |
235 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL)) | |
236 #endif | |
237 #ifdef FEAT_WINDOWS | |
238 # define PV_WFH OPT_WIN(WV_WFH) | |
239 #endif | |
782 | 240 #ifdef FEAT_VERTSPLIT |
241 # define PV_WFW OPT_WIN(WV_WFW) | |
242 #endif | |
694 | 243 #define PV_WRAP OPT_WIN(WV_WRAP) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
244 #ifdef FEAT_CURSORBIND |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
245 # define PV_CRBIND OPT_WIN(WV_CRBIND) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
246 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
247 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
248 # define PV_COCU OPT_WIN(WV_COCU) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
249 # define PV_COLE OPT_WIN(WV_COLE) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
250 #endif |
694 | 251 |
252 /* WV_ and BV_ values get typecasted to this for the "indir" field */ | |
7 | 253 typedef enum |
254 { | |
1601 | 255 PV_NONE = 0, |
256 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */ | |
7 | 257 } idopt_T; |
258 | |
259 /* | |
260 * Options local to a window have a value local to a buffer and global to all | |
261 * buffers. Indicate this by setting "var" to VAR_WIN. | |
262 */ | |
263 #define VAR_WIN ((char_u *)-1) | |
264 | |
265 /* | |
790 | 266 * These are the global values for options which are also local to a buffer. |
7 | 267 * Only to be used in option.c! |
268 */ | |
269 static int p_ai; | |
270 static int p_bin; | |
271 #ifdef FEAT_MBYTE | |
272 static int p_bomb; | |
273 #endif | |
274 #if defined(FEAT_QUICKFIX) | |
275 static char_u *p_bh; | |
276 static char_u *p_bt; | |
277 #endif | |
278 static int p_bl; | |
279 static int p_ci; | |
280 #ifdef FEAT_CINDENT | |
281 static int p_cin; | |
282 static char_u *p_cink; | |
283 static char_u *p_cino; | |
284 #endif | |
285 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
286 static char_u *p_cinw; | |
287 #endif | |
288 #ifdef FEAT_COMMENTS | |
289 static char_u *p_com; | |
290 #endif | |
291 #ifdef FEAT_FOLDING | |
292 static char_u *p_cms; | |
293 #endif | |
294 #ifdef FEAT_INS_EXPAND | |
295 static char_u *p_cpt; | |
296 #endif | |
12 | 297 #ifdef FEAT_COMPL_FUNC |
298 static char_u *p_cfu; | |
502 | 299 static char_u *p_ofu; |
12 | 300 #endif |
7 | 301 static int p_eol; |
302 static int p_et; | |
303 #ifdef FEAT_MBYTE | |
304 static char_u *p_fenc; | |
305 #endif | |
306 static char_u *p_ff; | |
307 static char_u *p_fo; | |
41 | 308 static char_u *p_flp; |
7 | 309 #ifdef FEAT_AUTOCMD |
310 static char_u *p_ft; | |
311 #endif | |
312 static long p_iminsert; | |
313 static long p_imsearch; | |
314 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) | |
315 static char_u *p_inex; | |
316 #endif | |
317 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
318 static char_u *p_inde; | |
319 static char_u *p_indk; | |
320 #endif | |
667 | 321 #if defined(FEAT_EVAL) |
322 static char_u *p_fex; | |
323 #endif | |
7 | 324 static int p_inf; |
325 static char_u *p_isk; | |
326 #ifdef FEAT_CRYPT | |
327 static char_u *p_key; | |
328 #endif | |
329 #ifdef FEAT_LISP | |
330 static int p_lisp; | |
331 #endif | |
332 static int p_ml; | |
333 static int p_ma; | |
334 static int p_mod; | |
335 static char_u *p_mps; | |
336 static char_u *p_nf; | |
337 static int p_pi; | |
12 | 338 #ifdef FEAT_TEXTOBJ |
339 static char_u *p_qe; | |
340 #endif | |
7 | 341 static int p_ro; |
342 #ifdef FEAT_SMARTINDENT | |
343 static int p_si; | |
344 #endif | |
345 #ifndef SHORT_FNAME | |
346 static int p_sn; | |
347 #endif | |
348 static long p_sts; | |
349 #if defined(FEAT_SEARCHPATH) | |
350 static char_u *p_sua; | |
351 #endif | |
352 static long p_sw; | |
353 static int p_swf; | |
354 #ifdef FEAT_SYN_HL | |
410 | 355 static long p_smc; |
7 | 356 static char_u *p_syn; |
744 | 357 #endif |
358 #ifdef FEAT_SPELL | |
386 | 359 static char_u *p_spc; |
314 | 360 static char_u *p_spf; |
221 | 361 static char_u *p_spl; |
7 | 362 #endif |
363 static long p_ts; | |
364 static long p_tw; | |
365 static int p_tx; | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
366 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
367 static int p_udf; |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
368 #endif |
7 | 369 static long p_wm; |
370 #ifdef FEAT_KEYMAP | |
371 static char_u *p_keymap; | |
372 #endif | |
373 | |
374 /* Saved values for when 'bin' is set. */ | |
375 static int p_et_nobin; | |
376 static int p_ml_nobin; | |
377 static long p_tw_nobin; | |
378 static long p_wm_nobin; | |
379 | |
380 /* Saved values for when 'paste' is set */ | |
381 static long p_tw_nopaste; | |
382 static long p_wm_nopaste; | |
383 static long p_sts_nopaste; | |
384 static int p_ai_nopaste; | |
385 | |
386 struct vimoption | |
387 { | |
388 char *fullname; /* full option name */ | |
389 char *shortname; /* permissible abbreviation */ | |
390 long_u flags; /* see below */ | |
391 char_u *var; /* global option: pointer to variable; | |
392 * window-local option: VAR_WIN; | |
393 * buffer-local option: global value */ | |
394 idopt_T indir; /* global option: PV_NONE; | |
395 * local option: indirect option index */ | |
396 char_u *def_val[2]; /* default values for variable (vi and vim) */ | |
397 #ifdef FEAT_EVAL | |
398 scid_T scriptID; /* script in which the option was last set */ | |
1883 | 399 # define SCRIPTID_INIT , 0 |
400 #else | |
401 # define SCRIPTID_INIT | |
7 | 402 #endif |
403 }; | |
404 | |
405 #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */ | |
406 #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */ | |
407 | |
408 /* | |
409 * Flags | |
410 */ | |
411 #define P_BOOL 0x01 /* the option is boolean */ | |
412 #define P_NUM 0x02 /* the option is numeric */ | |
413 #define P_STRING 0x04 /* the option is a string */ | |
414 #define P_ALLOCED 0x08 /* the string option is in allocated memory, | |
1941 | 415 must use free_string_option() when |
416 assigning new value. Not set if default is | |
417 the same. */ | |
7 | 418 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can |
419 never be used for local or hidden options! */ | |
420 #define P_NODEFAULT 0x40 /* don't set to default value */ | |
421 #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must | |
422 use vim_free() when assigning new value */ | |
423 #define P_WAS_SET 0x100 /* option has been set/reset */ | |
424 #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */ | |
425 #define P_VI_DEF 0x400 /* Use Vi default for Vim */ | |
426 #define P_VIM 0x800 /* Vim option, reset when 'cp' set */ | |
427 | |
428 /* when option changed, what to display: */ | |
429 #define P_RSTAT 0x1000 /* redraw status lines */ | |
430 #define P_RWIN 0x2000 /* redraw current window */ | |
431 #define P_RBUF 0x4000 /* redraw current buffer */ | |
432 #define P_RALL 0x6000 /* redraw all windows */ | |
433 #define P_RCLR 0x7000 /* clear and redraw all */ | |
434 | |
435 #define P_COMMA 0x8000 /* comma separated list */ | |
3443 | 436 #define P_NODUP 0x10000L /* don't allow duplicate strings */ |
437 #define P_FLAGLIST 0x20000L /* list of single-char flags */ | |
438 | |
439 #define P_SECURE 0x40000L /* cannot change in modeline or secure mode */ | |
440 #define P_GETTEXT 0x80000L /* expand default value with _() */ | |
441 #define P_NOGLOB 0x100000L /* do not use local value for global vimrc */ | |
442 #define P_NFNAME 0x200000L /* only normal file name chars allowed */ | |
443 #define P_INSECURE 0x400000L /* option was set from a modeline */ | |
444 #define P_PRI_MKRC 0x800000L /* priority for :mkvimrc (setting option has | |
1384 | 445 side effects) */ |
3443 | 446 #define P_NO_ML 0x1000000L /* not allowed in modeline */ |
447 #define P_CURSWANT 0x2000000L /* update curswant required; not needed when | |
448 * there is a redraw flag */ | |
7 | 449 |
714 | 450 #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" |
451 | |
819 | 452 /* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used |
453 * for the currency sign. */ | |
719 | 454 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
818 | 455 # define ISP_LATIN1 (char_u *)"@,~-255" |
719 | 456 #else |
457 # define ISP_LATIN1 (char_u *)"@,161-255" | |
458 #endif | |
459 | |
810 | 460 /* The 16 bit MS-DOS version is low on space, make the string as short as |
461 * possible when compiling with few features. */ | |
462 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \ | |
463 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
464 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL) |
3427 | 465 # define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn" |
466 #else | |
467 # define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill" | |
810 | 468 #endif |
469 | |
7 | 470 /* |
471 * options[] is initialized here. | |
472 * The order of the options MUST be alphabetic for ":set all" and findoption(). | |
473 * All option names MUST start with a lowercase letter (for findoption()). | |
474 * Exception: "t_" options are at the end. | |
475 * The options with a NULL variable are 'hidden': a set command for them is | |
476 * ignored and they are not printed. | |
477 */ | |
478 static struct vimoption | |
479 #ifdef FEAT_GUI_W16 | |
480 _far | |
481 #endif | |
482 options[] = | |
483 { | |
3443 | 484 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT, |
7 | 485 #ifdef FEAT_RIGHTLEFT |
486 (char_u *)&p_aleph, PV_NONE, | |
487 #else | |
488 (char_u *)NULL, PV_NONE, | |
489 #endif | |
490 { | |
491 #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32) | |
492 (char_u *)128L, | |
493 #else | |
494 (char_u *)224L, | |
495 #endif | |
1883 | 496 (char_u *)0L} SCRIPTID_INIT}, |
7 | 497 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, |
498 #if defined(FEAT_GUI) && defined(MACOS_X) | |
499 (char_u *)&p_antialias, PV_NONE, | |
500 {(char_u *)FALSE, (char_u *)FALSE} | |
501 #else | |
502 (char_u *)NULL, PV_NONE, | |
503 {(char_u *)FALSE, (char_u *)FALSE} | |
504 #endif | |
1883 | 505 SCRIPTID_INIT}, |
3443 | 506 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT, |
7 | 507 #ifdef FEAT_ARABIC |
508 (char_u *)VAR_WIN, PV_ARAB, | |
509 #else | |
510 (char_u *)NULL, PV_NONE, | |
511 #endif | |
1883 | 512 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 513 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, |
514 #ifdef FEAT_ARABIC | |
515 (char_u *)&p_arshape, PV_NONE, | |
516 #else | |
517 (char_u *)NULL, PV_NONE, | |
518 #endif | |
1883 | 519 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 520 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM, |
521 #ifdef FEAT_RIGHTLEFT | |
522 (char_u *)&p_ari, PV_NONE, | |
523 #else | |
524 (char_u *)NULL, PV_NONE, | |
525 #endif | |
1883 | 526 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 527 {"altkeymap", "akm", P_BOOL|P_VI_DEF, |
528 #ifdef FEAT_FKMAP | |
529 (char_u *)&p_altkeymap, PV_NONE, | |
530 #else | |
531 (char_u *)NULL, PV_NONE, | |
532 #endif | |
1883 | 533 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 534 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR, |
535 #if defined(FEAT_MBYTE) | |
536 (char_u *)&p_ambw, PV_NONE, | |
537 {(char_u *)"single", (char_u *)0L} | |
538 #else | |
539 (char_u *)NULL, PV_NONE, | |
540 {(char_u *)0L, (char_u *)0L} | |
541 #endif | |
1883 | 542 SCRIPTID_INIT}, |
820 | 543 #ifdef FEAT_AUTOCHDIR |
7 | 544 {"autochdir", "acd", P_BOOL|P_VI_DEF, |
545 (char_u *)&p_acd, PV_NONE, | |
1883 | 546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 547 #endif |
548 {"autoindent", "ai", P_BOOL|P_VI_DEF, | |
549 (char_u *)&p_ai, PV_AI, | |
1883 | 550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 551 {"autoprint", "ap", P_BOOL|P_VI_DEF, |
552 (char_u *)NULL, PV_NONE, | |
1883 | 553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 554 {"autoread", "ar", P_BOOL|P_VI_DEF, |
692 | 555 (char_u *)&p_ar, PV_AR, |
1883 | 556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 557 {"autowrite", "aw", P_BOOL|P_VI_DEF, |
558 (char_u *)&p_aw, PV_NONE, | |
1883 | 559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 560 {"autowriteall","awa", P_BOOL|P_VI_DEF, |
561 (char_u *)&p_awa, PV_NONE, | |
1883 | 562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 563 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR, |
564 (char_u *)&p_bg, PV_NONE, | |
565 { | |
566 #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI) | |
567 (char_u *)"dark", | |
568 #else | |
569 (char_u *)"light", | |
570 #endif | |
1883 | 571 (char_u *)0L} SCRIPTID_INIT}, |
7 | 572 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP, |
573 (char_u *)&p_bs, PV_NONE, | |
1883 | 574 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 575 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, |
576 (char_u *)&p_bk, PV_NONE, | |
1883 | 577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 578 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP, |
579 (char_u *)&p_bkc, PV_NONE, | |
580 #ifdef UNIX | |
581 {(char_u *)"yes", (char_u *)"auto"} | |
582 #else | |
583 {(char_u *)"auto", (char_u *)"auto"} | |
584 #endif | |
1883 | 585 SCRIPTID_INIT}, |
7 | 586 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, |
587 (char_u *)&p_bdir, PV_NONE, | |
1883 | 588 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT}, |
36 | 589 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME, |
7 | 590 (char_u *)&p_bex, PV_NONE, |
591 { | |
592 #ifdef VMS | |
593 (char_u *)"_", | |
594 #else | |
595 (char_u *)"~", | |
596 #endif | |
1883 | 597 (char_u *)0L} SCRIPTID_INIT}, |
7 | 598 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA, |
599 #ifdef FEAT_WILDIGN | |
600 (char_u *)&p_bsk, PV_NONE, | |
601 {(char_u *)"", (char_u *)0L} | |
602 #else | |
603 (char_u *)NULL, PV_NONE, | |
604 {(char_u *)0L, (char_u *)0L} | |
605 #endif | |
1883 | 606 SCRIPTID_INIT}, |
7 | 607 #ifdef FEAT_BEVAL |
608 {"balloondelay","bdlay",P_NUM|P_VI_DEF, | |
609 (char_u *)&p_bdlay, PV_NONE, | |
1883 | 610 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 611 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC, |
612 (char_u *)&p_beval, PV_NONE, | |
1883 | 613 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
190 | 614 # ifdef FEAT_EVAL |
786 | 615 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, |
790 | 616 (char_u *)&p_bexpr, PV_BEXPR, |
1883 | 617 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
190 | 618 # endif |
7 | 619 #endif |
620 {"beautify", "bf", P_BOOL|P_VI_DEF, | |
621 (char_u *)NULL, PV_NONE, | |
1883 | 622 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 623 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, |
624 (char_u *)&p_bin, PV_BIN, | |
1883 | 625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 626 {"bioskey", "biosk",P_BOOL|P_VI_DEF, |
627 #ifdef MSDOS | |
628 (char_u *)&p_biosk, PV_NONE, | |
629 #else | |
630 (char_u *)NULL, PV_NONE, | |
631 #endif | |
1883 | 632 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 633 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
634 #ifdef FEAT_MBYTE | |
635 (char_u *)&p_bomb, PV_BOMB, | |
636 #else | |
637 (char_u *)NULL, PV_NONE, | |
638 #endif | |
1883 | 639 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 640 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, |
641 #ifdef FEAT_LINEBREAK | |
642 (char_u *)&p_breakat, PV_NONE, | |
643 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L} | |
644 #else | |
645 (char_u *)NULL, PV_NONE, | |
646 {(char_u *)0L, (char_u *)0L} | |
647 #endif | |
1883 | 648 SCRIPTID_INIT}, |
7 | 649 {"browsedir", "bsdir",P_STRING|P_VI_DEF, |
650 #ifdef FEAT_BROWSE | |
651 (char_u *)&p_bsdir, PV_NONE, | |
652 {(char_u *)"last", (char_u *)0L} | |
653 #else | |
654 (char_u *)NULL, PV_NONE, | |
655 {(char_u *)0L, (char_u *)0L} | |
656 #endif | |
1883 | 657 SCRIPTID_INIT}, |
7 | 658 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, |
659 #if defined(FEAT_QUICKFIX) | |
660 (char_u *)&p_bh, PV_BH, | |
661 {(char_u *)"", (char_u *)0L} | |
662 #else | |
663 (char_u *)NULL, PV_NONE, | |
664 {(char_u *)0L, (char_u *)0L} | |
665 #endif | |
1883 | 666 SCRIPTID_INIT}, |
7 | 667 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, |
668 (char_u *)&p_bl, PV_BL, | |
669 {(char_u *)1L, (char_u *)0L} | |
1883 | 670 SCRIPTID_INIT}, |
7 | 671 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, |
672 #if defined(FEAT_QUICKFIX) | |
673 (char_u *)&p_bt, PV_BT, | |
674 {(char_u *)"", (char_u *)0L} | |
675 #else | |
676 (char_u *)NULL, PV_NONE, | |
677 {(char_u *)0L, (char_u *)0L} | |
678 #endif | |
1883 | 679 SCRIPTID_INIT}, |
7 | 680 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
805 | 681 #ifdef FEAT_MBYTE |
7 | 682 (char_u *)&p_cmp, PV_NONE, |
683 {(char_u *)"internal,keepascii", (char_u *)0L} | |
805 | 684 #else |
685 (char_u *)NULL, PV_NONE, | |
686 {(char_u *)0L, (char_u *)0L} | |
687 #endif | |
1883 | 688 SCRIPTID_INIT}, |
7 | 689 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
690 #ifdef FEAT_SEARCHPATH | |
691 (char_u *)&p_cdpath, PV_NONE, | |
692 {(char_u *)",,", (char_u *)0L} | |
693 #else | |
694 (char_u *)NULL, PV_NONE, | |
695 {(char_u *)0L, (char_u *)0L} | |
696 #endif | |
1883 | 697 SCRIPTID_INIT}, |
7 | 698 {"cedit", NULL, P_STRING, |
699 #ifdef FEAT_CMDWIN | |
700 (char_u *)&p_cedit, PV_NONE, | |
701 {(char_u *)"", (char_u *)CTRL_F_STR} | |
702 #else | |
703 (char_u *)NULL, PV_NONE, | |
704 {(char_u *)0L, (char_u *)0L} | |
705 #endif | |
1883 | 706 SCRIPTID_INIT}, |
7 | 707 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE, |
708 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL) | |
709 (char_u *)&p_ccv, PV_NONE, | |
710 {(char_u *)"", (char_u *)0L} | |
711 #else | |
712 (char_u *)NULL, PV_NONE, | |
713 {(char_u *)0L, (char_u *)0L} | |
714 #endif | |
1883 | 715 SCRIPTID_INIT}, |
7 | 716 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM, |
717 #ifdef FEAT_CINDENT | |
718 (char_u *)&p_cin, PV_CIN, | |
719 #else | |
720 (char_u *)NULL, PV_NONE, | |
721 #endif | |
1883 | 722 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 723 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
724 #ifdef FEAT_CINDENT | |
725 (char_u *)&p_cink, PV_CINK, | |
726 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L} | |
727 #else | |
728 (char_u *)NULL, PV_NONE, | |
729 {(char_u *)0L, (char_u *)0L} | |
730 #endif | |
1883 | 731 SCRIPTID_INIT}, |
7 | 732 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
733 #ifdef FEAT_CINDENT | |
734 (char_u *)&p_cino, PV_CINO, | |
735 #else | |
736 (char_u *)NULL, PV_NONE, | |
737 #endif | |
1883 | 738 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 739 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
740 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
741 (char_u *)&p_cinw, PV_CINW, | |
742 {(char_u *)"if,else,while,do,for,switch", | |
743 (char_u *)0L} | |
744 #else | |
745 (char_u *)NULL, PV_NONE, | |
746 {(char_u *)0L, (char_u *)0L} | |
747 #endif | |
1883 | 748 SCRIPTID_INIT}, |
7 | 749 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
750 #ifdef FEAT_CLIPBOARD | |
751 (char_u *)&p_cb, PV_NONE, | |
752 # ifdef FEAT_XCLIPBOARD | |
753 {(char_u *)"autoselect,exclude:cons\\|linux", | |
754 (char_u *)0L} | |
755 # else | |
756 {(char_u *)"", (char_u *)0L} | |
757 # endif | |
758 #else | |
759 (char_u *)NULL, PV_NONE, | |
760 {(char_u *)"", (char_u *)0L} | |
761 #endif | |
1883 | 762 SCRIPTID_INIT}, |
7 | 763 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL, |
764 (char_u *)&p_ch, PV_NONE, | |
1883 | 765 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 766 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF, |
767 #ifdef FEAT_CMDWIN | |
768 (char_u *)&p_cwh, PV_NONE, | |
769 #else | |
770 (char_u *)NULL, PV_NONE, | |
771 #endif | |
1883 | 772 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT}, |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
773 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN, |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
774 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
775 (char_u *)VAR_WIN, PV_CC, |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
776 #else |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
777 (char_u *)NULL, PV_NONE, |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
778 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
779 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 780 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, |
781 (char_u *)&Columns, PV_NONE, | |
1883 | 782 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT}, |
3443 | 783 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT, |
7 | 784 #ifdef FEAT_COMMENTS |
785 (char_u *)&p_com, PV_COM, | |
786 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", | |
787 (char_u *)0L} | |
788 #else | |
789 (char_u *)NULL, PV_NONE, | |
790 {(char_u *)0L, (char_u *)0L} | |
791 #endif | |
1883 | 792 SCRIPTID_INIT}, |
3443 | 793 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, |
7 | 794 #ifdef FEAT_FOLDING |
795 (char_u *)&p_cms, PV_CMS, | |
796 {(char_u *)"/*%s*/", (char_u *)0L} | |
797 #else | |
798 (char_u *)NULL, PV_NONE, | |
799 {(char_u *)0L, (char_u *)0L} | |
800 #endif | |
1883 | 801 SCRIPTID_INIT}, |
1384 | 802 /* P_PRI_MKRC isn't needed here, optval_default() |
803 * always returns TRUE for 'compatible' */ | |
7 | 804 {"compatible", "cp", P_BOOL|P_RALL, |
805 (char_u *)&p_cp, PV_NONE, | |
1883 | 806 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT}, |
7 | 807 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
808 #ifdef FEAT_INS_EXPAND | |
809 (char_u *)&p_cpt, PV_CPT, | |
810 {(char_u *)".,w,b,u,t,i", (char_u *)0L} | |
811 #else | |
812 (char_u *)NULL, PV_NONE, | |
813 {(char_u *)0L, (char_u *)0L} | |
814 #endif | |
1883 | 815 SCRIPTID_INIT}, |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
816 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
817 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
818 (char_u *)VAR_WIN, PV_COCU, |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
819 {(char_u *)"", (char_u *)NULL} |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
820 #else |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
821 (char_u *)NULL, PV_NONE, |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
822 {(char_u *)NULL, (char_u *)0L} |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
823 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
824 SCRIPTID_INIT}, |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
825 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF, |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
826 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
827 (char_u *)VAR_WIN, PV_COLE, |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
828 #else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
829 (char_u *)NULL, PV_NONE, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
830 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
831 {(char_u *)0L, (char_u *)0L} |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
832 SCRIPTID_INIT}, |
12 | 833 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, |
834 #ifdef FEAT_COMPL_FUNC | |
835 (char_u *)&p_cfu, PV_CFU, | |
836 {(char_u *)"", (char_u *)0L} | |
837 #else | |
838 (char_u *)NULL, PV_NONE, | |
839 {(char_u *)0L, (char_u *)0L} | |
840 #endif | |
1883 | 841 SCRIPTID_INIT}, |
540 | 842 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
843 #ifdef FEAT_INS_EXPAND | |
844 (char_u *)&p_cot, PV_NONE, | |
731 | 845 {(char_u *)"menu,preview", (char_u *)0L} |
540 | 846 #else |
847 (char_u *)NULL, PV_NONE, | |
848 {(char_u *)0L, (char_u *)0L} | |
849 #endif | |
1883 | 850 SCRIPTID_INIT}, |
7 | 851 {"confirm", "cf", P_BOOL|P_VI_DEF, |
852 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
853 (char_u *)&p_confirm, PV_NONE, | |
854 #else | |
855 (char_u *)NULL, PV_NONE, | |
856 #endif | |
1883 | 857 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 858 {"conskey", "consk",P_BOOL|P_VI_DEF, |
859 #ifdef MSDOS | |
860 (char_u *)&p_consk, PV_NONE, | |
861 #else | |
862 (char_u *)NULL, PV_NONE, | |
863 #endif | |
1883 | 864 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 865 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM, |
866 (char_u *)&p_ci, PV_CI, | |
1883 | 867 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 868 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST, |
869 (char_u *)&p_cpo, PV_NONE, | |
1883 | 870 {(char_u *)CPO_VI, (char_u *)CPO_VIM} |
871 SCRIPTID_INIT}, | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
872 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF, |
2184
5028c4d6d825
Fixed encryption big/little endian test.
Bram Moolenaar <bram@vim.org>
parents:
2180
diff
changeset
|
873 #ifdef FEAT_CRYPT |
2180
f60a0c9cbe6c
Add the blowfish encryption patch from Mohsin Ahmed. Needs more work.
Bram Moolenaar <bram@vim.org>
parents:
2178
diff
changeset
|
874 (char_u *)&p_cm, PV_CM, |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
875 {(char_u *)"zip", (char_u *)0L} |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
876 #else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
877 (char_u *)NULL, PV_NONE, |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
878 {(char_u *)0L, (char_u *)0L} |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
879 #endif |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
880 SCRIPTID_INIT}, |
7 | 881 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM, |
882 #ifdef FEAT_CSCOPE | |
883 (char_u *)&p_cspc, PV_NONE, | |
884 #else | |
885 (char_u *)NULL, PV_NONE, | |
886 #endif | |
1883 | 887 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 888 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
889 #ifdef FEAT_CSCOPE | |
890 (char_u *)&p_csprg, PV_NONE, | |
891 {(char_u *)"cscope", (char_u *)0L} | |
892 #else | |
893 (char_u *)NULL, PV_NONE, | |
894 {(char_u *)0L, (char_u *)0L} | |
895 #endif | |
1883 | 896 SCRIPTID_INIT}, |
7 | 897 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
898 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) | |
899 (char_u *)&p_csqf, PV_NONE, | |
900 {(char_u *)"", (char_u *)0L} | |
901 #else | |
902 (char_u *)NULL, PV_NONE, | |
903 {(char_u *)0L, (char_u *)0L} | |
904 #endif | |
1883 | 905 SCRIPTID_INIT}, |
2883 | 906 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM, |
907 #ifdef FEAT_CSCOPE | |
908 (char_u *)&p_csre, PV_NONE, | |
909 #else | |
910 (char_u *)NULL, PV_NONE, | |
911 #endif | |
912 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, | |
7 | 913 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM, |
914 #ifdef FEAT_CSCOPE | |
915 (char_u *)&p_cst, PV_NONE, | |
916 #else | |
917 (char_u *)NULL, PV_NONE, | |
918 #endif | |
1883 | 919 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 920 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM, |
921 #ifdef FEAT_CSCOPE | |
922 (char_u *)&p_csto, PV_NONE, | |
923 #else | |
924 (char_u *)NULL, PV_NONE, | |
925 #endif | |
1883 | 926 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 927 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM, |
928 #ifdef FEAT_CSCOPE | |
929 (char_u *)&p_csverbose, PV_NONE, | |
930 #else | |
931 (char_u *)NULL, PV_NONE, | |
932 #endif | |
1883 | 933 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
934 {"cursorbind", "crb", P_BOOL|P_VI_DEF, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
935 #ifdef FEAT_CURSORBIND |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
936 (char_u *)VAR_WIN, PV_CRBIND, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
937 #else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
938 (char_u *)NULL, PV_NONE, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
939 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
744 | 941 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN, |
942 #ifdef FEAT_SYN_HL | |
943 (char_u *)VAR_WIN, PV_CUC, | |
944 #else | |
945 (char_u *)NULL, PV_NONE, | |
946 #endif | |
1883 | 947 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
744 | 948 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN, |
949 #ifdef FEAT_SYN_HL | |
950 (char_u *)VAR_WIN, PV_CUL, | |
951 #else | |
952 (char_u *)NULL, PV_NONE, | |
953 #endif | |
1883 | 954 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 955 {"debug", NULL, P_STRING|P_VI_DEF, |
956 (char_u *)&p_debug, PV_NONE, | |
1883 | 957 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
3443 | 958 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, |
7 | 959 #ifdef FEAT_FIND_ID |
694 | 960 (char_u *)&p_def, PV_DEF, |
22 | 961 {(char_u *)"^\\s*#\\s*define", (char_u *)0L} |
7 | 962 #else |
963 (char_u *)NULL, PV_NONE, | |
964 {(char_u *)NULL, (char_u *)0L} | |
965 #endif | |
1883 | 966 SCRIPTID_INIT}, |
7 | 967 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM, |
968 #ifdef FEAT_MBYTE | |
969 (char_u *)&p_deco, PV_NONE, | |
970 #else | |
971 (char_u *)NULL, PV_NONE, | |
972 #endif | |
1883 | 973 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 974 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
975 #ifdef FEAT_INS_EXPAND | |
694 | 976 (char_u *)&p_dict, PV_DICT, |
7 | 977 #else |
978 (char_u *)NULL, PV_NONE, | |
979 #endif | |
1883 | 980 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 981 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB, |
982 #ifdef FEAT_DIFF | |
983 (char_u *)VAR_WIN, PV_DIFF, | |
984 #else | |
985 (char_u *)NULL, PV_NONE, | |
986 #endif | |
1883 | 987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
3443 | 988 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT, |
7 | 989 #if defined(FEAT_DIFF) && defined(FEAT_EVAL) |
990 (char_u *)&p_dex, PV_NONE, | |
991 {(char_u *)"", (char_u *)0L} | |
992 #else | |
993 (char_u *)NULL, PV_NONE, | |
994 {(char_u *)0L, (char_u *)0L} | |
995 #endif | |
1883 | 996 SCRIPTID_INIT}, |
7 | 997 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP, |
998 #ifdef FEAT_DIFF | |
999 (char_u *)&p_dip, PV_NONE, | |
1000 {(char_u *)"filler", (char_u *)NULL} | |
1001 #else | |
1002 (char_u *)NULL, PV_NONE, | |
1003 {(char_u *)"", (char_u *)NULL} | |
1004 #endif | |
1883 | 1005 SCRIPTID_INIT}, |
7 | 1006 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM, |
1007 #ifdef FEAT_DIGRAPHS | |
1008 (char_u *)&p_dg, PV_NONE, | |
1009 #else | |
1010 (char_u *)NULL, PV_NONE, | |
1011 #endif | |
1883 | 1012 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1013 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, |
1014 (char_u *)&p_dir, PV_NONE, | |
1883 | 1015 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1016 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP, |
1017 (char_u *)&p_dy, PV_NONE, | |
1883 | 1018 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1019 {"eadirection", "ead", P_STRING|P_VI_DEF, |
1020 #ifdef FEAT_VERTSPLIT | |
1021 (char_u *)&p_ead, PV_NONE, | |
1022 {(char_u *)"both", (char_u *)0L} | |
1023 #else | |
1024 (char_u *)NULL, PV_NONE, | |
1025 {(char_u *)NULL, (char_u *)0L} | |
1026 #endif | |
1883 | 1027 SCRIPTID_INIT}, |
7 | 1028 {"edcompatible","ed", P_BOOL|P_VI_DEF, |
1029 (char_u *)&p_ed, PV_NONE, | |
1883 | 1030 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1031 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML, |
7 | 1032 #ifdef FEAT_MBYTE |
1033 (char_u *)&p_enc, PV_NONE, | |
1034 {(char_u *)ENC_DFLT, (char_u *)0L} | |
1035 #else | |
1036 (char_u *)NULL, PV_NONE, | |
1037 {(char_u *)0L, (char_u *)0L} | |
1038 #endif | |
1883 | 1039 SCRIPTID_INIT}, |
7 | 1040 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
1041 (char_u *)&p_eol, PV_EOL, | |
1883 | 1042 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1043 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL, |
1044 (char_u *)&p_ea, PV_NONE, | |
1883 | 1045 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1046 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
694 | 1047 (char_u *)&p_ep, PV_EP, |
1883 | 1048 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1049 {"errorbells", "eb", P_BOOL|P_VI_DEF, |
1050 (char_u *)&p_eb, PV_NONE, | |
1883 | 1051 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1052 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
1053 #ifdef FEAT_QUICKFIX | |
1054 (char_u *)&p_ef, PV_NONE, | |
1055 {(char_u *)DFLT_ERRORFILE, (char_u *)0L} | |
1056 #else | |
1057 (char_u *)NULL, PV_NONE, | |
1058 {(char_u *)NULL, (char_u *)0L} | |
1059 #endif | |
1883 | 1060 SCRIPTID_INIT}, |
7 | 1061 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1062 #ifdef FEAT_QUICKFIX | |
694 | 1063 (char_u *)&p_efm, PV_EFM, |
1883 | 1064 {(char_u *)DFLT_EFM, (char_u *)0L} |
7 | 1065 #else |
1066 (char_u *)NULL, PV_NONE, | |
1067 {(char_u *)NULL, (char_u *)0L} | |
1068 #endif | |
1883 | 1069 SCRIPTID_INIT}, |
7 | 1070 {"esckeys", "ek", P_BOOL|P_VIM, |
1071 (char_u *)&p_ek, PV_NONE, | |
1883 | 1072 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, |
7 | 1073 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1074 #ifdef FEAT_AUTOCMD | |
1075 (char_u *)&p_ei, PV_NONE, | |
1076 #else | |
1077 (char_u *)NULL, PV_NONE, | |
1078 #endif | |
1883 | 1079 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1080 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM, |
1081 (char_u *)&p_et, PV_ET, | |
1883 | 1082 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1083 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE, |
1084 (char_u *)&p_exrc, PV_NONE, | |
1883 | 1085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1086 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC, |
1087 #ifdef FEAT_MBYTE | |
1088 (char_u *)&p_fenc, PV_FENC, | |
1089 {(char_u *)"", (char_u *)0L} | |
1090 #else | |
1091 (char_u *)NULL, PV_NONE, | |
1092 {(char_u *)0L, (char_u *)0L} | |
1093 #endif | |
1883 | 1094 SCRIPTID_INIT}, |
7 | 1095 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA, |
1096 #ifdef FEAT_MBYTE | |
1097 (char_u *)&p_fencs, PV_NONE, | |
1098 {(char_u *)"ucs-bom", (char_u *)0L} | |
1099 #else | |
1100 (char_u *)NULL, PV_NONE, | |
1101 {(char_u *)0L, (char_u *)0L} | |
1102 #endif | |
1883 | 1103 SCRIPTID_INIT}, |
3443 | 1104 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC|P_CURSWANT, |
7 | 1105 (char_u *)&p_ff, PV_FF, |
1883 | 1106 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1107 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP, |
1108 (char_u *)&p_ffs, PV_NONE, | |
1883 | 1109 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM} |
1110 SCRIPTID_INIT}, | |
4242 | 1111 {"fileignorecase", "fic", P_BOOL|P_VI_DEF, |
1112 (char_u *)&p_fic, PV_NONE, | |
1113 { | |
1114 #ifdef CASE_INSENSITIVE_FILENAME | |
1115 (char_u *)TRUE, | |
1116 #else | |
1117 (char_u *)FALSE, | |
1118 #endif | |
1119 (char_u *)0L} SCRIPTID_INIT}, | |
36 | 1120 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, |
7 | 1121 #ifdef FEAT_AUTOCMD |
1122 (char_u *)&p_ft, PV_FT, | |
1123 {(char_u *)"", (char_u *)0L} | |
1124 #else | |
1125 (char_u *)NULL, PV_NONE, | |
1126 {(char_u *)0L, (char_u *)0L} | |
1127 #endif | |
1883 | 1128 SCRIPTID_INIT}, |
7 | 1129 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
1130 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
1131 (char_u *)&p_fcs, PV_NONE, | |
1132 {(char_u *)"vert:|,fold:-", (char_u *)0L} | |
1133 #else | |
1134 (char_u *)NULL, PV_NONE, | |
1135 {(char_u *)"", (char_u *)0L} | |
1136 #endif | |
1883 | 1137 SCRIPTID_INIT}, |
7 | 1138 {"fkmap", "fk", P_BOOL|P_VI_DEF, |
1139 #ifdef FEAT_FKMAP | |
1140 (char_u *)&p_fkmap, PV_NONE, | |
1141 #else | |
1142 (char_u *)NULL, PV_NONE, | |
1143 #endif | |
1883 | 1144 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1145 {"flash", "fl", P_BOOL|P_VI_DEF, |
1146 (char_u *)NULL, PV_NONE, | |
1883 | 1147 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1148 #ifdef FEAT_FOLDING |
1149 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN, | |
1150 (char_u *)&p_fcl, PV_NONE, | |
1883 | 1151 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1152 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN, |
1153 (char_u *)VAR_WIN, PV_FDC, | |
1883 | 1154 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1155 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN, |
1156 (char_u *)VAR_WIN, PV_FEN, | |
1883 | 1157 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1158 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
1159 # ifdef FEAT_EVAL | |
1160 (char_u *)VAR_WIN, PV_FDE, | |
1161 {(char_u *)"0", (char_u *)NULL} | |
1162 # else | |
1163 (char_u *)NULL, PV_NONE, | |
1164 {(char_u *)NULL, (char_u *)0L} | |
1165 # endif | |
1883 | 1166 SCRIPTID_INIT}, |
7 | 1167 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
1168 (char_u *)VAR_WIN, PV_FDI, | |
1883 | 1169 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT}, |
7 | 1170 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN, |
1171 (char_u *)VAR_WIN, PV_FDL, | |
1883 | 1172 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
3443 | 1173 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT, |
7 | 1174 (char_u *)&p_fdls, PV_NONE, |
1883 | 1175 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1176 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF| |
1177 P_RWIN|P_COMMA|P_NODUP, | |
1178 (char_u *)VAR_WIN, PV_FMR, | |
1883 | 1179 {(char_u *)"{{{,}}}", (char_u *)NULL} |
1180 SCRIPTID_INIT}, | |
7 | 1181 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
1182 (char_u *)VAR_WIN, PV_FDM, | |
1883 | 1183 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT}, |
7 | 1184 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN, |
1185 (char_u *)VAR_WIN, PV_FML, | |
1883 | 1186 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1187 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN, |
1188 (char_u *)VAR_WIN, PV_FDN, | |
1883 | 1189 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, |
3443 | 1190 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT, |
7 | 1191 (char_u *)&p_fdo, PV_NONE, |
1192 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", | |
1883 | 1193 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1194 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
1195 # ifdef FEAT_EVAL | |
1196 (char_u *)VAR_WIN, PV_FDT, | |
1197 {(char_u *)"foldtext()", (char_u *)NULL} | |
29 | 1198 # else |
7 | 1199 (char_u *)NULL, PV_NONE, |
1200 {(char_u *)NULL, (char_u *)0L} | |
29 | 1201 # endif |
1883 | 1202 SCRIPTID_INIT}, |
7 | 1203 #endif |
667 | 1204 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, |
694 | 1205 #ifdef FEAT_EVAL |
667 | 1206 (char_u *)&p_fex, PV_FEX, |
1207 {(char_u *)"", (char_u *)0L} | |
1208 #else | |
1209 (char_u *)NULL, PV_NONE, | |
1210 {(char_u *)0L, (char_u *)0L} | |
1211 #endif | |
1883 | 1212 SCRIPTID_INIT}, |
7 | 1213 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST, |
1214 (char_u *)&p_fo, PV_FO, | |
1883 | 1215 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM} |
1216 SCRIPTID_INIT}, | |
41 | 1217 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF, |
1218 (char_u *)&p_flp, PV_FLP, | |
1883 | 1219 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", |
1220 (char_u *)0L} SCRIPTID_INIT}, | |
7 | 1221 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
1222 (char_u *)&p_fp, PV_NONE, | |
1883 | 1223 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
36 | 1224 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, |
1225 #ifdef HAVE_FSYNC | |
1226 (char_u *)&p_fs, PV_NONE, | |
1227 {(char_u *)TRUE, (char_u *)0L} | |
1228 #else | |
1229 (char_u *)NULL, PV_NONE, | |
1230 {(char_u *)FALSE, (char_u *)0L} | |
1231 #endif | |
1883 | 1232 SCRIPTID_INIT}, |
7 | 1233 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM, |
1234 (char_u *)&p_gd, PV_NONE, | |
1883 | 1235 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1236 {"graphic", "gr", P_BOOL|P_VI_DEF, |
1237 (char_u *)NULL, PV_NONE, | |
1883 | 1238 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1239 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1240 #ifdef FEAT_QUICKFIX | |
1241 (char_u *)&p_gefm, PV_NONE, | |
1883 | 1242 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L} |
7 | 1243 #else |
1244 (char_u *)NULL, PV_NONE, | |
1245 {(char_u *)NULL, (char_u *)0L} | |
1246 #endif | |
1883 | 1247 SCRIPTID_INIT}, |
7 | 1248 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
1249 #ifdef FEAT_QUICKFIX | |
694 | 1250 (char_u *)&p_gp, PV_GP, |
7 | 1251 { |
1252 # ifdef WIN3264 | |
1253 /* may be changed to "grep -n" in os_win32.c */ | |
1254 (char_u *)"findstr /n", | |
1255 # else | |
1256 # ifdef UNIX | |
1257 /* Add an extra file name so that grep will always | |
1258 * insert a file name in the match line. */ | |
1259 (char_u *)"grep -n $* /dev/null", | |
1260 # else | |
1261 # ifdef VMS | |
1262 (char_u *)"SEARCH/NUMBERS ", | |
1263 # else | |
1264 (char_u *)"grep -n ", | |
1883 | 1265 # endif |
1266 # endif | |
7 | 1267 # endif |
1883 | 1268 (char_u *)0L} |
7 | 1269 #else |
1270 (char_u *)NULL, PV_NONE, | |
1271 {(char_u *)NULL, (char_u *)0L} | |
1272 #endif | |
1883 | 1273 SCRIPTID_INIT}, |
7 | 1274 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1275 #ifdef CURSOR_SHAPE | |
1276 (char_u *)&p_guicursor, PV_NONE, | |
1277 { | |
1278 # ifdef FEAT_GUI | |
1279 (char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175", | |
1280 # else /* MSDOS or Win32 console */ | |
1281 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block", | |
1282 # endif | |
1283 (char_u *)0L} | |
1284 #else | |
1285 (char_u *)NULL, PV_NONE, | |
1286 {(char_u *)NULL, (char_u *)0L} | |
1287 #endif | |
1883 | 1288 SCRIPTID_INIT}, |
7 | 1289 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
1290 #ifdef FEAT_GUI | |
1291 (char_u *)&p_guifont, PV_NONE, | |
1292 {(char_u *)"", (char_u *)0L} | |
1293 #else | |
1294 (char_u *)NULL, PV_NONE, | |
1295 {(char_u *)NULL, (char_u *)0L} | |
1296 #endif | |
1883 | 1297 SCRIPTID_INIT}, |
7 | 1298 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA, |
1299 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET) | |
1300 (char_u *)&p_guifontset, PV_NONE, | |
1301 {(char_u *)"", (char_u *)0L} | |
1302 #else | |
1303 (char_u *)NULL, PV_NONE, | |
1304 {(char_u *)NULL, (char_u *)0L} | |
1305 #endif | |
1883 | 1306 SCRIPTID_INIT}, |
7 | 1307 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
1308 #if defined(FEAT_GUI) && defined(FEAT_MBYTE) | |
1309 (char_u *)&p_guifontwide, PV_NONE, | |
1310 {(char_u *)"", (char_u *)0L} | |
1311 #else | |
1312 (char_u *)NULL, PV_NONE, | |
1313 {(char_u *)NULL, (char_u *)0L} | |
1314 #endif | |
1883 | 1315 SCRIPTID_INIT}, |
7 | 1316 {"guiheadroom", "ghr", P_NUM|P_VI_DEF, |
574 | 1317 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) |
7 | 1318 (char_u *)&p_ghr, PV_NONE, |
1319 #else | |
1320 (char_u *)NULL, PV_NONE, | |
1321 #endif | |
1883 | 1322 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1323 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, |
574 | 1324 #if defined(FEAT_GUI) |
7 | 1325 (char_u *)&p_go, PV_NONE, |
1326 # if defined(UNIX) && !defined(MACOS) | |
685 | 1327 {(char_u *)"aegimrLtT", (char_u *)0L} |
7 | 1328 # else |
685 | 1329 {(char_u *)"egmrLtT", (char_u *)0L} |
7 | 1330 # endif |
1331 #else | |
1332 (char_u *)NULL, PV_NONE, | |
1333 {(char_u *)NULL, (char_u *)0L} | |
1334 #endif | |
1883 | 1335 SCRIPTID_INIT}, |
7 | 1336 {"guipty", NULL, P_BOOL|P_VI_DEF, |
1337 #if defined(FEAT_GUI) | |
1338 (char_u *)&p_guipty, PV_NONE, | |
1339 #else | |
1340 (char_u *)NULL, PV_NONE, | |
1341 #endif | |
1883 | 1342 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
827 | 1343 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN, |
688 | 1344 #if defined(FEAT_GUI_TABLINE) |
1345 (char_u *)&p_gtl, PV_NONE, | |
1346 {(char_u *)"", (char_u *)0L} | |
1347 #else | |
1348 (char_u *)NULL, PV_NONE, | |
1349 {(char_u *)NULL, (char_u *)0L} | |
1350 #endif | |
1883 | 1351 SCRIPTID_INIT}, |
842 | 1352 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN, |
839 | 1353 #if defined(FEAT_GUI_TABLINE) |
1354 (char_u *)&p_gtt, PV_NONE, | |
1355 {(char_u *)"", (char_u *)0L} | |
1356 #else | |
1357 (char_u *)NULL, PV_NONE, | |
1358 {(char_u *)NULL, (char_u *)0L} | |
1359 #endif | |
1883 | 1360 SCRIPTID_INIT}, |
7 | 1361 {"hardtabs", "ht", P_NUM|P_VI_DEF, |
1362 (char_u *)NULL, PV_NONE, | |
1883 | 1363 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1364 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
1365 (char_u *)&p_hf, PV_NONE, | |
1883 | 1366 {(char_u *)DFLT_HELPFILE, (char_u *)0L} |
1367 SCRIPTID_INIT}, | |
7 | 1368 {"helpheight", "hh", P_NUM|P_VI_DEF, |
1369 #ifdef FEAT_WINDOWS | |
1370 (char_u *)&p_hh, PV_NONE, | |
1371 #else | |
1372 (char_u *)NULL, PV_NONE, | |
1373 #endif | |
1883 | 1374 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1375 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA, |
1376 #ifdef FEAT_MULTI_LANG | |
1377 (char_u *)&p_hlg, PV_NONE, | |
1378 {(char_u *)"", (char_u *)0L} | |
1379 #else | |
1380 (char_u *)NULL, PV_NONE, | |
1381 {(char_u *)0L, (char_u *)0L} | |
1382 #endif | |
1883 | 1383 SCRIPTID_INIT}, |
7 | 1384 {"hidden", "hid", P_BOOL|P_VI_DEF, |
1385 (char_u *)&p_hid, PV_NONE, | |
1883 | 1386 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1387 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
1388 (char_u *)&p_hl, PV_NONE, | |
1883 | 1389 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L} |
1390 SCRIPTID_INIT}, | |
7 | 1391 {"history", "hi", P_NUM|P_VIM, |
1392 (char_u *)&p_hi, PV_NONE, | |
1883 | 1393 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT}, |
7 | 1394 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM, |
1395 #ifdef FEAT_RIGHTLEFT | |
1396 (char_u *)&p_hkmap, PV_NONE, | |
1397 #else | |
1398 (char_u *)NULL, PV_NONE, | |
1399 #endif | |
1883 | 1400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1401 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM, |
1402 #ifdef FEAT_RIGHTLEFT | |
1403 (char_u *)&p_hkmapp, PV_NONE, | |
1404 #else | |
1405 (char_u *)NULL, PV_NONE, | |
1406 #endif | |
1883 | 1407 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1408 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL, |
1409 (char_u *)&p_hls, PV_NONE, | |
1883 | 1410 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1411 {"icon", NULL, P_BOOL|P_VI_DEF, |
1412 #ifdef FEAT_TITLE | |
1413 (char_u *)&p_icon, PV_NONE, | |
1414 #else | |
1415 (char_u *)NULL, PV_NONE, | |
1416 #endif | |
1883 | 1417 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1418 {"iconstring", NULL, P_STRING|P_VI_DEF, |
1419 #ifdef FEAT_TITLE | |
1420 (char_u *)&p_iconstring, PV_NONE, | |
1421 #else | |
1422 (char_u *)NULL, PV_NONE, | |
1423 #endif | |
1883 | 1424 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1425 {"ignorecase", "ic", P_BOOL|P_VI_DEF, |
1426 (char_u *)&p_ic, PV_NONE, | |
1883 | 1427 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1428 {"imactivatekey","imak",P_STRING|P_VI_DEF, |
574 | 1429 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
7 | 1430 (char_u *)&p_imak, PV_NONE, |
1431 #else | |
1432 (char_u *)NULL, PV_NONE, | |
1433 #endif | |
1883 | 1434 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1435 {"imcmdline", "imc", P_BOOL|P_VI_DEF, |
1436 #ifdef USE_IM_CONTROL | |
1437 (char_u *)&p_imcmdline, PV_NONE, | |
1438 #else | |
1439 (char_u *)NULL, PV_NONE, | |
1440 #endif | |
1883 | 1441 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1442 {"imdisable", "imd", P_BOOL|P_VI_DEF, |
1443 #ifdef USE_IM_CONTROL | |
1444 (char_u *)&p_imdisable, PV_NONE, | |
1445 #else | |
1446 (char_u *)NULL, PV_NONE, | |
1447 #endif | |
1448 #ifdef __sgi | |
1449 {(char_u *)TRUE, (char_u *)0L} | |
1450 #else | |
1451 {(char_u *)FALSE, (char_u *)0L} | |
1452 #endif | |
1883 | 1453 SCRIPTID_INIT}, |
7 | 1454 {"iminsert", "imi", P_NUM|P_VI_DEF, |
1455 (char_u *)&p_iminsert, PV_IMI, | |
1456 #ifdef B_IMODE_IM | |
1457 {(char_u *)B_IMODE_IM, (char_u *)0L} | |
1458 #else | |
1459 {(char_u *)B_IMODE_NONE, (char_u *)0L} | |
1460 #endif | |
1883 | 1461 SCRIPTID_INIT}, |
7 | 1462 {"imsearch", "ims", P_NUM|P_VI_DEF, |
1463 (char_u *)&p_imsearch, PV_IMS, | |
1464 #ifdef B_IMODE_IM | |
1465 {(char_u *)B_IMODE_IM, (char_u *)0L} | |
1466 #else | |
1467 {(char_u *)B_IMODE_NONE, (char_u *)0L} | |
1468 #endif | |
1883 | 1469 SCRIPTID_INIT}, |
7 | 1470 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF, |
1471 #ifdef FEAT_FIND_ID | |
694 | 1472 (char_u *)&p_inc, PV_INC, |
7 | 1473 {(char_u *)"^\\s*#\\s*include", (char_u *)0L} |
1474 #else | |
1475 (char_u *)NULL, PV_NONE, | |
1476 {(char_u *)0L, (char_u *)0L} | |
1477 #endif | |
1883 | 1478 SCRIPTID_INIT}, |
7 | 1479 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF, |
1480 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) | |
1481 (char_u *)&p_inex, PV_INEX, | |
1482 {(char_u *)"", (char_u *)0L} | |
1483 #else | |
1484 (char_u *)NULL, PV_NONE, | |
1485 {(char_u *)0L, (char_u *)0L} | |
1486 #endif | |
1883 | 1487 SCRIPTID_INIT}, |
7 | 1488 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM, |
1489 (char_u *)&p_is, PV_NONE, | |
1883 | 1490 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1491 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, |
1492 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
1493 (char_u *)&p_inde, PV_INDE, | |
1494 {(char_u *)"", (char_u *)0L} | |
1495 #else | |
1496 (char_u *)NULL, PV_NONE, | |
1497 {(char_u *)0L, (char_u *)0L} | |
1498 #endif | |
1883 | 1499 SCRIPTID_INIT}, |
7 | 1500 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
1501 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
1502 (char_u *)&p_indk, PV_INDK, | |
1503 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L} | |
1504 #else | |
1505 (char_u *)NULL, PV_NONE, | |
1506 {(char_u *)0L, (char_u *)0L} | |
1507 #endif | |
1883 | 1508 SCRIPTID_INIT}, |
7 | 1509 {"infercase", "inf", P_BOOL|P_VI_DEF, |
1510 (char_u *)&p_inf, PV_INF, | |
1883 | 1511 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1512 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM, |
1513 (char_u *)&p_im, PV_NONE, | |
1883 | 1514 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1515 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1516 (char_u *)&p_isf, PV_NONE, | |
1517 { | |
1518 #ifdef BACKSLASH_IN_FILENAME | |
1519 /* Excluded are: & and ^ are special in cmd.exe | |
1520 * ( and ) are used in text separating fnames */ | |
1521 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=", | |
1522 #else | |
1523 # ifdef AMIGA | |
1524 (char_u *)"@,48-57,/,.,-,_,+,,,$,:", | |
1525 # else | |
1526 # ifdef VMS | |
1527 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~", | |
1528 # else /* UNIX et al. */ | |
1529 # ifdef EBCDIC | |
1530 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=", | |
1531 # else | |
1532 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=", | |
1533 # endif | |
1534 # endif | |
1535 # endif | |
1536 #endif | |
1883 | 1537 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1538 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1539 (char_u *)&p_isi, PV_NONE, | |
1540 { | |
1541 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) | |
1542 (char_u *)"@,48-57,_,128-167,224-235", | |
1543 #else | |
1544 # ifdef EBCDIC | |
1545 /* TODO: EBCDIC Check this! @ == isalpha()*/ | |
1546 (char_u *)"@,240-249,_,66-73,81-89,98-105," | |
1547 "112-120,128,140-142,156,158,172," | |
1548 "174,186,191,203-207,219-225,235-239," | |
1549 "251-254", | |
1550 # else | |
1551 (char_u *)"@,48-57,_,192-255", | |
1552 # endif | |
1553 #endif | |
1883 | 1554 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1555 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP, |
1556 (char_u *)&p_isk, PV_ISK, | |
1557 { | |
1558 #ifdef EBCDIC | |
1559 (char_u *)"@,240-249,_", | |
1560 /* TODO: EBCDIC Check this! @ == isalpha()*/ | |
1561 (char_u *)"@,240-249,_,66-73,81-89,98-105," | |
1562 "112-120,128,140-142,156,158,172," | |
1563 "174,186,191,203-207,219-225,235-239," | |
1564 "251-254", | |
1565 #else | |
1566 (char_u *)"@,48-57,_", | |
1567 # if defined(MSDOS) || defined(MSWIN) || defined(OS2) | |
1568 (char_u *)"@,48-57,_,128-167,224-235" | |
1569 # else | |
714 | 1570 ISK_LATIN1 |
7 | 1571 # endif |
1572 #endif | |
1883 | 1573 } SCRIPTID_INIT}, |
7 | 1574 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
1575 (char_u *)&p_isp, PV_NONE, | |
1576 { | |
36 | 1577 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \ |
1578 || (defined(MACOS) && !defined(MACOS_X)) \ | |
7 | 1579 || defined(VMS) |
1580 (char_u *)"@,~-255", | |
1581 #else | |
1582 # ifdef EBCDIC | |
1583 /* all chars above 63 are printable */ | |
1584 (char_u *)"63-255", | |
1585 # else | |
719 | 1586 ISP_LATIN1, |
7 | 1587 # endif |
1588 #endif | |
1883 | 1589 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1590 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM, |
1591 (char_u *)&p_js, PV_NONE, | |
1883 | 1592 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1593 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC, |
1594 #ifdef FEAT_CRYPT | |
1595 (char_u *)&p_key, PV_KEY, | |
1596 {(char_u *)"", (char_u *)0L} | |
1597 #else | |
1598 (char_u *)NULL, PV_NONE, | |
1599 {(char_u *)0L, (char_u *)0L} | |
1600 #endif | |
1883 | 1601 SCRIPTID_INIT}, |
1384 | 1602 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC, |
7 | 1603 #ifdef FEAT_KEYMAP |
1604 (char_u *)&p_keymap, PV_KMAP, | |
1605 {(char_u *)"", (char_u *)0L} | |
1606 #else | |
1607 (char_u *)NULL, PV_NONE, | |
1608 {(char_u *)"", (char_u *)0L} | |
1609 #endif | |
1883 | 1610 SCRIPTID_INIT}, |
7 | 1611 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1612 #ifdef FEAT_VISUAL | |
1613 (char_u *)&p_km, PV_NONE, | |
1614 #else | |
1615 (char_u *)NULL, PV_NONE, | |
1616 #endif | |
1883 | 1617 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1618 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
694 | 1619 (char_u *)&p_kp, PV_KP, |
7 | 1620 { |
1621 #if defined(MSDOS) || defined(MSWIN) | |
1622 (char_u *)":help", | |
1623 #else | |
1624 #ifdef VMS | |
1625 (char_u *)"help", | |
1626 #else | |
1627 # if defined(OS2) | |
1628 (char_u *)"view /", | |
1629 # else | |
1630 # ifdef USEMAN_S | |
1631 (char_u *)"man -s", | |
1632 # else | |
1633 (char_u *)"man", | |
1634 # endif | |
1635 # endif | |
1636 #endif | |
1637 #endif | |
1883 | 1638 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1639 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1640 #ifdef FEAT_LANGMAP | |
1641 (char_u *)&p_langmap, PV_NONE, | |
1642 {(char_u *)"", /* unmatched } */ | |
1643 #else | |
1644 (char_u *)NULL, PV_NONE, | |
1645 {(char_u *)NULL, | |
1646 #endif | |
1883 | 1647 (char_u *)0L} SCRIPTID_INIT}, |
36 | 1648 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, |
7 | 1649 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) |
1650 (char_u *)&p_lm, PV_NONE, | |
1651 #else | |
1652 (char_u *)NULL, PV_NONE, | |
1653 #endif | |
1883 | 1654 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1655 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, |
1656 #ifdef FEAT_WINDOWS | |
1657 (char_u *)&p_ls, PV_NONE, | |
1658 #else | |
1659 (char_u *)NULL, PV_NONE, | |
1660 #endif | |
1883 | 1661 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1662 {"lazyredraw", "lz", P_BOOL|P_VI_DEF, |
1663 (char_u *)&p_lz, PV_NONE, | |
1883 | 1664 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1665 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN, |
1666 #ifdef FEAT_LINEBREAK | |
1667 (char_u *)VAR_WIN, PV_LBR, | |
1668 #else | |
1669 (char_u *)NULL, PV_NONE, | |
1670 #endif | |
1883 | 1671 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1672 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, |
1673 (char_u *)&Rows, PV_NONE, | |
1674 { | |
1675 #if defined(MSDOS) || defined(WIN3264) || defined(OS2) | |
1676 (char_u *)25L, | |
1677 #else | |
1678 (char_u *)24L, | |
1679 #endif | |
1883 | 1680 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1681 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR, |
1682 #ifdef FEAT_GUI | |
1683 (char_u *)&p_linespace, PV_NONE, | |
1684 #else | |
1685 (char_u *)NULL, PV_NONE, | |
1686 #endif | |
1687 #ifdef FEAT_GUI_W32 | |
1688 {(char_u *)1L, (char_u *)0L} | |
1689 #else | |
1690 {(char_u *)0L, (char_u *)0L} | |
1691 #endif | |
1883 | 1692 SCRIPTID_INIT}, |
7 | 1693 {"lisp", NULL, P_BOOL|P_VI_DEF, |
1694 #ifdef FEAT_LISP | |
1695 (char_u *)&p_lisp, PV_LISP, | |
1696 #else | |
1697 (char_u *)NULL, PV_NONE, | |
1698 #endif | |
1883 | 1699 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1700 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1701 #ifdef FEAT_LISP | |
1702 (char_u *)&p_lispwords, PV_NONE, | |
1703 {(char_u *)LISPWORD_VALUE, (char_u *)0L} | |
1704 #else | |
1705 (char_u *)NULL, PV_NONE, | |
1706 {(char_u *)"", (char_u *)0L} | |
1707 #endif | |
1883 | 1708 SCRIPTID_INIT}, |
7 | 1709 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
1710 (char_u *)VAR_WIN, PV_LIST, | |
1883 | 1711 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1712 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
1713 (char_u *)&p_lcs, PV_NONE, | |
1883 | 1714 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1715 {"loadplugins", "lpl", P_BOOL|P_VI_DEF, |
1716 (char_u *)&p_lpl, PV_NONE, | |
1883 | 1717 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
842 | 1718 #ifdef FEAT_GUI_MAC |
1719 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR, | |
1720 (char_u *)&p_macatsui, PV_NONE, | |
1883 | 1721 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
842 | 1722 #endif |
7 | 1723 {"magic", NULL, P_BOOL|P_VI_DEF, |
1724 (char_u *)&p_magic, PV_NONE, | |
1883 | 1725 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
634 | 1726 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
7 | 1727 #ifdef FEAT_QUICKFIX |
1728 (char_u *)&p_mef, PV_NONE, | |
1729 {(char_u *)"", (char_u *)0L} | |
1730 #else | |
1731 (char_u *)NULL, PV_NONE, | |
1732 {(char_u *)NULL, (char_u *)0L} | |
1733 #endif | |
1883 | 1734 SCRIPTID_INIT}, |
7 | 1735 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
1736 #ifdef FEAT_QUICKFIX | |
694 | 1737 (char_u *)&p_mp, PV_MP, |
7 | 1738 # ifdef VMS |
1739 {(char_u *)"MMS", (char_u *)0L} | |
1740 # else | |
1741 {(char_u *)"make", (char_u *)0L} | |
1742 # endif | |
1743 #else | |
1744 (char_u *)NULL, PV_NONE, | |
1745 {(char_u *)NULL, (char_u *)0L} | |
1746 #endif | |
1883 | 1747 SCRIPTID_INIT}, |
7 | 1748 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
1749 (char_u *)&p_mps, PV_MPS, | |
1883 | 1750 {(char_u *)"(:),{:},[:]", (char_u *)0L} |
1751 SCRIPTID_INIT}, | |
7 | 1752 {"matchtime", "mat", P_NUM|P_VI_DEF, |
1753 (char_u *)&p_mat, PV_NONE, | |
1883 | 1754 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT}, |
3443 | 1755 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT, |
714 | 1756 #ifdef FEAT_MBYTE |
1757 (char_u *)&p_mco, PV_NONE, | |
1758 #else | |
1759 (char_u *)NULL, PV_NONE, | |
1760 #endif | |
1883 | 1761 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1762 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF, |
1763 #ifdef FEAT_EVAL | |
1764 (char_u *)&p_mfd, PV_NONE, | |
1765 #else | |
1766 (char_u *)NULL, PV_NONE, | |
1767 #endif | |
1883 | 1768 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1769 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF, |
1770 (char_u *)&p_mmd, PV_NONE, | |
1883 | 1771 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1772 {"maxmem", "mm", P_NUM|P_VI_DEF, |
1773 (char_u *)&p_mm, PV_NONE, | |
1883 | 1774 {(char_u *)DFLT_MAXMEM, (char_u *)0L} |
1775 SCRIPTID_INIT}, | |
190 | 1776 {"maxmempattern","mmp", P_NUM|P_VI_DEF, |
1777 (char_u *)&p_mmp, PV_NONE, | |
1883 | 1778 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1779 {"maxmemtot", "mmt", P_NUM|P_VI_DEF, |
1780 (char_u *)&p_mmt, PV_NONE, | |
1883 | 1781 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L} |
1782 SCRIPTID_INIT}, | |
7 | 1783 {"menuitems", "mis", P_NUM|P_VI_DEF, |
1784 #ifdef FEAT_MENU | |
1785 (char_u *)&p_mis, PV_NONE, | |
1786 #else | |
1787 (char_u *)NULL, PV_NONE, | |
1788 #endif | |
1883 | 1789 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1790 {"mesg", NULL, P_BOOL|P_VI_DEF, |
1791 (char_u *)NULL, PV_NONE, | |
1883 | 1792 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
484 | 1793 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE, |
744 | 1794 #ifdef FEAT_SPELL |
484 | 1795 (char_u *)&p_msm, PV_NONE, |
1796 {(char_u *)"460000,2000,500", (char_u *)0L} | |
1797 #else | |
1798 (char_u *)NULL, PV_NONE, | |
1799 {(char_u *)0L, (char_u *)0L} | |
1800 #endif | |
1883 | 1801 SCRIPTID_INIT}, |
7 | 1802 {"modeline", "ml", P_BOOL|P_VIM, |
1803 (char_u *)&p_ml, PV_ML, | |
1883 | 1804 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, |
7 | 1805 {"modelines", "mls", P_NUM|P_VI_DEF, |
1806 (char_u *)&p_mls, PV_NONE, | |
1883 | 1807 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1808 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB, |
1809 (char_u *)&p_ma, PV_MA, | |
1883 | 1810 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1811 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
1812 (char_u *)&p_mod, PV_MOD, | |
1883 | 1813 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1814 {"more", NULL, P_BOOL|P_VIM, |
1815 (char_u *)&p_more, PV_NONE, | |
1883 | 1816 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, |
7 | 1817 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST, |
1818 (char_u *)&p_mouse, PV_NONE, | |
1819 { | |
1820 #if defined(MSDOS) || defined(WIN3264) | |
1821 (char_u *)"a", | |
1822 #else | |
1823 (char_u *)"", | |
1824 #endif | |
1883 | 1825 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1826 {"mousefocus", "mousef", P_BOOL|P_VI_DEF, |
1827 #ifdef FEAT_GUI | |
1828 (char_u *)&p_mousef, PV_NONE, | |
1829 #else | |
1830 (char_u *)NULL, PV_NONE, | |
1831 #endif | |
1883 | 1832 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1833 {"mousehide", "mh", P_BOOL|P_VI_DEF, |
1834 #ifdef FEAT_GUI | |
1835 (char_u *)&p_mh, PV_NONE, | |
1836 #else | |
1837 (char_u *)NULL, PV_NONE, | |
1838 #endif | |
1883 | 1839 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1840 {"mousemodel", "mousem", P_STRING|P_VI_DEF, |
1841 (char_u *)&p_mousem, PV_NONE, | |
1842 { | |
1843 #if defined(MSDOS) || defined(MSWIN) | |
1844 (char_u *)"popup", | |
1845 #else | |
1846 # if defined(MACOS) | |
1847 (char_u *)"popup_setpos", | |
1848 # else | |
1849 (char_u *)"extend", | |
1850 # endif | |
1851 #endif | |
1883 | 1852 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1853 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
1854 #ifdef FEAT_MOUSESHAPE | |
1855 (char_u *)&p_mouseshape, PV_NONE, | |
1856 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L} | |
1857 #else | |
1858 (char_u *)NULL, PV_NONE, | |
1859 {(char_u *)NULL, (char_u *)0L} | |
1860 #endif | |
1883 | 1861 SCRIPTID_INIT}, |
7 | 1862 {"mousetime", "mouset", P_NUM|P_VI_DEF, |
1863 (char_u *)&p_mouset, PV_NONE, | |
1883 | 1864 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT}, |
14 | 1865 {"mzquantum", "mzq", P_NUM, |
1866 #ifdef FEAT_MZSCHEME | |
1867 (char_u *)&p_mzq, PV_NONE, | |
1868 #else | |
1869 (char_u *)NULL, PV_NONE, | |
1870 #endif | |
1883 | 1871 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT}, |
7 | 1872 {"novice", NULL, P_BOOL|P_VI_DEF, |
1873 (char_u *)NULL, PV_NONE, | |
1883 | 1874 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1875 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
1876 (char_u *)&p_nf, PV_NF, | |
1883 | 1877 {(char_u *)"octal,hex", (char_u *)0L} |
1878 SCRIPTID_INIT}, | |
7 | 1879 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, |
1880 (char_u *)VAR_WIN, PV_NU, | |
1883 | 1881 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
13 | 1882 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM, |
1883 #ifdef FEAT_LINEBREAK | |
1884 (char_u *)VAR_WIN, PV_NUW, | |
1885 #else | |
1886 (char_u *)NULL, PV_NONE, | |
1887 #endif | |
1883 | 1888 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT}, |
523 | 1889 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, |
502 | 1890 #ifdef FEAT_COMPL_FUNC |
1891 (char_u *)&p_ofu, PV_OFU, | |
1892 {(char_u *)"", (char_u *)0L} | |
1893 #else | |
1894 (char_u *)NULL, PV_NONE, | |
1895 {(char_u *)0L, (char_u *)0L} | |
1896 #endif | |
1883 | 1897 SCRIPTID_INIT}, |
7 | 1898 {"open", NULL, P_BOOL|P_VI_DEF, |
1899 (char_u *)NULL, PV_NONE, | |
1883 | 1900 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
1004 | 1901 {"opendevice", "odev", P_BOOL|P_VI_DEF, |
1902 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) | |
1903 (char_u *)&p_odev, PV_NONE, | |
1904 #else | |
1905 (char_u *)NULL, PV_NONE, | |
1906 #endif | |
1907 {(char_u *)FALSE, (char_u *)FALSE} | |
1883 | 1908 SCRIPTID_INIT}, |
593 | 1909 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE, |
1910 (char_u *)&p_opfunc, PV_NONE, | |
1883 | 1911 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1912 {"optimize", "opt", P_BOOL|P_VI_DEF, |
1913 (char_u *)NULL, PV_NONE, | |
1883 | 1914 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1915 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF, |
2834 | 1916 (char_u *)NULL, PV_NONE, |
1917 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, | |
7 | 1918 {"paragraphs", "para", P_STRING|P_VI_DEF, |
1919 (char_u *)&p_para, PV_NONE, | |
1564 | 1920 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp", |
1883 | 1921 (char_u *)0L} SCRIPTID_INIT}, |
1384 | 1922 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC, |
7 | 1923 (char_u *)&p_paste, PV_NONE, |
1883 | 1924 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1925 {"pastetoggle", "pt", P_STRING|P_VI_DEF, |
1926 (char_u *)&p_pt, PV_NONE, | |
1883 | 1927 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1928 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE, |
1929 #if defined(FEAT_DIFF) && defined(FEAT_EVAL) | |
1930 (char_u *)&p_pex, PV_NONE, | |
1931 {(char_u *)"", (char_u *)0L} | |
1932 #else | |
1933 (char_u *)NULL, PV_NONE, | |
1934 {(char_u *)0L, (char_u *)0L} | |
1935 #endif | |
1883 | 1936 SCRIPTID_INIT}, |
36 | 1937 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME, |
7 | 1938 (char_u *)&p_pm, PV_NONE, |
1883 | 1939 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 1940 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
694 | 1941 (char_u *)&p_path, PV_PATH, |
7 | 1942 { |
1943 #if defined AMIGA || defined MSDOS || defined MSWIN | |
1944 (char_u *)".,,", | |
1945 #else | |
1946 # if defined(__EMX__) | |
1947 (char_u *)".,/emx/include,,", | |
1948 # else /* Unix, probably */ | |
1949 (char_u *)".,/usr/include,,", | |
1950 # endif | |
1951 #endif | |
1883 | 1952 (char_u *)0L} SCRIPTID_INIT}, |
7 | 1953 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM, |
1954 (char_u *)&p_pi, PV_PI, | |
1883 | 1955 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
13 | 1956 {"previewheight", "pvh", P_NUM|P_VI_DEF, |
7 | 1957 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
1958 (char_u *)&p_pvh, PV_NONE, | |
1959 #else | |
1960 (char_u *)NULL, PV_NONE, | |
1961 #endif | |
1883 | 1962 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 1963 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, |
1964 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | |
1965 (char_u *)VAR_WIN, PV_PVW, | |
1966 #else | |
1967 (char_u *)NULL, PV_NONE, | |
1968 #endif | |
1883 | 1969 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
36 | 1970 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE, |
7 | 1971 #ifdef FEAT_PRINTER |
1972 (char_u *)&p_pdev, PV_NONE, | |
1973 {(char_u *)"", (char_u *)0L} | |
1974 #else | |
1975 (char_u *)NULL, PV_NONE, | |
1976 {(char_u *)NULL, (char_u *)0L} | |
1977 #endif | |
1883 | 1978 SCRIPTID_INIT}, |
7 | 1979 {"printencoding", "penc", P_STRING|P_VI_DEF, |
1980 #ifdef FEAT_POSTSCRIPT | |
1981 (char_u *)&p_penc, PV_NONE, | |
1982 {(char_u *)"", (char_u *)0L} | |
1983 #else | |
1984 (char_u *)NULL, PV_NONE, | |
1985 {(char_u *)NULL, (char_u *)0L} | |
1986 #endif | |
1883 | 1987 SCRIPTID_INIT}, |
7 | 1988 {"printexpr", "pexpr", P_STRING|P_VI_DEF, |
1989 #ifdef FEAT_POSTSCRIPT | |
1990 (char_u *)&p_pexpr, PV_NONE, | |
1991 {(char_u *)"", (char_u *)0L} | |
1992 #else | |
1993 (char_u *)NULL, PV_NONE, | |
1994 {(char_u *)NULL, (char_u *)0L} | |
1995 #endif | |
1883 | 1996 SCRIPTID_INIT}, |
7 | 1997 {"printfont", "pfn", P_STRING|P_VI_DEF, |
1998 #ifdef FEAT_PRINTER | |
1999 (char_u *)&p_pfn, PV_NONE, | |
2000 { | |
2001 # ifdef MSWIN | |
2002 (char_u *)"Courier_New:h10", | |
2003 # else | |
2004 (char_u *)"courier", | |
2005 # endif | |
2006 (char_u *)0L} | |
2007 #else | |
2008 (char_u *)NULL, PV_NONE, | |
2009 {(char_u *)NULL, (char_u *)0L} | |
2010 #endif | |
1883 | 2011 SCRIPTID_INIT}, |
7 | 2012 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT, |
2013 #ifdef FEAT_PRINTER | |
2014 (char_u *)&p_header, PV_NONE, | |
2015 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L} | |
2016 #else | |
2017 (char_u *)NULL, PV_NONE, | |
2018 {(char_u *)NULL, (char_u *)0L} | |
2019 #endif | |
1883 | 2020 SCRIPTID_INIT}, |
15 | 2021 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF, |
2022 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) | |
2023 (char_u *)&p_pmcs, PV_NONE, | |
2024 {(char_u *)"", (char_u *)0L} | |
2025 #else | |
2026 (char_u *)NULL, PV_NONE, | |
2027 {(char_u *)NULL, (char_u *)0L} | |
2028 #endif | |
1883 | 2029 SCRIPTID_INIT}, |
15 | 2030 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF, |
2031 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) | |
2032 (char_u *)&p_pmfn, PV_NONE, | |
2033 {(char_u *)"", (char_u *)0L} | |
2034 #else | |
2035 (char_u *)NULL, PV_NONE, | |
2036 {(char_u *)NULL, (char_u *)0L} | |
2037 #endif | |
1883 | 2038 SCRIPTID_INIT}, |
7 | 2039 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2040 #ifdef FEAT_PRINTER | |
2041 (char_u *)&p_popt, PV_NONE, | |
2042 {(char_u *)"", (char_u *)0L} | |
2043 #else | |
2044 (char_u *)NULL, PV_NONE, | |
2045 {(char_u *)NULL, (char_u *)0L} | |
2046 #endif | |
1883 | 2047 SCRIPTID_INIT}, |
7 | 2048 {"prompt", NULL, P_BOOL|P_VI_DEF, |
168 | 2049 (char_u *)&p_prompt, PV_NONE, |
1883 | 2050 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
767 | 2051 {"pumheight", "ph", P_NUM|P_VI_DEF, |
2052 #ifdef FEAT_INS_EXPAND | |
2053 (char_u *)&p_ph, PV_NONE, | |
2054 #else | |
2055 (char_u *)NULL, PV_NONE, | |
2056 #endif | |
1883 | 2057 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
12 | 2058 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF, |
2059 #ifdef FEAT_TEXTOBJ | |
2060 (char_u *)&p_qe, PV_QE, | |
2061 {(char_u *)"\\", (char_u *)0L} | |
2062 #else | |
2063 (char_u *)NULL, PV_NONE, | |
2064 {(char_u *)NULL, (char_u *)0L} | |
2065 #endif | |
1883 | 2066 SCRIPTID_INIT}, |
7 | 2067 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, |
2068 (char_u *)&p_ro, PV_RO, | |
1883 | 2069 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2070 {"redraw", NULL, P_BOOL|P_VI_DEF, |
2071 (char_u *)NULL, PV_NONE, | |
1883 | 2072 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
1521 | 2073 {"redrawtime", "rdt", P_NUM|P_VI_DEF, |
2074 #ifdef FEAT_RELTIME | |
2075 (char_u *)&p_rdt, PV_NONE, | |
2076 #else | |
2077 (char_u *)NULL, PV_NONE, | |
2078 #endif | |
1883 | 2079 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT}, |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
2080 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN, |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
2081 (char_u *)VAR_WIN, PV_RNU, |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
2082 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2083 {"remap", NULL, P_BOOL|P_VI_DEF, |
2084 (char_u *)&p_remap, PV_NONE, | |
1883 | 2085 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2086 {"report", NULL, P_NUM|P_VI_DEF, |
2087 (char_u *)&p_report, PV_NONE, | |
1883 | 2088 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2089 {"restorescreen", "rs", P_BOOL|P_VI_DEF, |
2090 #ifdef WIN3264 | |
2091 (char_u *)&p_rs, PV_NONE, | |
2092 #else | |
2093 (char_u *)NULL, PV_NONE, | |
2094 #endif | |
1883 | 2095 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2096 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM, |
2097 #ifdef FEAT_RIGHTLEFT | |
2098 (char_u *)&p_ri, PV_NONE, | |
2099 #else | |
2100 (char_u *)NULL, PV_NONE, | |
2101 #endif | |
1883 | 2102 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2103 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN, |
2104 #ifdef FEAT_RIGHTLEFT | |
2105 (char_u *)VAR_WIN, PV_RL, | |
2106 #else | |
2107 (char_u *)NULL, PV_NONE, | |
2108 #endif | |
1883 | 2109 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2110 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, |
2111 #ifdef FEAT_RIGHTLEFT | |
2112 (char_u *)VAR_WIN, PV_RLC, | |
2113 {(char_u *)"search", (char_u *)NULL} | |
2114 #else | |
2115 (char_u *)NULL, PV_NONE, | |
2116 {(char_u *)NULL, (char_u *)0L} | |
2117 #endif | |
1883 | 2118 SCRIPTID_INIT}, |
7 | 2119 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT, |
2120 #ifdef FEAT_CMDL_INFO | |
2121 (char_u *)&p_ru, PV_NONE, | |
2122 #else | |
2123 (char_u *)NULL, PV_NONE, | |
2124 #endif | |
1883 | 2125 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2126 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, |
2127 #ifdef FEAT_STL_OPT | |
2128 (char_u *)&p_ruf, PV_NONE, | |
2129 #else | |
2130 (char_u *)NULL, PV_NONE, | |
2131 #endif | |
1883 | 2132 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2133 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE, |
2134 (char_u *)&p_rtp, PV_NONE, | |
1883 | 2135 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L} |
2136 SCRIPTID_INIT}, | |
7 | 2137 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF, |
2138 (char_u *)VAR_WIN, PV_SCROLL, | |
1883 | 2139 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2140 {"scrollbind", "scb", P_BOOL|P_VI_DEF, |
2141 #ifdef FEAT_SCROLLBIND | |
2142 (char_u *)VAR_WIN, PV_SCBIND, | |
2143 #else | |
2144 (char_u *)NULL, PV_NONE, | |
2145 #endif | |
1883 | 2146 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2147 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, |
2148 (char_u *)&p_sj, PV_NONE, | |
1883 | 2149 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2150 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, |
2151 (char_u *)&p_so, PV_NONE, | |
1883 | 2152 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2153 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2154 #ifdef FEAT_SCROLLBIND | |
2155 (char_u *)&p_sbo, PV_NONE, | |
2156 {(char_u *)"ver,jump", (char_u *)0L} | |
2157 #else | |
2158 (char_u *)NULL, PV_NONE, | |
2159 {(char_u *)0L, (char_u *)0L} | |
2160 #endif | |
1883 | 2161 SCRIPTID_INIT}, |
7 | 2162 {"sections", "sect", P_STRING|P_VI_DEF, |
2163 (char_u *)&p_sections, PV_NONE, | |
1883 | 2164 {(char_u *)"SHNHH HUnhsh", (char_u *)0L} |
2165 SCRIPTID_INIT}, | |
7 | 2166 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE, |
2167 (char_u *)&p_secure, PV_NONE, | |
1883 | 2168 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2169 {"selection", "sel", P_STRING|P_VI_DEF, |
2170 #ifdef FEAT_VISUAL | |
2171 (char_u *)&p_sel, PV_NONE, | |
2172 #else | |
2173 (char_u *)NULL, PV_NONE, | |
2174 #endif | |
1883 | 2175 {(char_u *)"inclusive", (char_u *)0L} |
2176 SCRIPTID_INIT}, | |
7 | 2177 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2178 #ifdef FEAT_VISUAL | |
2179 (char_u *)&p_slm, PV_NONE, | |
2180 #else | |
2181 (char_u *)NULL, PV_NONE, | |
2182 #endif | |
1883 | 2183 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2184 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2185 #ifdef FEAT_SESSION | |
2186 (char_u *)&p_ssop, PV_NONE, | |
828 | 2187 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize", |
7 | 2188 (char_u *)0L} |
2189 #else | |
2190 (char_u *)NULL, PV_NONE, | |
2191 {(char_u *)0L, (char_u *)0L} | |
2192 #endif | |
1883 | 2193 SCRIPTID_INIT}, |
7 | 2194 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
2195 (char_u *)&p_sh, PV_NONE, | |
2196 { | |
2197 #ifdef VMS | |
2198 (char_u *)"-", | |
2199 #else | |
2200 # if defined(MSDOS) | |
2201 (char_u *)"command", | |
2202 # else | |
2203 # if defined(WIN16) | |
2204 (char_u *)"command.com", | |
2205 # else | |
2206 # if defined(WIN3264) | |
2207 (char_u *)"", /* set in set_init_1() */ | |
2208 # else | |
2209 # if defined(OS2) | |
2210 (char_u *)"cmd.exe", | |
2211 # else | |
2212 # if defined(ARCHIE) | |
2213 (char_u *)"gos", | |
2214 # else | |
2215 (char_u *)"sh", | |
2216 # endif | |
2217 # endif | |
2218 # endif | |
2219 # endif | |
2220 # endif | |
2221 #endif /* VMS */ | |
1883 | 2222 (char_u *)0L} SCRIPTID_INIT}, |
7 | 2223 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE, |
2224 (char_u *)&p_shcf, PV_NONE, | |
2225 { | |
2226 #if defined(MSDOS) || defined(MSWIN) | |
2227 (char_u *)"/c", | |
2228 #else | |
2229 # if defined(OS2) | |
2230 (char_u *)"/c", | |
2231 # else | |
2232 (char_u *)"-c", | |
2233 # endif | |
2234 #endif | |
1883 | 2235 (char_u *)0L} SCRIPTID_INIT}, |
7 | 2236 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE, |
2237 #ifdef FEAT_QUICKFIX | |
2238 (char_u *)&p_sp, PV_NONE, | |
2239 { | |
2240 #if defined(UNIX) || defined(OS2) | |
2241 # ifdef ARCHIE | |
2242 (char_u *)"2>", | |
2243 # else | |
2244 (char_u *)"| tee", | |
2245 # endif | |
2246 #else | |
2247 (char_u *)">", | |
2248 #endif | |
2249 (char_u *)0L} | |
2250 #else | |
2251 (char_u *)NULL, PV_NONE, | |
2252 {(char_u *)0L, (char_u *)0L} | |
2253 #endif | |
1883 | 2254 SCRIPTID_INIT}, |
7 | 2255 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE, |
2256 (char_u *)&p_shq, PV_NONE, | |
1883 | 2257 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2258 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE, |
2259 (char_u *)&p_srr, PV_NONE, | |
1883 | 2260 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2261 {"shellslash", "ssl", P_BOOL|P_VI_DEF, |
2262 #ifdef BACKSLASH_IN_FILENAME | |
2263 (char_u *)&p_ssl, PV_NONE, | |
2264 #else | |
2265 (char_u *)NULL, PV_NONE, | |
2266 #endif | |
1883 | 2267 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
168 | 2268 {"shelltemp", "stmp", P_BOOL, |
2269 (char_u *)&p_stmp, PV_NONE, | |
1883 | 2270 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, |
7 | 2271 {"shelltype", "st", P_NUM|P_VI_DEF, |
2272 #ifdef AMIGA | |
2273 (char_u *)&p_st, PV_NONE, | |
2274 #else | |
2275 (char_u *)NULL, PV_NONE, | |
2276 #endif | |
1883 | 2277 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2278 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE, |
2279 (char_u *)&p_sxq, PV_NONE, | |
2280 { | |
2281 #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__) | |
2282 (char_u *)"\"", | |
2283 #else | |
2284 (char_u *)"", | |
2285 #endif | |
1883 | 2286 (char_u *)0L} SCRIPTID_INIT}, |
3359 | 2287 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE, |
2288 (char_u *)&p_sxe, PV_NONE, | |
2289 { | |
2290 #if defined(MSDOS) || defined(WIN16) || defined(WIN3264) | |
2291 (char_u *)"\"&|<>()@^", | |
2292 #else | |
2293 (char_u *)"", | |
2294 #endif | |
2295 (char_u *)0L} SCRIPTID_INIT}, | |
7 | 2296 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM, |
2297 (char_u *)&p_sr, PV_NONE, | |
1883 | 2298 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2299 {"shiftwidth", "sw", P_NUM|P_VI_DEF, |
2300 (char_u *)&p_sw, PV_SW, | |
1883 | 2301 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2302 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST, |
2303 (char_u *)&p_shm, PV_NONE, | |
1883 | 2304 {(char_u *)"", (char_u *)"filnxtToO"} |
2305 SCRIPTID_INIT}, | |
7 | 2306 {"shortname", "sn", P_BOOL|P_VI_DEF, |
2307 #ifdef SHORT_FNAME | |
2308 (char_u *)NULL, PV_NONE, | |
2309 #else | |
2310 (char_u *)&p_sn, PV_SN, | |
2311 #endif | |
1883 | 2312 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2313 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL, |
2314 #ifdef FEAT_LINEBREAK | |
2315 (char_u *)&p_sbr, PV_NONE, | |
2316 #else | |
2317 (char_u *)NULL, PV_NONE, | |
2318 #endif | |
1883 | 2319 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2320 {"showcmd", "sc", P_BOOL|P_VIM, |
2321 #ifdef FEAT_CMDL_INFO | |
2322 (char_u *)&p_sc, PV_NONE, | |
2323 #else | |
2324 (char_u *)NULL, PV_NONE, | |
2325 #endif | |
2326 {(char_u *)FALSE, | |
2327 #ifdef UNIX | |
2328 (char_u *)FALSE | |
2329 #else | |
2330 (char_u *)TRUE | |
2331 #endif | |
1883 | 2332 } SCRIPTID_INIT}, |
7 | 2333 {"showfulltag", "sft", P_BOOL|P_VI_DEF, |
2334 (char_u *)&p_sft, PV_NONE, | |
1883 | 2335 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2336 {"showmatch", "sm", P_BOOL|P_VI_DEF, |
2337 (char_u *)&p_sm, PV_NONE, | |
1883 | 2338 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2339 {"showmode", "smd", P_BOOL|P_VIM, |
2340 (char_u *)&p_smd, PV_NONE, | |
1883 | 2341 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, |
677 | 2342 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL, |
2343 #ifdef FEAT_WINDOWS | |
2344 (char_u *)&p_stal, PV_NONE, | |
2345 #else | |
2346 (char_u *)NULL, PV_NONE, | |
2347 #endif | |
1883 | 2348 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2349 {"sidescroll", "ss", P_NUM|P_VI_DEF, |
2350 (char_u *)&p_ss, PV_NONE, | |
1883 | 2351 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2352 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, |
2353 (char_u *)&p_siso, PV_NONE, | |
1883 | 2354 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2355 {"slowopen", "slow", P_BOOL|P_VI_DEF, |
2356 (char_u *)NULL, PV_NONE, | |
1883 | 2357 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2358 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM, |
2359 (char_u *)&p_scs, PV_NONE, | |
1883 | 2360 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2361 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM, |
2362 #ifdef FEAT_SMARTINDENT | |
2363 (char_u *)&p_si, PV_SI, | |
2364 #else | |
2365 (char_u *)NULL, PV_NONE, | |
2366 #endif | |
1883 | 2367 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2368 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM, |
2369 (char_u *)&p_sta, PV_NONE, | |
1883 | 2370 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2371 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM, |
2372 (char_u *)&p_sts, PV_STS, | |
1883 | 2373 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2374 {"sourceany", NULL, P_BOOL|P_VI_DEF, |
2375 (char_u *)NULL, PV_NONE, | |
1883 | 2376 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
221 | 2377 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
744 | 2378 #ifdef FEAT_SPELL |
221 | 2379 (char_u *)VAR_WIN, PV_SPELL, |
2380 #else | |
2381 (char_u *)NULL, PV_NONE, | |
2382 #endif | |
1883 | 2383 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
477 | 2384 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF, |
744 | 2385 #ifdef FEAT_SPELL |
386 | 2386 (char_u *)&p_spc, PV_SPC, |
389 | 2387 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L} |
386 | 2388 #else |
2389 (char_u *)NULL, PV_NONE, | |
2390 {(char_u *)0L, (char_u *)0L} | |
2391 #endif | |
1883 | 2392 SCRIPTID_INIT}, |
386 | 2393 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA, |
744 | 2394 #ifdef FEAT_SPELL |
314 | 2395 (char_u *)&p_spf, PV_SPF, |
2396 {(char_u *)"", (char_u *)0L} | |
2397 #else | |
2398 (char_u *)NULL, PV_NONE, | |
2399 {(char_u *)0L, (char_u *)0L} | |
2400 #endif | |
1883 | 2401 SCRIPTID_INIT}, |
374 | 2402 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND, |
744 | 2403 #ifdef FEAT_SPELL |
221 | 2404 (char_u *)&p_spl, PV_SPL, |
314 | 2405 {(char_u *)"en", (char_u *)0L} |
221 | 2406 #else |
2407 (char_u *)NULL, PV_NONE, | |
2408 {(char_u *)0L, (char_u *)0L} | |
2409 #endif | |
1883 | 2410 SCRIPTID_INIT}, |
875 | 2411 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA, |
744 | 2412 #ifdef FEAT_SPELL |
344 | 2413 (char_u *)&p_sps, PV_NONE, |
2414 {(char_u *)"best", (char_u *)0L} | |
2415 #else | |
2416 (char_u *)NULL, PV_NONE, | |
2417 {(char_u *)0L, (char_u *)0L} | |
2418 #endif | |
1883 | 2419 SCRIPTID_INIT}, |
7 | 2420 {"splitbelow", "sb", P_BOOL|P_VI_DEF, |
2421 #ifdef FEAT_WINDOWS | |
2422 (char_u *)&p_sb, PV_NONE, | |
2423 #else | |
2424 (char_u *)NULL, PV_NONE, | |
2425 #endif | |
1883 | 2426 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2427 {"splitright", "spr", P_BOOL|P_VI_DEF, |
2428 #ifdef FEAT_VERTSPLIT | |
2429 (char_u *)&p_spr, PV_NONE, | |
2430 #else | |
2431 (char_u *)NULL, PV_NONE, | |
2432 #endif | |
1883 | 2433 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2434 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM, |
2435 (char_u *)&p_sol, PV_NONE, | |
1883 | 2436 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2437 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, |
2438 #ifdef FEAT_STL_OPT | |
694 | 2439 (char_u *)&p_stl, PV_STL, |
7 | 2440 #else |
2441 (char_u *)NULL, PV_NONE, | |
2442 #endif | |
1883 | 2443 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2444 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2445 (char_u *)&p_su, PV_NONE, | |
2446 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj", | |
1883 | 2447 (char_u *)0L} SCRIPTID_INIT}, |
7 | 2448 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP, |
694 | 2449 #ifdef FEAT_SEARCHPATH |
7 | 2450 (char_u *)&p_sua, PV_SUA, |
2451 {(char_u *)"", (char_u *)0L} | |
2452 #else | |
2453 (char_u *)NULL, PV_NONE, | |
2454 {(char_u *)0L, (char_u *)0L} | |
2455 #endif | |
1883 | 2456 SCRIPTID_INIT}, |
7 | 2457 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT, |
2458 (char_u *)&p_swf, PV_SWF, | |
1883 | 2459 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2460 {"swapsync", "sws", P_STRING|P_VI_DEF, |
2461 (char_u *)&p_sws, PV_NONE, | |
1883 | 2462 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2463 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2464 (char_u *)&p_swb, PV_NONE, | |
1883 | 2465 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
410 | 2466 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF, |
2467 #ifdef FEAT_SYN_HL | |
2468 (char_u *)&p_smc, PV_SMC, | |
2469 {(char_u *)3000L, (char_u *)0L} | |
2470 #else | |
2471 (char_u *)NULL, PV_NONE, | |
2472 {(char_u *)0L, (char_u *)0L} | |
2473 #endif | |
1883 | 2474 SCRIPTID_INIT}, |
36 | 2475 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, |
7 | 2476 #ifdef FEAT_SYN_HL |
2477 (char_u *)&p_syn, PV_SYN, | |
2478 {(char_u *)"", (char_u *)0L} | |
2479 #else | |
2480 (char_u *)NULL, PV_NONE, | |
2481 {(char_u *)0L, (char_u *)0L} | |
2482 #endif | |
1883 | 2483 SCRIPTID_INIT}, |
677 | 2484 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL, |
2485 #ifdef FEAT_STL_OPT | |
670 | 2486 (char_u *)&p_tal, PV_NONE, |
2487 #else | |
2488 (char_u *)NULL, PV_NONE, | |
2489 #endif | |
1883 | 2490 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
699 | 2491 {"tabpagemax", "tpm", P_NUM|P_VI_DEF, |
2492 #ifdef FEAT_WINDOWS | |
2493 (char_u *)&p_tpm, PV_NONE, | |
2494 #else | |
2495 (char_u *)NULL, PV_NONE, | |
2496 #endif | |
1883 | 2497 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2498 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF, |
2499 (char_u *)&p_ts, PV_TS, | |
1883 | 2500 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2501 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF, |
2502 (char_u *)&p_tbs, PV_NONE, | |
2503 #ifdef VMS /* binary searching doesn't appear to work on VMS */ | |
2504 {(char_u *)0L, (char_u *)0L} | |
2505 #else | |
2506 {(char_u *)TRUE, (char_u *)0L} | |
2507 #endif | |
1883 | 2508 SCRIPTID_INIT}, |
7 | 2509 {"taglength", "tl", P_NUM|P_VI_DEF, |
2510 (char_u *)&p_tl, PV_NONE, | |
1883 | 2511 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2512 {"tagrelative", "tr", P_BOOL|P_VIM, |
2513 (char_u *)&p_tr, PV_NONE, | |
1883 | 2514 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, |
7 | 2515 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
694 | 2516 (char_u *)&p_tags, PV_TAGS, |
7 | 2517 { |
2518 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME) | |
2519 (char_u *)"./tags,./TAGS,tags,TAGS", | |
2520 #else | |
2521 (char_u *)"./tags,tags", | |
2522 #endif | |
1883 | 2523 (char_u *)0L} SCRIPTID_INIT}, |
7 | 2524 {"tagstack", "tgst", P_BOOL|P_VI_DEF, |
2525 (char_u *)&p_tgst, PV_NONE, | |
1883 | 2526 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2527 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, |
2528 (char_u *)&T_NAME, PV_NONE, | |
1883 | 2529 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2530 {"termbidi", "tbidi", P_BOOL|P_VI_DEF, |
2531 #ifdef FEAT_ARABIC | |
2532 (char_u *)&p_tbidi, PV_NONE, | |
2533 #else | |
2534 (char_u *)NULL, PV_NONE, | |
2535 #endif | |
1883 | 2536 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2537 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR, |
2538 #ifdef FEAT_MBYTE | |
2539 (char_u *)&p_tenc, PV_NONE, | |
2540 {(char_u *)"", (char_u *)0L} | |
2541 #else | |
2542 (char_u *)NULL, PV_NONE, | |
2543 {(char_u *)0L, (char_u *)0L} | |
2544 #endif | |
1883 | 2545 SCRIPTID_INIT}, |
7 | 2546 {"terse", NULL, P_BOOL|P_VI_DEF, |
2547 (char_u *)&p_terse, PV_NONE, | |
1883 | 2548 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2549 {"textauto", "ta", P_BOOL|P_VIM, |
2550 (char_u *)&p_ta, PV_NONE, | |
1883 | 2551 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE} |
2552 SCRIPTID_INIT}, | |
7 | 2553 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC, |
2554 (char_u *)&p_tx, PV_TX, | |
2555 { | |
2556 #ifdef USE_CRNL | |
2557 (char_u *)TRUE, | |
2558 #else | |
2559 (char_u *)FALSE, | |
2560 #endif | |
1883 | 2561 (char_u *)0L} SCRIPTID_INIT}, |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2562 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF, |
7 | 2563 (char_u *)&p_tw, PV_TW, |
1883 | 2564 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2565 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
2566 #ifdef FEAT_INS_EXPAND | |
694 | 2567 (char_u *)&p_tsr, PV_TSR, |
7 | 2568 #else |
2569 (char_u *)NULL, PV_NONE, | |
2570 #endif | |
1883 | 2571 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2572 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM, |
2573 (char_u *)&p_to, PV_NONE, | |
1883 | 2574 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2575 {"timeout", "to", P_BOOL|P_VI_DEF, |
2576 (char_u *)&p_timeout, PV_NONE, | |
1883 | 2577 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2578 {"timeoutlen", "tm", P_NUM|P_VI_DEF, |
2579 (char_u *)&p_tm, PV_NONE, | |
1883 | 2580 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2581 {"title", NULL, P_BOOL|P_VI_DEF, |
2582 #ifdef FEAT_TITLE | |
2583 (char_u *)&p_title, PV_NONE, | |
2584 #else | |
2585 (char_u *)NULL, PV_NONE, | |
2586 #endif | |
1883 | 2587 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2588 {"titlelen", NULL, P_NUM|P_VI_DEF, |
2589 #ifdef FEAT_TITLE | |
2590 (char_u *)&p_titlelen, PV_NONE, | |
2591 #else | |
2592 (char_u *)NULL, PV_NONE, | |
2593 #endif | |
1883 | 2594 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT}, |
667 | 2595 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC, |
7 | 2596 #ifdef FEAT_TITLE |
2597 (char_u *)&p_titleold, PV_NONE, | |
2598 {(char_u *)N_("Thanks for flying Vim"), | |
2599 (char_u *)0L} | |
2600 #else | |
2601 (char_u *)NULL, PV_NONE, | |
2602 {(char_u *)0L, (char_u *)0L} | |
2603 #endif | |
1883 | 2604 SCRIPTID_INIT}, |
7 | 2605 {"titlestring", NULL, P_STRING|P_VI_DEF, |
2606 #ifdef FEAT_TITLE | |
2607 (char_u *)&p_titlestring, PV_NONE, | |
2608 #else | |
2609 (char_u *)NULL, PV_NONE, | |
2610 #endif | |
1883 | 2611 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2612 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
2613 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP, | |
2614 (char_u *)&p_toolbar, PV_NONE, | |
1883 | 2615 {(char_u *)"icons,tooltips", (char_u *)0L} |
2616 SCRIPTID_INIT}, | |
7 | 2617 #endif |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2271
diff
changeset
|
2618 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) |
7 | 2619 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF, |
2620 (char_u *)&p_tbis, PV_NONE, | |
1883 | 2621 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2622 #endif |
2623 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM, | |
2624 (char_u *)&p_ttimeout, PV_NONE, | |
1883 | 2625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2626 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF, |
2627 (char_u *)&p_ttm, PV_NONE, | |
1883 | 2628 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2629 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF, |
2630 (char_u *)&p_tbi, PV_NONE, | |
1883 | 2631 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2632 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF, |
2633 (char_u *)&p_tf, PV_NONE, | |
1883 | 2634 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2635 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, |
2636 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) | |
2637 (char_u *)&p_ttym, PV_NONE, | |
2638 #else | |
2639 (char_u *)NULL, PV_NONE, | |
2640 #endif | |
1883 | 2641 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2642 {"ttyscroll", "tsl", P_NUM|P_VI_DEF, |
2643 (char_u *)&p_ttyscroll, PV_NONE, | |
1883 | 2644 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2645 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, |
2646 (char_u *)&T_NAME, PV_NONE, | |
1883 | 2647 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2648 {"undodir", "udir", P_STRING|P_EXPAND|P_COMMA|P_NODUP|P_SECURE|P_VI_DEF, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2649 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2650 (char_u *)&p_udir, PV_NONE, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2651 {(char_u *)".", (char_u *)0L} |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2652 #else |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2653 (char_u *)NULL, PV_NONE, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2654 {(char_u *)0L, (char_u *)0L} |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2655 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2656 SCRIPTID_INIT}, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2657 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2658 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2659 (char_u *)&p_udf, PV_UDF, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2660 #else |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2661 (char_u *)NULL, PV_NONE, |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2662 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
2663 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2664 {"undolevels", "ul", P_NUM|P_VI_DEF, |
2665 (char_u *)&p_ul, PV_NONE, | |
2666 { | |
2667 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS) | |
2668 (char_u *)1000L, | |
2669 #else | |
2670 (char_u *)100L, | |
2671 #endif | |
1883 | 2672 (char_u *)0L} SCRIPTID_INIT}, |
2394
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2379
diff
changeset
|
2673 {"undoreload", "ur", P_NUM|P_VI_DEF, |
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2379
diff
changeset
|
2674 (char_u *)&p_ur, PV_NONE, |
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2379
diff
changeset
|
2675 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2676 {"updatecount", "uc", P_NUM|P_VI_DEF, |
2677 (char_u *)&p_uc, PV_NONE, | |
1883 | 2678 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2679 {"updatetime", "ut", P_NUM|P_VI_DEF, |
2680 (char_u *)&p_ut, PV_NONE, | |
1883 | 2681 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2682 {"verbose", "vbs", P_NUM|P_VI_DEF, |
2683 (char_u *)&p_verbose, PV_NONE, | |
1883 | 2684 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
294 | 2685 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
2686 (char_u *)&p_vfile, PV_NONE, | |
1883 | 2687 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2688 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
2689 #ifdef FEAT_SESSION | |
2690 (char_u *)&p_vdir, PV_NONE, | |
2691 {(char_u *)DFLT_VDIR, (char_u *)0L} | |
2692 #else | |
2693 (char_u *)NULL, PV_NONE, | |
2694 {(char_u *)0L, (char_u *)0L} | |
2695 #endif | |
1883 | 2696 SCRIPTID_INIT}, |
7 | 2697 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2698 #ifdef FEAT_SESSION | |
2699 (char_u *)&p_vop, PV_NONE, | |
2700 {(char_u *)"folds,options,cursor", (char_u *)0L} | |
2701 #else | |
2702 (char_u *)NULL, PV_NONE, | |
2703 {(char_u *)0L, (char_u *)0L} | |
2704 #endif | |
1883 | 2705 SCRIPTID_INIT}, |
7 | 2706 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE, |
2707 #ifdef FEAT_VIMINFO | |
2708 (char_u *)&p_viminfo, PV_NONE, | |
2709 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) | |
1733 | 2710 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"} |
7 | 2711 #else |
2712 # ifdef AMIGA | |
2713 {(char_u *)"", | |
1733 | 2714 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"} |
7 | 2715 # else |
1733 | 2716 {(char_u *)"", (char_u *)"'100,<50,s10,h"} |
7 | 2717 # endif |
2718 #endif | |
2719 #else | |
2720 (char_u *)NULL, PV_NONE, | |
2721 {(char_u *)0L, (char_u *)0L} | |
2722 #endif | |
1883 | 2723 SCRIPTID_INIT}, |
3443 | 2724 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM|P_CURSWANT, |
7 | 2725 #ifdef FEAT_VIRTUALEDIT |
2726 (char_u *)&p_ve, PV_NONE, | |
2727 {(char_u *)"", (char_u *)""} | |
2728 #else | |
2729 (char_u *)NULL, PV_NONE, | |
2730 {(char_u *)0L, (char_u *)0L} | |
2731 #endif | |
1883 | 2732 SCRIPTID_INIT}, |
7 | 2733 {"visualbell", "vb", P_BOOL|P_VI_DEF, |
2734 (char_u *)&p_vb, PV_NONE, | |
1883 | 2735 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2736 {"w300", NULL, P_NUM|P_VI_DEF, |
2737 (char_u *)NULL, PV_NONE, | |
1883 | 2738 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2739 {"w1200", NULL, P_NUM|P_VI_DEF, |
2740 (char_u *)NULL, PV_NONE, | |
1883 | 2741 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2742 {"w9600", NULL, P_NUM|P_VI_DEF, |
2743 (char_u *)NULL, PV_NONE, | |
1883 | 2744 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2745 {"warn", NULL, P_BOOL|P_VI_DEF, |
2746 (char_u *)&p_warn, PV_NONE, | |
1883 | 2747 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2748 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR, |
2749 (char_u *)&p_wiv, PV_NONE, | |
1883 | 2750 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2751 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST, |
2752 (char_u *)&p_ww, PV_NONE, | |
1883 | 2753 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT}, |
7 | 2754 {"wildchar", "wc", P_NUM|P_VIM, |
2755 (char_u *)&p_wc, PV_NONE, | |
1883 | 2756 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB} |
2757 SCRIPTID_INIT}, | |
2652 | 2758 {"wildcharm", "wcm", P_NUM|P_VI_DEF, |
7 | 2759 (char_u *)&p_wcm, PV_NONE, |
1883 | 2760 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2761 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2762 #ifdef FEAT_WILDIGN | |
2763 (char_u *)&p_wig, PV_NONE, | |
2764 #else | |
2765 (char_u *)NULL, PV_NONE, | |
2766 #endif | |
1883 | 2767 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
2652 | 2768 {"wildignorecase", "wic", P_BOOL|P_VI_DEF, |
2769 (char_u *)&p_wic, PV_NONE, | |
2770 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, | |
7 | 2771 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF, |
2772 #ifdef FEAT_WILDMENU | |
2773 (char_u *)&p_wmnu, PV_NONE, | |
2774 #else | |
2775 (char_u *)NULL, PV_NONE, | |
2776 #endif | |
1883 | 2777 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2778 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
2779 (char_u *)&p_wim, PV_NONE, | |
1883 | 2780 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT}, |
40 | 2781 {"wildoptions", "wop", P_STRING|P_VI_DEF, |
2782 #ifdef FEAT_CMDL_COMPL | |
2783 (char_u *)&p_wop, PV_NONE, | |
2784 {(char_u *)"", (char_u *)0L} | |
2785 #else | |
2786 (char_u *)NULL, PV_NONE, | |
2787 {(char_u *)NULL, (char_u *)0L} | |
2788 #endif | |
1883 | 2789 SCRIPTID_INIT}, |
7 | 2790 {"winaltkeys", "wak", P_STRING|P_VI_DEF, |
2791 #ifdef FEAT_WAK | |
2792 (char_u *)&p_wak, PV_NONE, | |
2793 {(char_u *)"menu", (char_u *)0L} | |
2794 #else | |
2795 (char_u *)NULL, PV_NONE, | |
2796 {(char_u *)NULL, (char_u *)0L} | |
2797 #endif | |
1883 | 2798 SCRIPTID_INIT}, |
7 | 2799 {"window", "wi", P_NUM|P_VI_DEF, |
164 | 2800 (char_u *)&p_window, PV_NONE, |
1883 | 2801 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2802 {"winheight", "wh", P_NUM|P_VI_DEF, |
2803 #ifdef FEAT_WINDOWS | |
2804 (char_u *)&p_wh, PV_NONE, | |
2805 #else | |
2806 (char_u *)NULL, PV_NONE, | |
2807 #endif | |
1883 | 2808 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2809 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, |
694 | 2810 #ifdef FEAT_WINDOWS |
7 | 2811 (char_u *)VAR_WIN, PV_WFH, |
2812 #else | |
2813 (char_u *)NULL, PV_NONE, | |
2814 #endif | |
1883 | 2815 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
782 | 2816 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT, |
2817 #ifdef FEAT_VERTSPLIT | |
2818 (char_u *)VAR_WIN, PV_WFW, | |
2819 #else | |
2820 (char_u *)NULL, PV_NONE, | |
2821 #endif | |
1883 | 2822 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2823 {"winminheight", "wmh", P_NUM|P_VI_DEF, |
2824 #ifdef FEAT_WINDOWS | |
2825 (char_u *)&p_wmh, PV_NONE, | |
2826 #else | |
2827 (char_u *)NULL, PV_NONE, | |
2828 #endif | |
1883 | 2829 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2830 {"winminwidth", "wmw", P_NUM|P_VI_DEF, |
2831 #ifdef FEAT_VERTSPLIT | |
2832 (char_u *)&p_wmw, PV_NONE, | |
2833 #else | |
2834 (char_u *)NULL, PV_NONE, | |
2835 #endif | |
1883 | 2836 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2837 {"winwidth", "wiw", P_NUM|P_VI_DEF, |
2838 #ifdef FEAT_VERTSPLIT | |
2839 (char_u *)&p_wiw, PV_NONE, | |
2840 #else | |
2841 (char_u *)NULL, PV_NONE, | |
2842 #endif | |
1883 | 2843 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2844 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
2845 (char_u *)VAR_WIN, PV_WRAP, | |
1883 | 2846 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2847 {"wrapmargin", "wm", P_NUM|P_VI_DEF, |
2848 (char_u *)&p_wm, PV_WM, | |
1883 | 2849 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2850 {"wrapscan", "ws", P_BOOL|P_VI_DEF, |
2851 (char_u *)&p_ws, PV_NONE, | |
1883 | 2852 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2853 {"write", NULL, P_BOOL|P_VI_DEF, |
2854 (char_u *)&p_write, PV_NONE, | |
1883 | 2855 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2856 {"writeany", "wa", P_BOOL|P_VI_DEF, |
2857 (char_u *)&p_wa, PV_NONE, | |
1883 | 2858 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2859 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM, |
2860 (char_u *)&p_wb, PV_NONE, | |
2861 { | |
2862 #ifdef FEAT_WRITEBACKUP | |
2863 (char_u *)TRUE, | |
2864 #else | |
2865 (char_u *)FALSE, | |
2866 #endif | |
1883 | 2867 (char_u *)0L} SCRIPTID_INIT}, |
7 | 2868 {"writedelay", "wd", P_NUM|P_VI_DEF, |
2869 (char_u *)&p_wd, PV_NONE, | |
1883 | 2870 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, |
7 | 2871 |
2872 /* terminal output codes */ | |
36 | 2873 #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \ |
7 | 2874 (char_u *)&vvv, PV_NONE, \ |
1883 | 2875 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, |
7 | 2876 |
2877 p_term("t_AB", T_CAB) | |
2878 p_term("t_AF", T_CAF) | |
2879 p_term("t_AL", T_CAL) | |
2880 p_term("t_al", T_AL) | |
2881 p_term("t_bc", T_BC) | |
2882 p_term("t_cd", T_CD) | |
2883 p_term("t_ce", T_CE) | |
2884 p_term("t_cl", T_CL) | |
2885 p_term("t_cm", T_CM) | |
2886 p_term("t_Co", T_CCO) | |
2887 p_term("t_CS", T_CCS) | |
2888 p_term("t_cs", T_CS) | |
2889 #ifdef FEAT_VERTSPLIT | |
2890 p_term("t_CV", T_CSV) | |
2891 #endif | |
2892 p_term("t_ut", T_UT) | |
2893 p_term("t_da", T_DA) | |
2894 p_term("t_db", T_DB) | |
2895 p_term("t_DL", T_CDL) | |
2896 p_term("t_dl", T_DL) | |
2897 p_term("t_fs", T_FS) | |
2898 p_term("t_IE", T_CIE) | |
2899 p_term("t_IS", T_CIS) | |
2900 p_term("t_ke", T_KE) | |
2901 p_term("t_ks", T_KS) | |
2902 p_term("t_le", T_LE) | |
2903 p_term("t_mb", T_MB) | |
2904 p_term("t_md", T_MD) | |
2905 p_term("t_me", T_ME) | |
2906 p_term("t_mr", T_MR) | |
2907 p_term("t_ms", T_MS) | |
2908 p_term("t_nd", T_ND) | |
2909 p_term("t_op", T_OP) | |
2910 p_term("t_RI", T_CRI) | |
2911 p_term("t_RV", T_CRV) | |
4215 | 2912 p_term("t_u7", T_U7) |
7 | 2913 p_term("t_Sb", T_CSB) |
2914 p_term("t_Sf", T_CSF) | |
2915 p_term("t_se", T_SE) | |
2916 p_term("t_so", T_SO) | |
2917 p_term("t_sr", T_SR) | |
2918 p_term("t_ts", T_TS) | |
2919 p_term("t_te", T_TE) | |
2920 p_term("t_ti", T_TI) | |
2921 p_term("t_ue", T_UE) | |
2922 p_term("t_us", T_US) | |
2923 p_term("t_vb", T_VB) | |
2924 p_term("t_ve", T_VE) | |
2925 p_term("t_vi", T_VI) | |
2926 p_term("t_vs", T_VS) | |
2927 p_term("t_WP", T_CWP) | |
2928 p_term("t_WS", T_CWS) | |
36 | 2929 p_term("t_SI", T_CSI) |
2930 p_term("t_EI", T_CEI) | |
7 | 2931 p_term("t_xs", T_XS) |
2932 p_term("t_ZH", T_CZH) | |
2933 p_term("t_ZR", T_CZR) | |
2934 | |
2935 /* terminal key codes are not in here */ | |
2936 | |
1883 | 2937 /* end marker */ |
2938 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT} | |
7 | 2939 }; |
2940 | |
2941 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption)) | |
2942 | |
2943 #ifdef FEAT_MBYTE | |
2944 static char *(p_ambw_values[]) = {"single", "double", NULL}; | |
2945 #endif | |
2946 static char *(p_bg_values[]) = {"light", "dark", NULL}; | |
2947 static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL}; | |
2948 static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL}; | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
2949 #ifdef FEAT_CRYPT |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
2950 static char *(p_cm_values[]) = {"zip", "blowfish", NULL}; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
2951 #endif |
40 | 2952 #ifdef FEAT_CMDL_COMPL |
2953 static char *(p_wop_values[]) = {"tagfile", NULL}; | |
2954 #endif | |
7 | 2955 #ifdef FEAT_WAK |
2956 static char *(p_wak_values[]) = {"yes", "menu", "no", NULL}; | |
2957 #endif | |
2958 static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL}; | |
2959 #ifdef FEAT_VISUAL | |
2960 static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL}; | |
2961 static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL}; | |
2962 #endif | |
2963 #ifdef FEAT_VISUAL | |
2964 static char *(p_km_values[]) = {"startsel", "stopsel", NULL}; | |
2965 #endif | |
2966 #ifdef FEAT_BROWSE | |
2967 static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL}; | |
2968 #endif | |
2969 #ifdef FEAT_SCROLLBIND | |
2970 static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; | |
2971 #endif | |
839 | 2972 static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL}; |
7 | 2973 #ifdef FEAT_VERTSPLIT |
2974 static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; | |
2975 #endif | |
2976 #if defined(FEAT_QUICKFIX) | |
17 | 2977 # ifdef FEAT_AUTOCMD |
2978 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL}; | |
2979 # else | |
7 | 2980 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL}; |
17 | 2981 # endif |
7 | 2982 static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; |
2983 #endif | |
2984 static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; | |
2985 #ifdef FEAT_FOLDING | |
2986 static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", | |
540 | 2987 # ifdef FEAT_DIFF |
7 | 2988 "diff", |
540 | 2989 # endif |
7 | 2990 NULL}; |
2991 static char *(p_fcl_values[]) = {"all", NULL}; | |
2992 #endif | |
540 | 2993 #ifdef FEAT_INS_EXPAND |
731 | 2994 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL}; |
540 | 2995 #endif |
7 | 2996 |
2997 static void set_option_default __ARGS((int, int opt_flags, int compatible)); | |
2998 static void set_options_default __ARGS((int opt_flags)); | |
671 | 2999 static char_u *term_bg_default __ARGS((void)); |
634 | 3000 static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value)); |
7 | 3001 static char_u *illegal_char __ARGS((char_u *, int)); |
3002 static int string_to_key __ARGS((char_u *arg)); | |
3003 #ifdef FEAT_CMDWIN | |
3004 static char_u *check_cedit __ARGS((void)); | |
3005 #endif | |
3006 #ifdef FEAT_TITLE | |
3007 static void did_set_title __ARGS((int icon)); | |
3008 #endif | |
3009 static char_u *option_expand __ARGS((int opt_idx, char_u *val)); | |
3010 static void didset_options __ARGS((void)); | |
3011 static void check_string_option __ARGS((char_u **pp)); | |
681 | 3012 #if defined(FEAT_EVAL) || defined(PROTO) |
3013 static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags)); | |
3014 #else | |
3015 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
3016 #endif | |
7 | 3017 static void set_string_option_global __ARGS((int opt_idx, char_u **varp)); |
3018 static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags)); | |
3019 static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags)); | |
3020 static char_u *set_chars_option __ARGS((char_u **varp)); | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3021 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3022 static int int_cmp __ARGS((const void *a, const void *b)); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3023 #endif |
7 | 3024 #ifdef FEAT_CLIPBOARD |
3025 static char_u *check_clipboard_option __ARGS((void)); | |
3026 #endif | |
744 | 3027 #ifdef FEAT_SPELL |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3028 static char_u *compile_cap_prog __ARGS((synblock_T *synblock)); |
386 | 3029 #endif |
694 | 3030 #ifdef FEAT_EVAL |
3031 static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id)); | |
3032 #endif | |
7 | 3033 static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags)); |
274 | 3034 static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags)); |
7 | 3035 static void check_redraw __ARGS((long_u flags)); |
3036 static int findoption __ARGS((char_u *)); | |
3037 static int find_key_option __ARGS((char_u *)); | |
3038 static void showoptions __ARGS((int all, int opt_flags)); | |
3039 static int optval_default __ARGS((struct vimoption *, char_u *varp)); | |
3040 static void showoneopt __ARGS((struct vimoption *, int opt_flags)); | |
3041 static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand)); | |
3042 static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep)); | |
3043 static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value)); | |
3044 static int istermoption __ARGS((struct vimoption *)); | |
3045 static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags)); | |
3046 static char_u *get_varp __ARGS((struct vimoption *)); | |
3047 static void option_value2string __ARGS((struct vimoption *, int opt_flags)); | |
3048 static int wc_use_keyname __ARGS((char_u *varp, long *wcp)); | |
3049 #ifdef FEAT_LANGMAP | |
3050 static void langmap_init __ARGS((void)); | |
3051 static void langmap_set __ARGS((void)); | |
3052 #endif | |
3053 static void paste_option_changed __ARGS((void)); | |
3054 static void compatible_set __ARGS((void)); | |
3055 #ifdef FEAT_LINEBREAK | |
3056 static void fill_breakat_flags __ARGS((void)); | |
3057 #endif | |
3058 static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list)); | |
3059 static int check_opt_strings __ARGS((char_u *val, char **values, int)); | |
3060 static int check_opt_wim __ARGS((void)); | |
3061 | |
3062 /* | |
3063 * Initialize the options, first part. | |
3064 * | |
3065 * Called only once from main(), just after creating the first buffer. | |
3066 */ | |
3067 void | |
3068 set_init_1() | |
3069 { | |
3070 char_u *p; | |
3071 int opt_idx; | |
835 | 3072 long_u n; |
7 | 3073 |
3074 #ifdef FEAT_LANGMAP | |
3075 langmap_init(); | |
3076 #endif | |
3077 | |
3078 /* Be Vi compatible by default */ | |
3079 p_cp = TRUE; | |
3080 | |
164 | 3081 /* Use POSIX compatibility when $VIM_POSIX is set. */ |
3082 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) | |
168 | 3083 { |
164 | 3084 set_string_default("cpo", (char_u *)CPO_ALL); |
168 | 3085 set_string_default("shm", (char_u *)"A"); |
3086 } | |
164 | 3087 |
7 | 3088 /* |
3089 * Find default value for 'shell' option. | |
161 | 3090 * Don't use it if it is empty. |
7 | 3091 */ |
161 | 3092 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) |
7 | 3093 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
3094 # ifdef __EMX__ | |
161 | 3095 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL) |
7 | 3096 # endif |
161 | 3097 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) |
7 | 3098 # ifdef WIN3264 |
161 | 3099 || ((p = default_shell()) != NULL && *p != NUL) |
7 | 3100 # endif |
3101 #endif | |
161 | 3102 ) |
7 | 3103 set_string_default("sh", p); |
3104 | |
3105 #ifdef FEAT_WILDIGN | |
3106 /* | |
3107 * Set the default for 'backupskip' to include environment variables for | |
3108 * temp files. | |
3109 */ | |
3110 { | |
3111 # ifdef UNIX | |
3112 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; | |
3113 # else | |
3114 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; | |
3115 # endif | |
170 | 3116 int len; |
3117 garray_T ga; | |
3118 int mustfree; | |
7 | 3119 |
3120 ga_init2(&ga, 1, 100); | |
3121 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) | |
3122 { | |
170 | 3123 mustfree = FALSE; |
7 | 3124 # ifdef UNIX |
3125 if (*names[n] == NUL) | |
3126 p = (char_u *)"/tmp"; | |
3127 else | |
3128 # endif | |
170 | 3129 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 3130 if (p != NULL && *p != NUL) |
3131 { | |
3132 /* First time count the NUL, otherwise count the ','. */ | |
835 | 3133 len = (int)STRLEN(p) + 3; |
7 | 3134 if (ga_grow(&ga, len) == OK) |
3135 { | |
3136 if (ga.ga_len > 0) | |
3137 STRCAT(ga.ga_data, ","); | |
3138 STRCAT(ga.ga_data, p); | |
3139 add_pathsep(ga.ga_data); | |
3140 STRCAT(ga.ga_data, "*"); | |
3141 ga.ga_len += len; | |
3142 } | |
3143 } | |
170 | 3144 if (mustfree) |
3145 vim_free(p); | |
7 | 3146 } |
3147 if (ga.ga_data != NULL) | |
3148 { | |
3149 set_string_default("bsk", ga.ga_data); | |
3150 vim_free(ga.ga_data); | |
3151 } | |
3152 } | |
3153 #endif | |
3154 | |
3155 /* | |
3156 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
3157 */ | |
3158 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 3159 if (opt_idx >= 0) |
3160 { | |
7 | 3161 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 3162 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
3163 #endif | |
3164 { | |
7 | 3165 #ifdef HAVE_AVAIL_MEM |
838 | 3166 /* Use amount of memory available at this moment. */ |
3634 | 3167 n = (mch_avail_mem(FALSE) >> 1); |
7 | 3168 #else |
3169 # ifdef HAVE_TOTAL_MEM | |
838 | 3170 /* Use amount of memory available to Vim. */ |
1110 | 3171 n = (mch_total_mem(FALSE) >> 1); |
7 | 3172 # else |
838 | 3173 n = (0x7fffffff >> 11); |
7 | 3174 # endif |
3175 #endif | |
3176 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 3177 opt_idx = findoption((char_u *)"maxmem"); |
3178 if (opt_idx >= 0) | |
3179 { | |
3180 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) | |
3181 if ((long)options[opt_idx].def_val[VI_DEFAULT] > n | |
3182 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L) | |
3183 #endif | |
3184 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
3185 } | |
3186 } | |
7 | 3187 } |
3188 | |
3189 #ifdef FEAT_GUI_W32 | |
3190 /* force 'shortname' for Win32s */ | |
3191 if (gui_is_win32s()) | |
838 | 3192 { |
3193 opt_idx = findoption((char_u *)"shortname"); | |
3194 if (opt_idx >= 0) | |
3195 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE; | |
3196 } | |
7 | 3197 #endif |
3198 | |
3199 #ifdef FEAT_SEARCHPATH | |
3200 { | |
3201 char_u *cdpath; | |
3202 char_u *buf; | |
3203 int i; | |
3204 int j; | |
170 | 3205 int mustfree = FALSE; |
7 | 3206 |
3207 /* Initialize the 'cdpath' option's default value. */ | |
170 | 3208 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 3209 if (cdpath != NULL) |
3210 { | |
3211 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2)); | |
3212 if (buf != NULL) | |
3213 { | |
3214 buf[0] = ','; /* start with ",", current dir first */ | |
3215 j = 1; | |
3216 for (i = 0; cdpath[i] != NUL; ++i) | |
3217 { | |
3218 if (vim_ispathlistsep(cdpath[i])) | |
3219 buf[j++] = ','; | |
3220 else | |
3221 { | |
3222 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
3223 buf[j++] = '\\'; | |
3224 buf[j++] = cdpath[i]; | |
3225 } | |
3226 } | |
3227 buf[j] = NUL; | |
3228 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 3229 if (opt_idx >= 0) |
3230 { | |
3231 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
3232 options[opt_idx].flags |= P_DEF_ALLOCED; | |
3233 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
3234 else |
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
3235 vim_free(buf); /* cannot happen */ |
7 | 3236 } |
170 | 3237 if (mustfree) |
3238 vim_free(cdpath); | |
7 | 3239 } |
3240 } | |
3241 #endif | |
3242 | |
3243 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) | |
3244 /* Set print encoding on platforms that don't default to latin1 */ | |
3245 set_string_default("penc", | |
3246 # if defined(MSWIN) || defined(OS2) | |
3247 (char_u *)"cp1252" | |
3248 # else | |
3249 # ifdef VMS | |
3250 (char_u *)"dec-mcs" | |
3251 # else | |
3252 # ifdef EBCDIC | |
3253 (char_u *)"ebcdic-uk" | |
3254 # else | |
3255 # ifdef MAC | |
3256 (char_u *)"mac-roman" | |
3257 # else /* HPUX */ | |
3258 (char_u *)"hp-roman8" | |
3259 # endif | |
3260 # endif | |
3261 # endif | |
3262 # endif | |
3263 ); | |
3264 #endif | |
3265 | |
3266 #ifdef FEAT_POSTSCRIPT | |
3267 /* 'printexpr' must be allocated to be able to evaluate it. */ | |
3268 set_string_default("pexpr", | |
8 | 3269 # if defined(MSWIN) || defined(MSDOS) || defined(OS2) |
3270 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" | |
7 | 3271 # else |
3272 # ifdef VMS | |
3273 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" | |
3274 | |
3275 # else | |
3276 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" | |
3277 # endif | |
3278 # endif | |
3279 ); | |
3280 #endif | |
3281 | |
3282 /* | |
3283 * Set all the options (except the terminal options) to their default | |
3284 * value. Also set the global value for local options. | |
3285 */ | |
3286 set_options_default(0); | |
3287 | |
3288 #ifdef FEAT_GUI | |
3289 if (found_reverse_arg) | |
3290 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | |
3291 #endif | |
3292 | |
3293 curbuf->b_p_initialized = TRUE; | |
3294 curbuf->b_p_ar = -1; /* no local 'autoread' value */ | |
3295 check_buf_options(curbuf); | |
3296 check_win_options(curwin); | |
3297 check_options(); | |
3298 | |
3299 /* Must be before option_expand(), because that one needs vim_isIDc() */ | |
3300 didset_options(); | |
3301 | |
744 | 3302 #ifdef FEAT_SPELL |
227 | 3303 /* Use the current chartab for the generic chartab. */ |
3304 init_spell_chartab(); | |
3305 #endif | |
3306 | |
7 | 3307 #ifdef FEAT_LINEBREAK |
3308 /* | |
3309 * initialize the table for 'breakat'. | |
3310 */ | |
3311 fill_breakat_flags(); | |
3312 #endif | |
3313 | |
3314 /* | |
3315 * Expand environment variables and things like "~" for the defaults. | |
3316 * If option_expand() returns non-NULL the variable is expanded. This can | |
3317 * only happen for non-indirect options. | |
3318 * Also set the default to the expanded value, so ":set" does not list | |
3319 * them. | |
3320 * Don't set the P_ALLOCED flag, because we don't want to free the | |
3321 * default. | |
3322 */ | |
3323 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) | |
3324 { | |
3325 if ((options[opt_idx].flags & P_GETTEXT) | |
3326 && options[opt_idx].var != NULL) | |
3327 p = (char_u *)_(*(char **)options[opt_idx].var); | |
3328 else | |
3329 p = option_expand(opt_idx, NULL); | |
3330 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
3331 { | |
3332 *(char_u **)options[opt_idx].var = p; | |
3333 /* VIMEXP | |
3334 * Defaults for all expanded options are currently the same for Vi | |
3335 * and Vim. When this changes, add some code here! Also need to | |
3336 * split P_DEF_ALLOCED in two. | |
3337 */ | |
3338 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
3339 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
3340 options[opt_idx].def_val[VI_DEFAULT] = p; | |
3341 options[opt_idx].flags |= P_DEF_ALLOCED; | |
3342 } | |
3343 } | |
3344 | |
3345 /* Initialize the highlight_attr[] table. */ | |
3346 highlight_changed(); | |
3347 | |
3348 save_file_ff(curbuf); /* Buffer is unchanged */ | |
3349 | |
3350 /* Parse default for 'wildmode' */ | |
3351 check_opt_wim(); | |
3352 | |
3353 #if defined(FEAT_ARABIC) | |
3354 /* Detect use of mlterm. | |
3355 * Mlterm is a terminal emulator akin to xterm that has some special | |
3356 * abilities (bidi namely). | |
3357 * NOTE: mlterm's author is being asked to 'set' a variable | |
3358 * instead of an environment variable due to inheritance. | |
3359 */ | |
3360 if (mch_getenv((char_u *)"MLTERM") != NULL) | |
3361 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | |
3362 #endif | |
3363 | |
3364 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
3365 /* Parse default for 'fillchars'. */ | |
3366 (void)set_chars_option(&p_fcs); | |
3367 #endif | |
3368 | |
3369 #ifdef FEAT_CLIPBOARD | |
3370 /* Parse default for 'clipboard' */ | |
3371 (void)check_clipboard_option(); | |
3372 #endif | |
3373 | |
3374 #ifdef FEAT_MBYTE | |
3375 # if defined(WIN3264) && defined(FEAT_GETTEXT) | |
3376 /* | |
3377 * If $LANG isn't set, try to get a good value for it. This makes the | |
3378 * right language be used automatically. Don't do this for English. | |
3379 */ | |
3380 if (mch_getenv((char_u *)"LANG") == NULL) | |
3381 { | |
3382 char buf[20]; | |
3383 | |
3384 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. | |
3385 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use | |
3386 * only the first two. */ | |
3387 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, | |
3388 (LPTSTR)buf, 20); | |
3389 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
3390 { | |
3391 /* There are a few exceptions (probably more) */ | |
3392 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) | |
3393 STRCPY(buf, "zh_TW"); | |
3394 else if (STRNICMP(buf, "chs", 3) == 0 | |
3395 || STRNICMP(buf, "zhc", 3) == 0) | |
3396 STRCPY(buf, "zh_CN"); | |
3397 else if (STRNICMP(buf, "jp", 2) == 0) | |
3398 STRCPY(buf, "ja"); | |
3399 else | |
3400 buf[2] = NUL; /* truncate to two-letter code */ | |
3401 vim_setenv("LANG", buf); | |
3402 } | |
3403 } | |
168 | 3404 # else |
767 | 3405 # ifdef MACOS_CONVERT |
1622 | 3406 /* Moved to os_mac_conv.c to avoid dependency problems. */ |
3407 mac_lang_init(); | |
168 | 3408 # endif |
7 | 3409 # endif |
3410 | |
3411 /* enc_locale() will try to find the encoding of the current locale. */ | |
3412 p = enc_locale(); | |
3413 if (p != NULL) | |
3414 { | |
3415 char_u *save_enc; | |
3416 | |
3417 /* Try setting 'encoding' and check if the value is valid. | |
3418 * If not, go back to the default "latin1". */ | |
3419 save_enc = p_enc; | |
3420 p_enc = p; | |
1080 | 3421 if (STRCMP(p_enc, "gb18030") == 0) |
3422 { | |
3423 /* We don't support "gb18030", but "cp936" is a good substitute | |
3424 * for practical purposes, thus use that. It's not an alias to | |
3425 * still support conversion between gb18030 and utf-8. */ | |
3426 p_enc = vim_strsave((char_u *)"cp936"); | |
3427 vim_free(p); | |
3428 } | |
7 | 3429 if (mb_init() == NULL) |
3430 { | |
3431 opt_idx = findoption((char_u *)"encoding"); | |
838 | 3432 if (opt_idx >= 0) |
3433 { | |
3434 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
3435 options[opt_idx].flags |= P_DEF_ALLOCED; | |
3436 } | |
7 | 3437 |
24 | 3438 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \ |
3439 || defined(VMS) | |
3440 if (STRCMP(p_enc, "latin1") == 0 | |
3441 # ifdef FEAT_MBYTE | |
3442 || enc_utf8 | |
3443 # endif | |
3444 ) | |
3445 { | |
714 | 3446 /* Adjust the default for 'isprint' and 'iskeyword' to match |
3447 * latin1. Also set the defaults for when 'nocompatible' is | |
3448 * set. */ | |
24 | 3449 set_string_option_direct((char_u *)"isp", -1, |
719 | 3450 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 3451 set_string_option_direct((char_u *)"isk", -1, |
3452 ISK_LATIN1, OPT_FREE, SID_NONE); | |
3453 opt_idx = findoption((char_u *)"isp"); | |
838 | 3454 if (opt_idx >= 0) |
3455 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 3456 opt_idx = findoption((char_u *)"isk"); |
838 | 3457 if (opt_idx >= 0) |
3458 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 3459 (void)init_chartab(); |
3460 } | |
3461 #endif | |
3462 | |
7 | 3463 # if defined(WIN3264) && !defined(FEAT_GUI) |
3464 /* Win32 console: When GetACP() returns a different value from | |
3465 * GetConsoleCP() set 'termencoding'. */ | |
3466 if (GetACP() != GetConsoleCP()) | |
3467 { | |
3468 char buf[50]; | |
3469 | |
3470 sprintf(buf, "cp%ld", (long)GetConsoleCP()); | |
3471 p_tenc = vim_strsave((char_u *)buf); | |
3472 if (p_tenc != NULL) | |
3473 { | |
3474 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 3475 if (opt_idx >= 0) |
3476 { | |
3477 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
3478 options[opt_idx].flags |= P_DEF_ALLOCED; | |
3479 } | |
7 | 3480 convert_setup(&input_conv, p_tenc, p_enc); |
3481 convert_setup(&output_conv, p_enc, p_tenc); | |
3482 } | |
3483 else | |
3484 p_tenc = empty_option; | |
3485 } | |
3486 # endif | |
170 | 3487 # if defined(WIN3264) && defined(FEAT_MBYTE) |
3488 /* $HOME may have characters in active code page. */ | |
3489 init_homedir(); | |
3490 # endif | |
7 | 3491 } |
3492 else | |
3493 { | |
3494 vim_free(p_enc); | |
3495 p_enc = save_enc; | |
3496 } | |
3497 } | |
3498 #endif | |
3499 | |
3500 #ifdef FEAT_MULTI_LANG | |
3501 /* Set the default for 'helplang'. */ | |
3502 set_helplang_default(get_mess_lang()); | |
3503 #endif | |
3504 } | |
3505 | |
3506 /* | |
3507 * Set an option to its default value. | |
3508 * This does not take care of side effects! | |
3509 */ | |
3510 static void | |
3511 set_option_default(opt_idx, opt_flags, compatible) | |
3512 int opt_idx; | |
3513 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ | |
3514 int compatible; /* use Vi default value */ | |
3515 { | |
3516 char_u *varp; /* pointer to variable for current option */ | |
3517 int dvi; /* index in def_val[] */ | |
3518 long_u flags; | |
681 | 3519 long_u *flagsp; |
7 | 3520 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
3521 | |
3522 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
3523 flags = options[opt_idx].flags; | |
320 | 3524 if (varp != NULL) /* skip hidden option, nothing to do for it */ |
7 | 3525 { |
3526 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
3527 if (flags & P_STRING) | |
3528 { | |
3529 /* Use set_string_option_direct() for local options to handle | |
3530 * freeing and allocating the value. */ | |
3531 if (options[opt_idx].indir != PV_NONE) | |
3532 set_string_option_direct(NULL, opt_idx, | |
694 | 3533 options[opt_idx].def_val[dvi], opt_flags, 0); |
7 | 3534 else |
3535 { | |
3536 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) | |
3537 free_string_option(*(char_u **)(varp)); | |
3538 *(char_u **)varp = options[opt_idx].def_val[dvi]; | |
3539 options[opt_idx].flags &= ~P_ALLOCED; | |
3540 } | |
3541 } | |
3542 else if (flags & P_NUM) | |
3543 { | |
1017 | 3544 if (options[opt_idx].indir == PV_SCROLL) |
7 | 3545 win_comp_scroll(curwin); |
3546 else | |
3547 { | |
840 | 3548 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi]; |
7 | 3549 /* May also set global value for local option. */ |
3550 if (both) | |
3551 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
3552 *(long *)varp; | |
3553 } | |
3554 } | |
3555 else /* P_BOOL */ | |
3556 { | |
840 | 3557 /* the cast to long is required for Manx C, long_i is needed for |
3558 * MSVC */ | |
3559 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; | |
1111 | 3560 #ifdef UNIX |
3561 /* 'modeline' defaults to off for root */ | |
3562 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) | |
3563 *(int *)varp = FALSE; | |
3564 #endif | |
7 | 3565 /* May also set global value for local option. */ |
3566 if (both) | |
3567 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
3568 *(int *)varp; | |
3569 } | |
634 | 3570 |
681 | 3571 /* The default value is not insecure. */ |
3572 flagsp = insecure_flag(opt_idx, opt_flags); | |
3573 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 3574 } |
3575 | |
3576 #ifdef FEAT_EVAL | |
694 | 3577 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); |
7 | 3578 #endif |
3579 } | |
3580 | |
3581 /* | |
3582 * Set all options (except terminal options) to their default value. | |
3583 */ | |
3584 static void | |
3585 set_options_default(opt_flags) | |
3586 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ | |
3587 { | |
3588 int i; | |
3589 #ifdef FEAT_WINDOWS | |
3590 win_T *wp; | |
671 | 3591 tabpage_T *tp; |
7 | 3592 #endif |
3593 | |
3594 for (i = 0; !istermoption(&options[i]); i++) | |
3595 if (!(options[i].flags & P_NODEFAULT)) | |
3596 set_option_default(i, opt_flags, p_cp); | |
3597 | |
3598 #ifdef FEAT_WINDOWS | |
3599 /* The 'scroll' option must be computed for all windows. */ | |
671 | 3600 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 3601 win_comp_scroll(wp); |
3602 #else | |
3603 win_comp_scroll(curwin); | |
3604 #endif | |
3605 } | |
3606 | |
3607 /* | |
3608 * Set the Vi-default value of a string option. | |
3609 * Used for 'sh', 'backupskip' and 'term'. | |
3610 */ | |
3611 void | |
3612 set_string_default(name, val) | |
3613 char *name; | |
3614 char_u *val; | |
3615 { | |
3616 char_u *p; | |
3617 int opt_idx; | |
3618 | |
3619 p = vim_strsave(val); | |
3620 if (p != NULL) /* we don't want a NULL */ | |
3621 { | |
3622 opt_idx = findoption((char_u *)name); | |
838 | 3623 if (opt_idx >= 0) |
3624 { | |
3625 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
3626 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
3627 options[opt_idx].def_val[VI_DEFAULT] = p; | |
3628 options[opt_idx].flags |= P_DEF_ALLOCED; | |
3629 } | |
7 | 3630 } |
3631 } | |
3632 | |
3633 /* | |
3634 * Set the Vi-default value of a number option. | |
3635 * Used for 'lines' and 'columns'. | |
3636 */ | |
3637 void | |
3638 set_number_default(name, val) | |
3639 char *name; | |
3640 long val; | |
3641 { | |
838 | 3642 int opt_idx; |
3643 | |
3644 opt_idx = findoption((char_u *)name); | |
3645 if (opt_idx >= 0) | |
840 | 3646 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 3647 } |
3648 | |
359 | 3649 #if defined(EXITFREE) || defined(PROTO) |
3650 /* | |
3651 * Free all options. | |
3652 */ | |
3653 void | |
3654 free_all_options() | |
3655 { | |
3656 int i; | |
3657 | |
3658 for (i = 0; !istermoption(&options[i]); i++) | |
3659 { | |
3660 if (options[i].indir == PV_NONE) | |
3661 { | |
3662 /* global option: free value and default value. */ | |
3663 if (options[i].flags & P_ALLOCED && options[i].var != NULL) | |
3664 free_string_option(*(char_u **)options[i].var); | |
3665 if (options[i].flags & P_DEF_ALLOCED) | |
3666 free_string_option(options[i].def_val[VI_DEFAULT]); | |
3667 } | |
3668 else if (options[i].var != VAR_WIN | |
3669 && (options[i].flags & P_STRING)) | |
3670 /* buffer-local option: free global value */ | |
3671 free_string_option(*(char_u **)options[i].var); | |
3672 } | |
3673 } | |
3674 #endif | |
3675 | |
3676 | |
7 | 3677 /* |
3678 * Initialize the options, part two: After getting Rows and Columns and | |
3679 * setting 'term'. | |
3680 */ | |
3681 void | |
3682 set_init_2() | |
3683 { | |
164 | 3684 int idx; |
3685 | |
7 | 3686 /* |
3687 * 'scroll' defaults to half the window height. Note that this default is | |
3688 * wrong when the window height changes. | |
3689 */ | |
836 | 3690 set_number_default("scroll", (long)((long_u)Rows >> 1)); |
168 | 3691 idx = findoption((char_u *)"scroll"); |
838 | 3692 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 3693 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 3694 comp_col(); |
3695 | |
164 | 3696 /* |
3697 * 'window' is only for backwards compatibility with Vi. | |
3698 * Default is Rows - 1. | |
3699 */ | |
857 | 3700 if (!option_was_set((char_u *)"window")) |
164 | 3701 p_window = Rows - 1; |
3702 set_number_default("window", Rows - 1); | |
3703 | |
671 | 3704 /* For DOS console the default is always black. */ |
7 | 3705 #if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)) |
671 | 3706 /* |
3707 * If 'background' wasn't set by the user, try guessing the value, | |
3708 * depending on the terminal name. Only need to check for terminals | |
3709 * with a dark background, that can handle color. | |
3710 */ | |
3711 idx = findoption((char_u *)"bg"); | |
838 | 3712 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
3713 && *term_bg_default() == 'd') | |
671 | 3714 { |
694 | 3715 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); |
671 | 3716 /* don't mark it as set, when starting the GUI it may be |
3717 * changed again */ | |
3718 options[idx].flags &= ~P_WAS_SET; | |
7 | 3719 } |
3720 #endif | |
440 | 3721 |
3722 #ifdef CURSOR_SHAPE | |
3723 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ | |
3724 #endif | |
3725 #ifdef FEAT_MOUSESHAPE | |
3726 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ | |
3727 #endif | |
3728 #ifdef FEAT_PRINTER | |
3729 (void)parse_printoptions(); /* parse 'printoptions' default value */ | |
3730 #endif | |
7 | 3731 } |
3732 | |
3733 /* | |
671 | 3734 * Return "dark" or "light" depending on the kind of terminal. |
3735 * This is just guessing! Recognized are: | |
3736 * "linux" Linux console | |
3737 * "screen.linux" Linux console with screen | |
3738 * "cygwin" Cygwin shell | |
3739 * "putty" Putty program | |
3740 * We also check the COLORFGBG environment variable, which is set by | |
3741 * rxvt and derivatives. This variable contains either two or three | |
3742 * values separated by semicolons; we want the last value in either | |
3743 * case. If this value is 0-6 or 8, our background is dark. | |
3744 */ | |
3745 static char_u * | |
3746 term_bg_default() | |
3747 { | |
3748 #if defined(MSDOS) || defined(OS2) || defined(WIN3264) | |
3749 /* DOS console nearly always black */ | |
3750 return (char_u *)"dark"; | |
3751 #else | |
677 | 3752 char_u *p; |
3753 | |
671 | 3754 if (STRCMP(T_NAME, "linux") == 0 |
3755 || STRCMP(T_NAME, "screen.linux") == 0 | |
3756 || STRCMP(T_NAME, "cygwin") == 0 | |
3757 || STRCMP(T_NAME, "putty") == 0 | |
3758 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL | |
3759 && (p = vim_strrchr(p, ';')) != NULL | |
3760 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') | |
3761 && p[2] == NUL)) | |
3762 return (char_u *)"dark"; | |
3763 return (char_u *)"light"; | |
3764 #endif | |
3765 } | |
3766 | |
3767 /* | |
7 | 3768 * Initialize the options, part three: After reading the .vimrc |
3769 */ | |
3770 void | |
3771 set_init_3() | |
3772 { | |
3773 #if defined(UNIX) || defined(OS2) || defined(WIN3264) | |
3774 /* | |
3775 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
3776 * This is done after other initializations, where 'shell' might have been | |
3777 * set, but only if they have not been set before. | |
3778 */ | |
3779 char_u *p; | |
3780 int idx_srr; | |
3781 int do_srr; | |
3782 #ifdef FEAT_QUICKFIX | |
3783 int idx_sp; | |
3784 int do_sp; | |
3785 #endif | |
3786 | |
3787 idx_srr = findoption((char_u *)"srr"); | |
838 | 3788 if (idx_srr < 0) |
3789 do_srr = FALSE; | |
3790 else | |
3791 do_srr = !(options[idx_srr].flags & P_WAS_SET); | |
7 | 3792 #ifdef FEAT_QUICKFIX |
3793 idx_sp = findoption((char_u *)"sp"); | |
838 | 3794 if (idx_sp < 0) |
3795 do_sp = FALSE; | |
3796 else | |
3797 do_sp = !(options[idx_sp].flags & P_WAS_SET); | |
7 | 3798 #endif |
3799 | |
3800 /* | |
3801 * Isolate the name of the shell: | |
3802 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f". | |
3803 * - Remove any argument. E.g., "csh -f" -> "csh". | |
2135
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3804 * But don't allow a space in the path, so that this works: |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3805 * "/usr/bin/csh --rcfile ~/.cshrc" |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3806 * But don't do that for Windows, it's common to have a space in the path. |
7 | 3807 */ |
2135
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3808 #ifdef WIN3264 |
7 | 3809 p = gettail(p_sh); |
3810 p = vim_strnsave(p, (int)(skiptowhite(p) - p)); | |
2135
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3811 #else |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3812 p = skiptowhite(p_sh); |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3813 if (*p == NUL) |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3814 { |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3815 /* No white space, use the tail. */ |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3816 p = vim_strsave(gettail(p_sh)); |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3817 } |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3818 else |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3819 { |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3820 char_u *p1, *p2; |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3821 |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3822 /* Find the last path separator before the space. */ |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3823 p1 = p_sh; |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3824 for (p2 = p_sh; p2 < p; mb_ptr_adv(p2)) |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3825 if (vim_ispathsep(*p2)) |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3826 p1 = p2 + 1; |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3827 p = vim_strnsave(p1, (int)(p - p1)); |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3828 } |
7aee5e68548a
updated for version 7.2.417
Bram Moolenaar <bram@zimbu.org>
parents:
2086
diff
changeset
|
3829 #endif |
7 | 3830 if (p != NULL) |
3831 { | |
3832 /* | |
3833 * Default for p_sp is "| tee", for p_srr is ">". | |
3834 * For known shells it is changed here to include stderr. | |
3835 */ | |
3836 if ( fnamecmp(p, "csh") == 0 | |
3837 || fnamecmp(p, "tcsh") == 0 | |
3838 # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */ | |
3839 || fnamecmp(p, "csh.exe") == 0 | |
3840 || fnamecmp(p, "tcsh.exe") == 0 | |
3841 # endif | |
3842 ) | |
3843 { | |
3844 #if defined(FEAT_QUICKFIX) | |
3845 if (do_sp) | |
3846 { | |
3847 # ifdef WIN3264 | |
3848 p_sp = (char_u *)">&"; | |
3849 # else | |
3850 p_sp = (char_u *)"|& tee"; | |
3851 # endif | |
3852 options[idx_sp].def_val[VI_DEFAULT] = p_sp; | |
3853 } | |
3854 #endif | |
3855 if (do_srr) | |
3856 { | |
3857 p_srr = (char_u *)">&"; | |
3858 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
3859 } | |
3860 } | |
3861 else | |
3862 # ifndef OS2 /* Always use bourne shell style redirection if we reach this */ | |
3863 if ( fnamecmp(p, "sh") == 0 | |
3864 || fnamecmp(p, "ksh") == 0 | |
2774 | 3865 || fnamecmp(p, "mksh") == 0 |
3866 || fnamecmp(p, "pdksh") == 0 | |
7 | 3867 || fnamecmp(p, "zsh") == 0 |
836 | 3868 || fnamecmp(p, "zsh-beta") == 0 |
7 | 3869 || fnamecmp(p, "bash") == 0 |
3870 # ifdef WIN3264 | |
3871 || fnamecmp(p, "cmd") == 0 | |
3872 || fnamecmp(p, "sh.exe") == 0 | |
3873 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 3874 || fnamecmp(p, "mksh.exe") == 0 |
3875 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 3876 || fnamecmp(p, "zsh.exe") == 0 |
836 | 3877 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 3878 || fnamecmp(p, "bash.exe") == 0 |
3879 || fnamecmp(p, "cmd.exe") == 0 | |
3880 # endif | |
3881 ) | |
3882 # endif | |
3883 { | |
3884 #if defined(FEAT_QUICKFIX) | |
3885 if (do_sp) | |
3886 { | |
3887 # ifdef WIN3264 | |
3888 p_sp = (char_u *)">%s 2>&1"; | |
3889 # else | |
3890 p_sp = (char_u *)"2>&1| tee"; | |
3891 # endif | |
3892 options[idx_sp].def_val[VI_DEFAULT] = p_sp; | |
3893 } | |
3894 #endif | |
3895 if (do_srr) | |
3896 { | |
3897 p_srr = (char_u *)">%s 2>&1"; | |
3898 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
3899 } | |
3900 } | |
3901 vim_free(p); | |
3902 } | |
3903 #endif | |
3904 | |
3905 #if defined(MSDOS) || defined(WIN3264) || defined(OS2) | |
3906 /* | |
3352 | 3907 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
3908 * 'shell' option. | |
7 | 3909 * This is done after other initializations, where 'shell' might have been |
3910 * set, but only if they have not been set before. Default for p_shcf is | |
3911 * "/c", for p_shq is "". For "sh" like shells it is changed here to | |
3912 * "-c" and "\"", but not for DJGPP, because it starts the shell without | |
3913 * command.com. And for Win32 we need to set p_sxq instead. | |
3914 */ | |
10 | 3915 if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 3916 { |
3917 int idx3; | |
3918 | |
3919 idx3 = findoption((char_u *)"shcf"); | |
838 | 3920 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 3921 { |
3922 p_shcf = (char_u *)"-c"; | |
3923 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
3924 } | |
3925 | |
3926 # ifndef DJGPP | |
3927 # ifdef WIN3264 | |
3928 /* Somehow Win32 requires the quotes around the redirection too */ | |
3929 idx3 = findoption((char_u *)"sxq"); | |
838 | 3930 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 3931 { |
3932 p_sxq = (char_u *)"\""; | |
3933 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
3934 } | |
3935 # else | |
3936 idx3 = findoption((char_u *)"shq"); | |
838 | 3937 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 3938 { |
3939 p_shq = (char_u *)"\""; | |
3940 options[idx3].def_val[VI_DEFAULT] = p_shq; | |
3941 } | |
3942 # endif | |
3943 # endif | |
3944 } | |
3352 | 3945 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
3946 { | |
3947 int idx3; | |
3948 | |
3949 /* | |
3950 * cmd.exe on Windows will strip the first and last double quote given | |
3951 * on the command line, e.g. most of the time things like: | |
3952 * cmd /c "my path/to/echo" "my args to echo" | |
3953 * become: | |
3954 * my path/to/echo" "my args to echo | |
3955 * when executed. | |
3956 * | |
3357 | 3957 * To avoid this, set shellxquote to surround the command in |
3958 * parenthesis. This appears to make most commands work, without | |
3959 * breaking commands that worked previously, such as | |
3960 * '"path with spaces/cmd" "a&b"'. | |
3352 | 3961 */ |
3962 idx3 = findoption((char_u *)"sxq"); | |
3963 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
3964 { | |
3357 | 3965 p_sxq = (char_u *)"("; |
3352 | 3966 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
3967 } | |
3968 | |
3969 idx3 = findoption((char_u *)"shcf"); | |
3970 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
3971 { | |
3357 | 3972 p_shcf = (char_u *)"/c"; |
3352 | 3973 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
3974 } | |
3975 } | |
7 | 3976 #endif |
3977 | |
3978 #ifdef FEAT_TITLE | |
3979 set_title_defaults(); | |
3980 #endif | |
3981 } | |
3982 | |
3983 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
3984 /* | |
3985 * When 'helplang' is still at its default value, set it to "lang". | |
3986 * Only the first two characters of "lang" are used. | |
3987 */ | |
3988 void | |
3989 set_helplang_default(lang) | |
3990 char_u *lang; | |
3991 { | |
3992 int idx; | |
3993 | |
3994 if (lang == NULL || STRLEN(lang) < 2) /* safety check */ | |
3995 return; | |
3996 idx = findoption((char_u *)"hlg"); | |
838 | 3997 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
7 | 3998 { |
3999 if (options[idx].flags & P_ALLOCED) | |
4000 free_string_option(p_hlg); | |
4001 p_hlg = vim_strsave(lang); | |
4002 if (p_hlg == NULL) | |
4003 p_hlg = empty_option; | |
4004 else | |
18 | 4005 { |
4006 /* zh_CN becomes "cn", zh_TW becomes "tw". */ | |
4007 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) | |
4008 { | |
4009 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); | |
4010 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); | |
4011 } | |
7 | 4012 p_hlg[2] = NUL; |
18 | 4013 } |
7 | 4014 options[idx].flags |= P_ALLOCED; |
4015 } | |
4016 } | |
4017 #endif | |
4018 | |
4019 #ifdef FEAT_GUI | |
4020 static char_u *gui_bg_default __ARGS((void)); | |
4021 | |
4022 static char_u * | |
4023 gui_bg_default() | |
4024 { | |
4025 if (gui_get_lightness(gui.back_pixel) < 127) | |
4026 return (char_u *)"dark"; | |
4027 return (char_u *)"light"; | |
4028 } | |
4029 | |
4030 /* | |
4031 * Option initializations that can only be done after opening the GUI window. | |
4032 */ | |
4033 void | |
4034 init_gui_options() | |
4035 { | |
4036 /* Set the 'background' option according to the lightness of the | |
4037 * background color, unless the user has set it already. */ | |
4038 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) | |
4039 { | |
4040 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); | |
4041 highlight_changed(); | |
4042 } | |
4043 } | |
4044 #endif | |
4045 | |
4046 #ifdef FEAT_TITLE | |
4047 /* | |
4048 * 'title' and 'icon' only default to true if they have not been set or reset | |
4049 * in .vimrc and we can read the old value. | |
4050 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
4051 * they can be reset. This reduces startup time when using X on a remote | |
4052 * machine. | |
4053 */ | |
4054 void | |
4055 set_title_defaults() | |
4056 { | |
4057 int idx1; | |
4058 long val; | |
4059 | |
4060 /* | |
4061 * If GUI is (going to be) used, we can always set the window title and | |
4062 * icon name. Saves a bit of time, because the X11 display server does | |
4063 * not need to be contacted. | |
4064 */ | |
4065 idx1 = findoption((char_u *)"title"); | |
838 | 4066 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 4067 { |
4068 #ifdef FEAT_GUI | |
4069 if (gui.starting || gui.in_use) | |
4070 val = TRUE; | |
4071 else | |
4072 #endif | |
4073 val = mch_can_restore_title(); | |
840 | 4074 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 4075 p_title = val; |
4076 } | |
4077 idx1 = findoption((char_u *)"icon"); | |
838 | 4078 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 4079 { |
4080 #ifdef FEAT_GUI | |
4081 if (gui.starting || gui.in_use) | |
4082 val = TRUE; | |
4083 else | |
4084 #endif | |
4085 val = mch_can_restore_icon(); | |
840 | 4086 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 4087 p_icon = val; |
4088 } | |
4089 } | |
4090 #endif | |
4091 | |
4092 /* | |
4093 * Parse 'arg' for option settings. | |
4094 * | |
4095 * 'arg' may be IObuff, but only when no errors can be present and option | |
4096 * does not need to be expanded with option_expand(). | |
4097 * "opt_flags": | |
4098 * 0 for ":set" | |
717 | 4099 * OPT_GLOBAL for ":setglobal" |
4100 * OPT_LOCAL for ":setlocal" and a modeline | |
7 | 4101 * OPT_MODELINE for a modeline |
717 | 4102 * OPT_WINONLY to only set window-local options |
4103 * OPT_NOWIN to skip setting window-local options | |
7 | 4104 * |
4105 * returns FAIL if an error is detected, OK otherwise | |
4106 */ | |
4107 int | |
4108 do_set(arg, opt_flags) | |
4109 char_u *arg; /* option string (may be written to!) */ | |
4110 int opt_flags; | |
4111 { | |
4112 int opt_idx; | |
4113 char_u *errmsg; | |
4114 char_u errbuf[80]; | |
4115 char_u *startarg; | |
4116 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ | |
4117 int nextchar; /* next non-white char after option name */ | |
4118 int afterchar; /* character just after option name */ | |
4119 int len; | |
4120 int i; | |
4121 long value; | |
4122 int key; | |
4123 long_u flags; /* flags for current option */ | |
4124 char_u *varp = NULL; /* pointer to variable for current option */ | |
4125 int did_show = FALSE; /* already showed one value */ | |
4126 int adding; /* "opt+=arg" */ | |
4127 int prepending; /* "opt^=arg" */ | |
4128 int removing; /* "opt-=arg" */ | |
4129 int cp_val = 0; | |
4130 char_u key_name[2]; | |
4131 | |
4132 if (*arg == NUL) | |
4133 { | |
4134 showoptions(0, opt_flags); | |
168 | 4135 did_show = TRUE; |
4136 goto theend; | |
7 | 4137 } |
4138 | |
4139 while (*arg != NUL) /* loop to process all options */ | |
4140 { | |
4141 errmsg = NULL; | |
4142 startarg = arg; /* remember for error message */ | |
4143 | |
36 | 4144 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
4145 && !(opt_flags & OPT_MODELINE)) | |
7 | 4146 { |
4147 /* | |
4148 * ":set all" show all options. | |
4149 * ":set all&" set all options to their default value. | |
4150 */ | |
4151 arg += 3; | |
4152 if (*arg == '&') | |
4153 { | |
4154 ++arg; | |
4155 /* Only for :set command set global value of local options. */ | |
4156 set_options_default(OPT_FREE | opt_flags); | |
4157 } | |
4158 else | |
168 | 4159 { |
7 | 4160 showoptions(1, opt_flags); |
168 | 4161 did_show = TRUE; |
4162 } | |
7 | 4163 } |
36 | 4164 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 4165 { |
4166 showoptions(2, opt_flags); | |
4167 show_termcodes(); | |
168 | 4168 did_show = TRUE; |
7 | 4169 arg += 7; |
4170 } | |
4171 else | |
4172 { | |
4173 prefix = 1; | |
1911 | 4174 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 4175 { |
4176 prefix = 0; | |
4177 arg += 2; | |
4178 } | |
4179 else if (STRNCMP(arg, "inv", 3) == 0) | |
4180 { | |
4181 prefix = 2; | |
4182 arg += 3; | |
4183 } | |
4184 | |
4185 /* find end of name */ | |
4186 key = 0; | |
4187 if (*arg == '<') | |
4188 { | |
4189 nextchar = 0; | |
4190 opt_idx = -1; | |
4191 /* look out for <t_>;> */ | |
4192 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) | |
4193 len = 5; | |
4194 else | |
4195 { | |
4196 len = 1; | |
4197 while (arg[len] != NUL && arg[len] != '>') | |
4198 ++len; | |
4199 } | |
4200 if (arg[len] != '>') | |
4201 { | |
4202 errmsg = e_invarg; | |
4203 goto skip; | |
4204 } | |
4205 arg[len] = NUL; /* put NUL after name */ | |
4206 if (arg[1] == 't' && arg[2] == '_') /* could be term code */ | |
4207 opt_idx = findoption(arg + 1); | |
4208 arg[len++] = '>'; /* restore '>' */ | |
4209 if (opt_idx == -1) | |
4210 key = find_key_option(arg + 1); | |
4211 } | |
4212 else | |
4213 { | |
4214 len = 0; | |
4215 /* | |
4216 * The two characters after "t_" may not be alphanumeric. | |
4217 */ | |
4218 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4219 len = 4; | |
4220 else | |
4221 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
4222 ++len; | |
4223 nextchar = arg[len]; | |
4224 arg[len] = NUL; /* put NUL after name */ | |
4225 opt_idx = findoption(arg); | |
4226 arg[len] = nextchar; /* restore nextchar */ | |
4227 if (opt_idx == -1) | |
4228 key = find_key_option(arg); | |
4229 } | |
4230 | |
4231 /* remember character after option name */ | |
4232 afterchar = arg[len]; | |
4233 | |
4234 /* skip white space, allow ":set ai ?" */ | |
4235 while (vim_iswhite(arg[len])) | |
4236 ++len; | |
4237 | |
4238 adding = FALSE; | |
4239 prepending = FALSE; | |
4240 removing = FALSE; | |
4241 if (arg[len] != NUL && arg[len + 1] == '=') | |
4242 { | |
4243 if (arg[len] == '+') | |
4244 { | |
4245 adding = TRUE; /* "+=" */ | |
4246 ++len; | |
4247 } | |
4248 else if (arg[len] == '^') | |
4249 { | |
4250 prepending = TRUE; /* "^=" */ | |
4251 ++len; | |
4252 } | |
4253 else if (arg[len] == '-') | |
4254 { | |
4255 removing = TRUE; /* "-=" */ | |
4256 ++len; | |
4257 } | |
4258 } | |
4259 nextchar = arg[len]; | |
4260 | |
4261 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ | |
4262 { | |
4263 errmsg = (char_u *)N_("E518: Unknown option"); | |
4264 goto skip; | |
4265 } | |
4266 | |
4267 if (opt_idx >= 0) | |
4268 { | |
4269 if (options[opt_idx].var == NULL) /* hidden option: skip */ | |
4270 { | |
4271 /* Only give an error message when requesting the value of | |
4272 * a hidden option, ignore setting it. */ | |
4273 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL | |
4274 && (!(options[opt_idx].flags & P_BOOL) | |
4275 || nextchar == '?')) | |
4276 errmsg = (char_u *)N_("E519: Option not supported"); | |
4277 goto skip; | |
4278 } | |
4279 | |
4280 flags = options[opt_idx].flags; | |
4281 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
4282 } | |
4283 else | |
4284 { | |
4285 flags = P_STRING; | |
4286 if (key < 0) | |
4287 { | |
4288 key_name[0] = KEY2TERMCAP0(key); | |
4289 key_name[1] = KEY2TERMCAP1(key); | |
4290 } | |
4291 else | |
4292 { | |
4293 key_name[0] = KS_KEY; | |
4294 key_name[1] = (key & 0xff); | |
4295 } | |
4296 } | |
4297 | |
634 | 4298 /* Skip all options that are not window-local (used when showing |
4299 * an already loaded buffer in a window). */ | |
4300 if ((opt_flags & OPT_WINONLY) | |
4301 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
4302 goto skip; | |
4303 | |
717 | 4304 /* Skip all options that are window-local (used for :vimgrep). */ |
4305 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 | |
4306 && options[opt_idx].var == VAR_WIN) | |
4307 goto skip; | |
4308 | |
1807 | 4309 /* Disallow changing some options from modelines. */ |
4310 if (opt_flags & OPT_MODELINE) | |
7 | 4311 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4312 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 4313 { |
4314 errmsg = (char_u *)_("E520: Not allowed in a modeline"); | |
4315 goto skip; | |
4316 } | |
1810 | 4317 #ifdef FEAT_DIFF |
1807 | 4318 /* In diff mode some options are overruled. This avoids that |
4319 * 'foldmethod' becomes "marker" instead of "diff" and that | |
4320 * "wrap" gets set. */ | |
4321 if (curwin->w_p_diff | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
4322 && opt_idx >= 0 /* shut up coverity warning */ |
1807 | 4323 && (options[opt_idx].indir == PV_FDM |
4324 || options[opt_idx].indir == PV_WRAP)) | |
4325 goto skip; | |
1810 | 4326 #endif |
7 | 4327 } |
4328 | |
4329 #ifdef HAVE_SANDBOX | |
4330 /* Disallow changing some options in the sandbox */ | |
634 | 4331 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 4332 { |
4333 errmsg = (char_u *)_(e_sandbox); | |
4334 goto skip; | |
4335 } | |
4336 #endif | |
4337 | |
4338 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
4339 { | |
4340 arg += len; | |
4341 cp_val = p_cp; | |
4342 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
4343 { | |
4344 if (arg[3] == 'm') /* "opt&vim": set to Vim default */ | |
4345 { | |
4346 cp_val = FALSE; | |
4347 arg += 3; | |
4348 } | |
4349 else /* "opt&vi": set to Vi default */ | |
4350 { | |
4351 cp_val = TRUE; | |
4352 arg += 2; | |
4353 } | |
4354 } | |
4355 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL | |
4356 && arg[1] != NUL && !vim_iswhite(arg[1])) | |
4357 { | |
4358 errmsg = e_trailing; | |
4359 goto skip; | |
4360 } | |
4361 } | |
4362 | |
4363 /* | |
4364 * allow '=' and ':' as MSDOS command.com allows only one | |
4365 * '=' character per "set" command line. grrr. (jw) | |
4366 */ | |
4367 if (nextchar == '?' | |
4368 || (prefix == 1 | |
4369 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
4370 && !(flags & P_BOOL))) | |
4371 { | |
4372 /* | |
4373 * print value | |
4374 */ | |
4375 if (did_show) | |
4376 msg_putchar('\n'); /* cursor below last one */ | |
4377 else | |
4378 { | |
4379 gotocmdline(TRUE); /* cursor at status line */ | |
4380 did_show = TRUE; /* remember that we did a line */ | |
4381 } | |
4382 if (opt_idx >= 0) | |
4383 { | |
4384 showoneopt(&options[opt_idx], opt_flags); | |
4385 #ifdef FEAT_EVAL | |
4386 if (p_verbose > 0) | |
694 | 4387 { |
4388 /* Mention where the option was last set. */ | |
4389 if (varp == options[opt_idx].var) | |
4390 last_set_msg(options[opt_idx].scriptID); | |
4391 else if ((int)options[opt_idx].indir & PV_WIN) | |
4392 last_set_msg(curwin->w_p_scriptID[ | |
4393 (int)options[opt_idx].indir & PV_MASK]); | |
4394 else if ((int)options[opt_idx].indir & PV_BUF) | |
4395 last_set_msg(curbuf->b_p_scriptID[ | |
4396 (int)options[opt_idx].indir & PV_MASK]); | |
4397 } | |
7 | 4398 #endif |
4399 } | |
4400 else | |
4401 { | |
4402 char_u *p; | |
4403 | |
4404 p = find_termcode(key_name); | |
4405 if (p == NULL) | |
4406 { | |
2726 | 4407 errmsg = (char_u *)N_("E846: Key code not set"); |
7 | 4408 goto skip; |
4409 } | |
4410 else | |
4411 (void)show_one_termcode(key_name, p, TRUE); | |
4412 } | |
4413 if (nextchar != '?' | |
4414 && nextchar != NUL && !vim_iswhite(afterchar)) | |
4415 errmsg = e_trailing; | |
4416 } | |
4417 else | |
4418 { | |
4419 if (flags & P_BOOL) /* boolean */ | |
4420 { | |
4421 if (nextchar == '=' || nextchar == ':') | |
4422 { | |
4423 errmsg = e_invarg; | |
4424 goto skip; | |
4425 } | |
4426 | |
4427 /* | |
4428 * ":set opt!": invert | |
4429 * ":set opt&": reset to default value | |
4430 * ":set opt<": reset to global value | |
4431 */ | |
4432 if (nextchar == '!') | |
4433 value = *(int *)(varp) ^ 1; | |
4434 else if (nextchar == '&') | |
840 | 4435 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 4436 ((flags & P_VI_DEF) || cp_val) |
4437 ? VI_DEFAULT : VIM_DEFAULT]; | |
4438 else if (nextchar == '<') | |
4439 { | |
4440 /* For 'autoread' -1 means to use global value. */ | |
4441 if ((int *)varp == &curbuf->b_p_ar | |
4442 && opt_flags == OPT_LOCAL) | |
4443 value = -1; | |
4444 else | |
4445 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
4446 OPT_GLOBAL); | |
4447 } | |
4448 else | |
4449 { | |
4450 /* | |
4451 * ":set invopt": invert | |
4452 * ":set opt" or ":set noopt": set or reset | |
4453 */ | |
4454 if (nextchar != NUL && !vim_iswhite(afterchar)) | |
4455 { | |
4456 errmsg = e_trailing; | |
4457 goto skip; | |
4458 } | |
4459 if (prefix == 2) /* inv */ | |
4460 value = *(int *)(varp) ^ 1; | |
4461 else | |
4462 value = prefix; | |
4463 } | |
4464 | |
4465 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
4466 opt_flags); | |
4467 } | |
4468 else /* numeric or string */ | |
4469 { | |
4470 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
4471 || prefix != 1) | |
4472 { | |
4473 errmsg = e_invarg; | |
4474 goto skip; | |
4475 } | |
4476 | |
4477 if (flags & P_NUM) /* numeric */ | |
4478 { | |
4479 /* | |
4480 * Different ways to set a number option: | |
4481 * & set to default value | |
4482 * < set to global value | |
4483 * <xx> accept special key codes for 'wildchar' | |
4484 * c accept any non-digit for 'wildchar' | |
4485 * [-]0-9 set number | |
4486 * other error | |
4487 */ | |
4488 ++arg; | |
4489 if (nextchar == '&') | |
840 | 4490 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 4491 ((flags & P_VI_DEF) || cp_val) |
4492 ? VI_DEFAULT : VIM_DEFAULT]; | |
4493 else if (nextchar == '<') | |
4494 value = *(long *)get_varp_scope(&(options[opt_idx]), | |
4495 OPT_GLOBAL); | |
4496 else if (((long *)varp == &p_wc | |
4497 || (long *)varp == &p_wcm) | |
4498 && (*arg == '<' | |
4499 || *arg == '^' | |
4500 || ((!arg[1] || vim_iswhite(arg[1])) | |
4501 && !VIM_ISDIGIT(*arg)))) | |
4502 { | |
4503 value = string_to_key(arg); | |
4504 if (value == 0 && (long *)varp != &p_wcm) | |
4505 { | |
4506 errmsg = e_invarg; | |
4507 goto skip; | |
4508 } | |
4509 } | |
4510 /* allow negative numbers (for 'undolevels') */ | |
4511 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
4512 { | |
4513 i = 0; | |
4514 if (*arg == '-') | |
4515 i = 1; | |
4516 #ifdef HAVE_STRTOL | |
4517 value = strtol((char *)arg, NULL, 0); | |
4518 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x') | |
4519 i += 2; | |
4520 #else | |
4521 value = atol((char *)arg); | |
4522 #endif | |
4523 while (VIM_ISDIGIT(arg[i])) | |
4524 ++i; | |
4525 if (arg[i] != NUL && !vim_iswhite(arg[i])) | |
4526 { | |
4527 errmsg = e_invarg; | |
4528 goto skip; | |
4529 } | |
4530 } | |
4531 else | |
4532 { | |
4533 errmsg = (char_u *)N_("E521: Number required after ="); | |
4534 goto skip; | |
4535 } | |
4536 | |
4537 if (adding) | |
4538 value = *(long *)varp + value; | |
4539 if (prepending) | |
4540 value = *(long *)varp * value; | |
4541 if (removing) | |
4542 value = *(long *)varp - value; | |
4543 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 4544 errbuf, sizeof(errbuf), opt_flags); |
7 | 4545 } |
4546 else if (opt_idx >= 0) /* string */ | |
4547 { | |
4548 char_u *save_arg = NULL; | |
4549 char_u *s = NULL; | |
4550 char_u *oldval; /* previous value if *varp */ | |
4551 char_u *newval; | |
4552 char_u *origval; | |
4553 unsigned newlen; | |
4554 int comma; | |
4555 int bs; | |
4556 int new_value_alloced; /* new string option | |
4557 was allocated */ | |
4558 | |
4559 /* When using ":set opt=val" for a global option | |
4560 * with a local value the local value will be | |
4561 * reset, use the global value here. */ | |
4562 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 4563 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 4564 varp = options[opt_idx].var; |
4565 | |
4566 /* The old value is kept until we are sure that the | |
4567 * new value is valid. */ | |
4568 oldval = *(char_u **)varp; | |
4569 if (nextchar == '&') /* set to default val */ | |
4570 { | |
4571 newval = options[opt_idx].def_val[ | |
4572 ((flags & P_VI_DEF) || cp_val) | |
4573 ? VI_DEFAULT : VIM_DEFAULT]; | |
4574 if ((char_u **)varp == &p_bg) | |
4575 { | |
4576 /* guess the value of 'background' */ | |
4577 #ifdef FEAT_GUI | |
4578 if (gui.in_use) | |
4579 newval = gui_bg_default(); | |
4580 else | |
4581 #endif | |
671 | 4582 newval = term_bg_default(); |
7 | 4583 } |
4584 | |
4585 /* expand environment variables and ~ (since the | |
4586 * default value was already expanded, only | |
4587 * required when an environment variable was set | |
4588 * later */ | |
4589 if (newval == NULL) | |
4590 newval = empty_option; | |
4591 else | |
4592 { | |
4593 s = option_expand(opt_idx, newval); | |
4594 if (s == NULL) | |
4595 s = newval; | |
4596 newval = vim_strsave(s); | |
4597 } | |
4598 new_value_alloced = TRUE; | |
4599 } | |
4600 else if (nextchar == '<') /* set to global val */ | |
4601 { | |
4602 newval = vim_strsave(*(char_u **)get_varp_scope( | |
4603 &(options[opt_idx]), OPT_GLOBAL)); | |
4604 new_value_alloced = TRUE; | |
4605 } | |
4606 else | |
4607 { | |
4608 ++arg; /* jump to after the '=' or ':' */ | |
4609 | |
4610 /* | |
4611 * Set 'keywordprg' to ":help" if an empty | |
4612 * value was passed to :set by the user. | |
4613 * Misuse errbuf[] for the resulting string. | |
4614 */ | |
4615 if (varp == (char_u *)&p_kp | |
4616 && (*arg == NUL || *arg == ' ')) | |
4617 { | |
4618 STRCPY(errbuf, ":help"); | |
4619 save_arg = arg; | |
4620 arg = errbuf; | |
4621 } | |
4622 /* | |
3168 | 4623 * Convert 'backspace' number to string, for |
4624 * adding, prepending and removing string. | |
4625 */ | |
4626 else if (varp == (char_u *)&p_bs | |
4627 && VIM_ISDIGIT(**(char_u **)varp)) | |
4628 { | |
4629 i = getdigits((char_u **)varp); | |
4630 switch (i) | |
4631 { | |
4632 case 0: | |
4633 *(char_u **)varp = empty_option; | |
4634 break; | |
4635 case 1: | |
4636 *(char_u **)varp = vim_strsave( | |
4637 (char_u *)"indent,eol"); | |
4638 break; | |
4639 case 2: | |
4640 *(char_u **)varp = vim_strsave( | |
4641 (char_u *)"indent,eol,start"); | |
4642 break; | |
4643 } | |
4644 vim_free(oldval); | |
4645 oldval = *(char_u **)varp; | |
4646 } | |
4647 /* | |
7 | 4648 * Convert 'whichwrap' number to string, for |
4649 * backwards compatibility with Vim 3.0. | |
4650 * Misuse errbuf[] for the resulting string. | |
4651 */ | |
4652 else if (varp == (char_u *)&p_ww | |
4653 && VIM_ISDIGIT(*arg)) | |
4654 { | |
4655 *errbuf = NUL; | |
4656 i = getdigits(&arg); | |
4657 if (i & 1) | |
4658 STRCAT(errbuf, "b,"); | |
4659 if (i & 2) | |
4660 STRCAT(errbuf, "s,"); | |
4661 if (i & 4) | |
4662 STRCAT(errbuf, "h,l,"); | |
4663 if (i & 8) | |
4664 STRCAT(errbuf, "<,>,"); | |
4665 if (i & 16) | |
4666 STRCAT(errbuf, "[,],"); | |
4667 if (*errbuf != NUL) /* remove trailing , */ | |
4668 errbuf[STRLEN(errbuf) - 1] = NUL; | |
4669 save_arg = arg; | |
4670 arg = errbuf; | |
4671 } | |
4672 /* | |
4673 * Remove '>' before 'dir' and 'bdir', for | |
4674 * backwards compatibility with version 3.0 | |
4675 */ | |
4676 else if ( *arg == '>' | |
4677 && (varp == (char_u *)&p_dir | |
4678 || varp == (char_u *)&p_bdir)) | |
4679 { | |
4680 ++arg; | |
4681 } | |
4682 | |
4683 /* When setting the local value of a global | |
4684 * option, the old value may be the global value. */ | |
692 | 4685 if (((int)options[opt_idx].indir & PV_BOTH) |
7 | 4686 && (opt_flags & OPT_LOCAL)) |
4687 origval = *(char_u **)get_varp( | |
4688 &options[opt_idx]); | |
4689 else | |
4690 origval = oldval; | |
4691 | |
4692 /* | |
4693 * Copy the new string into allocated memory. | |
4694 * Can't use set_string_option_direct(), because | |
4695 * we need to remove the backslashes. | |
4696 */ | |
4697 /* get a bit too much */ | |
4698 newlen = (unsigned)STRLEN(arg) + 1; | |
4699 if (adding || prepending || removing) | |
4700 newlen += (unsigned)STRLEN(origval) + 1; | |
4701 newval = alloc(newlen); | |
4702 if (newval == NULL) /* out of mem, don't change */ | |
4703 break; | |
4704 s = newval; | |
4705 | |
4706 /* | |
4707 * Copy the string, skip over escaped chars. | |
4708 * For MS-DOS and WIN32 backslashes before normal | |
4709 * file name characters are not removed, and keep | |
4710 * backslash at start, for "\\machine\path", but | |
4711 * do remove it for "\\\\machine\\path". | |
4712 * The reverse is found in ExpandOldSetting(). | |
4713 */ | |
4714 while (*arg && !vim_iswhite(*arg)) | |
4715 { | |
4716 if (*arg == '\\' && arg[1] != NUL | |
4717 #ifdef BACKSLASH_IN_FILENAME | |
4718 && !((flags & P_EXPAND) | |
4719 && vim_isfilec(arg[1]) | |
4720 && (arg[1] != '\\' | |
4721 || (s == newval | |
4722 && arg[2] != '\\'))) | |
4723 #endif | |
4724 ) | |
4725 ++arg; /* remove backslash */ | |
4726 #ifdef FEAT_MBYTE | |
4727 if (has_mbyte | |
474 | 4728 && (i = (*mb_ptr2len)(arg)) > 1) |
7 | 4729 { |
4730 /* copy multibyte char */ | |
4731 mch_memmove(s, arg, (size_t)i); | |
4732 arg += i; | |
4733 s += i; | |
4734 } | |
4735 else | |
4736 #endif | |
4737 *s++ = *arg++; | |
4738 } | |
4739 *s = NUL; | |
4740 | |
4741 /* | |
4742 * Expand environment variables and ~. | |
4743 * Don't do it when adding without inserting a | |
4744 * comma. | |
4745 */ | |
4746 if (!(adding || prepending || removing) | |
4747 || (flags & P_COMMA)) | |
4748 { | |
4749 s = option_expand(opt_idx, newval); | |
4750 if (s != NULL) | |
4751 { | |
4752 vim_free(newval); | |
4753 newlen = (unsigned)STRLEN(s) + 1; | |
4754 if (adding || prepending || removing) | |
4755 newlen += (unsigned)STRLEN(origval) + 1; | |
4756 newval = alloc(newlen); | |
4757 if (newval == NULL) | |
4758 break; | |
4759 STRCPY(newval, s); | |
4760 } | |
4761 } | |
4762 | |
4763 /* locate newval[] in origval[] when removing it | |
4764 * and when adding to avoid duplicates */ | |
4765 i = 0; /* init for GCC */ | |
4766 if (removing || (flags & P_NODUP)) | |
4767 { | |
4768 i = (int)STRLEN(newval); | |
4769 bs = 0; | |
4770 for (s = origval; *s; ++s) | |
4771 { | |
4772 if ((!(flags & P_COMMA) | |
4773 || s == origval | |
4774 || (s[-1] == ',' && !(bs & 1))) | |
4775 && STRNCMP(s, newval, i) == 0 | |
4776 && (!(flags & P_COMMA) | |
4777 || s[i] == ',' | |
4778 || s[i] == NUL)) | |
4779 break; | |
2726 | 4780 /* Count backslashes. Only a comma with an |
4781 * even number of backslashes before it is | |
7 | 4782 * recognized as a separator */ |
4783 if (s > origval && s[-1] == '\\') | |
4784 ++bs; | |
4785 else | |
4786 bs = 0; | |
4787 } | |
4788 | |
4789 /* do not add if already there */ | |
4790 if ((adding || prepending) && *s) | |
4791 { | |
4792 prepending = FALSE; | |
4793 adding = FALSE; | |
4794 STRCPY(newval, origval); | |
4795 } | |
4796 } | |
4797 | |
4798 /* concatenate the two strings; add a ',' if | |
4799 * needed */ | |
4800 if (adding || prepending) | |
4801 { | |
4802 comma = ((flags & P_COMMA) && *origval != NUL | |
4803 && *newval != NUL); | |
4804 if (adding) | |
4805 { | |
4806 i = (int)STRLEN(origval); | |
4807 mch_memmove(newval + i + comma, newval, | |
4808 STRLEN(newval) + 1); | |
4809 mch_memmove(newval, origval, (size_t)i); | |
4810 } | |
4811 else | |
4812 { | |
4813 i = (int)STRLEN(newval); | |
1622 | 4814 STRMOVE(newval + i + comma, origval); |
7 | 4815 } |
4816 if (comma) | |
4817 newval[i] = ','; | |
4818 } | |
4819 | |
4820 /* Remove newval[] from origval[]. (Note: "i" has | |
4821 * been set above and is used here). */ | |
4822 if (removing) | |
4823 { | |
4824 STRCPY(newval, origval); | |
4825 if (*s) | |
4826 { | |
4827 /* may need to remove a comma */ | |
4828 if (flags & P_COMMA) | |
4829 { | |
4830 if (s == origval) | |
4831 { | |
4832 /* include comma after string */ | |
4833 if (s[i] == ',') | |
4834 ++i; | |
4835 } | |
4836 else | |
4837 { | |
4838 /* include comma before string */ | |
4839 --s; | |
4840 ++i; | |
4841 } | |
4842 } | |
1622 | 4843 STRMOVE(newval + (s - origval), s + i); |
7 | 4844 } |
4845 } | |
4846 | |
4847 if (flags & P_FLAGLIST) | |
4848 { | |
4849 /* Remove flags that appear twice. */ | |
4850 for (s = newval; *s; ++s) | |
4851 if ((!(flags & P_COMMA) || *s != ',') | |
4852 && vim_strchr(s + 1, *s) != NULL) | |
4853 { | |
1622 | 4854 STRMOVE(s, s + 1); |
7 | 4855 --s; |
4856 } | |
4857 } | |
4858 | |
4859 if (save_arg != NULL) /* number for 'whichwrap' */ | |
4860 arg = save_arg; | |
4861 new_value_alloced = TRUE; | |
4862 } | |
4863 | |
4864 /* Set the new value. */ | |
4865 *(char_u **)(varp) = newval; | |
4866 | |
4867 /* Handle side effects, and set the global value for | |
4868 * ":set" on local options. */ | |
4869 errmsg = did_set_string_option(opt_idx, (char_u **)varp, | |
4870 new_value_alloced, oldval, errbuf, opt_flags); | |
4871 | |
4872 /* If error detected, print the error message. */ | |
4873 if (errmsg != NULL) | |
4874 goto skip; | |
4875 } | |
4876 else /* key code option */ | |
4877 { | |
4878 char_u *p; | |
4879 | |
4880 if (nextchar == '&') | |
4881 { | |
4882 if (add_termcap_entry(key_name, TRUE) == FAIL) | |
4883 errmsg = (char_u *)N_("E522: Not found in termcap"); | |
4884 } | |
4885 else | |
4886 { | |
4887 ++arg; /* jump to after the '=' or ':' */ | |
4888 for (p = arg; *p && !vim_iswhite(*p); ++p) | |
4889 if (*p == '\\' && p[1] != NUL) | |
4890 ++p; | |
4891 nextchar = *p; | |
4892 *p = NUL; | |
4893 add_termcode(key_name, arg, FALSE); | |
4894 *p = nextchar; | |
4895 } | |
4896 if (full_screen) | |
4897 ttest(FALSE); | |
4898 redraw_all_later(CLEAR); | |
4899 } | |
4900 } | |
634 | 4901 |
7 | 4902 if (opt_idx >= 0) |
634 | 4903 did_set_option(opt_idx, opt_flags, |
4904 !prepending && !adding && !removing); | |
7 | 4905 } |
4906 | |
4907 skip: | |
4908 /* | |
4909 * Advance to next argument. | |
4910 * - skip until a blank found, taking care of backslashes | |
4911 * - skip blanks | |
4912 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
4913 */ | |
4914 for (i = 0; i < 2 ; ++i) | |
4915 { | |
4916 while (*arg != NUL && !vim_iswhite(*arg)) | |
4917 if (*arg++ == '\\' && *arg != NUL) | |
4918 ++arg; | |
4919 arg = skipwhite(arg); | |
4920 if (*arg != '=') | |
4921 break; | |
4922 } | |
4923 } | |
4924 | |
4925 if (errmsg != NULL) | |
4926 { | |
419 | 4927 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 4928 i = (int)STRLEN(IObuff) + 2; |
7 | 4929 if (i + (arg - startarg) < IOSIZE) |
4930 { | |
4931 /* append the argument with the error */ | |
4932 STRCAT(IObuff, ": "); | |
4933 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
4934 IObuff[i + (arg - startarg)] = NUL; | |
4935 } | |
4936 /* make sure all characters are printable */ | |
4937 trans_characters(IObuff, IOSIZE); | |
4938 | |
4939 ++no_wait_return; /* wait_return done later */ | |
4940 emsg(IObuff); /* show error highlighted */ | |
4941 --no_wait_return; | |
4942 | |
4943 return FAIL; | |
4944 } | |
4945 | |
4946 arg = skipwhite(arg); | |
4947 } | |
4948 | |
168 | 4949 theend: |
4950 if (silent_mode && did_show) | |
4951 { | |
4952 /* After displaying option values in silent mode. */ | |
4953 silent_mode = FALSE; | |
4954 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
4955 msg_putchar('\n'); | |
4956 cursor_on(); /* msg_start() switches it off */ | |
4957 out_flush(); | |
4958 silent_mode = TRUE; | |
4959 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ | |
4960 } | |
4961 | |
7 | 4962 return OK; |
4963 } | |
4964 | |
634 | 4965 /* |
4966 * Call this when an option has been given a new value through a user command. | |
4967 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
4968 */ | |
4969 static void | |
4970 did_set_option(opt_idx, opt_flags, new_value) | |
4971 int opt_idx; | |
4972 int opt_flags; /* possibly with OPT_MODELINE */ | |
4973 int new_value; /* value was replaced completely */ | |
4974 { | |
681 | 4975 long_u *p; |
4976 | |
634 | 4977 options[opt_idx].flags |= P_WAS_SET; |
4978 | |
4979 /* When an option is set in the sandbox, from a modeline or in secure mode | |
4980 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the | |
681 | 4981 * flag. */ |
4982 p = insecure_flag(opt_idx, opt_flags); | |
634 | 4983 if (secure |
4984 #ifdef HAVE_SANDBOX | |
4985 || sandbox != 0 | |
4986 #endif | |
4987 || (opt_flags & OPT_MODELINE)) | |
681 | 4988 *p = *p | P_INSECURE; |
4989 else if (new_value) | |
4990 *p = *p & ~P_INSECURE; | |
634 | 4991 } |
4992 | |
7 | 4993 static char_u * |
4994 illegal_char(errbuf, c) | |
4995 char_u *errbuf; | |
4996 int c; | |
4997 { | |
4998 if (errbuf == NULL) | |
4999 return (char_u *)""; | |
5000 sprintf((char *)errbuf, _("E539: Illegal character <%s>"), | |
274 | 5001 (char *)transchar(c)); |
7 | 5002 return errbuf; |
5003 } | |
5004 | |
5005 /* | |
5006 * Convert a key name or string into a key value. | |
5007 * Used for 'wildchar' and 'cedit' options. | |
5008 */ | |
5009 static int | |
5010 string_to_key(arg) | |
5011 char_u *arg; | |
5012 { | |
5013 if (*arg == '<') | |
5014 return find_key_option(arg + 1); | |
5015 if (*arg == '^') | |
5016 return Ctrl_chr(arg[1]); | |
5017 return *arg; | |
5018 } | |
5019 | |
5020 #ifdef FEAT_CMDWIN | |
5021 /* | |
5022 * Check value of 'cedit' and set cedit_key. | |
5023 * Returns NULL if value is OK, error message otherwise. | |
5024 */ | |
5025 static char_u * | |
5026 check_cedit() | |
5027 { | |
5028 int n; | |
5029 | |
5030 if (*p_cedit == NUL) | |
5031 cedit_key = -1; | |
5032 else | |
5033 { | |
5034 n = string_to_key(p_cedit); | |
5035 if (vim_isprintc(n)) | |
5036 return e_invarg; | |
5037 cedit_key = n; | |
5038 } | |
5039 return NULL; | |
5040 } | |
5041 #endif | |
5042 | |
5043 #ifdef FEAT_TITLE | |
5044 /* | |
5045 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
5046 * maketitle() to create and display it. | |
5047 * When switching the title or icon off, call mch_restore_title() to get | |
5048 * the old value back. | |
5049 */ | |
5050 static void | |
5051 did_set_title(icon) | |
5052 int icon; /* Did set icon instead of title */ | |
5053 { | |
5054 if (starting != NO_SCREEN | |
5055 #ifdef FEAT_GUI | |
5056 && !gui.starting | |
5057 #endif | |
5058 ) | |
5059 { | |
5060 maketitle(); | |
5061 if (icon) | |
5062 { | |
5063 if (!p_icon) | |
5064 mch_restore_title(2); | |
5065 } | |
5066 else | |
5067 { | |
5068 if (!p_title) | |
5069 mch_restore_title(1); | |
5070 } | |
5071 } | |
5072 } | |
5073 #endif | |
5074 | |
5075 /* | |
5076 * set_options_bin - called when 'bin' changes value. | |
5077 */ | |
5078 void | |
5079 set_options_bin(oldval, newval, opt_flags) | |
5080 int oldval; | |
5081 int newval; | |
5082 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ | |
5083 { | |
5084 /* | |
5085 * The option values that are changed when 'bin' changes are | |
5086 * copied when 'bin is set and restored when 'bin' is reset. | |
5087 */ | |
5088 if (newval) | |
5089 { | |
5090 if (!oldval) /* switched on */ | |
5091 { | |
5092 if (!(opt_flags & OPT_GLOBAL)) | |
5093 { | |
5094 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
5095 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
5096 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
5097 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
5098 } | |
5099 if (!(opt_flags & OPT_LOCAL)) | |
5100 { | |
5101 p_tw_nobin = p_tw; | |
5102 p_wm_nobin = p_wm; | |
5103 p_ml_nobin = p_ml; | |
5104 p_et_nobin = p_et; | |
5105 } | |
5106 } | |
5107 | |
5108 if (!(opt_flags & OPT_GLOBAL)) | |
5109 { | |
5110 curbuf->b_p_tw = 0; /* no automatic line wrap */ | |
5111 curbuf->b_p_wm = 0; /* no automatic line wrap */ | |
5112 curbuf->b_p_ml = 0; /* no modelines */ | |
5113 curbuf->b_p_et = 0; /* no expandtab */ | |
5114 } | |
5115 if (!(opt_flags & OPT_LOCAL)) | |
5116 { | |
5117 p_tw = 0; | |
5118 p_wm = 0; | |
5119 p_ml = FALSE; | |
5120 p_et = FALSE; | |
5121 p_bin = TRUE; /* needed when called for the "-b" argument */ | |
5122 } | |
5123 } | |
5124 else if (oldval) /* switched off */ | |
5125 { | |
5126 if (!(opt_flags & OPT_GLOBAL)) | |
5127 { | |
5128 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
5129 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
5130 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
5131 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
5132 } | |
5133 if (!(opt_flags & OPT_LOCAL)) | |
5134 { | |
5135 p_tw = p_tw_nobin; | |
5136 p_wm = p_wm_nobin; | |
5137 p_ml = p_ml_nobin; | |
5138 p_et = p_et_nobin; | |
5139 } | |
5140 } | |
5141 } | |
5142 | |
5143 #ifdef FEAT_VIMINFO | |
5144 /* | |
5145 * Find the parameter represented by the given character (eg ', :, ", or /), | |
5146 * and return its associated value in the 'viminfo' string. | |
5147 * Only works for number parameters, not for 'r' or 'n'. | |
23 | 5148 * If the parameter is not specified in the string or there is no following |
5149 * number, return -1. | |
7 | 5150 */ |
5151 int | |
5152 get_viminfo_parameter(type) | |
5153 int type; | |
5154 { | |
5155 char_u *p; | |
5156 | |
5157 p = find_viminfo_parameter(type); | |
5158 if (p != NULL && VIM_ISDIGIT(*p)) | |
5159 return atoi((char *)p); | |
5160 return -1; | |
5161 } | |
5162 | |
5163 /* | |
5164 * Find the parameter represented by the given character (eg ''', ':', '"', or | |
5165 * '/') in the 'viminfo' option and return a pointer to the string after it. | |
5166 * Return NULL if the parameter is not specified in the string. | |
5167 */ | |
5168 char_u * | |
5169 find_viminfo_parameter(type) | |
5170 int type; | |
5171 { | |
5172 char_u *p; | |
5173 | |
5174 for (p = p_viminfo; *p; ++p) | |
5175 { | |
5176 if (*p == type) | |
5177 return p + 1; | |
5178 if (*p == 'n') /* 'n' is always the last one */ | |
5179 break; | |
5180 p = vim_strchr(p, ','); /* skip until next ',' */ | |
5181 if (p == NULL) /* hit the end without finding parameter */ | |
5182 break; | |
5183 } | |
5184 return NULL; | |
5185 } | |
5186 #endif | |
5187 | |
5188 /* | |
5189 * Expand environment variables for some string options. | |
5190 * These string options cannot be indirect! | |
5191 * If "val" is NULL expand the current value of the option. | |
5192 * Return pointer to NameBuff, or NULL when not expanded. | |
5193 */ | |
5194 static char_u * | |
5195 option_expand(opt_idx, val) | |
5196 int opt_idx; | |
5197 char_u *val; | |
5198 { | |
5199 /* if option doesn't need expansion nothing to do */ | |
5200 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) | |
5201 return NULL; | |
5202 | |
5203 /* If val is longer than MAXPATHL no meaningful expansion can be done, | |
5204 * expand_env() would truncate the string. */ | |
5205 if (val != NULL && STRLEN(val) > MAXPATHL) | |
5206 return NULL; | |
5207 | |
5208 if (val == NULL) | |
5209 val = *(char_u **)options[opt_idx].var; | |
5210 | |
5211 /* | |
5212 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
5213 * Escape spaces when expanding 'tags', they are used to separate file | |
5214 * names. | |
374 | 5215 * For 'spellsuggest' expand after "file:". |
7 | 5216 */ |
5217 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 5218 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 5219 #ifdef FEAT_SPELL |
374 | 5220 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
5221 #endif | |
5222 NULL); | |
7 | 5223 if (STRCMP(NameBuff, val) == 0) /* they are the same */ |
5224 return NULL; | |
5225 | |
5226 return NameBuff; | |
5227 } | |
5228 | |
5229 /* | |
5230 * After setting various option values: recompute variables that depend on | |
5231 * option values. | |
5232 */ | |
5233 static void | |
5234 didset_options() | |
5235 { | |
5236 /* initialize the table for 'iskeyword' et.al. */ | |
5237 (void)init_chartab(); | |
5238 | |
805 | 5239 #ifdef FEAT_MBYTE |
7 | 5240 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); |
805 | 5241 #endif |
7 | 5242 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE); |
5243 #ifdef FEAT_SESSION | |
5244 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE); | |
5245 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE); | |
5246 #endif | |
5247 #ifdef FEAT_FOLDING | |
5248 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); | |
5249 #endif | |
5250 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); | |
5251 #ifdef FEAT_VIRTUALEDIT | |
5252 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); | |
5253 #endif | |
5254 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) | |
5255 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); | |
5256 #endif | |
744 | 5257 #ifdef FEAT_SPELL |
484 | 5258 (void)spell_check_msm(); |
374 | 5259 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5260 (void)compile_cap_prog(curwin->w_s); |
344 | 5261 #endif |
7 | 5262 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
5263 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); | |
5264 #endif | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2271
diff
changeset
|
5265 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) |
7 | 5266 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE); |
5267 #endif | |
5268 #ifdef FEAT_CMDWIN | |
5269 /* set cedit_key */ | |
5270 (void)check_cedit(); | |
5271 #endif | |
5272 } | |
5273 | |
5274 /* | |
5275 * Check for string options that are NULL (normally only termcap options). | |
5276 */ | |
5277 void | |
5278 check_options() | |
5279 { | |
5280 int opt_idx; | |
5281 | |
5282 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
5283 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
5284 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
5285 } | |
5286 | |
5287 /* | |
5288 * Check string options in a buffer for NULL value. | |
5289 */ | |
5290 void | |
5291 check_buf_options(buf) | |
5292 buf_T *buf; | |
5293 { | |
5294 #if defined(FEAT_QUICKFIX) | |
5295 check_string_option(&buf->b_p_bh); | |
5296 check_string_option(&buf->b_p_bt); | |
5297 #endif | |
5298 #ifdef FEAT_MBYTE | |
5299 check_string_option(&buf->b_p_fenc); | |
5300 #endif | |
5301 check_string_option(&buf->b_p_ff); | |
5302 #ifdef FEAT_FIND_ID | |
5303 check_string_option(&buf->b_p_def); | |
5304 check_string_option(&buf->b_p_inc); | |
5305 # ifdef FEAT_EVAL | |
5306 check_string_option(&buf->b_p_inex); | |
5307 # endif | |
5308 #endif | |
5309 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5310 check_string_option(&buf->b_p_inde); | |
5311 check_string_option(&buf->b_p_indk); | |
5312 #endif | |
790 | 5313 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5314 check_string_option(&buf->b_p_bexpr); | |
5315 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5316 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5317 check_string_option(&buf->b_p_cm); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5318 #endif |
667 | 5319 #if defined(FEAT_EVAL) |
5320 check_string_option(&buf->b_p_fex); | |
5321 #endif | |
7 | 5322 #ifdef FEAT_CRYPT |
5323 check_string_option(&buf->b_p_key); | |
5324 #endif | |
5325 check_string_option(&buf->b_p_kp); | |
5326 check_string_option(&buf->b_p_mps); | |
5327 check_string_option(&buf->b_p_fo); | |
41 | 5328 check_string_option(&buf->b_p_flp); |
7 | 5329 check_string_option(&buf->b_p_isk); |
5330 #ifdef FEAT_COMMENTS | |
5331 check_string_option(&buf->b_p_com); | |
5332 #endif | |
5333 #ifdef FEAT_FOLDING | |
5334 check_string_option(&buf->b_p_cms); | |
5335 #endif | |
5336 check_string_option(&buf->b_p_nf); | |
12 | 5337 #ifdef FEAT_TEXTOBJ |
5338 check_string_option(&buf->b_p_qe); | |
5339 #endif | |
7 | 5340 #ifdef FEAT_SYN_HL |
5341 check_string_option(&buf->b_p_syn); | |
744 | 5342 #endif |
5343 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5344 check_string_option(&buf->b_s.b_p_spc); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5345 check_string_option(&buf->b_s.b_p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5346 check_string_option(&buf->b_s.b_p_spl); |
7 | 5347 #endif |
5348 #ifdef FEAT_SEARCHPATH | |
5349 check_string_option(&buf->b_p_sua); | |
5350 #endif | |
5351 #ifdef FEAT_CINDENT | |
5352 check_string_option(&buf->b_p_cink); | |
5353 check_string_option(&buf->b_p_cino); | |
5354 #endif | |
5355 #ifdef FEAT_AUTOCMD | |
5356 check_string_option(&buf->b_p_ft); | |
5357 #endif | |
5358 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
5359 check_string_option(&buf->b_p_cinw); | |
5360 #endif | |
5361 #ifdef FEAT_INS_EXPAND | |
5362 check_string_option(&buf->b_p_cpt); | |
5363 #endif | |
12 | 5364 #ifdef FEAT_COMPL_FUNC |
5365 check_string_option(&buf->b_p_cfu); | |
502 | 5366 check_string_option(&buf->b_p_ofu); |
12 | 5367 #endif |
7 | 5368 #ifdef FEAT_KEYMAP |
5369 check_string_option(&buf->b_p_keymap); | |
5370 #endif | |
5371 #ifdef FEAT_QUICKFIX | |
5372 check_string_option(&buf->b_p_gp); | |
5373 check_string_option(&buf->b_p_mp); | |
5374 check_string_option(&buf->b_p_efm); | |
5375 #endif | |
5376 check_string_option(&buf->b_p_ep); | |
5377 check_string_option(&buf->b_p_path); | |
5378 check_string_option(&buf->b_p_tags); | |
5379 #ifdef FEAT_INS_EXPAND | |
5380 check_string_option(&buf->b_p_dict); | |
5381 check_string_option(&buf->b_p_tsr); | |
5382 #endif | |
5383 } | |
5384 | |
5385 /* | |
5386 * Free the string allocated for an option. | |
5387 * Checks for the string being empty_option. This may happen if we're out of | |
5388 * memory, vim_strsave() returned NULL, which was replaced by empty_option by | |
5389 * check_options(). | |
5390 * Does NOT check for P_ALLOCED flag! | |
5391 */ | |
5392 void | |
5393 free_string_option(p) | |
5394 char_u *p; | |
5395 { | |
5396 if (p != empty_option) | |
5397 vim_free(p); | |
5398 } | |
5399 | |
5400 void | |
5401 clear_string_option(pp) | |
5402 char_u **pp; | |
5403 { | |
5404 if (*pp != empty_option) | |
5405 vim_free(*pp); | |
5406 *pp = empty_option; | |
5407 } | |
5408 | |
5409 static void | |
5410 check_string_option(pp) | |
5411 char_u **pp; | |
5412 { | |
5413 if (*pp == NULL) | |
5414 *pp = empty_option; | |
5415 } | |
5416 | |
5417 /* | |
5418 * Mark a terminal option as allocated, found by a pointer into term_strings[]. | |
5419 */ | |
5420 void | |
5421 set_term_option_alloced(p) | |
5422 char_u **p; | |
5423 { | |
5424 int opt_idx; | |
5425 | |
5426 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
5427 if (options[opt_idx].var == (char_u *)p) | |
5428 { | |
5429 options[opt_idx].flags |= P_ALLOCED; | |
5430 return; | |
5431 } | |
5432 return; /* cannot happen: didn't find it! */ | |
5433 } | |
5434 | |
634 | 5435 #if defined(FEAT_EVAL) || defined(PROTO) |
5436 /* | |
5437 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
5438 * Return FALSE when it wasn't. | |
5439 * Return -1 for an unknown option. | |
5440 */ | |
5441 int | |
681 | 5442 was_set_insecurely(opt, opt_flags) |
5443 char_u *opt; | |
5444 int opt_flags; | |
634 | 5445 { |
5446 int idx = findoption(opt); | |
681 | 5447 long_u *flagp; |
634 | 5448 |
5449 if (idx >= 0) | |
681 | 5450 { |
5451 flagp = insecure_flag(idx, opt_flags); | |
5452 return (*flagp & P_INSECURE) != 0; | |
5453 } | |
634 | 5454 EMSG2(_(e_intern2), "was_set_insecurely()"); |
5455 return -1; | |
5456 } | |
681 | 5457 |
5458 /* | |
5459 * Get a pointer to the flags used for the P_INSECURE flag of option | |
5460 * "opt_idx". For some local options a local flags field is used. | |
5461 */ | |
5462 static long_u * | |
5463 insecure_flag(opt_idx, opt_flags) | |
5464 int opt_idx; | |
5465 int opt_flags; | |
5466 { | |
5467 if (opt_flags & OPT_LOCAL) | |
5468 switch ((int)options[opt_idx].indir) | |
5469 { | |
5470 #ifdef FEAT_STL_OPT | |
694 | 5471 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 5472 #endif |
5473 #ifdef FEAT_EVAL | |
885 | 5474 # ifdef FEAT_FOLDING |
694 | 5475 case PV_FDE: return &curwin->w_p_fde_flags; |
5476 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 5477 # endif |
790 | 5478 # ifdef FEAT_BEVAL |
5479 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
5480 # endif | |
681 | 5481 # if defined(FEAT_CINDENT) |
694 | 5482 case PV_INDE: return &curbuf->b_p_inde_flags; |
681 | 5483 # endif |
694 | 5484 case PV_FEX: return &curbuf->b_p_fex_flags; |
681 | 5485 # ifdef FEAT_FIND_ID |
694 | 5486 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 5487 # endif |
5488 #endif | |
5489 } | |
5490 | |
5491 /* Nothing special, return global flags field. */ | |
5492 return &options[opt_idx].flags; | |
5493 } | |
634 | 5494 #endif |
5495 | |
1805 | 5496 #ifdef FEAT_TITLE |
5497 static void redraw_titles __ARGS((void)); | |
5498 | |
5499 /* | |
5500 * Redraw the window title and/or tab page text later. | |
5501 */ | |
5502 static void redraw_titles() | |
5503 { | |
5504 need_maketitle = TRUE; | |
5505 # ifdef FEAT_WINDOWS | |
5506 redraw_tabline = TRUE; | |
5507 # endif | |
5508 } | |
5509 #endif | |
5510 | |
7 | 5511 /* |
5512 * Set a string option to a new value (without checking the effect). | |
5513 * The string is copied into allocated memory. | |
5514 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. | |
694 | 5515 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is |
1157 | 5516 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid". |
7 | 5517 */ |
5518 void | |
694 | 5519 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid) |
7 | 5520 char_u *name; |
5521 int opt_idx; | |
5522 char_u *val; | |
5523 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ | |
1877 | 5524 int set_sid UNUSED; |
7 | 5525 { |
5526 char_u *s; | |
5527 char_u **varp; | |
5528 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
944 | 5529 int idx = opt_idx; |
5530 | |
5531 if (idx == -1) /* use name */ | |
5532 { | |
5533 idx = findoption(name); | |
5534 if (idx < 0) /* not found (should not happen) */ | |
694 | 5535 { |
5536 EMSG2(_(e_intern2), "set_string_option_direct()"); | |
7 | 5537 return; |
694 | 5538 } |
7 | 5539 } |
5540 | |
944 | 5541 if (options[idx].var == NULL) /* can't set hidden option */ |
7 | 5542 return; |
5543 | |
5544 s = vim_strsave(val); | |
5545 if (s != NULL) | |
5546 { | |
944 | 5547 varp = (char_u **)get_varp_scope(&(options[idx]), |
7 | 5548 both ? OPT_LOCAL : opt_flags); |
944 | 5549 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED)) |
7 | 5550 free_string_option(*varp); |
5551 *varp = s; | |
5552 | |
5553 /* For buffer/window local option may also set the global value. */ | |
5554 if (both) | |
944 | 5555 set_string_option_global(idx, varp); |
5556 | |
5557 options[idx].flags |= P_ALLOCED; | |
7 | 5558 |
5559 /* When setting both values of a global option with a local value, | |
5560 * make the local value empty, so that the global value is used. */ | |
944 | 5561 if (((int)options[idx].indir & PV_BOTH) && both) |
7 | 5562 { |
5563 free_string_option(*varp); | |
5564 *varp = empty_option; | |
5565 } | |
694 | 5566 # ifdef FEAT_EVAL |
5567 if (set_sid != SID_NONE) | |
944 | 5568 set_option_scriptID_idx(idx, opt_flags, |
694 | 5569 set_sid == 0 ? current_SID : set_sid); |
5570 # endif | |
7 | 5571 } |
5572 } | |
5573 | |
5574 /* | |
5575 * Set global value for string option when it's a local option. | |
5576 */ | |
5577 static void | |
5578 set_string_option_global(opt_idx, varp) | |
5579 int opt_idx; /* option index */ | |
5580 char_u **varp; /* pointer to option variable */ | |
5581 { | |
5582 char_u **p, *s; | |
5583 | |
5584 /* the global value is always allocated */ | |
5585 if (options[opt_idx].var == VAR_WIN) | |
5586 p = (char_u **)GLOBAL_WO(varp); | |
5587 else | |
5588 p = (char_u **)options[opt_idx].var; | |
5589 if (options[opt_idx].indir != PV_NONE | |
5590 && p != varp | |
5591 && (s = vim_strsave(*varp)) != NULL) | |
5592 { | |
5593 free_string_option(*p); | |
5594 *p = s; | |
5595 } | |
5596 } | |
5597 | |
5598 /* | |
5599 * Set a string option to a new value, and handle the effects. | |
5600 */ | |
5601 static void | |
5602 set_string_option(opt_idx, value, opt_flags) | |
5603 int opt_idx; | |
5604 char_u *value; | |
5605 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ | |
5606 { | |
5607 char_u *s; | |
5608 char_u **varp; | |
5609 char_u *oldval; | |
5610 | |
5611 if (options[opt_idx].var == NULL) /* don't set hidden option */ | |
5612 return; | |
5613 | |
5614 s = vim_strsave(value); | |
5615 if (s != NULL) | |
5616 { | |
5617 varp = (char_u **)get_varp_scope(&(options[opt_idx]), | |
5618 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 5619 ? (((int)options[opt_idx].indir & PV_BOTH) |
7 | 5620 ? OPT_GLOBAL : OPT_LOCAL) |
5621 : opt_flags); | |
5622 oldval = *varp; | |
5623 *varp = s; | |
634 | 5624 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, |
5625 opt_flags) == NULL) | |
5626 did_set_option(opt_idx, opt_flags, TRUE); | |
7 | 5627 } |
5628 } | |
5629 | |
5630 /* | |
5631 * Handle string options that need some action to perform when changed. | |
5632 * Returns NULL for success, or an error message for an error. | |
5633 */ | |
5634 static char_u * | |
5635 did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, | |
5636 opt_flags) | |
5637 int opt_idx; /* index in options[] table */ | |
5638 char_u **varp; /* pointer to the option variable */ | |
5639 int new_value_alloced; /* new value was allocated */ | |
5640 char_u *oldval; /* previous value of the option */ | |
5641 char_u *errbuf; /* buffer for errors, or NULL */ | |
5642 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ | |
5643 { | |
5644 char_u *errmsg = NULL; | |
5645 char_u *s, *p; | |
5646 int did_chartab = FALSE; | |
5647 char_u **gvarp; | |
835 | 5648 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED); |
1801 | 5649 #ifdef FEAT_GUI |
5650 /* set when changing an option that only requires a redraw in the GUI */ | |
5651 int redraw_gui_only = FALSE; | |
5652 #endif | |
7 | 5653 |
5654 /* Get the global option to compare with, otherwise we would have to check | |
5655 * two values for all local options. */ | |
5656 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); | |
5657 | |
5658 /* Disallow changing some options from secure mode */ | |
5659 if ((secure | |
5660 #ifdef HAVE_SANDBOX | |
5661 || sandbox != 0 | |
5662 #endif | |
5663 ) && (options[opt_idx].flags & P_SECURE)) | |
5664 { | |
5665 errmsg = e_secure; | |
5666 } | |
5667 | |
36 | 5668 /* Check for a "normal" file name in some options. Disallow a path |
5669 * separator (slash and/or backslash), wildcards and characters that are | |
5670 * often illegal in a file name. */ | |
5671 else if ((options[opt_idx].flags & P_NFNAME) | |
39 | 5672 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) |
36 | 5673 { |
5674 errmsg = e_invarg; | |
5675 } | |
5676 | |
7 | 5677 /* 'term' */ |
5678 else if (varp == &T_NAME) | |
5679 { | |
5680 if (T_NAME[0] == NUL) | |
5681 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); | |
5682 #ifdef FEAT_GUI | |
5683 if (gui.in_use) | |
5684 errmsg = (char_u *)N_("E530: Cannot change term in GUI"); | |
5685 else if (term_is_gui(T_NAME)) | |
5686 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI"); | |
5687 #endif | |
5688 else if (set_termname(T_NAME) == FAIL) | |
5689 errmsg = (char_u *)N_("E522: Not found in termcap"); | |
5690 else | |
5691 /* Screen colors may have changed. */ | |
5692 redraw_later_clear(); | |
5693 } | |
5694 | |
5695 /* 'backupcopy' */ | |
5696 else if (varp == &p_bkc) | |
5697 { | |
5698 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK) | |
5699 errmsg = e_invarg; | |
5700 if (((bkc_flags & BKC_AUTO) != 0) | |
5701 + ((bkc_flags & BKC_YES) != 0) | |
5702 + ((bkc_flags & BKC_NO) != 0) != 1) | |
5703 { | |
5704 /* Must have exactly one of "auto", "yes" and "no". */ | |
5705 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE); | |
5706 errmsg = e_invarg; | |
5707 } | |
5708 } | |
5709 | |
5710 /* 'backupext' and 'patchmode' */ | |
5711 else if (varp == &p_bex || varp == &p_pm) | |
5712 { | |
5713 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, | |
5714 *p_pm == '.' ? p_pm + 1 : p_pm) == 0) | |
5715 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal"); | |
5716 } | |
5717 | |
5718 /* | |
5719 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[] | |
5720 * If the new option is invalid, use old value. 'lisp' option: refill | |
5721 * chartab[] for '-' char | |
5722 */ | |
5723 else if ( varp == &p_isi | |
5724 || varp == &(curbuf->b_p_isk) | |
5725 || varp == &p_isp | |
5726 || varp == &p_isf) | |
5727 { | |
5728 if (init_chartab() == FAIL) | |
5729 { | |
5730 did_chartab = TRUE; /* need to restore it below */ | |
5731 errmsg = e_invarg; /* error in value */ | |
5732 } | |
5733 } | |
5734 | |
5735 /* 'helpfile' */ | |
5736 else if (varp == &p_hf) | |
5737 { | |
5738 /* May compute new values for $VIM and $VIMRUNTIME */ | |
5739 if (didset_vim) | |
5740 { | |
5741 vim_setenv((char_u *)"VIM", (char_u *)""); | |
5742 didset_vim = FALSE; | |
5743 } | |
5744 if (didset_vimruntime) | |
5745 { | |
5746 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); | |
5747 didset_vimruntime = FALSE; | |
5748 } | |
5749 } | |
5750 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5751 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5752 /* 'colorcolumn' */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5753 else if (varp == &curwin->w_p_cc) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5754 errmsg = check_colorcolumn(curwin); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5755 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5756 |
7 | 5757 #ifdef FEAT_MULTI_LANG |
5758 /* 'helplang' */ | |
5759 else if (varp == &p_hlg) | |
5760 { | |
5761 /* Check for "", "ab", "ab,cd", etc. */ | |
5762 for (s = p_hlg; *s != NUL; s += 3) | |
5763 { | |
5764 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) | |
5765 { | |
5766 errmsg = e_invarg; | |
5767 break; | |
5768 } | |
5769 if (s[2] == NUL) | |
5770 break; | |
5771 } | |
5772 } | |
5773 #endif | |
5774 | |
5775 /* 'highlight' */ | |
5776 else if (varp == &p_hl) | |
5777 { | |
5778 if (highlight_changed() == FAIL) | |
5779 errmsg = e_invarg; /* invalid flags */ | |
5780 } | |
5781 | |
5782 /* 'nrformats' */ | |
5783 else if (gvarp == &p_nf) | |
5784 { | |
5785 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) | |
5786 errmsg = e_invarg; | |
5787 } | |
5788 | |
5789 #ifdef FEAT_SESSION | |
5790 /* 'sessionoptions' */ | |
5791 else if (varp == &p_ssop) | |
5792 { | |
5793 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) | |
5794 errmsg = e_invarg; | |
5795 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) | |
5796 { | |
5797 /* Don't allow both "sesdir" and "curdir". */ | |
5798 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); | |
5799 errmsg = e_invarg; | |
5800 } | |
5801 } | |
5802 /* 'viewoptions' */ | |
5803 else if (varp == &p_vop) | |
5804 { | |
5805 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) | |
5806 errmsg = e_invarg; | |
5807 } | |
5808 #endif | |
5809 | |
5810 /* 'scrollopt' */ | |
5811 #ifdef FEAT_SCROLLBIND | |
5812 else if (varp == &p_sbo) | |
5813 { | |
5814 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) | |
5815 errmsg = e_invarg; | |
5816 } | |
5817 #endif | |
5818 | |
5819 /* 'ambiwidth' */ | |
5820 #ifdef FEAT_MBYTE | |
5821 else if (varp == &p_ambw) | |
5822 { | |
5823 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) | |
5824 errmsg = e_invarg; | |
2492
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
5825 else if (set_chars_option(&p_lcs) != NULL) |
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
5826 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'"); |
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
5827 # if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
5828 else if (set_chars_option(&p_fcs) != NULL) |
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
5829 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'"); |
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
5830 # endif |
7 | 5831 } |
5832 #endif | |
5833 | |
5834 /* 'background' */ | |
5835 else if (varp == &p_bg) | |
5836 { | |
5837 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) | |
5838 { | |
5839 #ifdef FEAT_EVAL | |
5840 int dark = (*p_bg == 'd'); | |
5841 #endif | |
5842 | |
5843 init_highlight(FALSE, FALSE); | |
5844 | |
5845 #ifdef FEAT_EVAL | |
5846 if (dark != (*p_bg == 'd') | |
5847 && get_var_value((char_u *)"g:colors_name") != NULL) | |
5848 { | |
5849 /* The color scheme must have set 'background' back to another | |
5850 * value, that's not what we want here. Disable the color | |
5851 * scheme and set the colors again. */ | |
148 | 5852 do_unlet((char_u *)"g:colors_name", TRUE); |
7 | 5853 free_string_option(p_bg); |
5854 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); | |
5855 check_string_option(&p_bg); | |
5856 init_highlight(FALSE, FALSE); | |
5857 } | |
5858 #endif | |
5859 } | |
5860 else | |
5861 errmsg = e_invarg; | |
5862 } | |
5863 | |
5864 /* 'wildmode' */ | |
5865 else if (varp == &p_wim) | |
5866 { | |
5867 if (check_opt_wim() == FAIL) | |
5868 errmsg = e_invarg; | |
5869 } | |
5870 | |
40 | 5871 #ifdef FEAT_CMDL_COMPL |
5872 /* 'wildoptions' */ | |
5873 else if (varp == &p_wop) | |
5874 { | |
5875 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK) | |
5876 errmsg = e_invarg; | |
5877 } | |
5878 #endif | |
5879 | |
7 | 5880 #ifdef FEAT_WAK |
5881 /* 'winaltkeys' */ | |
5882 else if (varp == &p_wak) | |
5883 { | |
5884 if (*p_wak == NUL | |
5885 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) | |
5886 errmsg = e_invarg; | |
5887 # ifdef FEAT_MENU | |
5888 # ifdef FEAT_GUI_MOTIF | |
5889 else if (gui.in_use) | |
5890 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); | |
5891 # else | |
5892 # ifdef FEAT_GUI_GTK | |
5893 else if (gui.in_use) | |
5894 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); | |
5895 # endif | |
5896 # endif | |
5897 # endif | |
5898 } | |
5899 #endif | |
5900 | |
5901 #ifdef FEAT_AUTOCMD | |
5902 /* 'eventignore' */ | |
5903 else if (varp == &p_ei) | |
5904 { | |
5905 if (check_ei() == FAIL) | |
5906 errmsg = e_invarg; | |
5907 } | |
5908 #endif | |
5909 | |
5910 #ifdef FEAT_MBYTE | |
5911 /* 'encoding' and 'fileencoding' */ | |
5912 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc) | |
5913 { | |
5914 if (gvarp == &p_fenc) | |
5915 { | |
1535 | 5916 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL) |
7 | 5917 errmsg = e_modifiable; |
5918 else if (vim_strchr(*varp, ',') != NULL) | |
5919 /* No comma allowed in 'fileencoding'; catches confusing it | |
5920 * with 'fileencodings'. */ | |
5921 errmsg = e_invarg; | |
39 | 5922 else |
5923 { | |
7 | 5924 # ifdef FEAT_TITLE |
5925 /* May show a "+" in the title now. */ | |
1805 | 5926 redraw_titles(); |
7 | 5927 # endif |
39 | 5928 /* Add 'fileencoding' to the swap file. */ |
5929 ml_setflags(curbuf); | |
5930 } | |
7 | 5931 } |
5932 if (errmsg == NULL) | |
5933 { | |
5934 /* canonize the value, so that STRCMP() can be used on it */ | |
5935 p = enc_canonize(*varp); | |
5936 if (p != NULL) | |
5937 { | |
5938 vim_free(*varp); | |
5939 *varp = p; | |
5940 } | |
5941 if (varp == &p_enc) | |
5942 { | |
5943 errmsg = mb_init(); | |
5944 # ifdef FEAT_TITLE | |
1805 | 5945 redraw_titles(); |
7 | 5946 # endif |
5947 } | |
5948 } | |
5949 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2271
diff
changeset
|
5950 # if defined(FEAT_GUI_GTK) |
7 | 5951 if (errmsg == NULL && varp == &p_tenc && gui.in_use) |
5952 { | |
5953 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */ | |
5954 if (STRCMP(p_tenc, "utf-8") != 0) | |
5955 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI"); | |
5956 } | |
5957 # endif | |
5958 | |
5959 if (errmsg == NULL) | |
5960 { | |
5961 # ifdef FEAT_KEYMAP | |
5962 /* When 'keymap' is used and 'encoding' changes, reload the keymap | |
5963 * (with another encoding). */ | |
5964 if (varp == &p_enc && *curbuf->b_p_keymap != NUL) | |
5965 (void)keymap_init(); | |
5966 # endif | |
5967 | |
5968 /* When 'termencoding' is not empty and 'encoding' changes or when | |
5969 * 'termencoding' changes, need to setup for keyboard input and | |
5970 * display output conversion. */ | |
5971 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) | |
5972 { | |
5973 convert_setup(&input_conv, p_tenc, p_enc); | |
5974 convert_setup(&output_conv, p_enc, p_tenc); | |
5975 } | |
170 | 5976 |
5977 # if defined(WIN3264) && defined(FEAT_MBYTE) | |
5978 /* $HOME may have characters in active code page. */ | |
5979 if (varp == &p_enc) | |
5980 init_homedir(); | |
5981 # endif | |
7 | 5982 } |
5983 } | |
5984 #endif | |
5985 | |
5986 #if defined(FEAT_POSTSCRIPT) | |
5987 else if (varp == &p_penc) | |
5988 { | |
5989 /* Canonize printencoding if VIM standard one */ | |
5990 p = enc_canonize(p_penc); | |
5991 if (p != NULL) | |
5992 { | |
5993 vim_free(p_penc); | |
5994 p_penc = p; | |
5995 } | |
5996 else | |
5997 { | |
5998 /* Ensure lower case and '-' for '_' */ | |
5999 for (s = p_penc; *s != NUL; s++) | |
6000 { | |
6001 if (*s == '_') | |
6002 *s = '-'; | |
6003 else | |
6004 *s = TOLOWER_ASC(*s); | |
6005 } | |
6006 } | |
6007 } | |
6008 #endif | |
6009 | |
574 | 6010 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
7 | 6011 else if (varp == &p_imak) |
6012 { | |
6013 if (gui.in_use && !im_xim_isvalid_imactivate()) | |
6014 errmsg = e_invarg; | |
6015 } | |
6016 #endif | |
6017 | |
6018 #ifdef FEAT_KEYMAP | |
6019 else if (varp == &curbuf->b_p_keymap) | |
6020 { | |
6021 /* load or unload key mapping tables */ | |
6022 errmsg = keymap_init(); | |
6023 | |
1833 | 6024 if (errmsg == NULL) |
6025 { | |
6026 if (*curbuf->b_p_keymap != NUL) | |
6027 { | |
6028 /* Installed a new keymap, switch on using it. */ | |
6029 curbuf->b_p_iminsert = B_IMODE_LMAP; | |
6030 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) | |
6031 curbuf->b_p_imsearch = B_IMODE_LMAP; | |
6032 } | |
6033 else | |
6034 { | |
6035 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */ | |
6036 if (curbuf->b_p_iminsert == B_IMODE_LMAP) | |
6037 curbuf->b_p_iminsert = B_IMODE_NONE; | |
6038 if (curbuf->b_p_imsearch == B_IMODE_LMAP) | |
6039 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
6040 } | |
6041 if ((opt_flags & OPT_LOCAL) == 0) | |
6042 { | |
6043 set_iminsert_global(); | |
6044 set_imsearch_global(); | |
6045 } | |
7 | 6046 # ifdef FEAT_WINDOWS |
6047 status_redraw_curbuf(); | |
6048 # endif | |
6049 } | |
6050 } | |
6051 #endif | |
6052 | |
6053 /* 'fileformat' */ | |
6054 else if (gvarp == &p_ff) | |
6055 { | |
6056 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) | |
6057 errmsg = e_modifiable; | |
6058 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) | |
6059 errmsg = e_invarg; | |
6060 else | |
6061 { | |
6062 /* may also change 'textmode' */ | |
6063 if (get_fileformat(curbuf) == EOL_DOS) | |
6064 curbuf->b_p_tx = TRUE; | |
6065 else | |
6066 curbuf->b_p_tx = FALSE; | |
6067 #ifdef FEAT_TITLE | |
1805 | 6068 redraw_titles(); |
7 | 6069 #endif |
39 | 6070 /* update flag in swap file */ |
6071 ml_setflags(curbuf); | |
2073
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
6072 /* Redraw needed when switching to/from "mac": a CR in the text |
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
6073 * will be displayed differently. */ |
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
6074 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm') |
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
6075 redraw_curbuf_later(NOT_VALID); |
7 | 6076 } |
6077 } | |
6078 | |
6079 /* 'fileformats' */ | |
6080 else if (varp == &p_ffs) | |
6081 { | |
6082 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) | |
6083 errmsg = e_invarg; | |
6084 else | |
6085 { | |
6086 /* also change 'textauto' */ | |
6087 if (*p_ffs == NUL) | |
6088 p_ta = FALSE; | |
6089 else | |
6090 p_ta = TRUE; | |
6091 } | |
6092 } | |
6093 | |
2267 | 6094 #if defined(FEAT_CRYPT) |
7 | 6095 /* 'cryptkey' */ |
6096 else if (gvarp == &p_key) | |
6097 { | |
2267 | 6098 # if defined(FEAT_CMDHIST) |
7 | 6099 /* Make sure the ":set" command doesn't show the new value in the |
6100 * history. */ | |
6101 remove_key_from_history(); | |
2267 | 6102 # endif |
6103 if (STRCMP(curbuf->b_p_key, oldval) != 0) | |
6104 /* Need to update the swapfile. */ | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6105 ml_set_crypt_key(curbuf, oldval, get_crypt_method(curbuf)); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6106 } |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6107 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6108 else if (gvarp == &p_cm) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6109 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6110 if (opt_flags & OPT_LOCAL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6111 p = curbuf->b_p_cm; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6112 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6113 p = p_cm; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6114 if (check_opt_strings(p, p_cm_values, TRUE) != OK) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6115 errmsg = e_invarg; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6116 else if (get_crypt_method(curbuf) > 0 && blowfish_self_test() == FAIL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6117 errmsg = e_invarg; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6118 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6119 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6120 /* When setting the global value to empty, make it "zip". */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6121 if (*p_cm == NUL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6122 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6123 if (new_value_alloced) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6124 free_string_option(p_cm); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6125 p_cm = vim_strsave((char_u *)"zip"); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6126 new_value_alloced = TRUE; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6127 } |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6128 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6129 /* Need to update the swapfile when the effective method changed. |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6130 * Set "s" to the effective old value, "p" to the effective new |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6131 * method and compare. */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6132 if ((opt_flags & OPT_LOCAL) && *oldval == NUL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6133 s = p_cm; /* was previously using the global value */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6134 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6135 s = oldval; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6136 if (*curbuf->b_p_cm == NUL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6137 p = p_cm; /* is now using the global value */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6138 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6139 p = curbuf->b_p_cm; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6140 if (STRCMP(s, p) != 0) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6141 ml_set_crypt_key(curbuf, curbuf->b_p_key, |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6142 crypt_method_from_string(s)); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6143 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6144 /* If the global value changes need to update the swapfile for all |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6145 * buffers using that value. */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6146 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6147 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6148 buf_T *buf; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6149 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6150 for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6151 if (buf != curbuf && *buf->b_p_cm == NUL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6152 ml_set_crypt_key(buf, buf->b_p_key, |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6153 crypt_method_from_string(oldval)); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6154 } |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6155 } |
7 | 6156 } |
6157 #endif | |
6158 | |
6159 /* 'matchpairs' */ | |
6160 else if (gvarp == &p_mps) | |
6161 { | |
4029 | 6162 #ifdef FEAT_MBYTE |
6163 if (has_mbyte) | |
6164 { | |
6165 for (p = *varp; *p != NUL; ++p) | |
6166 { | |
4033 | 6167 int x2 = -1; |
6168 int x3 = -1; | |
4029 | 6169 |
6170 if (*p != NUL) | |
6171 p += mb_ptr2len(p); | |
6172 if (*p != NUL) | |
6173 x2 = *p++; | |
6174 if (*p != NUL) | |
6175 { | |
6176 x3 = mb_ptr2char(p); | |
6177 p += mb_ptr2len(p); | |
6178 } | |
4033 | 6179 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) |
4029 | 6180 { |
6181 errmsg = e_invarg; | |
6182 break; | |
6183 } | |
6184 if (*p == NUL) | |
6185 break; | |
6186 } | |
6187 } | |
6188 else | |
6189 #endif | |
6190 { | |
6191 /* Check for "x:y,x:y" */ | |
6192 for (p = *varp; *p != NUL; p += 4) | |
6193 { | |
6194 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) | |
6195 { | |
6196 errmsg = e_invarg; | |
6197 break; | |
6198 } | |
6199 if (p[3] == NUL) | |
6200 break; | |
6201 } | |
7 | 6202 } |
6203 } | |
6204 | |
6205 #ifdef FEAT_COMMENTS | |
6206 /* 'comments' */ | |
6207 else if (gvarp == &p_com) | |
6208 { | |
6209 for (s = *varp; *s; ) | |
6210 { | |
6211 while (*s && *s != ':') | |
6212 { | |
6213 if (vim_strchr((char_u *)COM_ALL, *s) == NULL | |
6214 && !VIM_ISDIGIT(*s) && *s != '-') | |
6215 { | |
6216 errmsg = illegal_char(errbuf, *s); | |
6217 break; | |
6218 } | |
6219 ++s; | |
6220 } | |
6221 if (*s++ == NUL) | |
6222 errmsg = (char_u *)N_("E524: Missing colon"); | |
6223 else if (*s == ',' || *s == NUL) | |
6224 errmsg = (char_u *)N_("E525: Zero length string"); | |
6225 if (errmsg != NULL) | |
6226 break; | |
6227 while (*s && *s != ',') | |
6228 { | |
6229 if (*s == '\\' && s[1] != NUL) | |
6230 ++s; | |
6231 ++s; | |
6232 } | |
6233 s = skip_to_option_part(s); | |
6234 } | |
6235 } | |
6236 #endif | |
6237 | |
6238 /* 'listchars' */ | |
6239 else if (varp == &p_lcs) | |
6240 { | |
6241 errmsg = set_chars_option(varp); | |
6242 } | |
6243 | |
6244 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
6245 /* 'fillchars' */ | |
6246 else if (varp == &p_fcs) | |
6247 { | |
6248 errmsg = set_chars_option(varp); | |
6249 } | |
6250 #endif | |
6251 | |
6252 #ifdef FEAT_CMDWIN | |
6253 /* 'cedit' */ | |
6254 else if (varp == &p_cedit) | |
6255 { | |
6256 errmsg = check_cedit(); | |
6257 } | |
6258 #endif | |
6259 | |
294 | 6260 /* 'verbosefile' */ |
6261 else if (varp == &p_vfile) | |
6262 { | |
6263 verbose_stop(); | |
6264 if (*p_vfile != NUL && verbose_open() == FAIL) | |
6265 errmsg = e_invarg; | |
6266 } | |
6267 | |
7 | 6268 #ifdef FEAT_VIMINFO |
6269 /* 'viminfo' */ | |
6270 else if (varp == &p_viminfo) | |
6271 { | |
6272 for (s = p_viminfo; *s;) | |
6273 { | |
6274 /* Check it's a valid character */ | |
6275 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) | |
6276 { | |
6277 errmsg = illegal_char(errbuf, *s); | |
6278 break; | |
6279 } | |
6280 if (*s == 'n') /* name is always last one */ | |
6281 { | |
6282 break; | |
6283 } | |
6284 else if (*s == 'r') /* skip until next ',' */ | |
6285 { | |
6286 while (*++s && *s != ',') | |
6287 ; | |
6288 } | |
23 | 6289 else if (*s == '%') |
6290 { | |
6291 /* optional number */ | |
6292 while (vim_isdigit(*++s)) | |
6293 ; | |
6294 } | |
6295 else if (*s == '!' || *s == 'h' || *s == 'c') | |
7 | 6296 ++s; /* no extra chars */ |
6297 else /* must have a number */ | |
6298 { | |
6299 while (vim_isdigit(*++s)) | |
6300 ; | |
6301 | |
6302 if (!VIM_ISDIGIT(*(s - 1))) | |
6303 { | |
6304 if (errbuf != NULL) | |
6305 { | |
133 | 6306 sprintf((char *)errbuf, |
6307 _("E526: Missing number after <%s>"), | |
7 | 6308 transchar_byte(*(s - 1))); |
6309 errmsg = errbuf; | |
6310 } | |
6311 else | |
6312 errmsg = (char_u *)""; | |
6313 break; | |
6314 } | |
6315 } | |
6316 if (*s == ',') | |
6317 ++s; | |
6318 else if (*s) | |
6319 { | |
6320 if (errbuf != NULL) | |
6321 errmsg = (char_u *)N_("E527: Missing comma"); | |
6322 else | |
6323 errmsg = (char_u *)""; | |
6324 break; | |
6325 } | |
6326 } | |
6327 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) | |
6328 errmsg = (char_u *)N_("E528: Must specify a ' value"); | |
6329 } | |
6330 #endif /* FEAT_VIMINFO */ | |
6331 | |
6332 /* terminal options */ | |
6333 else if (istermoption(&options[opt_idx]) && full_screen) | |
6334 { | |
6335 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ | |
6336 if (varp == &T_CCO) | |
6337 { | |
1846 | 6338 int colors = atoi((char *)T_CCO); |
6339 | |
6340 /* Only reinitialize colors if t_Co value has really changed to | |
6341 * avoid expensive reload of colorscheme if t_Co is set to the | |
6342 * same value multiple times. */ | |
6343 if (colors != t_colors) | |
6344 { | |
6345 t_colors = colors; | |
6346 if (t_colors <= 1) | |
6347 { | |
6348 if (new_value_alloced) | |
6349 vim_free(T_CCO); | |
6350 T_CCO = empty_option; | |
6351 } | |
6352 /* We now have a different color setup, initialize it again. */ | |
6353 init_highlight(TRUE, FALSE); | |
6354 } | |
7 | 6355 } |
6356 ttest(FALSE); | |
6357 if (varp == &T_ME) | |
6358 { | |
6359 out_str(T_ME); | |
6360 redraw_later(CLEAR); | |
6361 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32)) | |
6362 /* Since t_me has been set, this probably means that the user | |
6363 * wants to use this as default colors. Need to reset default | |
6364 * background/foreground colors. */ | |
6365 mch_set_normal_colors(); | |
6366 #endif | |
6367 } | |
6368 } | |
6369 | |
6370 #ifdef FEAT_LINEBREAK | |
6371 /* 'showbreak' */ | |
6372 else if (varp == &p_sbr) | |
6373 { | |
6374 for (s = p_sbr; *s; ) | |
6375 { | |
6376 if (ptr2cells(s) != 1) | |
6377 errmsg = (char_u *)N_("E595: contains unprintable or wide character"); | |
39 | 6378 mb_ptr_adv(s); |
7 | 6379 } |
6380 } | |
6381 #endif | |
6382 | |
6383 #ifdef FEAT_GUI | |
6384 /* 'guifont' */ | |
6385 else if (varp == &p_guifont) | |
6386 { | |
6387 if (gui.in_use) | |
6388 { | |
6389 p = p_guifont; | |
574 | 6390 # if defined(FEAT_GUI_GTK) |
7 | 6391 /* |
6392 * Put up a font dialog and let the user select a new value. | |
6393 * If this is cancelled go back to the old value but don't | |
6394 * give an error message. | |
6395 */ | |
6396 if (STRCMP(p, "*") == 0) | |
6397 { | |
6398 p = gui_mch_font_dialog(oldval); | |
6399 | |
6400 if (new_value_alloced) | |
6401 free_string_option(p_guifont); | |
6402 | |
6403 p_guifont = (p != NULL) ? p : vim_strsave(oldval); | |
6404 new_value_alloced = TRUE; | |
6405 } | |
6406 # endif | |
6407 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) | |
6408 { | |
6409 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) | |
6410 if (STRCMP(p_guifont, "*") == 0) | |
6411 { | |
6412 /* Dialog was cancelled: Keep the old value without giving | |
6413 * an error message. */ | |
6414 if (new_value_alloced) | |
6415 free_string_option(p_guifont); | |
6416 p_guifont = vim_strsave(oldval); | |
6417 new_value_alloced = TRUE; | |
6418 } | |
6419 else | |
6420 # endif | |
6421 errmsg = (char_u *)N_("E596: Invalid font(s)"); | |
6422 } | |
6423 } | |
1801 | 6424 redraw_gui_only = TRUE; |
7 | 6425 } |
6426 # ifdef FEAT_XFONTSET | |
6427 else if (varp == &p_guifontset) | |
6428 { | |
6429 if (STRCMP(p_guifontset, "*") == 0) | |
6430 errmsg = (char_u *)N_("E597: can't select fontset"); | |
6431 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) | |
6432 errmsg = (char_u *)N_("E598: Invalid fontset"); | |
1801 | 6433 redraw_gui_only = TRUE; |
7 | 6434 } |
6435 # endif | |
6436 # ifdef FEAT_MBYTE | |
6437 else if (varp == &p_guifontwide) | |
6438 { | |
6439 if (STRCMP(p_guifontwide, "*") == 0) | |
6440 errmsg = (char_u *)N_("E533: can't select wide font"); | |
6441 else if (gui_get_wide_font() == FAIL) | |
6442 errmsg = (char_u *)N_("E534: Invalid wide font"); | |
1801 | 6443 redraw_gui_only = TRUE; |
7 | 6444 } |
6445 # endif | |
6446 #endif | |
6447 | |
6448 #ifdef CURSOR_SHAPE | |
6449 /* 'guicursor' */ | |
6450 else if (varp == &p_guicursor) | |
6451 errmsg = parse_shape_opt(SHAPE_CURSOR); | |
6452 #endif | |
6453 | |
6454 #ifdef FEAT_MOUSESHAPE | |
6455 /* 'mouseshape' */ | |
6456 else if (varp == &p_mouseshape) | |
6457 { | |
6458 errmsg = parse_shape_opt(SHAPE_MOUSE); | |
6459 update_mouseshape(-1); | |
6460 } | |
6461 #endif | |
6462 | |
6463 #ifdef FEAT_PRINTER | |
6464 else if (varp == &p_popt) | |
440 | 6465 errmsg = parse_printoptions(); |
16 | 6466 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT) |
15 | 6467 else if (varp == &p_pmfn) |
440 | 6468 errmsg = parse_printmbfont(); |
15 | 6469 # endif |
7 | 6470 #endif |
6471 | |
6472 #ifdef FEAT_LANGMAP | |
6473 /* 'langmap' */ | |
6474 else if (varp == &p_langmap) | |
6475 langmap_set(); | |
6476 #endif | |
6477 | |
6478 #ifdef FEAT_LINEBREAK | |
6479 /* 'breakat' */ | |
6480 else if (varp == &p_breakat) | |
6481 fill_breakat_flags(); | |
6482 #endif | |
6483 | |
6484 #ifdef FEAT_TITLE | |
6485 /* 'titlestring' and 'iconstring' */ | |
6486 else if (varp == &p_titlestring || varp == &p_iconstring) | |
6487 { | |
6488 # ifdef FEAT_STL_OPT | |
6489 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; | |
6490 | |
6491 /* NULL => statusline syntax */ | |
6492 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) | |
6493 stl_syntax |= flagval; | |
6494 else | |
6495 stl_syntax &= ~flagval; | |
6496 # endif | |
6497 did_set_title(varp == &p_iconstring); | |
6498 | |
6499 } | |
6500 #endif | |
6501 | |
6502 #ifdef FEAT_GUI | |
6503 /* 'guioptions' */ | |
6504 else if (varp == &p_go) | |
1801 | 6505 { |
7 | 6506 gui_init_which_components(oldval); |
1801 | 6507 redraw_gui_only = TRUE; |
6508 } | |
7 | 6509 #endif |
6510 | |
688 | 6511 #if defined(FEAT_GUI_TABLINE) |
6512 /* 'guitablabel' */ | |
6513 else if (varp == &p_gtl) | |
1801 | 6514 { |
827 | 6515 redraw_tabline = TRUE; |
1801 | 6516 redraw_gui_only = TRUE; |
6517 } | |
6518 /* 'guitabtooltip' */ | |
6519 else if (varp == &p_gtt) | |
6520 { | |
6521 redraw_gui_only = TRUE; | |
6522 } | |
688 | 6523 #endif |
6524 | |
7 | 6525 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) |
6526 /* 'ttymouse' */ | |
6527 else if (varp == &p_ttym) | |
6528 { | |
190 | 6529 /* Switch the mouse off before changing the escape sequences used for |
6530 * that. */ | |
6531 mch_setmouse(FALSE); | |
7 | 6532 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) |
6533 errmsg = e_invarg; | |
6534 else | |
6535 check_mouse_termcode(); | |
227 | 6536 if (termcap_active) |
6537 setmouse(); /* may switch it on again */ | |
7 | 6538 } |
6539 #endif | |
6540 | |
6541 #ifdef FEAT_VISUAL | |
6542 /* 'selection' */ | |
6543 else if (varp == &p_sel) | |
6544 { | |
6545 if (*p_sel == NUL | |
6546 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) | |
6547 errmsg = e_invarg; | |
6548 } | |
6549 | |
6550 /* 'selectmode' */ | |
6551 else if (varp == &p_slm) | |
6552 { | |
6553 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) | |
6554 errmsg = e_invarg; | |
6555 } | |
6556 #endif | |
6557 | |
6558 #ifdef FEAT_BROWSE | |
6559 /* 'browsedir' */ | |
6560 else if (varp == &p_bsdir) | |
6561 { | |
6562 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK | |
6563 && !mch_isdir(p_bsdir)) | |
6564 errmsg = e_invarg; | |
6565 } | |
6566 #endif | |
6567 | |
6568 #ifdef FEAT_VISUAL | |
6569 /* 'keymodel' */ | |
6570 else if (varp == &p_km) | |
6571 { | |
6572 if (check_opt_strings(p_km, p_km_values, TRUE) != OK) | |
6573 errmsg = e_invarg; | |
6574 else | |
6575 { | |
6576 km_stopsel = (vim_strchr(p_km, 'o') != NULL); | |
6577 km_startsel = (vim_strchr(p_km, 'a') != NULL); | |
6578 } | |
6579 } | |
6580 #endif | |
6581 | |
6582 /* 'mousemodel' */ | |
6583 else if (varp == &p_mousem) | |
6584 { | |
6585 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) | |
6586 errmsg = e_invarg; | |
6587 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) | |
6588 else if (*p_mousem != *oldval) | |
6589 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need | |
6590 * to create or delete the popup menus. */ | |
6591 gui_motif_update_mousemodel(root_menu); | |
6592 #endif | |
6593 } | |
6594 | |
6595 /* 'switchbuf' */ | |
6596 else if (varp == &p_swb) | |
6597 { | |
1622 | 6598 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK) |
7 | 6599 errmsg = e_invarg; |
6600 } | |
6601 | |
6602 /* 'debug' */ | |
6603 else if (varp == &p_debug) | |
6604 { | |
839 | 6605 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK) |
7 | 6606 errmsg = e_invarg; |
6607 } | |
6608 | |
6609 /* 'display' */ | |
6610 else if (varp == &p_dy) | |
6611 { | |
6612 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) | |
6613 errmsg = e_invarg; | |
6614 else | |
6615 (void)init_chartab(); | |
6616 | |
6617 } | |
6618 | |
6619 #ifdef FEAT_VERTSPLIT | |
6620 /* 'eadirection' */ | |
6621 else if (varp == &p_ead) | |
6622 { | |
6623 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) | |
6624 errmsg = e_invarg; | |
6625 } | |
6626 #endif | |
6627 | |
6628 #ifdef FEAT_CLIPBOARD | |
6629 /* 'clipboard' */ | |
6630 else if (varp == &p_cb) | |
6631 errmsg = check_clipboard_option(); | |
6632 #endif | |
6633 | |
744 | 6634 #ifdef FEAT_SPELL |
323 | 6635 /* When 'spelllang' or 'spellfile' is set and there is a window for this |
6636 * buffer in which 'spell' is set load the wordlists. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6637 else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf)) |
221 | 6638 { |
258 | 6639 win_T *wp; |
323 | 6640 int l; |
6641 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6642 if (varp == &(curbuf->b_s.b_p_spf)) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6643 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6644 l = (int)STRLEN(curbuf->b_s.b_p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6645 if (l > 0 && (l < 4 || STRCMP(curbuf->b_s.b_p_spf + l - 4, |
323 | 6646 ".add") != 0)) |
6647 errmsg = e_invarg; | |
6648 } | |
6649 | |
6650 if (errmsg == NULL) | |
6651 { | |
6652 FOR_ALL_WINDOWS(wp) | |
6653 if (wp->w_buffer == curbuf && wp->w_p_spell) | |
6654 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6655 errmsg = did_set_spelllang(wp); |
258 | 6656 # ifdef FEAT_WINDOWS |
323 | 6657 break; |
258 | 6658 # endif |
323 | 6659 } |
6660 } | |
221 | 6661 } |
386 | 6662 /* When 'spellcapcheck' is set compile the regexp program. */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6663 else if (varp == &(curwin->w_s->b_p_spc)) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6664 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6665 errmsg = compile_cap_prog(curwin->w_s); |
386 | 6666 } |
344 | 6667 /* 'spellsuggest' */ |
6668 else if (varp == &p_sps) | |
6669 { | |
374 | 6670 if (spell_check_sps() != OK) |
344 | 6671 errmsg = e_invarg; |
6672 } | |
484 | 6673 /* 'mkspellmem' */ |
6674 else if (varp == &p_msm) | |
6675 { | |
6676 if (spell_check_msm() != OK) | |
6677 errmsg = e_invarg; | |
6678 } | |
221 | 6679 #endif |
6680 | |
7 | 6681 #ifdef FEAT_QUICKFIX |
6682 /* When 'bufhidden' is set, check for valid value. */ | |
6683 else if (gvarp == &p_bh) | |
6684 { | |
6685 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) | |
6686 errmsg = e_invarg; | |
6687 } | |
6688 | |
6689 /* When 'buftype' is set, check for valid value. */ | |
6690 else if (gvarp == &p_bt) | |
6691 { | |
6692 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) | |
6693 errmsg = e_invarg; | |
6694 else | |
6695 { | |
6696 # ifdef FEAT_WINDOWS | |
6697 if (curwin->w_status_height) | |
6698 { | |
6699 curwin->w_redr_status = TRUE; | |
6700 redraw_later(VALID); | |
6701 } | |
6702 # endif | |
6703 curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); | |
2060
1da25369227b
updated for version 7.2.345
Bram Moolenaar <bram@zimbu.org>
parents:
1958
diff
changeset
|
6704 # ifdef FEAT_TITLE |
1da25369227b
updated for version 7.2.345
Bram Moolenaar <bram@zimbu.org>
parents:
1958
diff
changeset
|
6705 redraw_titles(); |
1da25369227b
updated for version 7.2.345
Bram Moolenaar <bram@zimbu.org>
parents:
1958
diff
changeset
|
6706 # endif |
7 | 6707 } |
6708 } | |
6709 #endif | |
6710 | |
6711 #ifdef FEAT_STL_OPT | |
6712 /* 'statusline' or 'rulerformat' */ | |
40 | 6713 else if (gvarp == &p_stl || varp == &p_ruf) |
7 | 6714 { |
6715 int wid; | |
6716 | |
6717 if (varp == &p_ruf) /* reset ru_wid first */ | |
6718 ru_wid = 0; | |
6719 s = *varp; | |
6720 if (varp == &p_ruf && *s == '%') | |
6721 { | |
6722 /* set ru_wid if 'ruf' starts with "%99(" */ | |
6723 if (*++s == '-') /* ignore a '-' */ | |
6724 s++; | |
6725 wid = getdigits(&s); | |
6726 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) | |
6727 ru_wid = wid; | |
6728 else | |
6729 errmsg = check_stl_option(p_ruf); | |
6730 } | |
917 | 6731 /* check 'statusline' only if it doesn't start with "%!" */ |
1382 | 6732 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') |
7 | 6733 errmsg = check_stl_option(s); |
40 | 6734 if (varp == &p_ruf && errmsg == NULL) |
7 | 6735 comp_col(); |
6736 } | |
6737 #endif | |
6738 | |
6739 #ifdef FEAT_INS_EXPAND | |
6740 /* check if it is a valid value for 'complete' -- Acevedo */ | |
6741 else if (gvarp == &p_cpt) | |
6742 { | |
6743 for (s = *varp; *s;) | |
6744 { | |
3634 | 6745 while (*s == ',' || *s == ' ') |
7 | 6746 s++; |
6747 if (!*s) | |
6748 break; | |
6749 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) | |
6750 { | |
6751 errmsg = illegal_char(errbuf, *s); | |
6752 break; | |
6753 } | |
6754 if (*++s != NUL && *s != ',' && *s != ' ') | |
6755 { | |
6756 if (s[-1] == 'k' || s[-1] == 's') | |
6757 { | |
6758 /* skip optional filename after 'k' and 's' */ | |
6759 while (*s && *s != ',' && *s != ' ') | |
6760 { | |
6761 if (*s == '\\') | |
6762 ++s; | |
6763 ++s; | |
6764 } | |
6765 } | |
6766 else | |
6767 { | |
6768 if (errbuf != NULL) | |
6769 { | |
6770 sprintf((char *)errbuf, | |
6771 _("E535: Illegal character after <%c>"), | |
6772 *--s); | |
6773 errmsg = errbuf; | |
6774 } | |
6775 else | |
6776 errmsg = (char_u *)""; | |
6777 break; | |
6778 } | |
6779 } | |
6780 } | |
6781 } | |
540 | 6782 |
6783 /* 'completeopt' */ | |
6784 else if (varp == &p_cot) | |
6785 { | |
6786 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK) | |
6787 errmsg = e_invarg; | |
6788 } | |
7 | 6789 #endif /* FEAT_INS_EXPAND */ |
6790 | |
6791 | |
6792 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) | |
6793 else if (varp == &p_toolbar) | |
6794 { | |
6795 if (opt_strings_flags(p_toolbar, p_toolbar_values, | |
6796 &toolbar_flags, TRUE) != OK) | |
6797 errmsg = e_invarg; | |
6798 else | |
6799 { | |
6800 out_flush(); | |
6801 gui_mch_show_toolbar((toolbar_flags & | |
6802 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); | |
6803 } | |
6804 } | |
6805 #endif | |
6806 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2271
diff
changeset
|
6807 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) |
7 | 6808 /* 'toolbariconsize': GTK+ 2 only */ |
6809 else if (varp == &p_tbis) | |
6810 { | |
6811 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) | |
6812 errmsg = e_invarg; | |
6813 else | |
6814 { | |
6815 out_flush(); | |
6816 gui_mch_show_toolbar((toolbar_flags & | |
6817 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); | |
6818 } | |
6819 } | |
6820 #endif | |
6821 | |
6822 /* 'pastetoggle': translate key codes like in a mapping */ | |
6823 else if (varp == &p_pt) | |
6824 { | |
6825 if (*p_pt) | |
6826 { | |
859 | 6827 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE); |
7 | 6828 if (p != NULL) |
6829 { | |
6830 if (new_value_alloced) | |
6831 free_string_option(p_pt); | |
6832 p_pt = p; | |
6833 new_value_alloced = TRUE; | |
6834 } | |
6835 } | |
6836 } | |
6837 | |
6838 /* 'backspace' */ | |
6839 else if (varp == &p_bs) | |
6840 { | |
6841 if (VIM_ISDIGIT(*p_bs)) | |
6842 { | |
6843 if (*p_bs >'2' || p_bs[1] != NUL) | |
6844 errmsg = e_invarg; | |
6845 } | |
6846 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) | |
6847 errmsg = e_invarg; | |
6848 } | |
6849 | |
805 | 6850 #ifdef FEAT_MBYTE |
7 | 6851 /* 'casemap' */ |
6852 else if (varp == &p_cmp) | |
6853 { | |
6854 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) | |
6855 errmsg = e_invarg; | |
6856 } | |
805 | 6857 #endif |
7 | 6858 |
6859 #ifdef FEAT_DIFF | |
6860 /* 'diffopt' */ | |
6861 else if (varp == &p_dip) | |
6862 { | |
6863 if (diffopt_changed() == FAIL) | |
6864 errmsg = e_invarg; | |
6865 } | |
6866 #endif | |
6867 | |
6868 #ifdef FEAT_FOLDING | |
6869 /* 'foldmethod' */ | |
6870 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) | |
6871 { | |
6872 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK | |
6873 || *curwin->w_p_fdm == NUL) | |
6874 errmsg = e_invarg; | |
6875 else | |
2086
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
6876 { |
7 | 6877 foldUpdateAll(curwin); |
2086
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
6878 if (foldmethodIsDiff(curwin)) |
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
6879 newFoldLevel(); |
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
6880 } |
7 | 6881 } |
6882 # ifdef FEAT_EVAL | |
6883 /* 'foldexpr' */ | |
6884 else if (varp == &curwin->w_p_fde) | |
6885 { | |
6886 if (foldmethodIsExpr(curwin)) | |
6887 foldUpdateAll(curwin); | |
6888 } | |
6889 # endif | |
6890 /* 'foldmarker' */ | |
6891 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) | |
6892 { | |
6893 p = vim_strchr(*varp, ','); | |
6894 if (p == NULL) | |
6895 errmsg = (char_u *)N_("E536: comma required"); | |
6896 else if (p == *varp || p[1] == NUL) | |
6897 errmsg = e_invarg; | |
6898 else if (foldmethodIsMarker(curwin)) | |
6899 foldUpdateAll(curwin); | |
6900 } | |
6901 /* 'commentstring' */ | |
6902 else if (gvarp == &p_cms) | |
6903 { | |
6904 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) | |
6905 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s"); | |
6906 } | |
6907 /* 'foldopen' */ | |
6908 else if (varp == &p_fdo) | |
6909 { | |
6910 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) | |
6911 errmsg = e_invarg; | |
6912 } | |
6913 /* 'foldclose' */ | |
6914 else if (varp == &p_fcl) | |
6915 { | |
6916 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) | |
6917 errmsg = e_invarg; | |
6918 } | |
828 | 6919 /* 'foldignore' */ |
6920 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi) | |
6921 { | |
6922 if (foldmethodIsIndent(curwin)) | |
6923 foldUpdateAll(curwin); | |
6924 } | |
7 | 6925 #endif |
6926 | |
6927 #ifdef FEAT_VIRTUALEDIT | |
6928 /* 'virtualedit' */ | |
6929 else if (varp == &p_ve) | |
6930 { | |
6931 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK) | |
6932 errmsg = e_invarg; | |
6933 else if (STRCMP(p_ve, oldval) != 0) | |
6934 { | |
6935 /* Recompute cursor position in case the new 've' setting | |
6936 * changes something. */ | |
6937 validate_virtcol(); | |
6938 coladvance(curwin->w_virtcol); | |
6939 } | |
6940 } | |
6941 #endif | |
6942 | |
6943 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) | |
6944 else if (varp == &p_csqf) | |
6945 { | |
6946 if (p_csqf != NULL) | |
6947 { | |
6948 p = p_csqf; | |
6949 while (*p != NUL) | |
6950 { | |
6951 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL | |
6952 || p[1] == NUL | |
6953 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL | |
6954 || (p[2] != NUL && p[2] != ',')) | |
6955 { | |
6956 errmsg = e_invarg; | |
6957 break; | |
6958 } | |
6959 else if (p[2] == NUL) | |
6960 break; | |
6961 else | |
6962 p += 3; | |
6963 } | |
6964 } | |
6965 } | |
6966 #endif | |
6967 | |
6968 /* Options that are a list of flags. */ | |
6969 else | |
6970 { | |
6971 p = NULL; | |
6972 if (varp == &p_ww) | |
6973 p = (char_u *)WW_ALL; | |
6974 if (varp == &p_shm) | |
6975 p = (char_u *)SHM_ALL; | |
6976 else if (varp == &(p_cpo)) | |
6977 p = (char_u *)CPO_ALL; | |
6978 else if (varp == &(curbuf->b_p_fo)) | |
6979 p = (char_u *)FO_ALL; | |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
6980 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
6981 else if (varp == &curwin->w_p_cocu) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
6982 p = (char_u *)COCU_ALL; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
6983 #endif |
7 | 6984 else if (varp == &p_mouse) |
6985 { | |
6986 #ifdef FEAT_MOUSE | |
6987 p = (char_u *)MOUSE_ALL; | |
6988 #else | |
6989 if (*p_mouse != NUL) | |
6990 errmsg = (char_u *)N_("E538: No mouse support"); | |
6991 #endif | |
6992 } | |
6993 #if defined(FEAT_GUI) | |
6994 else if (varp == &p_go) | |
6995 p = (char_u *)GO_ALL; | |
6996 #endif | |
6997 if (p != NULL) | |
6998 { | |
6999 for (s = *varp; *s; ++s) | |
7000 if (vim_strchr(p, *s) == NULL) | |
7001 { | |
7002 errmsg = illegal_char(errbuf, *s); | |
7003 break; | |
7004 } | |
7005 } | |
7006 } | |
7007 | |
7008 /* | |
7009 * If error detected, restore the previous value. | |
7010 */ | |
7011 if (errmsg != NULL) | |
7012 { | |
7013 if (new_value_alloced) | |
7014 free_string_option(*varp); | |
7015 *varp = oldval; | |
7016 /* | |
7017 * When resetting some values, need to act on it. | |
7018 */ | |
7019 if (did_chartab) | |
7020 (void)init_chartab(); | |
7021 if (varp == &p_hl) | |
7022 (void)highlight_changed(); | |
7023 } | |
7024 else | |
7025 { | |
7026 #ifdef FEAT_EVAL | |
7027 /* Remember where the option was set. */ | |
694 | 7028 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); |
7 | 7029 #endif |
7030 /* | |
7031 * Free string options that are in allocated memory. | |
24 | 7032 * Use "free_oldval", because recursiveness may change the flags under |
7033 * our fingers (esp. init_highlight()). | |
7 | 7034 */ |
24 | 7035 if (free_oldval) |
7 | 7036 free_string_option(oldval); |
7037 if (new_value_alloced) | |
7038 options[opt_idx].flags |= P_ALLOCED; | |
7039 else | |
7040 options[opt_idx].flags &= ~P_ALLOCED; | |
7041 | |
7042 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 7043 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 7044 { |
7045 /* global option with local value set to use global value; free | |
7046 * the local value and make it empty */ | |
7047 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); | |
7048 free_string_option(*(char_u **)p); | |
7049 *(char_u **)p = empty_option; | |
7050 } | |
7051 | |
7052 /* May set global value for local option. */ | |
7053 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) | |
7054 set_string_option_global(opt_idx, varp); | |
480 | 7055 |
7056 #ifdef FEAT_AUTOCMD | |
7057 /* | |
7058 * Trigger the autocommand only after setting the flags. | |
7059 */ | |
7060 # ifdef FEAT_SYN_HL | |
7061 /* When 'syntax' is set, load the syntax of that name */ | |
7062 if (varp == &(curbuf->b_p_syn)) | |
7063 { | |
7064 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, | |
7065 curbuf->b_fname, TRUE, curbuf); | |
7066 } | |
7067 # endif | |
7068 else if (varp == &(curbuf->b_p_ft)) | |
7069 { | |
7070 /* 'filetype' is set, trigger the FileType autocommand */ | |
7071 did_filetype = TRUE; | |
7072 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, | |
7073 curbuf->b_fname, TRUE, curbuf); | |
7074 } | |
7075 #endif | |
744 | 7076 #ifdef FEAT_SPELL |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7077 if (varp == &(curwin->w_s->b_p_spl)) |
480 | 7078 { |
7079 char_u fname[200]; | |
7080 | |
7081 /* | |
7082 * Source the spell/LANG.vim in 'runtimepath'. | |
7083 * They could set 'spellcapcheck' depending on the language. | |
7084 * Use the first name in 'spelllang' up to '_region' or | |
7085 * '.encoding'. | |
7086 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7087 for (p = curwin->w_s->b_p_spl; *p != NUL; ++p) |
480 | 7088 if (vim_strchr((char_u *)"_.,", *p) != NULL) |
7089 break; | |
7090 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7091 (int)(p - curwin->w_s->b_p_spl), curwin->w_s->b_p_spl); |
480 | 7092 source_runtime(fname, TRUE); |
7093 } | |
7094 #endif | |
7 | 7095 } |
7096 | |
7097 #ifdef FEAT_MOUSE | |
7098 if (varp == &p_mouse) | |
7099 { | |
7100 # ifdef FEAT_MOUSE_TTY | |
7101 if (*p_mouse == NUL) | |
7102 mch_setmouse(FALSE); /* switch mouse off */ | |
7103 else | |
7104 # endif | |
7105 setmouse(); /* in case 'mouse' changed */ | |
7106 } | |
7107 #endif | |
7108 | |
3443 | 7109 if (curwin->w_curswant != MAXCOL |
7110 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0) | |
7111 curwin->w_set_curswant = TRUE; | |
7112 | |
1801 | 7113 #ifdef FEAT_GUI |
7114 /* check redraw when it's not a GUI option or the GUI is active. */ | |
7115 if (!redraw_gui_only || gui.in_use) | |
7116 #endif | |
7117 check_redraw(options[opt_idx].flags); | |
7 | 7118 |
7119 return errmsg; | |
7120 } | |
7121 | |
4113 | 7122 #if defined(FEAT_SYN_HL) || defined(PROTO) |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7123 /* |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7124 * Simple int comparison function for use with qsort() |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7125 */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7126 static int |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7127 int_cmp(a, b) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7128 const void *a; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7129 const void *b; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7130 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7131 return *(const int *)a - *(const int *)b; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7132 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7133 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7134 /* |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7135 * Handle setting 'colorcolumn' or 'textwidth' in window "wp". |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7136 * Returns error message, NULL if it's OK. |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7137 */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7138 char_u * |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7139 check_colorcolumn(wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7140 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7141 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7142 char_u *s; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7143 int col; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7144 int count = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7145 int color_cols[256]; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7146 int i; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7147 int j = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7148 |
3089 | 7149 if (wp->w_buffer == NULL) |
7150 return NULL; /* buffer was closed */ | |
7151 | |
2323
1a6c5a3ff687
Fix bad parsing of 'colorcolumn'. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2317
diff
changeset
|
7152 for (s = wp->w_p_cc; *s != NUL && count < 255;) |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7153 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7154 if (*s == '-' || *s == '+') |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7155 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7156 /* -N and +N: add to 'textwidth' */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7157 col = (*s == '-') ? -1 : 1; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7158 ++s; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7159 if (!VIM_ISDIGIT(*s)) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7160 return e_invarg; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7161 col = col * getdigits(&s); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7162 if (wp->w_buffer->b_p_tw == 0) |
2323
1a6c5a3ff687
Fix bad parsing of 'colorcolumn'. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2317
diff
changeset
|
7163 goto skip; /* 'textwidth' not set, skip this item */ |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7164 col += wp->w_buffer->b_p_tw; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7165 if (col < 0) |
2323
1a6c5a3ff687
Fix bad parsing of 'colorcolumn'. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2317
diff
changeset
|
7166 goto skip; |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7167 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7168 else if (VIM_ISDIGIT(*s)) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7169 col = getdigits(&s); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7170 else |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7171 return e_invarg; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7172 color_cols[count++] = col - 1; /* 1-based to 0-based */ |
2323
1a6c5a3ff687
Fix bad parsing of 'colorcolumn'. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2317
diff
changeset
|
7173 skip: |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7174 if (*s == NUL) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7175 break; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7176 if (*s != ',') |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7177 return e_invarg; |
2323
1a6c5a3ff687
Fix bad parsing of 'colorcolumn'. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2317
diff
changeset
|
7178 if (*++s == NUL) |
1a6c5a3ff687
Fix bad parsing of 'colorcolumn'. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2317
diff
changeset
|
7179 return e_invarg; /* illegal trailing comma as in "set cc=80," */ |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7180 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7181 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7182 vim_free(wp->w_p_cc_cols); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7183 if (count == 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7184 wp->w_p_cc_cols = NULL; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7185 else |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7186 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7187 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1)); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7188 if (wp->w_p_cc_cols != NULL) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7189 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7190 /* sort the columns for faster usage on screen redraw inside |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7191 * win_line() */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7192 qsort(color_cols, count, sizeof(int), int_cmp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7193 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7194 for (i = 0; i < count; ++i) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7195 /* skip duplicates */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7196 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7197 wp->w_p_cc_cols[j++] = color_cols[i]; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7198 wp->w_p_cc_cols[j] = -1; /* end marker */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7199 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7200 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7201 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7202 return NULL; /* no error */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7203 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7204 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7205 |
7 | 7206 /* |
7207 * Handle setting 'listchars' or 'fillchars'. | |
7208 * Returns error message, NULL if it's OK. | |
7209 */ | |
7210 static char_u * | |
7211 set_chars_option(varp) | |
7212 char_u **varp; | |
7213 { | |
7214 int round, i, len, entries; | |
7215 char_u *p, *s; | |
7216 int c1, c2 = 0; | |
7217 struct charstab | |
7218 { | |
7219 int *cp; | |
7220 char *name; | |
7221 }; | |
7222 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
7223 static struct charstab filltab[] = | |
7224 { | |
7225 {&fill_stl, "stl"}, | |
7226 {&fill_stlnc, "stlnc"}, | |
7227 {&fill_vert, "vert"}, | |
7228 {&fill_fold, "fold"}, | |
7229 {&fill_diff, "diff"}, | |
7230 }; | |
7231 #endif | |
7232 static struct charstab lcstab[] = | |
7233 { | |
7234 {&lcs_eol, "eol"}, | |
7235 {&lcs_ext, "extends"}, | |
12 | 7236 {&lcs_nbsp, "nbsp"}, |
7 | 7237 {&lcs_prec, "precedes"}, |
7238 {&lcs_tab2, "tab"}, | |
7239 {&lcs_trail, "trail"}, | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7240 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7241 {&lcs_conceal, "conceal"}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7242 #else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7243 {NULL, "conceal"}, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7244 #endif |
7 | 7245 }; |
7246 struct charstab *tab; | |
7247 | |
7248 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
7249 if (varp == &p_lcs) | |
7250 #endif | |
7251 { | |
7252 tab = lcstab; | |
7253 entries = sizeof(lcstab) / sizeof(struct charstab); | |
7254 } | |
7255 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
7256 else | |
7257 { | |
7258 tab = filltab; | |
7259 entries = sizeof(filltab) / sizeof(struct charstab); | |
7260 } | |
7261 #endif | |
7262 | |
7263 /* first round: check for valid value, second round: assign values */ | |
7264 for (round = 0; round <= 1; ++round) | |
7265 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7266 if (round > 0) |
7 | 7267 { |
7268 /* After checking that the value is valid: set defaults: space for | |
7269 * 'fillchars', NUL for 'listchars' */ | |
7270 for (i = 0; i < entries; ++i) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7271 if (tab[i].cp != NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7272 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); |
7 | 7273 if (varp == &p_lcs) |
7274 lcs_tab1 = NUL; | |
7275 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) | |
7276 else | |
7277 fill_diff = '-'; | |
7278 #endif | |
7279 } | |
7280 p = *varp; | |
7281 while (*p) | |
7282 { | |
7283 for (i = 0; i < entries; ++i) | |
7284 { | |
7285 len = (int)STRLEN(tab[i].name); | |
7286 if (STRNCMP(p, tab[i].name, len) == 0 | |
7287 && p[len] == ':' | |
7288 && p[len + 1] != NUL) | |
7289 { | |
7290 s = p + len + 1; | |
7291 #ifdef FEAT_MBYTE | |
7292 c1 = mb_ptr2char_adv(&s); | |
819 | 7293 if (mb_char2cells(c1) > 1) |
7294 continue; | |
7 | 7295 #else |
7296 c1 = *s++; | |
7297 #endif | |
7298 if (tab[i].cp == &lcs_tab2) | |
7299 { | |
7300 if (*s == NUL) | |
7301 continue; | |
7302 #ifdef FEAT_MBYTE | |
7303 c2 = mb_ptr2char_adv(&s); | |
819 | 7304 if (mb_char2cells(c2) > 1) |
7305 continue; | |
7 | 7306 #else |
7307 c2 = *s++; | |
7308 #endif | |
7309 } | |
7310 if (*s == ',' || *s == NUL) | |
7311 { | |
7312 if (round) | |
7313 { | |
7314 if (tab[i].cp == &lcs_tab2) | |
7315 { | |
7316 lcs_tab1 = c1; | |
7317 lcs_tab2 = c2; | |
7318 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7319 else if (tab[i].cp != NULL) |
7 | 7320 *(tab[i].cp) = c1; |
7321 | |
7322 } | |
7323 p = s; | |
7324 break; | |
7325 } | |
7326 } | |
7327 } | |
7328 | |
7329 if (i == entries) | |
7330 return e_invarg; | |
7331 if (*p == ',') | |
7332 ++p; | |
7333 } | |
7334 } | |
7335 | |
7336 return NULL; /* no error */ | |
7337 } | |
7338 | |
7339 #ifdef FEAT_STL_OPT | |
7340 /* | |
7341 * Check validity of options with the 'statusline' format. | |
7342 * Return error message or NULL. | |
7343 */ | |
7344 char_u * | |
7345 check_stl_option(s) | |
7346 char_u *s; | |
7347 { | |
7348 int itemcnt = 0; | |
7349 int groupdepth = 0; | |
7350 static char_u errbuf[80]; | |
7351 | |
7352 while (*s && itemcnt < STL_MAX_ITEM) | |
7353 { | |
7354 /* Check for valid keys after % sequences */ | |
7355 while (*s && *s != '%') | |
7356 s++; | |
7357 if (!*s) | |
7358 break; | |
7359 s++; | |
7360 if (*s != '%' && *s != ')') | |
7361 ++itemcnt; | |
7362 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK) | |
7363 { | |
7364 s++; | |
7365 continue; | |
7366 } | |
7367 if (*s == ')') | |
7368 { | |
7369 s++; | |
7370 if (--groupdepth < 0) | |
7371 break; | |
7372 continue; | |
7373 } | |
7374 if (*s == '-') | |
7375 s++; | |
7376 while (VIM_ISDIGIT(*s)) | |
7377 s++; | |
680 | 7378 if (*s == STL_USER_HL) |
7 | 7379 continue; |
7380 if (*s == '.') | |
7381 { | |
7382 s++; | |
7383 while (*s && VIM_ISDIGIT(*s)) | |
7384 s++; | |
7385 } | |
7386 if (*s == '(') | |
7387 { | |
7388 groupdepth++; | |
7389 continue; | |
7390 } | |
7391 if (vim_strchr(STL_ALL, *s) == NULL) | |
7392 { | |
7393 return illegal_char(errbuf, *s); | |
7394 } | |
7395 if (*s == '{') | |
7396 { | |
7397 s++; | |
7398 while (*s != '}' && *s) | |
7399 s++; | |
7400 if (*s != '}') | |
7401 return (char_u *)N_("E540: Unclosed expression sequence"); | |
7402 } | |
7403 } | |
7404 if (itemcnt >= STL_MAX_ITEM) | |
7405 return (char_u *)N_("E541: too many items"); | |
7406 if (groupdepth != 0) | |
7407 return (char_u *)N_("E542: unbalanced groups"); | |
7408 return NULL; | |
7409 } | |
7410 #endif | |
7411 | |
7412 #ifdef FEAT_CLIPBOARD | |
7413 /* | |
7414 * Extract the items in the 'clipboard' option and set global values. | |
7415 */ | |
7416 static char_u * | |
7417 check_clipboard_option() | |
7418 { | |
2654 | 7419 int new_unnamed = 0; |
3678 | 7420 int new_autoselect_star = FALSE; |
7421 int new_autoselect_plus = FALSE; | |
7 | 7422 int new_autoselectml = FALSE; |
1904 | 7423 int new_html = FALSE; |
7 | 7424 regprog_T *new_exclude_prog = NULL; |
7425 char_u *errmsg = NULL; | |
7426 char_u *p; | |
7427 | |
7428 for (p = p_cb; *p != NUL; ) | |
7429 { | |
7430 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) | |
7431 { | |
2654 | 7432 new_unnamed |= CLIP_UNNAMED; |
7 | 7433 p += 7; |
7434 } | |
3634 | 7435 else if (STRNCMP(p, "unnamedplus", 11) == 0 |
2654 | 7436 && (p[11] == ',' || p[11] == NUL)) |
7437 { | |
7438 new_unnamed |= CLIP_UNNAMED_PLUS; | |
7439 p += 11; | |
7440 } | |
7 | 7441 else if (STRNCMP(p, "autoselect", 10) == 0 |
3678 | 7442 && (p[10] == ',' || p[10] == NUL)) |
7443 { | |
7444 new_autoselect_star = TRUE; | |
7 | 7445 p += 10; |
7446 } | |
3678 | 7447 else if (STRNCMP(p, "autoselectplus", 14) == 0 |
7448 && (p[14] == ',' || p[14] == NUL)) | |
7449 { | |
7450 new_autoselect_plus = TRUE; | |
7451 p += 14; | |
7452 } | |
7 | 7453 else if (STRNCMP(p, "autoselectml", 12) == 0 |
3678 | 7454 && (p[12] == ',' || p[12] == NUL)) |
7 | 7455 { |
7456 new_autoselectml = TRUE; | |
7457 p += 12; | |
7458 } | |
1904 | 7459 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL)) |
7460 { | |
7461 new_html = TRUE; | |
7462 p += 4; | |
7463 } | |
7 | 7464 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) |
7465 { | |
7466 p += 8; | |
7467 new_exclude_prog = vim_regcomp(p, RE_MAGIC); | |
7468 if (new_exclude_prog == NULL) | |
7469 errmsg = e_invarg; | |
7470 break; | |
7471 } | |
7472 else | |
7473 { | |
7474 errmsg = e_invarg; | |
7475 break; | |
7476 } | |
7477 if (*p == ',') | |
7478 ++p; | |
7479 } | |
7480 if (errmsg == NULL) | |
7481 { | |
7482 clip_unnamed = new_unnamed; | |
3678 | 7483 clip_autoselect_star = new_autoselect_star; |
7484 clip_autoselect_plus = new_autoselect_plus; | |
7 | 7485 clip_autoselectml = new_autoselectml; |
1904 | 7486 clip_html = new_html; |
7 | 7487 vim_free(clip_exclude_prog); |
7488 clip_exclude_prog = new_exclude_prog; | |
2248 | 7489 #ifdef FEAT_GUI_GTK |
2183 | 7490 if (gui.in_use) |
7491 { | |
7492 gui_gtk_set_selection_targets(); | |
7493 gui_gtk_set_dnd_targets(); | |
7494 } | |
7495 #endif | |
7 | 7496 } |
7497 else | |
7498 vim_free(new_exclude_prog); | |
7499 | |
7500 return errmsg; | |
7501 } | |
7502 #endif | |
7503 | |
744 | 7504 #ifdef FEAT_SPELL |
386 | 7505 /* |
7506 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'. | |
7507 * Return error message when failed, NULL when OK. | |
7508 */ | |
7509 static char_u * | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7510 compile_cap_prog(synblock) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7511 synblock_T *synblock; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7512 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7513 regprog_T *rp = synblock->b_cap_prog; |
582 | 7514 char_u *re; |
389 | 7515 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7516 if (*synblock->b_p_spc == NUL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7517 synblock->b_cap_prog = NULL; |
582 | 7518 else |
7519 { | |
7520 /* Prepend a ^ so that we only match at one column */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7521 re = concat_str((char_u *)"^", synblock->b_p_spc); |
582 | 7522 if (re != NULL) |
7523 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7524 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7525 if (synblock->b_cap_prog == NULL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7526 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7527 synblock->b_cap_prog = rp; /* restore the previous program */ |
582 | 7528 return e_invarg; |
7529 } | |
7530 vim_free(re); | |
7531 } | |
386 | 7532 } |
7533 | |
7534 vim_free(rp); | |
7535 return NULL; | |
7536 } | |
7537 #endif | |
7538 | |
681 | 7539 #if defined(FEAT_EVAL) || defined(PROTO) |
7540 /* | |
694 | 7541 * Set the scriptID for an option, taking care of setting the buffer- or |
7542 * window-local value. | |
681 | 7543 */ |
694 | 7544 static void |
7545 set_option_scriptID_idx(opt_idx, opt_flags, id) | |
7546 int opt_idx; | |
7547 int opt_flags; | |
7548 int id; | |
7549 { | |
7550 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
7551 int indir = (int)options[opt_idx].indir; | |
7552 | |
7553 /* Remember where the option was set. For local options need to do that | |
7554 * in the buffer or window structure. */ | |
7555 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) | |
681 | 7556 options[opt_idx].scriptID = id; |
694 | 7557 if (both || (opt_flags & OPT_LOCAL)) |
7558 { | |
7559 if (indir & PV_BUF) | |
7560 curbuf->b_p_scriptID[indir & PV_MASK] = id; | |
7561 else if (indir & PV_WIN) | |
7562 curwin->w_p_scriptID[indir & PV_MASK] = id; | |
7563 } | |
681 | 7564 } |
7565 #endif | |
7566 | |
7 | 7567 /* |
7568 * Set the value of a boolean option, and take care of side effects. | |
7569 * Returns NULL for success, or an error message for an error. | |
7570 */ | |
7571 static char_u * | |
7572 set_bool_option(opt_idx, varp, value, opt_flags) | |
7573 int opt_idx; /* index in options[] table */ | |
7574 char_u *varp; /* pointer to the option variable */ | |
7575 int value; /* new value */ | |
7576 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ | |
7577 { | |
7578 int old_value = *(int *)varp; | |
7579 | |
7580 /* Disallow changing some options from secure mode */ | |
7581 if ((secure | |
7582 #ifdef HAVE_SANDBOX | |
7583 || sandbox != 0 | |
7584 #endif | |
7585 ) && (options[opt_idx].flags & P_SECURE)) | |
7586 return e_secure; | |
7587 | |
7588 *(int *)varp = value; /* set the new value */ | |
7589 #ifdef FEAT_EVAL | |
7590 /* Remember where the option was set. */ | |
694 | 7591 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); |
7 | 7592 #endif |
7593 | |
634 | 7594 #ifdef FEAT_GUI |
7595 need_mouse_correct = TRUE; | |
7596 #endif | |
7597 | |
7 | 7598 /* May set global value for local option. */ |
7599 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
7600 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
7601 | |
7602 /* | |
7603 * Handle side effects of changing a bool option. | |
7604 */ | |
7605 | |
7606 /* 'compatible' */ | |
7607 if ((int *)varp == &p_cp) | |
7608 { | |
7609 compatible_set(); | |
7610 } | |
7611 | |
3246 | 7612 #ifdef FEAT_PERSISTENT_UNDO |
7613 /* 'undofile' */ | |
7614 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) | |
7615 { | |
3894 | 7616 /* Only take action when the option was set. When reset we do not |
7617 * delete the undo file, the option may be set again without making | |
7618 * any changes in between. */ | |
7619 if (curbuf->b_p_udf || p_udf) | |
7620 { | |
7621 char_u hash[UNDO_HASH_SIZE]; | |
7622 buf_T *save_curbuf = curbuf; | |
7623 | |
7624 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next) | |
7625 { | |
7626 /* When 'undofile' is set globally: for every buffer, otherwise | |
7627 * only for the current buffer: Try to read in the undofile, | |
7628 * if one exists, the buffer wasn't changed and the buffer was | |
7629 * loaded */ | |
7630 if ((curbuf == save_curbuf | |
3246 | 7631 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 7632 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
7633 { | |
7634 u_compute_hash(hash); | |
7635 u_read_undo(NULL, hash, curbuf->b_fname); | |
7636 } | |
7637 } | |
7638 curbuf = save_curbuf; | |
7639 } | |
3246 | 7640 } |
7641 #endif | |
7642 | |
4219 | 7643 /* If 'number' is set, reset 'relativenumber'. */ |
7644 /* If 'relativenumber' is set, reset 'number'. */ | |
7645 else if ((int *)varp == &curwin->w_p_nu && curwin->w_p_nu) | |
7646 { | |
7647 curwin->w_p_rnu = FALSE; | |
7648 | |
7649 /* Only reset the global value if the own value is set globally. */ | |
7650 if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)) | |
4113 | 7651 curwin->w_allbuf_opt.wo_rnu = FALSE; |
4219 | 7652 } |
7653 else if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu) | |
7654 { | |
7655 curwin->w_p_nu = FALSE; | |
7656 | |
7657 /* Only reset the global value if the own value is set globally. */ | |
7658 if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)) | |
4113 | 7659 curwin->w_allbuf_opt.wo_nu = FALSE; |
4219 | 7660 } |
7661 else if ((int *)varp == &curwin->w_allbuf_opt.wo_nu | |
7662 && curwin->w_allbuf_opt.wo_nu) | |
7663 { | |
7664 curwin->w_allbuf_opt.wo_rnu = FALSE; | |
7665 } | |
7666 else if ((int *)varp == &curwin->w_allbuf_opt.wo_rnu | |
7667 && curwin->w_allbuf_opt.wo_rnu) | |
7668 { | |
7669 curwin->w_allbuf_opt.wo_nu = FALSE; | |
1945 | 7670 } |
7671 | |
7 | 7672 else if ((int *)varp == &curbuf->b_p_ro) |
7673 { | |
548 | 7674 /* when 'readonly' is reset globally, also reset readonlymode */ |
7 | 7675 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
7676 readonlymode = FALSE; | |
548 | 7677 |
7678 /* when 'readonly' is set may give W10 again */ | |
7679 if (curbuf->b_p_ro) | |
7680 curbuf->b_did_warn = FALSE; | |
7681 | |
7 | 7682 #ifdef FEAT_TITLE |
1805 | 7683 redraw_titles(); |
7 | 7684 #endif |
7685 } | |
7686 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7687 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7688 else if ((int *)varp == &p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7689 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7690 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7691 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7692 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7693 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
7694 |
7 | 7695 #ifdef FEAT_TITLE |
7696 /* when 'modifiable' is changed, redraw the window title */ | |
7697 else if ((int *)varp == &curbuf->b_p_ma) | |
1805 | 7698 { |
7699 redraw_titles(); | |
7700 } | |
7 | 7701 /* when 'endofline' is changed, redraw the window title */ |
7702 else if ((int *)varp == &curbuf->b_p_eol) | |
1805 | 7703 { |
7704 redraw_titles(); | |
7705 } | |
7706 # ifdef FEAT_MBYTE | |
7707 /* when 'bomb' is changed, redraw the window title and tab page text */ | |
1352 | 7708 else if ((int *)varp == &curbuf->b_p_bomb) |
1805 | 7709 { |
7710 redraw_titles(); | |
7711 } | |
7712 # endif | |
7 | 7713 #endif |
7714 | |
7715 /* when 'bin' is set also set some other options */ | |
7716 else if ((int *)varp == &curbuf->b_p_bin) | |
7717 { | |
7718 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
7719 #ifdef FEAT_TITLE | |
1805 | 7720 redraw_titles(); |
7 | 7721 #endif |
7722 } | |
7723 | |
7724 #ifdef FEAT_AUTOCMD | |
7725 /* when 'buflisted' changes, trigger autocommands */ | |
7726 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) | |
7727 { | |
7728 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
7729 NULL, NULL, TRUE, curbuf); | |
7730 } | |
7731 #endif | |
7732 | |
7733 /* when 'swf' is set, create swapfile, when reset remove swapfile */ | |
7734 else if ((int *)varp == &curbuf->b_p_swf) | |
7735 { | |
7736 if (curbuf->b_p_swf && p_uc) | |
7737 ml_open_file(curbuf); /* create the swap file */ | |
7738 else | |
1157 | 7739 /* no need to reset curbuf->b_may_swap, ml_open_file() will check |
7740 * buf->b_p_swf */ | |
7 | 7741 mf_close_file(curbuf, TRUE); /* remove the swap file */ |
7742 } | |
7743 | |
7744 /* when 'terse' is set change 'shortmess' */ | |
7745 else if ((int *)varp == &p_terse) | |
7746 { | |
7747 char_u *p; | |
7748 | |
7749 p = vim_strchr(p_shm, SHM_SEARCH); | |
7750 | |
7751 /* insert 's' in p_shm */ | |
7752 if (p_terse && p == NULL) | |
7753 { | |
7754 STRCPY(IObuff, p_shm); | |
7755 STRCAT(IObuff, "s"); | |
694 | 7756 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 7757 } |
7758 /* remove 's' from p_shm */ | |
7759 else if (!p_terse && p != NULL) | |
1622 | 7760 STRMOVE(p, p + 1); |
7 | 7761 } |
7762 | |
7763 /* when 'paste' is set or reset also change other options */ | |
7764 else if ((int *)varp == &p_paste) | |
7765 { | |
7766 paste_option_changed(); | |
7767 } | |
7768 | |
7769 /* when 'insertmode' is set from an autocommand need to do work here */ | |
7770 else if ((int *)varp == &p_im) | |
7771 { | |
7772 if (p_im) | |
7773 { | |
7774 if ((State & INSERT) == 0) | |
7775 need_start_insertmode = TRUE; | |
7776 stop_insert_mode = FALSE; | |
7777 } | |
7778 else | |
7779 { | |
7780 need_start_insertmode = FALSE; | |
7781 stop_insert_mode = TRUE; | |
644 | 7782 if (restart_edit != 0 && mode_displayed) |
7 | 7783 clear_cmdline = TRUE; /* remove "(insert)" */ |
7784 restart_edit = 0; | |
7785 } | |
7786 } | |
7787 | |
7788 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ | |
7789 else if ((int *)varp == &p_ic && p_hls) | |
7790 { | |
744 | 7791 redraw_all_later(SOME_VALID); |
7 | 7792 } |
7793 | |
7794 #ifdef FEAT_SEARCH_EXTRA | |
7795 /* when 'hlsearch' is set or reset: reset no_hlsearch */ | |
7796 else if ((int *)varp == &p_hls) | |
7797 { | |
7798 no_hlsearch = FALSE; | |
7799 } | |
7800 #endif | |
7801 | |
7802 #ifdef FEAT_SCROLLBIND | |
7803 /* when 'scrollbind' is set: snapshot the current position to avoid a jump | |
7804 * at the end of normal_cmd() */ | |
7805 else if ((int *)varp == &curwin->w_p_scb) | |
7806 { | |
7807 if (curwin->w_p_scb) | |
7808 do_check_scrollbind(FALSE); | |
7809 } | |
7810 #endif | |
7811 | |
7812 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | |
7813 /* There can be only one window with 'previewwindow' set. */ | |
7814 else if ((int *)varp == &curwin->w_p_pvw) | |
7815 { | |
7816 if (curwin->w_p_pvw) | |
7817 { | |
7818 win_T *win; | |
7819 | |
7820 for (win = firstwin; win != NULL; win = win->w_next) | |
7821 if (win->w_p_pvw && win != curwin) | |
7822 { | |
7823 curwin->w_p_pvw = FALSE; | |
7824 return (char_u *)N_("E590: A preview window already exists"); | |
7825 } | |
7826 } | |
7827 } | |
7828 #endif | |
7829 | |
7830 /* when 'textmode' is set or reset also change 'fileformat' */ | |
7831 else if ((int *)varp == &curbuf->b_p_tx) | |
7832 { | |
7833 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
7834 } | |
7835 | |
7836 /* when 'textauto' is set or reset also change 'fileformats' */ | |
7837 else if ((int *)varp == &p_ta) | |
7838 set_string_option_direct((char_u *)"ffs", -1, | |
7839 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 7840 OPT_FREE | opt_flags, 0); |
7 | 7841 |
7842 /* | |
7843 * When 'lisp' option changes include/exclude '-' in | |
7844 * keyword characters. | |
7845 */ | |
7846 #ifdef FEAT_LISP | |
7847 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
7848 { | |
7849 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ | |
7850 } | |
7851 #endif | |
7852 | |
7853 #ifdef FEAT_TITLE | |
7854 /* when 'title' changed, may need to change the title; same for 'icon' */ | |
7855 else if ((int *)varp == &p_title) | |
7856 { | |
7857 did_set_title(FALSE); | |
7858 } | |
7859 | |
7860 else if ((int *)varp == &p_icon) | |
7861 { | |
7862 did_set_title(TRUE); | |
7863 } | |
7864 #endif | |
7865 | |
7866 else if ((int *)varp == &curbuf->b_changed) | |
7867 { | |
7868 if (!value) | |
7869 save_file_ff(curbuf); /* Buffer is unchanged */ | |
7870 #ifdef FEAT_TITLE | |
1805 | 7871 redraw_titles(); |
7 | 7872 #endif |
7873 #ifdef FEAT_AUTOCMD | |
7874 modified_was_set = value; | |
7875 #endif | |
7876 } | |
7877 | |
7878 #ifdef BACKSLASH_IN_FILENAME | |
7879 else if ((int *)varp == &p_ssl) | |
7880 { | |
7881 if (p_ssl) | |
7882 { | |
7883 psepc = '/'; | |
7884 psepcN = '\\'; | |
7885 pseps[0] = '/'; | |
7886 } | |
7887 else | |
7888 { | |
7889 psepc = '\\'; | |
7890 psepcN = '/'; | |
7891 pseps[0] = '\\'; | |
7892 } | |
7893 | |
7894 /* need to adjust the file name arguments and buffer names. */ | |
7895 buflist_slash_adjust(); | |
7896 alist_slash_adjust(); | |
7897 # ifdef FEAT_EVAL | |
7898 scriptnames_slash_adjust(); | |
7899 # endif | |
7900 } | |
7901 #endif | |
7902 | |
7903 /* If 'wrap' is set, set w_leftcol to zero. */ | |
7904 else if ((int *)varp == &curwin->w_p_wrap) | |
7905 { | |
7906 if (curwin->w_p_wrap) | |
7907 curwin->w_leftcol = 0; | |
7908 } | |
7909 | |
7910 #ifdef FEAT_WINDOWS | |
7911 else if ((int *)varp == &p_ea) | |
7912 { | |
7913 if (p_ea && !old_value) | |
7914 win_equal(curwin, FALSE, 0); | |
7915 } | |
7916 #endif | |
7917 | |
7918 else if ((int *)varp == &p_wiv) | |
7919 { | |
7920 /* | |
7921 * When 'weirdinvert' changed, set/reset 't_xs'. | |
7922 * Then set 'weirdinvert' according to value of 't_xs'. | |
7923 */ | |
7924 if (p_wiv && !old_value) | |
7925 T_XS = (char_u *)"y"; | |
7926 else if (!p_wiv && old_value) | |
7927 T_XS = empty_option; | |
7928 p_wiv = (*T_XS != NUL); | |
7929 } | |
7930 | |
190 | 7931 #ifdef FEAT_BEVAL |
7 | 7932 else if ((int *)varp == &p_beval) |
7933 { | |
3170 | 7934 if (p_beval && !old_value) |
7 | 7935 gui_mch_enable_beval_area(balloonEval); |
3170 | 7936 else if (!p_beval && old_value) |
7 | 7937 gui_mch_disable_beval_area(balloonEval); |
7938 } | |
820 | 7939 #endif |
7940 | |
7941 #ifdef FEAT_AUTOCHDIR | |
7 | 7942 else if ((int *)varp == &p_acd) |
7943 { | |
961 | 7944 /* Change directories when the 'acd' option is set now. */ |
7945 DO_AUTOCHDIR | |
7 | 7946 } |
7947 #endif | |
7948 | |
7949 #ifdef FEAT_DIFF | |
7950 /* 'diff' */ | |
7951 else if ((int *)varp == &curwin->w_p_diff) | |
7952 { | |
16 | 7953 /* May add or remove the buffer from the list of diff buffers. */ |
7954 diff_buf_adjust(curwin); | |
7955 # ifdef FEAT_FOLDING | |
7 | 7956 if (foldmethodIsDiff(curwin)) |
7957 foldUpdateAll(curwin); | |
16 | 7958 # endif |
7 | 7959 } |
7960 #endif | |
7961 | |
7962 #ifdef USE_IM_CONTROL | |
7963 /* 'imdisable' */ | |
7964 else if ((int *)varp == &p_imdisable) | |
7965 { | |
7966 /* Only de-activate it here, it will be enabled when changing mode. */ | |
7967 if (p_imdisable) | |
7968 im_set_active(FALSE); | |
3129 | 7969 else if (State & INSERT) |
7970 /* When the option is set from an autocommand, it may need to take | |
7971 * effect right away. */ | |
7972 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); | |
7 | 7973 } |
7974 #endif | |
7975 | |
744 | 7976 #ifdef FEAT_SPELL |
258 | 7977 /* 'spell' */ |
7978 else if ((int *)varp == &curwin->w_p_spell) | |
7979 { | |
7980 if (curwin->w_p_spell) | |
7981 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7982 char_u *errmsg = did_set_spelllang(curwin); |
258 | 7983 if (errmsg != NULL) |
7984 EMSG(_(errmsg)); | |
7985 } | |
7986 } | |
7987 #endif | |
7988 | |
7 | 7989 #ifdef FEAT_FKMAP |
7990 else if ((int *)varp == &p_altkeymap) | |
7991 { | |
7992 if (old_value != p_altkeymap) | |
7993 { | |
7994 if (!p_altkeymap) | |
7995 { | |
7996 p_hkmap = p_fkmap; | |
7997 p_fkmap = 0; | |
7998 } | |
7999 else | |
8000 { | |
8001 p_fkmap = p_hkmap; | |
8002 p_hkmap = 0; | |
8003 } | |
8004 (void)init_chartab(); | |
8005 } | |
8006 } | |
8007 | |
8008 /* | |
8009 * In case some second language keymapping options have changed, check | |
8010 * and correct the setting in a consistent way. | |
8011 */ | |
8012 | |
8013 /* | |
8014 * If hkmap or fkmap are set, reset Arabic keymapping. | |
8015 */ | |
8016 if ((p_hkmap || p_fkmap) && p_altkeymap) | |
8017 { | |
8018 p_altkeymap = p_fkmap; | |
8019 # ifdef FEAT_ARABIC | |
8020 curwin->w_p_arab = FALSE; | |
8021 # endif | |
8022 (void)init_chartab(); | |
8023 } | |
8024 | |
8025 /* | |
8026 * If hkmap set, reset Farsi keymapping. | |
8027 */ | |
8028 if (p_hkmap && p_altkeymap) | |
8029 { | |
8030 p_altkeymap = 0; | |
8031 p_fkmap = 0; | |
8032 # ifdef FEAT_ARABIC | |
8033 curwin->w_p_arab = FALSE; | |
8034 # endif | |
8035 (void)init_chartab(); | |
8036 } | |
8037 | |
8038 /* | |
8039 * If fkmap set, reset Hebrew keymapping. | |
8040 */ | |
8041 if (p_fkmap && !p_altkeymap) | |
8042 { | |
8043 p_altkeymap = 1; | |
8044 p_hkmap = 0; | |
8045 # ifdef FEAT_ARABIC | |
8046 curwin->w_p_arab = FALSE; | |
8047 # endif | |
8048 (void)init_chartab(); | |
8049 } | |
8050 #endif | |
8051 | |
8052 #ifdef FEAT_ARABIC | |
8053 if ((int *)varp == &curwin->w_p_arab) | |
8054 { | |
8055 if (curwin->w_p_arab) | |
8056 { | |
8057 /* | |
8058 * 'arabic' is set, handle various sub-settings. | |
8059 */ | |
8060 if (!p_tbidi) | |
8061 { | |
8062 /* set rightleft mode */ | |
8063 if (!curwin->w_p_rl) | |
8064 { | |
8065 curwin->w_p_rl = TRUE; | |
8066 changed_window_setting(); | |
8067 } | |
8068 | |
8069 /* Enable Arabic shaping (major part of what Arabic requires) */ | |
8070 if (!p_arshape) | |
8071 { | |
8072 p_arshape = TRUE; | |
8073 redraw_later_clear(); | |
8074 } | |
8075 } | |
8076 | |
8077 /* Arabic requires a utf-8 encoding, inform the user if its not | |
8078 * set. */ | |
8079 if (STRCMP(p_enc, "utf-8") != 0) | |
16 | 8080 { |
1848 | 8081 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
8082 | |
16 | 8083 msg_source(hl_attr(HLF_W)); |
1848 | 8084 MSG_ATTR(_(w_arabic), hl_attr(HLF_W)); |
8085 #ifdef FEAT_EVAL | |
8086 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
8087 #endif | |
16 | 8088 } |
7 | 8089 |
8090 # ifdef FEAT_MBYTE | |
8091 /* set 'delcombine' */ | |
8092 p_deco = TRUE; | |
8093 # endif | |
8094 | |
8095 # ifdef FEAT_KEYMAP | |
8096 /* Force-set the necessary keymap for arabic */ | |
8097 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", | |
8098 OPT_LOCAL); | |
8099 # endif | |
8100 # ifdef FEAT_FKMAP | |
8101 p_altkeymap = 0; | |
8102 p_hkmap = 0; | |
8103 p_fkmap = 0; | |
8104 (void)init_chartab(); | |
8105 # endif | |
8106 } | |
8107 else | |
8108 { | |
8109 /* | |
8110 * 'arabic' is reset, handle various sub-settings. | |
8111 */ | |
8112 if (!p_tbidi) | |
8113 { | |
8114 /* reset rightleft mode */ | |
8115 if (curwin->w_p_rl) | |
8116 { | |
8117 curwin->w_p_rl = FALSE; | |
8118 changed_window_setting(); | |
8119 } | |
8120 | |
8121 /* 'arabicshape' isn't reset, it is a global option and | |
8122 * another window may still need it "on". */ | |
8123 } | |
8124 | |
8125 /* 'delcombine' isn't reset, it is a global option and another | |
8126 * window may still want it "on". */ | |
8127 | |
8128 # ifdef FEAT_KEYMAP | |
8129 /* Revert to the default keymap */ | |
8130 curbuf->b_p_iminsert = B_IMODE_NONE; | |
8131 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
8132 # endif | |
8133 } | |
3443 | 8134 } |
8135 | |
1958 | 8136 #endif |
8137 | |
7 | 8138 /* |
8139 * End of handling side effects for bool options. | |
8140 */ | |
8141 | |
8142 options[opt_idx].flags |= P_WAS_SET; | |
8143 | |
8144 comp_col(); /* in case 'ruler' or 'showcmd' changed */ | |
3443 | 8145 if (curwin->w_curswant != MAXCOL |
8146 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0) | |
8147 curwin->w_set_curswant = TRUE; | |
7 | 8148 check_redraw(options[opt_idx].flags); |
8149 | |
8150 return NULL; | |
8151 } | |
8152 | |
8153 /* | |
8154 * Set the value of a number option, and take care of side effects. | |
8155 * Returns NULL for success, or an error message for an error. | |
8156 */ | |
8157 static char_u * | |
274 | 8158 set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags) |
7 | 8159 int opt_idx; /* index in options[] table */ |
8160 char_u *varp; /* pointer to the option variable */ | |
8161 long value; /* new value */ | |
8162 char_u *errbuf; /* buffer for error messages */ | |
274 | 8163 size_t errbuflen; /* length of "errbuf" */ |
7 | 8164 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and |
8165 OPT_MODELINE */ | |
8166 { | |
8167 char_u *errmsg = NULL; | |
8168 long old_value = *(long *)varp; | |
8169 long old_Rows = Rows; /* remember old Rows */ | |
8170 long old_Columns = Columns; /* remember old Columns */ | |
8171 long *pp = (long *)varp; | |
8172 | |
634 | 8173 /* Disallow changing some options from secure mode. */ |
8174 if ((secure | |
8175 #ifdef HAVE_SANDBOX | |
8176 || sandbox != 0 | |
8177 #endif | |
8178 ) && (options[opt_idx].flags & P_SECURE)) | |
8179 return e_secure; | |
7 | 8180 |
8181 *pp = value; | |
8182 #ifdef FEAT_EVAL | |
8183 /* Remember where the option was set. */ | |
694 | 8184 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); |
7 | 8185 #endif |
634 | 8186 #ifdef FEAT_GUI |
8187 need_mouse_correct = TRUE; | |
8188 #endif | |
7 | 8189 |
3740 | 8190 if (curbuf->b_p_sw < 0) |
7 | 8191 { |
8192 errmsg = e_positive; | |
8193 curbuf->b_p_sw = curbuf->b_p_ts; | |
8194 } | |
8195 | |
8196 /* | |
8197 * Number options that need some action when changed | |
8198 */ | |
8199 #ifdef FEAT_WINDOWS | |
8200 if (pp == &p_wh || pp == &p_hh) | |
8201 { | |
8202 if (p_wh < 1) | |
8203 { | |
8204 errmsg = e_positive; | |
8205 p_wh = 1; | |
8206 } | |
8207 if (p_wmh > p_wh) | |
8208 { | |
8209 errmsg = e_winheight; | |
8210 p_wh = p_wmh; | |
8211 } | |
8212 if (p_hh < 0) | |
8213 { | |
8214 errmsg = e_positive; | |
8215 p_hh = 0; | |
8216 } | |
8217 | |
8218 /* Change window height NOW */ | |
8219 if (lastwin != firstwin) | |
8220 { | |
8221 if (pp == &p_wh && curwin->w_height < p_wh) | |
8222 win_setheight((int)p_wh); | |
8223 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
8224 win_setheight((int)p_hh); | |
8225 } | |
8226 } | |
8227 | |
8228 /* 'winminheight' */ | |
8229 else if (pp == &p_wmh) | |
8230 { | |
8231 if (p_wmh < 0) | |
8232 { | |
8233 errmsg = e_positive; | |
8234 p_wmh = 0; | |
8235 } | |
8236 if (p_wmh > p_wh) | |
8237 { | |
8238 errmsg = e_winheight; | |
8239 p_wmh = p_wh; | |
8240 } | |
8241 win_setminheight(); | |
8242 } | |
8243 | |
8244 # ifdef FEAT_VERTSPLIT | |
13 | 8245 else if (pp == &p_wiw) |
7 | 8246 { |
8247 if (p_wiw < 1) | |
8248 { | |
8249 errmsg = e_positive; | |
8250 p_wiw = 1; | |
8251 } | |
8252 if (p_wmw > p_wiw) | |
8253 { | |
8254 errmsg = e_winwidth; | |
8255 p_wiw = p_wmw; | |
8256 } | |
8257 | |
8258 /* Change window width NOW */ | |
8259 if (lastwin != firstwin && curwin->w_width < p_wiw) | |
8260 win_setwidth((int)p_wiw); | |
8261 } | |
8262 | |
8263 /* 'winminwidth' */ | |
8264 else if (pp == &p_wmw) | |
8265 { | |
8266 if (p_wmw < 0) | |
8267 { | |
8268 errmsg = e_positive; | |
8269 p_wmw = 0; | |
8270 } | |
8271 if (p_wmw > p_wiw) | |
8272 { | |
8273 errmsg = e_winwidth; | |
8274 p_wmw = p_wiw; | |
8275 } | |
8276 win_setminheight(); | |
8277 } | |
8278 # endif | |
8279 | |
8280 #endif | |
8281 | |
8282 #ifdef FEAT_WINDOWS | |
8283 /* (re)set last window status line */ | |
8284 else if (pp == &p_ls) | |
8285 { | |
8286 last_status(FALSE); | |
8287 } | |
670 | 8288 |
8289 /* (re)set tab page line */ | |
677 | 8290 else if (pp == &p_stal) |
670 | 8291 { |
8292 shell_new_rows(); /* recompute window positions and heights */ | |
8293 } | |
7 | 8294 #endif |
8295 | |
8296 #ifdef FEAT_GUI | |
8297 else if (pp == &p_linespace) | |
8298 { | |
444 | 8299 /* Recompute gui.char_height and resize the Vim window to keep the |
8300 * same number of lines. */ | |
8301 if (gui.in_use && gui_mch_adjust_charheight() == OK) | |
813 | 8302 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 8303 } |
8304 #endif | |
8305 | |
8306 #ifdef FEAT_FOLDING | |
8307 /* 'foldlevel' */ | |
8308 else if (pp == &curwin->w_p_fdl) | |
8309 { | |
8310 if (curwin->w_p_fdl < 0) | |
8311 curwin->w_p_fdl = 0; | |
8312 newFoldLevel(); | |
8313 } | |
8314 | |
1805 | 8315 /* 'foldminlines' */ |
7 | 8316 else if (pp == &curwin->w_p_fml) |
8317 { | |
8318 foldUpdateAll(curwin); | |
8319 } | |
8320 | |
8321 /* 'foldnestmax' */ | |
8322 else if (pp == &curwin->w_p_fdn) | |
8323 { | |
8324 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
8325 foldUpdateAll(curwin); | |
8326 } | |
8327 | |
8328 /* 'foldcolumn' */ | |
8329 else if (pp == &curwin->w_p_fdc) | |
8330 { | |
8331 if (curwin->w_p_fdc < 0) | |
8332 { | |
8333 errmsg = e_positive; | |
8334 curwin->w_p_fdc = 0; | |
8335 } | |
8336 else if (curwin->w_p_fdc > 12) | |
8337 { | |
8338 errmsg = e_invarg; | |
8339 curwin->w_p_fdc = 12; | |
8340 } | |
8341 } | |
8342 | |
8343 /* 'shiftwidth' or 'tabstop' */ | |
8344 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) | |
8345 { | |
8346 if (foldmethodIsIndent(curwin)) | |
8347 foldUpdateAll(curwin); | |
8348 } | |
8349 #endif /* FEAT_FOLDING */ | |
8350 | |
714 | 8351 #ifdef FEAT_MBYTE |
8352 /* 'maxcombine' */ | |
8353 else if (pp == &p_mco) | |
8354 { | |
8355 if (p_mco > MAX_MCO) | |
8356 p_mco = MAX_MCO; | |
8357 else if (p_mco < 0) | |
8358 p_mco = 0; | |
8359 screenclear(); /* will re-allocate the screen */ | |
8360 } | |
8361 #endif | |
8362 | |
7 | 8363 else if (pp == &curbuf->b_p_iminsert) |
8364 { | |
8365 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
8366 { | |
8367 errmsg = e_invarg; | |
8368 curbuf->b_p_iminsert = B_IMODE_NONE; | |
8369 } | |
8370 p_iminsert = curbuf->b_p_iminsert; | |
8371 if (termcap_active) /* don't do this in the alternate screen */ | |
8372 showmode(); | |
8373 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP) | |
8374 /* Show/unshow value of 'keymap' in status lines. */ | |
8375 status_redraw_curbuf(); | |
8376 #endif | |
8377 } | |
8378 | |
164 | 8379 else if (pp == &p_window) |
8380 { | |
8381 if (p_window < 1) | |
8382 p_window = 1; | |
8383 else if (p_window >= Rows) | |
8384 p_window = Rows - 1; | |
8385 } | |
8386 | |
7 | 8387 else if (pp == &curbuf->b_p_imsearch) |
8388 { | |
8389 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
8390 { | |
8391 errmsg = e_invarg; | |
8392 curbuf->b_p_imsearch = B_IMODE_NONE; | |
8393 } | |
8394 p_imsearch = curbuf->b_p_imsearch; | |
8395 } | |
8396 | |
8397 #ifdef FEAT_TITLE | |
8398 /* if 'titlelen' has changed, redraw the title */ | |
8399 else if (pp == &p_titlelen) | |
8400 { | |
8401 if (p_titlelen < 0) | |
8402 { | |
8403 errmsg = e_positive; | |
8404 p_titlelen = 85; | |
8405 } | |
8406 if (starting != NO_SCREEN && old_value != p_titlelen) | |
8407 need_maketitle = TRUE; | |
8408 } | |
8409 #endif | |
8410 | |
8411 /* if p_ch changed value, change the command line height */ | |
8412 else if (pp == &p_ch) | |
8413 { | |
8414 if (p_ch < 1) | |
8415 { | |
8416 errmsg = e_positive; | |
8417 p_ch = 1; | |
8418 } | |
1404 | 8419 if (p_ch > Rows - min_rows() + 1) |
8420 p_ch = Rows - min_rows() + 1; | |
7 | 8421 |
8422 /* Only compute the new window layout when startup has been | |
8423 * completed. Otherwise the frame sizes may be wrong. */ | |
8424 if (p_ch != old_value && full_screen | |
8425 #ifdef FEAT_GUI | |
8426 && !gui.starting | |
8427 #endif | |
8428 ) | |
824 | 8429 command_height(); |
7 | 8430 } |
8431 | |
8432 /* when 'updatecount' changes from zero to non-zero, open swap files */ | |
8433 else if (pp == &p_uc) | |
8434 { | |
8435 if (p_uc < 0) | |
8436 { | |
8437 errmsg = e_positive; | |
8438 p_uc = 100; | |
8439 } | |
8440 if (p_uc && !old_value) | |
8441 ml_open_files(); | |
8442 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8443 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8444 else if (pp == &curwin->w_p_cole) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8445 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8446 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8447 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8448 errmsg = e_positive; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8449 curwin->w_p_cole = 0; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8450 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8451 else if (curwin->w_p_cole > 3) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8452 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8453 errmsg = e_invarg; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
8454 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8455 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8456 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8457 #endif |
16 | 8458 #ifdef MZSCHEME_GUI_THREADS |
14 | 8459 else if (pp == &p_mzq) |
8460 mzvim_reset_timer(); | |
8461 #endif | |
7 | 8462 |
8463 /* sync undo before 'undolevels' changes */ | |
8464 else if (pp == &p_ul) | |
8465 { | |
8466 /* use the old value, otherwise u_sync() may not work properly */ | |
8467 p_ul = old_value; | |
825 | 8468 u_sync(TRUE); |
7 | 8469 p_ul = value; |
8470 } | |
8471 | |
13 | 8472 #ifdef FEAT_LINEBREAK |
8473 /* 'numberwidth' must be positive */ | |
8474 else if (pp == &curwin->w_p_nuw) | |
8475 { | |
8476 if (curwin->w_p_nuw < 1) | |
8477 { | |
8478 errmsg = e_positive; | |
8479 curwin->w_p_nuw = 1; | |
8480 } | |
8481 if (curwin->w_p_nuw > 10) | |
8482 { | |
8483 errmsg = e_invarg; | |
8484 curwin->w_p_nuw = 10; | |
8485 } | |
8486 curwin->w_nrwidth_line_count = 0; | |
8487 } | |
8488 #endif | |
8489 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8490 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8491 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8492 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8493 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8494 errmsg = e_positive; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8495 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8496 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8497 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8498 # ifdef FEAT_WINDOWS |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8499 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8500 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8501 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8502 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8503 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8504 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8505 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8506 # else |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8507 check_colorcolumn(curwin); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8508 # endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8509 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8510 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
8511 |
7 | 8512 /* |
8513 * Check the bounds for numeric options here | |
8514 */ | |
8515 if (Rows < min_rows() && full_screen) | |
8516 { | |
8517 if (errbuf != NULL) | |
8518 { | |
274 | 8519 vim_snprintf((char *)errbuf, errbuflen, |
8520 _("E593: Need at least %d lines"), min_rows()); | |
7 | 8521 errmsg = errbuf; |
8522 } | |
8523 Rows = min_rows(); | |
8524 } | |
8525 if (Columns < MIN_COLUMNS && full_screen) | |
8526 { | |
8527 if (errbuf != NULL) | |
8528 { | |
274 | 8529 vim_snprintf((char *)errbuf, errbuflen, |
8530 _("E594: Need at least %d columns"), MIN_COLUMNS); | |
7 | 8531 errmsg = errbuf; |
8532 } | |
8533 Columns = MIN_COLUMNS; | |
8534 } | |
534 | 8535 /* Limit the values to avoid an overflow in Rows * Columns. */ |
8536 if (Columns > 10000) | |
8537 Columns = 10000; | |
8538 if (Rows > 1000) | |
8539 Rows = 1000; | |
7 | 8540 |
8541 #ifdef DJGPP | |
8542 /* avoid a crash by checking for a too large value of 'columns' */ | |
8543 if (old_Columns != Columns && full_screen && term_console) | |
8544 mch_check_columns(); | |
8545 #endif | |
8546 | |
8547 /* | |
8548 * If the screen (shell) height has been changed, assume it is the | |
8549 * physical screenheight. | |
8550 */ | |
8551 if (old_Rows != Rows || old_Columns != Columns) | |
8552 { | |
8553 /* Changing the screen size is not allowed while updating the screen. */ | |
8554 if (updating_screen) | |
8555 *pp = old_value; | |
8556 else if (full_screen | |
8557 #ifdef FEAT_GUI | |
8558 && !gui.starting | |
8559 #endif | |
8560 ) | |
8561 set_shellsize((int)Columns, (int)Rows, TRUE); | |
8562 else | |
8563 { | |
8564 /* Postpone the resizing; check the size and cmdline position for | |
8565 * messages. */ | |
8566 check_shellsize(); | |
8567 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
8568 cmdline_row = Rows - p_ch; | |
8569 } | |
857 | 8570 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 8571 p_window = Rows - 1; |
7 | 8572 } |
8573 | |
8574 if (curbuf->b_p_ts <= 0) | |
8575 { | |
8576 errmsg = e_positive; | |
8577 curbuf->b_p_ts = 8; | |
8578 } | |
8579 if (p_tm < 0) | |
8580 { | |
8581 errmsg = e_positive; | |
8582 p_tm = 0; | |
8583 } | |
8584 if ((curwin->w_p_scr <= 0 | |
8585 || (curwin->w_p_scr > curwin->w_height | |
8586 && curwin->w_height > 0)) | |
8587 && full_screen) | |
8588 { | |
8589 if (pp == &(curwin->w_p_scr)) | |
8590 { | |
8591 if (curwin->w_p_scr != 0) | |
8592 errmsg = e_scroll; | |
8593 win_comp_scroll(curwin); | |
8594 } | |
8595 /* If 'scroll' became invalid because of a side effect silently adjust | |
8596 * it. */ | |
8597 else if (curwin->w_p_scr <= 0) | |
8598 curwin->w_p_scr = 1; | |
8599 else /* curwin->w_p_scr > curwin->w_height */ | |
8600 curwin->w_p_scr = curwin->w_height; | |
8601 } | |
1726 | 8602 if (p_hi < 0) |
8603 { | |
8604 errmsg = e_positive; | |
8605 p_hi = 0; | |
8606 } | |
7 | 8607 if (p_report < 0) |
8608 { | |
8609 errmsg = e_positive; | |
8610 p_report = 1; | |
8611 } | |
532 | 8612 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 8613 { |
8614 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ | |
8615 p_sj = Rows / 2; | |
8616 else | |
8617 { | |
8618 errmsg = e_scroll; | |
8619 p_sj = 1; | |
8620 } | |
8621 } | |
8622 if (p_so < 0 && full_screen) | |
8623 { | |
8624 errmsg = e_scroll; | |
8625 p_so = 0; | |
8626 } | |
8627 if (p_siso < 0 && full_screen) | |
8628 { | |
8629 errmsg = e_positive; | |
8630 p_siso = 0; | |
8631 } | |
8632 #ifdef FEAT_CMDWIN | |
8633 if (p_cwh < 1) | |
8634 { | |
8635 errmsg = e_positive; | |
8636 p_cwh = 1; | |
8637 } | |
8638 #endif | |
8639 if (p_ut < 0) | |
8640 { | |
8641 errmsg = e_positive; | |
8642 p_ut = 2000; | |
8643 } | |
8644 if (p_ss < 0) | |
8645 { | |
8646 errmsg = e_positive; | |
8647 p_ss = 0; | |
8648 } | |
8649 | |
8650 /* May set global value for local option. */ | |
8651 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
8652 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
8653 | |
8654 options[opt_idx].flags |= P_WAS_SET; | |
8655 | |
8656 comp_col(); /* in case 'columns' or 'ls' changed */ | |
3443 | 8657 if (curwin->w_curswant != MAXCOL |
8658 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0) | |
8659 curwin->w_set_curswant = TRUE; | |
7 | 8660 check_redraw(options[opt_idx].flags); |
8661 | |
8662 return errmsg; | |
8663 } | |
8664 | |
8665 /* | |
8666 * Called after an option changed: check if something needs to be redrawn. | |
8667 */ | |
8668 static void | |
8669 check_redraw(flags) | |
8670 long_u flags; | |
8671 { | |
8672 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ | |
3263 | 8673 int doclear = (flags & P_RCLR) == P_RCLR; |
8674 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 8675 |
8676 #ifdef FEAT_WINDOWS | |
8677 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ | |
8678 status_redraw_all(); | |
8679 #endif | |
8680 | |
8681 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
8682 changed_window_setting(); | |
8683 if (flags & P_RBUF) | |
8684 redraw_curbuf_later(NOT_VALID); | |
3263 | 8685 if (doclear) |
7 | 8686 redraw_all_later(CLEAR); |
8687 else if (all) | |
8688 redraw_all_later(NOT_VALID); | |
8689 } | |
8690 | |
8691 /* | |
8692 * Find index for option 'arg'. | |
8693 * Return -1 if not found. | |
8694 */ | |
8695 static int | |
8696 findoption(arg) | |
8697 char_u *arg; | |
8698 { | |
8699 int opt_idx; | |
8700 char *s, *p; | |
8701 static short quick_tab[27] = {0, 0}; /* quick access table */ | |
8702 int is_term_opt; | |
8703 | |
8704 /* | |
8705 * For first call: Initialize the quick-access table. | |
8706 * It contains the index for the first option that starts with a certain | |
8707 * letter. There are 26 letters, plus the first "t_" option. | |
8708 */ | |
8709 if (quick_tab[1] == 0) | |
8710 { | |
8711 p = options[0].fullname; | |
8712 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
8713 { | |
8714 if (s[0] != p[0]) | |
8715 { | |
8716 if (s[0] == 't' && s[1] == '_') | |
8717 quick_tab[26] = opt_idx; | |
8718 else | |
8719 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
8720 } | |
8721 p = s; | |
8722 } | |
8723 } | |
8724 | |
8725 /* | |
8726 * Check for name starting with an illegal character. | |
8727 */ | |
8728 #ifdef EBCDIC | |
8729 if (!islower(arg[0])) | |
8730 #else | |
8731 if (arg[0] < 'a' || arg[0] > 'z') | |
8732 #endif | |
8733 return -1; | |
8734 | |
8735 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
8736 if (is_term_opt) | |
8737 opt_idx = quick_tab[26]; | |
8738 else | |
8739 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
8740 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
8741 { | |
8742 if (STRCMP(arg, s) == 0) /* match full name */ | |
8743 break; | |
8744 } | |
8745 if (s == NULL && !is_term_opt) | |
8746 { | |
8747 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
8748 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
8749 { | |
8750 s = options[opt_idx].shortname; | |
8751 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ | |
8752 break; | |
8753 s = NULL; | |
8754 } | |
8755 } | |
8756 if (s == NULL) | |
8757 opt_idx = -1; | |
8758 return opt_idx; | |
8759 } | |
8760 | |
14 | 8761 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
7 | 8762 /* |
8763 * Get the value for an option. | |
8764 * | |
8765 * Returns: | |
8766 * Number or Toggle option: 1, *numval gets value. | |
8767 * String option: 0, *stringval gets allocated string. | |
8768 * Hidden Number or Toggle option: -1. | |
8769 * hidden String option: -2. | |
8770 * unknown option: -3. | |
8771 */ | |
8772 int | |
8773 get_option_value(name, numval, stringval, opt_flags) | |
8774 char_u *name; | |
8775 long *numval; | |
2269
fb627e94e6c6
Couple of small fixes for conceal feature. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2267
diff
changeset
|
8776 char_u **stringval; /* NULL when only checking existence */ |
7 | 8777 int opt_flags; |
8778 { | |
8779 int opt_idx; | |
8780 char_u *varp; | |
8781 | |
8782 opt_idx = findoption(name); | |
8783 if (opt_idx < 0) /* unknown option */ | |
8784 return -3; | |
8785 | |
8786 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
8787 | |
8788 if (options[opt_idx].flags & P_STRING) | |
8789 { | |
8790 if (varp == NULL) /* hidden option */ | |
8791 return -2; | |
8792 if (stringval != NULL) | |
8793 { | |
8794 #ifdef FEAT_CRYPT | |
8795 /* never return the value of the crypt key */ | |
1622 | 8796 if ((char_u **)varp == &curbuf->b_p_key |
8797 && **(char_u **)(varp) != NUL) | |
7 | 8798 *stringval = vim_strsave((char_u *)"*****"); |
8799 else | |
8800 #endif | |
8801 *stringval = vim_strsave(*(char_u **)(varp)); | |
8802 } | |
8803 return 0; | |
8804 } | |
8805 | |
8806 if (varp == NULL) /* hidden option */ | |
8807 return -1; | |
8808 if (options[opt_idx].flags & P_NUM) | |
8809 *numval = *(long *)varp; | |
8810 else | |
8811 { | |
8812 /* Special case: 'modified' is b_changed, but we also want to consider | |
8813 * it set when 'ff' or 'fenc' changed. */ | |
8814 if ((int *)varp == &curbuf->b_changed) | |
8815 *numval = curbufIsChanged(); | |
8816 else | |
8817 *numval = *(int *)varp; | |
8818 } | |
8819 return 1; | |
8820 } | |
8821 #endif | |
8822 | |
8823 /* | |
8824 * Set the value of option "name". | |
8825 * Use "string" for string options, use "number" for other options. | |
8826 */ | |
8827 void | |
8828 set_option_value(name, number, string, opt_flags) | |
8829 char_u *name; | |
8830 long number; | |
8831 char_u *string; | |
8832 int opt_flags; /* OPT_LOCAL or 0 (both) */ | |
8833 { | |
8834 int opt_idx; | |
8835 char_u *varp; | |
835 | 8836 long_u flags; |
7 | 8837 |
8838 opt_idx = findoption(name); | |
838 | 8839 if (opt_idx < 0) |
7 | 8840 EMSG2(_("E355: Unknown option: %s"), name); |
8841 else | |
8842 { | |
8843 flags = options[opt_idx].flags; | |
8844 #ifdef HAVE_SANDBOX | |
8845 /* Disallow changing some options in the sandbox */ | |
8846 if (sandbox > 0 && (flags & P_SECURE)) | |
634 | 8847 { |
7 | 8848 EMSG(_(e_sandbox)); |
634 | 8849 return; |
8850 } | |
8851 #endif | |
8852 if (flags & P_STRING) | |
7 | 8853 set_string_option(opt_idx, string, opt_flags); |
8854 else | |
8855 { | |
1667 | 8856 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
7 | 8857 if (varp != NULL) /* hidden option is not changed */ |
8858 { | |
1298 | 8859 if (number == 0 && string != NULL) |
8860 { | |
1757 | 8861 int idx; |
1298 | 8862 |
8863 /* Either we are given a string or we are setting option | |
8864 * to zero. */ | |
1757 | 8865 for (idx = 0; string[idx] == '0'; ++idx) |
1298 | 8866 ; |
1757 | 8867 if (string[idx] != NUL || idx == 0) |
1298 | 8868 { |
8869 /* There's another character after zeros or the string | |
8870 * is empty. In both cases, we are trying to set a | |
8871 * num option using a string. */ | |
8872 EMSG3(_("E521: Number required: &%s = '%s'"), | |
8873 name, string); | |
8874 return; /* do nothing as we hit an error */ | |
8875 | |
8876 } | |
8877 } | |
7 | 8878 if (flags & P_NUM) |
274 | 8879 (void)set_num_option(opt_idx, varp, number, |
8880 NULL, 0, opt_flags); | |
7 | 8881 else |
634 | 8882 (void)set_bool_option(opt_idx, varp, (int)number, |
8883 opt_flags); | |
7 | 8884 } |
8885 } | |
8886 } | |
8887 } | |
8888 | |
8889 /* | |
8890 * Get the terminal code for a terminal option. | |
8891 * Returns NULL when not found. | |
8892 */ | |
8893 char_u * | |
8894 get_term_code(tname) | |
8895 char_u *tname; | |
8896 { | |
8897 int opt_idx; | |
8898 char_u *varp; | |
8899 | |
8900 if (tname[0] != 't' || tname[1] != '_' || | |
8901 tname[2] == NUL || tname[3] == NUL) | |
8902 return NULL; | |
8903 if ((opt_idx = findoption(tname)) >= 0) | |
8904 { | |
8905 varp = get_varp(&(options[opt_idx])); | |
8906 if (varp != NULL) | |
8907 varp = *(char_u **)(varp); | |
8908 return varp; | |
8909 } | |
8910 return find_termcode(tname + 2); | |
8911 } | |
8912 | |
8913 char_u * | |
8914 get_highlight_default() | |
8915 { | |
8916 int i; | |
8917 | |
8918 i = findoption((char_u *)"hl"); | |
8919 if (i >= 0) | |
8920 return options[i].def_val[VI_DEFAULT]; | |
8921 return (char_u *)NULL; | |
8922 } | |
8923 | |
39 | 8924 #if defined(FEAT_MBYTE) || defined(PROTO) |
8925 char_u * | |
8926 get_encoding_default() | |
8927 { | |
8928 int i; | |
8929 | |
8930 i = findoption((char_u *)"enc"); | |
8931 if (i >= 0) | |
8932 return options[i].def_val[VI_DEFAULT]; | |
8933 return (char_u *)NULL; | |
8934 } | |
8935 #endif | |
8936 | |
7 | 8937 /* |
8938 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. | |
8939 */ | |
8940 static int | |
8941 find_key_option(arg) | |
8942 char_u *arg; | |
8943 { | |
8944 int key; | |
8945 int modifiers; | |
8946 | |
8947 /* | |
8948 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
8949 * add_termcap_entry(). | |
8950 */ | |
8951 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
8952 key = TERMCAP2KEY(arg[2], arg[3]); | |
8953 else | |
8954 { | |
8955 --arg; /* put arg at the '<' */ | |
8956 modifiers = 0; | |
1775 | 8957 key = find_special_key(&arg, &modifiers, TRUE, TRUE); |
7 | 8958 if (modifiers) /* can't handle modifiers here */ |
8959 key = 0; | |
8960 } | |
8961 return key; | |
8962 } | |
8963 | |
8964 /* | |
8965 * if 'all' == 0: show changed options | |
8966 * if 'all' == 1: show all normal options | |
8967 * if 'all' == 2: show all terminal options | |
8968 */ | |
8969 static void | |
8970 showoptions(all, opt_flags) | |
8971 int all; | |
8972 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ | |
8973 { | |
8974 struct vimoption *p; | |
8975 int col; | |
8976 int isterm; | |
8977 char_u *varp; | |
8978 struct vimoption **items; | |
8979 int item_count; | |
8980 int run; | |
8981 int row, rows; | |
8982 int cols; | |
8983 int i; | |
8984 int len; | |
8985 | |
8986 #define INC 20 | |
8987 #define GAP 3 | |
8988 | |
8989 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) * | |
8990 PARAM_COUNT)); | |
8991 if (items == NULL) | |
8992 return; | |
8993 | |
8994 /* Highlight title */ | |
8995 if (all == 2) | |
8996 MSG_PUTS_TITLE(_("\n--- Terminal codes ---")); | |
8997 else if (opt_flags & OPT_GLOBAL) | |
8998 MSG_PUTS_TITLE(_("\n--- Global option values ---")); | |
8999 else if (opt_flags & OPT_LOCAL) | |
9000 MSG_PUTS_TITLE(_("\n--- Local option values ---")); | |
9001 else | |
9002 MSG_PUTS_TITLE(_("\n--- Options ---")); | |
9003 | |
9004 /* | |
9005 * do the loop two times: | |
9006 * 1. display the short items | |
9007 * 2. display the long items (only strings and numbers) | |
9008 */ | |
9009 for (run = 1; run <= 2 && !got_int; ++run) | |
9010 { | |
9011 /* | |
9012 * collect the items in items[] | |
9013 */ | |
9014 item_count = 0; | |
9015 for (p = &options[0]; p->fullname != NULL; p++) | |
9016 { | |
9017 varp = NULL; | |
9018 isterm = istermoption(p); | |
9019 if (opt_flags != 0) | |
9020 { | |
9021 if (p->indir != PV_NONE && !isterm) | |
9022 varp = get_varp_scope(p, opt_flags); | |
9023 } | |
9024 else | |
9025 varp = get_varp(p); | |
9026 if (varp != NULL | |
9027 && ((all == 2 && isterm) | |
9028 || (all == 1 && !isterm) | |
9029 || (all == 0 && !optval_default(p, varp)))) | |
9030 { | |
9031 if (p->flags & P_BOOL) | |
9032 len = 1; /* a toggle option fits always */ | |
9033 else | |
9034 { | |
9035 option_value2string(p, opt_flags); | |
9036 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
9037 } | |
9038 if ((len <= INC - GAP && run == 1) || | |
9039 (len > INC - GAP && run == 2)) | |
9040 items[item_count++] = p; | |
9041 } | |
9042 } | |
9043 | |
9044 /* | |
9045 * display the items | |
9046 */ | |
9047 if (run == 1) | |
9048 { | |
9049 cols = (Columns + GAP - 3) / INC; | |
9050 if (cols == 0) | |
9051 cols = 1; | |
9052 rows = (item_count + cols - 1) / cols; | |
9053 } | |
9054 else /* run == 2 */ | |
9055 rows = item_count; | |
9056 for (row = 0; row < rows && !got_int; ++row) | |
9057 { | |
9058 msg_putchar('\n'); /* go to next line */ | |
9059 if (got_int) /* 'q' typed in more */ | |
9060 break; | |
9061 col = 0; | |
9062 for (i = row; i < item_count; i += rows) | |
9063 { | |
9064 msg_col = col; /* make columns */ | |
9065 showoneopt(items[i], opt_flags); | |
9066 col += INC; | |
9067 } | |
9068 out_flush(); | |
9069 ui_breakcheck(); | |
9070 } | |
9071 } | |
9072 vim_free(items); | |
9073 } | |
9074 | |
9075 /* | |
9076 * Return TRUE if option "p" has its default value. | |
9077 */ | |
9078 static int | |
9079 optval_default(p, varp) | |
9080 struct vimoption *p; | |
9081 char_u *varp; | |
9082 { | |
9083 int dvi; | |
9084 | |
9085 if (varp == NULL) | |
9086 return TRUE; /* hidden option is always at default */ | |
9087 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT; | |
9088 if (p->flags & P_NUM) | |
840 | 9089 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 9090 if (p->flags & P_BOOL) |
840 | 9091 /* the cast to long is required for Manx C, long_i is |
9092 * needed for MSVC */ | |
9093 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); | |
7 | 9094 /* P_STRING */ |
9095 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); | |
9096 } | |
9097 | |
9098 /* | |
9099 * showoneopt: show the value of one option | |
9100 * must not be called with a hidden option! | |
9101 */ | |
9102 static void | |
9103 showoneopt(p, opt_flags) | |
9104 struct vimoption *p; | |
9105 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */ | |
9106 { | |
168 | 9107 char_u *varp; |
9108 int save_silent = silent_mode; | |
9109 | |
9110 silent_mode = FALSE; | |
9111 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
7 | 9112 |
9113 varp = get_varp_scope(p, opt_flags); | |
9114 | |
9115 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ | |
9116 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed | |
9117 ? !curbufIsChanged() : !*(int *)varp)) | |
9118 MSG_PUTS("no"); | |
9119 else if ((p->flags & P_BOOL) && *(int *)varp < 0) | |
9120 MSG_PUTS("--"); | |
9121 else | |
9122 MSG_PUTS(" "); | |
9123 MSG_PUTS(p->fullname); | |
9124 if (!(p->flags & P_BOOL)) | |
9125 { | |
9126 msg_putchar('='); | |
9127 /* put value string in NameBuff */ | |
9128 option_value2string(p, opt_flags); | |
9129 msg_outtrans(NameBuff); | |
9130 } | |
168 | 9131 |
9132 silent_mode = save_silent; | |
9133 info_message = FALSE; | |
7 | 9134 } |
9135 | |
9136 /* | |
9137 * Write modified options as ":set" commands to a file. | |
9138 * | |
9139 * There are three values for "opt_flags": | |
9140 * OPT_GLOBAL: Write global option values and fresh values of | |
9141 * buffer-local options (used for start of a session | |
9142 * file). | |
9143 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
9144 * curwin (used for a vimrc file). | |
9145 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
9146 * and local values for window-local options of | |
9147 * curwin. Local values are also written when at the | |
9148 * default value, because a modeline or autocommand | |
9149 * may have set them when doing ":edit file" and the | |
9150 * user has set them back at the default or fresh | |
9151 * value. | |
9152 * When "local_only" is TRUE, don't write fresh | |
9153 * values, only local values (for ":mkview"). | |
9154 * (fresh value = value used for a new buffer or window for a local option). | |
9155 * | |
9156 * Return FAIL on error, OK otherwise. | |
9157 */ | |
9158 int | |
9159 makeset(fd, opt_flags, local_only) | |
9160 FILE *fd; | |
9161 int opt_flags; | |
9162 int local_only; | |
9163 { | |
9164 struct vimoption *p; | |
9165 char_u *varp; /* currently used value */ | |
9166 char_u *varp_fresh; /* local value */ | |
9167 char_u *varp_local = NULL; /* fresh value */ | |
9168 char *cmd; | |
9169 int round; | |
1384 | 9170 int pri; |
7 | 9171 |
9172 /* | |
9173 * The options that don't have a default (terminal name, columns, lines) | |
9174 * are never written. Terminal options are also not written. | |
1384 | 9175 * Do the loop over "options[]" twice: once for options with the |
9176 * P_PRI_MKRC flag and once without. | |
7 | 9177 */ |
1384 | 9178 for (pri = 1; pri >= 0; --pri) |
9179 { | |
9180 for (p = &options[0]; !istermoption(p); p++) | |
9181 if (!(p->flags & P_NO_MKRC) | |
9182 && !istermoption(p) | |
9183 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 9184 { |
9185 /* skip global option when only doing locals */ | |
9186 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) | |
9187 continue; | |
9188 | |
9189 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc | |
9190 * file, they are always buffer-specific. */ | |
9191 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) | |
9192 continue; | |
9193 | |
9194 /* Global values are only written when not at the default value. */ | |
9195 varp = get_varp_scope(p, opt_flags); | |
9196 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp)) | |
9197 continue; | |
9198 | |
9199 round = 2; | |
9200 if (p->indir != PV_NONE) | |
9201 { | |
9202 if (p->var == VAR_WIN) | |
9203 { | |
9204 /* skip window-local option when only doing globals */ | |
9205 if (!(opt_flags & OPT_LOCAL)) | |
9206 continue; | |
9207 /* When fresh value of window-local option is not at the | |
9208 * default, need to write it too. */ | |
9209 if (!(opt_flags & OPT_GLOBAL) && !local_only) | |
9210 { | |
9211 varp_fresh = get_varp_scope(p, OPT_GLOBAL); | |
9212 if (!optval_default(p, varp_fresh)) | |
9213 { | |
9214 round = 1; | |
9215 varp_local = varp; | |
9216 varp = varp_fresh; | |
9217 } | |
9218 } | |
9219 } | |
9220 } | |
9221 | |
9222 /* Round 1: fresh value for window-local options. | |
9223 * Round 2: other values */ | |
9224 for ( ; round <= 2; varp = varp_local, ++round) | |
9225 { | |
9226 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
9227 cmd = "set"; | |
9228 else | |
9229 cmd = "setlocal"; | |
9230 | |
9231 if (p->flags & P_BOOL) | |
9232 { | |
9233 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
9234 return FAIL; | |
9235 } | |
9236 else if (p->flags & P_NUM) | |
9237 { | |
9238 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
9239 return FAIL; | |
9240 } | |
9241 else /* P_STRING */ | |
9242 { | |
694 | 9243 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) |
9244 int do_endif = FALSE; | |
9245 | |
7 | 9246 /* Don't set 'syntax' and 'filetype' again if the value is |
9247 * already right, avoids reloading the syntax file. */ | |
694 | 9248 if ( |
9249 # if defined(FEAT_SYN_HL) | |
9250 p->indir == PV_SYN | |
9251 # if defined(FEAT_AUTOCMD) | |
9252 || | |
9253 # endif | |
9254 # endif | |
9255 # if defined(FEAT_AUTOCMD) | |
1683 | 9256 p->indir == PV_FT |
694 | 9257 # endif |
1683 | 9258 ) |
7 | 9259 { |
9260 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
9261 *(char_u **)(varp)) < 0 | |
9262 || put_eol(fd) < 0) | |
9263 return FAIL; | |
694 | 9264 do_endif = TRUE; |
7 | 9265 } |
694 | 9266 #endif |
7 | 9267 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, |
9268 (p->flags & P_EXPAND) != 0) == FAIL) | |
9269 return FAIL; | |
694 | 9270 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) |
9271 if (do_endif) | |
7 | 9272 { |
9273 if (put_line(fd, "endif") == FAIL) | |
9274 return FAIL; | |
9275 } | |
694 | 9276 #endif |
7 | 9277 } |
9278 } | |
9279 } | |
1384 | 9280 } |
7 | 9281 return OK; |
9282 } | |
9283 | |
9284 #if defined(FEAT_FOLDING) || defined(PROTO) | |
9285 /* | |
9286 * Generate set commands for the local fold options only. Used when | |
9287 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
9288 */ | |
9289 int | |
9290 makefoldset(fd) | |
9291 FILE *fd; | |
9292 { | |
9293 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL | |
9294 # ifdef FEAT_EVAL | |
9295 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE) | |
9296 == FAIL | |
9297 # endif | |
9298 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE) | |
9299 == FAIL | |
9300 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE) | |
9301 == FAIL | |
9302 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
9303 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
9304 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
9305 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
9306 ) | |
9307 return FAIL; | |
9308 | |
9309 return OK; | |
9310 } | |
9311 #endif | |
9312 | |
9313 static int | |
9314 put_setstring(fd, cmd, name, valuep, expand) | |
9315 FILE *fd; | |
9316 char *cmd; | |
9317 char *name; | |
9318 char_u **valuep; | |
9319 int expand; | |
9320 { | |
9321 char_u *s; | |
2780 | 9322 char_u *buf; |
7 | 9323 |
9324 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
9325 return FAIL; | |
9326 if (*valuep != NULL) | |
9327 { | |
9328 /* Output 'pastetoggle' as key names. For other | |
9329 * options some characters have to be escaped with | |
9330 * CTRL-V or backslash */ | |
9331 if (valuep == &p_pt) | |
9332 { | |
9333 s = *valuep; | |
9334 while (*s != NUL) | |
1601 | 9335 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
7 | 9336 return FAIL; |
9337 } | |
9338 else if (expand) | |
9339 { | |
2780 | 9340 buf = alloc(MAXPATHL); |
9341 if (buf == NULL) | |
9342 return FAIL; | |
7 | 9343 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); |
9344 if (put_escstr(fd, buf, 2) == FAIL) | |
2780 | 9345 { |
9346 vim_free(buf); | |
7 | 9347 return FAIL; |
2780 | 9348 } |
9349 vim_free(buf); | |
7 | 9350 } |
9351 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
9352 return FAIL; | |
9353 } | |
9354 if (put_eol(fd) < 0) | |
9355 return FAIL; | |
9356 return OK; | |
9357 } | |
9358 | |
9359 static int | |
9360 put_setnum(fd, cmd, name, valuep) | |
9361 FILE *fd; | |
9362 char *cmd; | |
9363 char *name; | |
9364 long *valuep; | |
9365 { | |
9366 long wc; | |
9367 | |
9368 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
9369 return FAIL; | |
9370 if (wc_use_keyname((char_u *)valuep, &wc)) | |
9371 { | |
9372 /* print 'wildchar' and 'wildcharm' as a key name */ | |
9373 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) | |
9374 return FAIL; | |
9375 } | |
9376 else if (fprintf(fd, "%ld", *valuep) < 0) | |
9377 return FAIL; | |
9378 if (put_eol(fd) < 0) | |
9379 return FAIL; | |
9380 return OK; | |
9381 } | |
9382 | |
9383 static int | |
9384 put_setbool(fd, cmd, name, value) | |
9385 FILE *fd; | |
9386 char *cmd; | |
9387 char *name; | |
9388 int value; | |
9389 { | |
1416 | 9390 if (value < 0) /* global/local option using global value */ |
9391 return OK; | |
7 | 9392 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
9393 || put_eol(fd) < 0) | |
9394 return FAIL; | |
9395 return OK; | |
9396 } | |
9397 | |
9398 /* | |
9399 * Clear all the terminal options. | |
9400 * If the option has been allocated, free the memory. | |
9401 * Terminal options are never hidden or indirect. | |
9402 */ | |
9403 void | |
9404 clear_termoptions() | |
9405 { | |
9406 /* | |
9407 * Reset a few things before clearing the old options. This may cause | |
9408 * outputting a few things that the terminal doesn't understand, but the | |
9409 * screen will be cleared later, so this is OK. | |
9410 */ | |
9411 #ifdef FEAT_MOUSE_TTY | |
9412 mch_setmouse(FALSE); /* switch mouse off */ | |
9413 #endif | |
9414 #ifdef FEAT_TITLE | |
9415 mch_restore_title(3); /* restore window titles */ | |
9416 #endif | |
9417 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) | |
9418 /* When starting the GUI close the display opened for the clipboard. | |
9419 * After restoring the title, because that will need the display. */ | |
9420 if (gui.starting) | |
9421 clear_xterm_clip(); | |
9422 #endif | |
9423 #ifdef WIN3264 | |
9424 /* | |
9425 * Check if this is allowed now. | |
9426 */ | |
9427 if (can_end_termcap_mode(FALSE) == TRUE) | |
9428 #endif | |
9429 stoptermcap(); /* stop termcap mode */ | |
9430 | |
359 | 9431 free_termoptions(); |
9432 } | |
9433 | |
9434 void | |
9435 free_termoptions() | |
9436 { | |
9437 struct vimoption *p; | |
9438 | |
7 | 9439 for (p = &options[0]; p->fullname != NULL; p++) |
9440 if (istermoption(p)) | |
9441 { | |
9442 if (p->flags & P_ALLOCED) | |
9443 free_string_option(*(char_u **)(p->var)); | |
9444 if (p->flags & P_DEF_ALLOCED) | |
9445 free_string_option(p->def_val[VI_DEFAULT]); | |
9446 *(char_u **)(p->var) = empty_option; | |
9447 p->def_val[VI_DEFAULT] = empty_option; | |
9448 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); | |
9449 } | |
9450 clear_termcodes(); | |
9451 } | |
9452 | |
9453 /* | |
1941 | 9454 * Free the string for one term option, if it was allocated. |
9455 * Set the string to empty_option and clear allocated flag. | |
9456 * "var" points to the option value. | |
9457 */ | |
9458 void | |
9459 free_one_termoption(var) | |
9460 char_u *var; | |
9461 { | |
9462 struct vimoption *p; | |
9463 | |
9464 for (p = &options[0]; p->fullname != NULL; p++) | |
9465 if (p->var == var) | |
9466 { | |
9467 if (p->flags & P_ALLOCED) | |
9468 free_string_option(*(char_u **)(p->var)); | |
9469 *(char_u **)(p->var) = empty_option; | |
9470 p->flags &= ~P_ALLOCED; | |
9471 break; | |
9472 } | |
9473 } | |
9474 | |
9475 /* | |
7 | 9476 * Set the terminal option defaults to the current value. |
9477 * Used after setting the terminal name. | |
9478 */ | |
9479 void | |
9480 set_term_defaults() | |
9481 { | |
9482 struct vimoption *p; | |
9483 | |
9484 for (p = &options[0]; p->fullname != NULL; p++) | |
9485 { | |
9486 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
9487 { | |
9488 if (p->flags & P_DEF_ALLOCED) | |
9489 { | |
9490 free_string_option(p->def_val[VI_DEFAULT]); | |
9491 p->flags &= ~P_DEF_ALLOCED; | |
9492 } | |
9493 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
9494 if (p->flags & P_ALLOCED) | |
9495 { | |
9496 p->flags |= P_DEF_ALLOCED; | |
9497 p->flags &= ~P_ALLOCED; /* don't free the value now */ | |
9498 } | |
9499 } | |
9500 } | |
9501 } | |
9502 | |
9503 /* | |
9504 * return TRUE if 'p' starts with 't_' | |
9505 */ | |
9506 static int | |
9507 istermoption(p) | |
9508 struct vimoption *p; | |
9509 { | |
9510 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
9511 } | |
9512 | |
9513 /* | |
9514 * Compute columns for ruler and shown command. 'sc_col' is also used to | |
9515 * decide what the maximum length of a message on the status line can be. | |
9516 * If there is a status line for the last window, 'sc_col' is independent | |
9517 * of 'ru_col'. | |
9518 */ | |
9519 | |
9520 #define COL_RULER 17 /* columns needed by standard ruler */ | |
9521 | |
9522 void | |
9523 comp_col() | |
9524 { | |
9525 #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS) | |
9526 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); | |
9527 | |
9528 sc_col = 0; | |
9529 ru_col = 0; | |
9530 if (p_ru) | |
9531 { | |
9532 #ifdef FEAT_STL_OPT | |
9533 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; | |
9534 #else | |
9535 ru_col = COL_RULER + 1; | |
9536 #endif | |
9537 /* no last status line, adjust sc_col */ | |
9538 if (!last_has_status) | |
9539 sc_col = ru_col; | |
9540 } | |
9541 if (p_sc) | |
9542 { | |
9543 sc_col += SHOWCMD_COLS; | |
9544 if (!p_ru || last_has_status) /* no need for separating space */ | |
9545 ++sc_col; | |
9546 } | |
9547 sc_col = Columns - sc_col; | |
9548 ru_col = Columns - ru_col; | |
9549 if (sc_col <= 0) /* screen too narrow, will become a mess */ | |
9550 sc_col = 1; | |
9551 if (ru_col <= 0) | |
9552 ru_col = 1; | |
9553 #else | |
9554 sc_col = Columns; | |
9555 ru_col = Columns; | |
9556 #endif | |
9557 } | |
9558 | |
9559 /* | |
9560 * Get pointer to option variable, depending on local or global scope. | |
9561 */ | |
9562 static char_u * | |
9563 get_varp_scope(p, opt_flags) | |
9564 struct vimoption *p; | |
9565 int opt_flags; | |
9566 { | |
9567 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) | |
9568 { | |
9569 if (p->var == VAR_WIN) | |
9570 return (char_u *)GLOBAL_WO(get_varp(p)); | |
9571 return p->var; | |
9572 } | |
692 | 9573 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 9574 { |
9575 switch ((int)p->indir) | |
9576 { | |
9577 #ifdef FEAT_QUICKFIX | |
694 | 9578 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
9579 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
9580 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
9581 #endif | |
9582 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
9583 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
9584 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 9585 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 9586 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); |
7 | 9587 #ifdef FEAT_FIND_ID |
694 | 9588 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
9589 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 9590 #endif |
9591 #ifdef FEAT_INS_EXPAND | |
694 | 9592 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
9593 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
7 | 9594 #endif |
790 | 9595 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
9596 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
9597 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9598 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9599 case PV_CM: return (char_u *)&(curbuf->b_p_cm); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9600 #endif |
40 | 9601 #ifdef FEAT_STL_OPT |
694 | 9602 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 9603 #endif |
7 | 9604 } |
9605 return NULL; /* "cannot happen" */ | |
9606 } | |
9607 return get_varp(p); | |
9608 } | |
9609 | |
9610 /* | |
9611 * Get pointer to option variable. | |
9612 */ | |
9613 static char_u * | |
9614 get_varp(p) | |
9615 struct vimoption *p; | |
9616 { | |
9617 /* hidden option, always return NULL */ | |
9618 if (p->var == NULL) | |
9619 return NULL; | |
9620 | |
9621 switch ((int)p->indir) | |
9622 { | |
9623 case PV_NONE: return p->var; | |
9624 | |
9625 /* global option with local value: use local value if it's been set */ | |
694 | 9626 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 9627 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 9628 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 9629 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 9630 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 9631 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 9632 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 9633 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 9634 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 9635 ? (char_u *)&(curbuf->b_p_tags) : p->var; |
9636 #ifdef FEAT_FIND_ID | |
694 | 9637 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 9638 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 9639 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 9640 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
9641 #endif | |
9642 #ifdef FEAT_INS_EXPAND | |
694 | 9643 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 9644 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 9645 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 9646 ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
9647 #endif | |
9648 #ifdef FEAT_QUICKFIX | |
694 | 9649 case PV_EFM: return *curbuf->b_p_efm != NUL |
9650 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
9651 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 9652 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 9653 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 9654 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
9655 #endif | |
790 | 9656 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
9657 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
9658 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
9659 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9660 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9661 case PV_CM: return *curbuf->b_p_cm != NUL |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9662 ? (char_u *)&(curbuf->b_p_cm) : p->var; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
9663 #endif |
40 | 9664 #ifdef FEAT_STL_OPT |
694 | 9665 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 9666 ? (char_u *)&(curwin->w_p_stl) : p->var; |
9667 #endif | |
7 | 9668 |
9669 #ifdef FEAT_ARABIC | |
9670 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
9671 #endif | |
9672 case PV_LIST: return (char_u *)&(curwin->w_p_list); | |
744 | 9673 #ifdef FEAT_SPELL |
9674 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
9675 #endif | |
221 | 9676 #ifdef FEAT_SYN_HL |
744 | 9677 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
9678 case PV_CUL: return (char_u *)&(curwin->w_p_cul); | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
9679 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 9680 #endif |
7 | 9681 #ifdef FEAT_DIFF |
9682 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
9683 #endif | |
9684 #ifdef FEAT_FOLDING | |
9685 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
9686 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
9687 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
9688 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
9689 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
9690 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
9691 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
9692 # ifdef FEAT_EVAL | |
9693 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
9694 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
9695 # endif | |
9696 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
9697 #endif | |
9698 case PV_NU: return (char_u *)&(curwin->w_p_nu); | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
9699 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 9700 #ifdef FEAT_LINEBREAK |
9701 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
9702 #endif | |
694 | 9703 #ifdef FEAT_WINDOWS |
7 | 9704 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
9705 #endif | |
782 | 9706 #ifdef FEAT_VERTSPLIT |
9707 case PV_WFW: return (char_u *)&(curwin->w_p_wfw); | |
9708 #endif | |
7 | 9709 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
9710 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); | |
9711 #endif | |
9712 #ifdef FEAT_RIGHTLEFT | |
9713 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
9714 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
9715 #endif | |
9716 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
9717 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); | |
9718 #ifdef FEAT_LINEBREAK | |
9719 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
9720 #endif | |
9721 #ifdef FEAT_SCROLLBIND | |
9722 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); | |
9723 #endif | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9724 #ifdef FEAT_CURSORBIND |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9725 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9726 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9727 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9728 case PV_COCU: return (char_u *)&(curwin->w_p_cocu); |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9729 case PV_COLE: return (char_u *)&(curwin->w_p_cole); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9730 #endif |
7 | 9731 |
9732 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
9733 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
9734 #ifdef FEAT_MBYTE | |
9735 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
9736 #endif | |
9737 #if defined(FEAT_QUICKFIX) | |
9738 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
9739 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
9740 #endif | |
9741 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
9742 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
9743 #ifdef FEAT_CINDENT | |
9744 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
9745 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
9746 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
9747 #endif | |
9748 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
9749 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); | |
9750 #endif | |
9751 #ifdef FEAT_COMMENTS | |
9752 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
9753 #endif | |
9754 #ifdef FEAT_FOLDING | |
9755 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
9756 #endif | |
9757 #ifdef FEAT_INS_EXPAND | |
9758 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); | |
9759 #endif | |
12 | 9760 #ifdef FEAT_COMPL_FUNC |
9761 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 9762 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 9763 #endif |
7 | 9764 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
9765 case PV_ET: return (char_u *)&(curbuf->b_p_et); | |
9766 #ifdef FEAT_MBYTE | |
9767 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
9768 #endif | |
9769 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
9770 #ifdef FEAT_AUTOCMD | |
9771 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
9772 #endif | |
9773 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 9774 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 9775 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
9776 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
9777 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
9778 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
9779 #ifdef FEAT_FIND_ID | |
9780 # ifdef FEAT_EVAL | |
9781 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
9782 # endif | |
9783 #endif | |
9784 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
9785 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); | |
9786 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
9787 #endif | |
694 | 9788 #ifdef FEAT_EVAL |
667 | 9789 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
9790 #endif | |
7 | 9791 #ifdef FEAT_CRYPT |
9792 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
9793 #endif | |
9794 #ifdef FEAT_LISP | |
9795 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
9796 #endif | |
9797 case PV_ML: return (char_u *)&(curbuf->b_p_ml); | |
9798 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
9799 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
9800 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
9801 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
9802 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 9803 #ifdef FEAT_TEXTOBJ |
9804 case PV_QE: return (char_u *)&(curbuf->b_p_qe); | |
9805 #endif | |
7 | 9806 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
9807 #ifdef FEAT_SMARTINDENT | |
9808 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
9809 #endif | |
9810 #ifndef SHORT_FNAME | |
9811 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
9812 #endif | |
9813 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
9814 #ifdef FEAT_SEARCHPATH | |
9815 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
9816 #endif | |
9817 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
9818 #ifdef FEAT_SYN_HL | |
410 | 9819 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 9820 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
9821 #endif | |
9822 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9823 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9824 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
9825 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); |
7 | 9826 #endif |
9827 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
9828 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
9829 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
9830 case PV_TX: return (char_u *)&(curbuf->b_p_tx); | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
9831 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
9832 case PV_UDF: return (char_u *)&(curbuf->b_p_udf); |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
9833 #endif |
7 | 9834 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
9835 #ifdef FEAT_KEYMAP | |
9836 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
9837 #endif | |
9838 default: EMSG(_("E356: get_varp ERROR")); | |
9839 } | |
9840 /* always return a valid pointer to avoid a crash! */ | |
9841 return (char_u *)&(curbuf->b_p_wm); | |
9842 } | |
9843 | |
9844 /* | |
9845 * Get the value of 'equalprg', either the buffer-local one or the global one. | |
9846 */ | |
9847 char_u * | |
9848 get_equalprg() | |
9849 { | |
9850 if (*curbuf->b_p_ep == NUL) | |
9851 return p_ep; | |
9852 return curbuf->b_p_ep; | |
9853 } | |
9854 | |
9855 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
9856 /* | |
9857 * Copy options from one window to another. | |
9858 * Used when splitting a window. | |
9859 */ | |
9860 void | |
9861 win_copy_options(wp_from, wp_to) | |
9862 win_T *wp_from; | |
9863 win_T *wp_to; | |
9864 { | |
9865 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
9866 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); | |
9867 # ifdef FEAT_RIGHTLEFT | |
9868 # ifdef FEAT_FKMAP | |
9869 /* Is this right? */ | |
9870 wp_to->w_farsi = wp_from->w_farsi; | |
9871 # endif | |
9872 # endif | |
9873 } | |
9874 #endif | |
9875 | |
9876 /* | |
9877 * Copy the options from one winopt_T to another. | |
9878 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
9879 * The 'scroll' option is not copied, because it depends on the window height. | |
9880 * The 'previewwindow' option is reset, there can be only one preview window. | |
9881 */ | |
9882 void | |
9883 copy_winopt(from, to) | |
9884 winopt_T *from; | |
9885 winopt_T *to; | |
9886 { | |
9887 #ifdef FEAT_ARABIC | |
9888 to->wo_arab = from->wo_arab; | |
9889 #endif | |
9890 to->wo_list = from->wo_list; | |
9891 to->wo_nu = from->wo_nu; | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
9892 to->wo_rnu = from->wo_rnu; |
13 | 9893 #ifdef FEAT_LINEBREAK |
9894 to->wo_nuw = from->wo_nuw; | |
9895 #endif | |
7 | 9896 #ifdef FEAT_RIGHTLEFT |
9897 to->wo_rl = from->wo_rl; | |
9898 to->wo_rlc = vim_strsave(from->wo_rlc); | |
9899 #endif | |
40 | 9900 #ifdef FEAT_STL_OPT |
9901 to->wo_stl = vim_strsave(from->wo_stl); | |
9902 #endif | |
7 | 9903 to->wo_wrap = from->wo_wrap; |
9904 #ifdef FEAT_LINEBREAK | |
9905 to->wo_lbr = from->wo_lbr; | |
9906 #endif | |
9907 #ifdef FEAT_SCROLLBIND | |
9908 to->wo_scb = from->wo_scb; | |
9909 #endif | |
2651 | 9910 #ifdef FEAT_CURSORBIND |
9911 to->wo_crb = from->wo_crb; | |
9912 #endif | |
744 | 9913 #ifdef FEAT_SPELL |
9914 to->wo_spell = from->wo_spell; | |
9915 #endif | |
221 | 9916 #ifdef FEAT_SYN_HL |
744 | 9917 to->wo_cuc = from->wo_cuc; |
9918 to->wo_cul = from->wo_cul; | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
9919 to->wo_cc = vim_strsave(from->wo_cc); |
221 | 9920 #endif |
7 | 9921 #ifdef FEAT_DIFF |
9922 to->wo_diff = from->wo_diff; | |
9923 #endif | |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9924 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9925 to->wo_cocu = vim_strsave(from->wo_cocu); |
2379
b67b0b5a93d3
Window split didn't copy the value of 'conceallevel'.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
9926 to->wo_cole = from->wo_cole; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9927 #endif |
7 | 9928 #ifdef FEAT_FOLDING |
9929 to->wo_fdc = from->wo_fdc; | |
9930 to->wo_fen = from->wo_fen; | |
9931 to->wo_fdi = vim_strsave(from->wo_fdi); | |
9932 to->wo_fml = from->wo_fml; | |
9933 to->wo_fdl = from->wo_fdl; | |
9934 to->wo_fdm = vim_strsave(from->wo_fdm); | |
9935 to->wo_fdn = from->wo_fdn; | |
9936 # ifdef FEAT_EVAL | |
9937 to->wo_fde = vim_strsave(from->wo_fde); | |
9938 to->wo_fdt = vim_strsave(from->wo_fdt); | |
9939 # endif | |
9940 to->wo_fmr = vim_strsave(from->wo_fmr); | |
9941 #endif | |
9942 check_winopt(to); /* don't want NULL pointers */ | |
9943 } | |
9944 | |
9945 /* | |
9946 * Check string options in a window for a NULL value. | |
9947 */ | |
9948 void | |
9949 check_win_options(win) | |
9950 win_T *win; | |
9951 { | |
9952 check_winopt(&win->w_onebuf_opt); | |
9953 check_winopt(&win->w_allbuf_opt); | |
9954 } | |
9955 | |
9956 /* | |
9957 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
9958 */ | |
9959 void | |
9960 check_winopt(wop) | |
1877 | 9961 winopt_T *wop UNUSED; |
7 | 9962 { |
9963 #ifdef FEAT_FOLDING | |
9964 check_string_option(&wop->wo_fdi); | |
9965 check_string_option(&wop->wo_fdm); | |
9966 # ifdef FEAT_EVAL | |
9967 check_string_option(&wop->wo_fde); | |
9968 check_string_option(&wop->wo_fdt); | |
9969 # endif | |
9970 check_string_option(&wop->wo_fmr); | |
9971 #endif | |
9972 #ifdef FEAT_RIGHTLEFT | |
9973 check_string_option(&wop->wo_rlc); | |
9974 #endif | |
40 | 9975 #ifdef FEAT_STL_OPT |
9976 check_string_option(&wop->wo_stl); | |
9977 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
9978 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
9979 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
9980 #endif |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9981 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9982 check_string_option(&wop->wo_cocu); |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
9983 #endif |
7 | 9984 } |
9985 | |
9986 /* | |
9987 * Free the allocated memory inside a winopt_T. | |
9988 */ | |
9989 void | |
9990 clear_winopt(wop) | |
1877 | 9991 winopt_T *wop UNUSED; |
7 | 9992 { |
9993 #ifdef FEAT_FOLDING | |
9994 clear_string_option(&wop->wo_fdi); | |
9995 clear_string_option(&wop->wo_fdm); | |
9996 # ifdef FEAT_EVAL | |
9997 clear_string_option(&wop->wo_fde); | |
9998 clear_string_option(&wop->wo_fdt); | |
9999 # endif | |
10000 clear_string_option(&wop->wo_fmr); | |
10001 #endif | |
10002 #ifdef FEAT_RIGHTLEFT | |
10003 clear_string_option(&wop->wo_rlc); | |
10004 #endif | |
40 | 10005 #ifdef FEAT_STL_OPT |
10006 clear_string_option(&wop->wo_stl); | |
10007 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
10008 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
10009 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
10010 #endif |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
10011 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
10012 clear_string_option(&wop->wo_cocu); |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
10013 #endif |
7 | 10014 } |
10015 | |
10016 /* | |
10017 * Copy global option values to local options for one buffer. | |
10018 * Used when creating a new buffer and sometimes when entering a buffer. | |
10019 * flags: | |
10020 * BCO_ENTER We will enter the buf buffer. | |
10021 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when | |
10022 * appropriate. | |
10023 * BCO_NOHELP Don't copy the values to a help buffer. | |
10024 */ | |
10025 void | |
10026 buf_copy_options(buf, flags) | |
10027 buf_T *buf; | |
10028 int flags; | |
10029 { | |
10030 int should_copy = TRUE; | |
10031 char_u *save_p_isk = NULL; /* init for GCC */ | |
10032 int dont_do_help; | |
10033 int did_isk = FALSE; | |
10034 | |
10035 /* | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
10036 * Don't do anything if the buffer is invalid. |
7 | 10037 */ |
10038 if (buf == NULL || !buf_valid(buf)) | |
10039 return; | |
10040 | |
10041 /* | |
10042 * Skip this when the option defaults have not been set yet. Happens when | |
10043 * main() allocates the first buffer. | |
10044 */ | |
10045 if (p_cpo != NULL) | |
10046 { | |
10047 /* | |
10048 * Always copy when entering and 'cpo' contains 'S'. | |
10049 * Don't copy when already initialized. | |
10050 * Don't copy when 'cpo' contains 's' and not entering. | |
10051 * 'S' BCO_ENTER initialized 's' should_copy | |
10052 * yes yes X X TRUE | |
10053 * yes no yes X FALSE | |
10054 * no X yes X FALSE | |
10055 * X no no yes FALSE | |
10056 * X no no no TRUE | |
10057 * no yes no X TRUE | |
10058 */ | |
10059 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
10060 && (buf->b_p_initialized | |
10061 || (!(flags & BCO_ENTER) | |
10062 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
10063 should_copy = FALSE; | |
10064 | |
10065 if (should_copy || (flags & BCO_ALWAYS)) | |
10066 { | |
10067 /* Don't copy the options specific to a help buffer when | |
10068 * BCO_NOHELP is given or the options were initialized already | |
10069 * (jumping back to a help file with CTRL-T or CTRL-O) */ | |
10070 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) | |
10071 || buf->b_p_initialized; | |
10072 if (dont_do_help) /* don't free b_p_isk */ | |
10073 { | |
10074 save_p_isk = buf->b_p_isk; | |
10075 buf->b_p_isk = NULL; | |
10076 } | |
10077 /* | |
10078 * Always free the allocated strings. | |
10079 * If not already initialized, set 'readonly' and copy 'fileformat'. | |
10080 */ | |
10081 if (!buf->b_p_initialized) | |
10082 { | |
10083 free_buf_options(buf, TRUE); | |
10084 buf->b_p_ro = FALSE; /* don't copy readonly */ | |
10085 buf->b_p_tx = p_tx; | |
10086 #ifdef FEAT_MBYTE | |
10087 buf->b_p_fenc = vim_strsave(p_fenc); | |
10088 #endif | |
10089 buf->b_p_ff = vim_strsave(p_ff); | |
10090 #if defined(FEAT_QUICKFIX) | |
10091 buf->b_p_bh = empty_option; | |
10092 buf->b_p_bt = empty_option; | |
10093 #endif | |
10094 } | |
10095 else | |
10096 free_buf_options(buf, FALSE); | |
10097 | |
10098 buf->b_p_ai = p_ai; | |
10099 buf->b_p_ai_nopaste = p_ai_nopaste; | |
10100 buf->b_p_sw = p_sw; | |
10101 buf->b_p_tw = p_tw; | |
10102 buf->b_p_tw_nopaste = p_tw_nopaste; | |
10103 buf->b_p_tw_nobin = p_tw_nobin; | |
10104 buf->b_p_wm = p_wm; | |
10105 buf->b_p_wm_nopaste = p_wm_nopaste; | |
10106 buf->b_p_wm_nobin = p_wm_nobin; | |
10107 buf->b_p_bin = p_bin; | |
402 | 10108 #ifdef FEAT_MBYTE |
10109 buf->b_p_bomb = p_bomb; | |
10110 #endif | |
7 | 10111 buf->b_p_et = p_et; |
10112 buf->b_p_et_nobin = p_et_nobin; | |
10113 buf->b_p_ml = p_ml; | |
10114 buf->b_p_ml_nobin = p_ml_nobin; | |
10115 buf->b_p_inf = p_inf; | |
10116 buf->b_p_swf = p_swf; | |
10117 #ifdef FEAT_INS_EXPAND | |
10118 buf->b_p_cpt = vim_strsave(p_cpt); | |
10119 #endif | |
12 | 10120 #ifdef FEAT_COMPL_FUNC |
10121 buf->b_p_cfu = vim_strsave(p_cfu); | |
502 | 10122 buf->b_p_ofu = vim_strsave(p_ofu); |
12 | 10123 #endif |
7 | 10124 buf->b_p_sts = p_sts; |
10125 buf->b_p_sts_nopaste = p_sts_nopaste; | |
10126 #ifndef SHORT_FNAME | |
10127 buf->b_p_sn = p_sn; | |
10128 #endif | |
10129 #ifdef FEAT_COMMENTS | |
10130 buf->b_p_com = vim_strsave(p_com); | |
10131 #endif | |
10132 #ifdef FEAT_FOLDING | |
10133 buf->b_p_cms = vim_strsave(p_cms); | |
10134 #endif | |
10135 buf->b_p_fo = vim_strsave(p_fo); | |
41 | 10136 buf->b_p_flp = vim_strsave(p_flp); |
7 | 10137 buf->b_p_nf = vim_strsave(p_nf); |
10138 buf->b_p_mps = vim_strsave(p_mps); | |
10139 #ifdef FEAT_SMARTINDENT | |
10140 buf->b_p_si = p_si; | |
10141 #endif | |
10142 buf->b_p_ci = p_ci; | |
10143 #ifdef FEAT_CINDENT | |
10144 buf->b_p_cin = p_cin; | |
10145 buf->b_p_cink = vim_strsave(p_cink); | |
10146 buf->b_p_cino = vim_strsave(p_cino); | |
10147 #endif | |
10148 #ifdef FEAT_AUTOCMD | |
10149 /* Don't copy 'filetype', it must be detected */ | |
10150 buf->b_p_ft = empty_option; | |
10151 #endif | |
10152 buf->b_p_pi = p_pi; | |
10153 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
10154 buf->b_p_cinw = vim_strsave(p_cinw); | |
10155 #endif | |
10156 #ifdef FEAT_LISP | |
10157 buf->b_p_lisp = p_lisp; | |
10158 #endif | |
10159 #ifdef FEAT_SYN_HL | |
10160 /* Don't copy 'syntax', it must be set */ | |
10161 buf->b_p_syn = empty_option; | |
410 | 10162 buf->b_p_smc = p_smc; |
744 | 10163 #endif |
10164 #ifdef FEAT_SPELL | |
2599 | 10165 buf->b_s.b_p_spc = vim_strsave(p_spc); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
10166 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
10167 buf->b_s.b_p_spf = vim_strsave(p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
10168 buf->b_s.b_p_spl = vim_strsave(p_spl); |
7 | 10169 #endif |
10170 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
10171 buf->b_p_inde = vim_strsave(p_inde); | |
10172 buf->b_p_indk = vim_strsave(p_indk); | |
10173 #endif | |
667 | 10174 #if defined(FEAT_EVAL) |
10175 buf->b_p_fex = vim_strsave(p_fex); | |
10176 #endif | |
7 | 10177 #ifdef FEAT_CRYPT |
10178 buf->b_p_key = vim_strsave(p_key); | |
10179 #endif | |
10180 #ifdef FEAT_SEARCHPATH | |
10181 buf->b_p_sua = vim_strsave(p_sua); | |
10182 #endif | |
10183 #ifdef FEAT_KEYMAP | |
10184 buf->b_p_keymap = vim_strsave(p_keymap); | |
10185 buf->b_kmap_state |= KEYMAP_INIT; | |
10186 #endif | |
10187 /* This isn't really an option, but copying the langmap and IME | |
10188 * state from the current buffer is better than resetting it. */ | |
10189 buf->b_p_iminsert = p_iminsert; | |
10190 buf->b_p_imsearch = p_imsearch; | |
10191 | |
10192 /* options that are normally global but also have a local value | |
10193 * are not copied, start using the global value */ | |
10194 buf->b_p_ar = -1; | |
10195 #ifdef FEAT_QUICKFIX | |
10196 buf->b_p_gp = empty_option; | |
10197 buf->b_p_mp = empty_option; | |
10198 buf->b_p_efm = empty_option; | |
10199 #endif | |
10200 buf->b_p_ep = empty_option; | |
10201 buf->b_p_kp = empty_option; | |
10202 buf->b_p_path = empty_option; | |
10203 buf->b_p_tags = empty_option; | |
10204 #ifdef FEAT_FIND_ID | |
10205 buf->b_p_def = empty_option; | |
10206 buf->b_p_inc = empty_option; | |
10207 # ifdef FEAT_EVAL | |
10208 buf->b_p_inex = vim_strsave(p_inex); | |
10209 # endif | |
10210 #endif | |
10211 #ifdef FEAT_INS_EXPAND | |
10212 buf->b_p_dict = empty_option; | |
10213 buf->b_p_tsr = empty_option; | |
10214 #endif | |
12 | 10215 #ifdef FEAT_TEXTOBJ |
10216 buf->b_p_qe = vim_strsave(p_qe); | |
10217 #endif | |
790 | 10218 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
10219 buf->b_p_bexpr = empty_option; | |
10220 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
10221 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
10222 buf->b_p_cm = empty_option; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
10223 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
10224 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
10225 buf->b_p_udf = p_udf; |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
10226 #endif |
7 | 10227 |
10228 /* | |
10229 * Don't copy the options set by ex_help(), use the saved values, | |
10230 * when going from a help buffer to a non-help buffer. | |
10231 * Don't touch these at all when BCO_NOHELP is used and going from | |
10232 * or to a help buffer. | |
10233 */ | |
10234 if (dont_do_help) | |
10235 buf->b_p_isk = save_p_isk; | |
10236 else | |
10237 { | |
10238 buf->b_p_isk = vim_strsave(p_isk); | |
10239 did_isk = TRUE; | |
10240 buf->b_p_ts = p_ts; | |
10241 buf->b_help = FALSE; | |
10242 #ifdef FEAT_QUICKFIX | |
10243 if (buf->b_p_bt[0] == 'h') | |
10244 clear_string_option(&buf->b_p_bt); | |
10245 #endif | |
10246 buf->b_p_ma = p_ma; | |
10247 } | |
10248 } | |
10249 | |
10250 /* | |
10251 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
10252 * flag that indicates that the options have been initialized. | |
10253 */ | |
10254 if (should_copy) | |
10255 buf->b_p_initialized = TRUE; | |
10256 } | |
10257 | |
10258 check_buf_options(buf); /* make sure we don't have NULLs */ | |
10259 if (did_isk) | |
10260 (void)buf_init_chartab(buf, FALSE); | |
10261 } | |
10262 | |
10263 /* | |
10264 * Reset the 'modifiable' option and its default value. | |
10265 */ | |
10266 void | |
10267 reset_modifiable() | |
10268 { | |
10269 int opt_idx; | |
10270 | |
10271 curbuf->b_p_ma = FALSE; | |
10272 p_ma = FALSE; | |
10273 opt_idx = findoption((char_u *)"ma"); | |
838 | 10274 if (opt_idx >= 0) |
10275 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 10276 } |
10277 | |
10278 /* | |
10279 * Set the global value for 'iminsert' to the local value. | |
10280 */ | |
10281 void | |
10282 set_iminsert_global() | |
10283 { | |
10284 p_iminsert = curbuf->b_p_iminsert; | |
10285 } | |
10286 | |
10287 /* | |
10288 * Set the global value for 'imsearch' to the local value. | |
10289 */ | |
10290 void | |
10291 set_imsearch_global() | |
10292 { | |
10293 p_imsearch = curbuf->b_p_imsearch; | |
10294 } | |
10295 | |
10296 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
10297 static int expand_option_idx = -1; | |
10298 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
10299 static int expand_option_flags = 0; | |
10300 | |
10301 void | |
10302 set_context_in_set_cmd(xp, arg, opt_flags) | |
10303 expand_T *xp; | |
10304 char_u *arg; | |
10305 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ | |
10306 { | |
10307 int nextchar; | |
10308 long_u flags = 0; /* init for GCC */ | |
10309 int opt_idx = 0; /* init for GCC */ | |
10310 char_u *p; | |
10311 char_u *s; | |
10312 int is_term_option = FALSE; | |
10313 int key; | |
10314 | |
10315 expand_option_flags = opt_flags; | |
10316 | |
10317 xp->xp_context = EXPAND_SETTINGS; | |
10318 if (*arg == NUL) | |
10319 { | |
10320 xp->xp_pattern = arg; | |
10321 return; | |
10322 } | |
10323 p = arg + STRLEN(arg) - 1; | |
10324 if (*p == ' ' && *(p - 1) != '\\') | |
10325 { | |
10326 xp->xp_pattern = p + 1; | |
10327 return; | |
10328 } | |
10329 while (p > arg) | |
10330 { | |
10331 s = p; | |
10332 /* count number of backslashes before ' ' or ',' */ | |
10333 if (*p == ' ' || *p == ',') | |
10334 { | |
10335 while (s > arg && *(s - 1) == '\\') | |
10336 --s; | |
10337 } | |
10338 /* break at a space with an even number of backslashes */ | |
10339 if (*p == ' ' && ((p - s) & 1) == 0) | |
10340 { | |
10341 ++p; | |
10342 break; | |
10343 } | |
10344 --p; | |
10345 } | |
1911 | 10346 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 10347 { |
10348 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
10349 p += 2; | |
10350 } | |
10351 if (STRNCMP(p, "inv", 3) == 0) | |
10352 { | |
10353 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
10354 p += 3; | |
10355 } | |
10356 xp->xp_pattern = arg = p; | |
10357 if (*arg == '<') | |
10358 { | |
10359 while (*p != '>') | |
10360 if (*p++ == NUL) /* expand terminal option name */ | |
10361 return; | |
10362 key = get_special_key_code(arg + 1); | |
10363 if (key == 0) /* unknown name */ | |
10364 { | |
10365 xp->xp_context = EXPAND_NOTHING; | |
10366 return; | |
10367 } | |
10368 nextchar = *++p; | |
10369 is_term_option = TRUE; | |
10370 expand_option_name[2] = KEY2TERMCAP0(key); | |
10371 expand_option_name[3] = KEY2TERMCAP1(key); | |
10372 } | |
10373 else | |
10374 { | |
10375 if (p[0] == 't' && p[1] == '_') | |
10376 { | |
10377 p += 2; | |
10378 if (*p != NUL) | |
10379 ++p; | |
10380 if (*p == NUL) | |
10381 return; /* expand option name */ | |
10382 nextchar = *++p; | |
10383 is_term_option = TRUE; | |
10384 expand_option_name[2] = p[-2]; | |
10385 expand_option_name[3] = p[-1]; | |
10386 } | |
10387 else | |
10388 { | |
10389 /* Allow * wildcard */ | |
10390 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') | |
10391 p++; | |
10392 if (*p == NUL) | |
10393 return; | |
10394 nextchar = *p; | |
10395 *p = NUL; | |
10396 opt_idx = findoption(arg); | |
10397 *p = nextchar; | |
10398 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
10399 { | |
10400 xp->xp_context = EXPAND_NOTHING; | |
10401 return; | |
10402 } | |
10403 flags = options[opt_idx].flags; | |
10404 if (flags & P_BOOL) | |
10405 { | |
10406 xp->xp_context = EXPAND_NOTHING; | |
10407 return; | |
10408 } | |
10409 } | |
10410 } | |
10411 /* handle "-=" and "+=" */ | |
10412 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') | |
10413 { | |
10414 ++p; | |
10415 nextchar = '='; | |
10416 } | |
10417 if ((nextchar != '=' && nextchar != ':') | |
10418 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
10419 { | |
10420 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
10421 return; | |
10422 } | |
10423 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
10424 { | |
10425 xp->xp_context = EXPAND_OLD_SETTING; | |
10426 if (is_term_option) | |
10427 expand_option_idx = -1; | |
10428 else | |
10429 expand_option_idx = opt_idx; | |
10430 xp->xp_pattern = p + 1; | |
10431 return; | |
10432 } | |
10433 xp->xp_context = EXPAND_NOTHING; | |
10434 if (is_term_option || (flags & P_NUM)) | |
10435 return; | |
10436 | |
10437 xp->xp_pattern = p + 1; | |
10438 | |
10439 if (flags & P_EXPAND) | |
10440 { | |
10441 p = options[opt_idx].var; | |
10442 if (p == (char_u *)&p_bdir | |
10443 || p == (char_u *)&p_dir | |
10444 || p == (char_u *)&p_path | |
10445 || p == (char_u *)&p_rtp | |
10446 #ifdef FEAT_SEARCHPATH | |
10447 || p == (char_u *)&p_cdpath | |
10448 #endif | |
10449 #ifdef FEAT_SESSION | |
10450 || p == (char_u *)&p_vdir | |
10451 #endif | |
10452 ) | |
10453 { | |
10454 xp->xp_context = EXPAND_DIRECTORIES; | |
10455 if (p == (char_u *)&p_path | |
10456 #ifdef FEAT_SEARCHPATH | |
10457 || p == (char_u *)&p_cdpath | |
10458 #endif | |
10459 ) | |
10460 xp->xp_backslash = XP_BS_THREE; | |
10461 else | |
10462 xp->xp_backslash = XP_BS_ONE; | |
10463 } | |
10464 else | |
10465 { | |
10466 xp->xp_context = EXPAND_FILES; | |
10467 /* for 'tags' need three backslashes for a space */ | |
10468 if (p == (char_u *)&p_tags) | |
10469 xp->xp_backslash = XP_BS_THREE; | |
10470 else | |
10471 xp->xp_backslash = XP_BS_ONE; | |
10472 } | |
10473 } | |
10474 | |
10475 /* For an option that is a list of file names, find the start of the | |
10476 * last file name. */ | |
10477 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) | |
10478 { | |
10479 /* count number of backslashes before ' ' or ',' */ | |
10480 if (*p == ' ' || *p == ',') | |
10481 { | |
10482 s = p; | |
10483 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
10484 --s; | |
10485 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
10486 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
10487 { | |
10488 xp->xp_pattern = p + 1; | |
10489 break; | |
10490 } | |
10491 } | |
374 | 10492 |
744 | 10493 #ifdef FEAT_SPELL |
374 | 10494 /* for 'spellsuggest' start at "file:" */ |
10495 if (options[opt_idx].var == (char_u *)&p_sps | |
10496 && STRNCMP(p, "file:", 5) == 0) | |
10497 { | |
10498 xp->xp_pattern = p + 5; | |
10499 break; | |
10500 } | |
10501 #endif | |
7 | 10502 } |
10503 | |
10504 return; | |
10505 } | |
10506 | |
10507 int | |
10508 ExpandSettings(xp, regmatch, num_file, file) | |
10509 expand_T *xp; | |
10510 regmatch_T *regmatch; | |
10511 int *num_file; | |
10512 char_u ***file; | |
10513 { | |
10514 int num_normal = 0; /* Nr of matching non-term-code settings */ | |
10515 int num_term = 0; /* Nr of matching terminal code settings */ | |
10516 int opt_idx; | |
10517 int match; | |
10518 int count = 0; | |
10519 char_u *str; | |
10520 int loop; | |
10521 int is_term_opt; | |
10522 char_u name_buf[MAX_KEY_NAME_LEN]; | |
10523 static char *(names[]) = {"all", "termcap"}; | |
10524 int ic = regmatch->rm_ic; /* remember the ignore-case flag */ | |
10525 | |
10526 /* do this loop twice: | |
10527 * loop == 0: count the number of matching options | |
10528 * loop == 1: copy the matching options into allocated memory | |
10529 */ | |
10530 for (loop = 0; loop <= 1; ++loop) | |
10531 { | |
10532 regmatch->rm_ic = ic; | |
10533 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
10534 { | |
1883 | 10535 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); |
10536 ++match) | |
7 | 10537 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
10538 { | |
10539 if (loop == 0) | |
10540 num_normal++; | |
10541 else | |
10542 (*file)[count++] = vim_strsave((char_u *)names[match]); | |
10543 } | |
10544 } | |
10545 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
10546 opt_idx++) | |
10547 { | |
10548 if (options[opt_idx].var == NULL) | |
10549 continue; | |
10550 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
10551 && !(options[opt_idx].flags & P_BOOL)) | |
10552 continue; | |
10553 is_term_opt = istermoption(&options[opt_idx]); | |
10554 if (is_term_opt && num_normal > 0) | |
10555 continue; | |
10556 match = FALSE; | |
10557 if (vim_regexec(regmatch, str, (colnr_T)0) | |
10558 || (options[opt_idx].shortname != NULL | |
10559 && vim_regexec(regmatch, | |
10560 (char_u *)options[opt_idx].shortname, (colnr_T)0))) | |
10561 match = TRUE; | |
10562 else if (is_term_opt) | |
10563 { | |
10564 name_buf[0] = '<'; | |
10565 name_buf[1] = 't'; | |
10566 name_buf[2] = '_'; | |
10567 name_buf[3] = str[2]; | |
10568 name_buf[4] = str[3]; | |
10569 name_buf[5] = '>'; | |
10570 name_buf[6] = NUL; | |
10571 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
10572 { | |
10573 match = TRUE; | |
10574 str = name_buf; | |
10575 } | |
10576 } | |
10577 if (match) | |
10578 { | |
10579 if (loop == 0) | |
10580 { | |
10581 if (is_term_opt) | |
10582 num_term++; | |
10583 else | |
10584 num_normal++; | |
10585 } | |
10586 else | |
10587 (*file)[count++] = vim_strsave(str); | |
10588 } | |
10589 } | |
10590 /* | |
10591 * Check terminal key codes, these are not in the option table | |
10592 */ | |
10593 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
10594 { | |
10595 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
10596 { | |
10597 if (!isprint(str[0]) || !isprint(str[1])) | |
10598 continue; | |
10599 | |
10600 name_buf[0] = 't'; | |
10601 name_buf[1] = '_'; | |
10602 name_buf[2] = str[0]; | |
10603 name_buf[3] = str[1]; | |
10604 name_buf[4] = NUL; | |
10605 | |
10606 match = FALSE; | |
10607 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
10608 match = TRUE; | |
10609 else | |
10610 { | |
10611 name_buf[0] = '<'; | |
10612 name_buf[1] = 't'; | |
10613 name_buf[2] = '_'; | |
10614 name_buf[3] = str[0]; | |
10615 name_buf[4] = str[1]; | |
10616 name_buf[5] = '>'; | |
10617 name_buf[6] = NUL; | |
10618 | |
10619 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
10620 match = TRUE; | |
10621 } | |
10622 if (match) | |
10623 { | |
10624 if (loop == 0) | |
10625 num_term++; | |
10626 else | |
10627 (*file)[count++] = vim_strsave(name_buf); | |
10628 } | |
10629 } | |
10630 | |
10631 /* | |
10632 * Check special key names. | |
10633 */ | |
10634 regmatch->rm_ic = TRUE; /* ignore case here */ | |
10635 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) | |
10636 { | |
10637 name_buf[0] = '<'; | |
10638 STRCPY(name_buf + 1, str); | |
10639 STRCAT(name_buf, ">"); | |
10640 | |
10641 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
10642 { | |
10643 if (loop == 0) | |
10644 num_term++; | |
10645 else | |
10646 (*file)[count++] = vim_strsave(name_buf); | |
10647 } | |
10648 } | |
10649 } | |
10650 if (loop == 0) | |
10651 { | |
10652 if (num_normal > 0) | |
10653 *num_file = num_normal; | |
10654 else if (num_term > 0) | |
10655 *num_file = num_term; | |
10656 else | |
10657 return OK; | |
10658 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *))); | |
10659 if (*file == NULL) | |
10660 { | |
10661 *file = (char_u **)""; | |
10662 return FAIL; | |
10663 } | |
10664 } | |
10665 } | |
10666 return OK; | |
10667 } | |
10668 | |
10669 int | |
10670 ExpandOldSetting(num_file, file) | |
10671 int *num_file; | |
10672 char_u ***file; | |
10673 { | |
10674 char_u *var = NULL; /* init for GCC */ | |
10675 char_u *buf; | |
10676 | |
10677 *num_file = 0; | |
10678 *file = (char_u **)alloc((unsigned)sizeof(char_u *)); | |
10679 if (*file == NULL) | |
10680 return FAIL; | |
10681 | |
10682 /* | |
10683 * For a terminal key code expand_option_idx is < 0. | |
10684 */ | |
10685 if (expand_option_idx < 0) | |
10686 { | |
10687 var = find_termcode(expand_option_name + 2); | |
10688 if (var == NULL) | |
10689 expand_option_idx = findoption(expand_option_name); | |
10690 } | |
10691 | |
10692 if (expand_option_idx >= 0) | |
10693 { | |
10694 /* put string of option value in NameBuff */ | |
10695 option_value2string(&options[expand_option_idx], expand_option_flags); | |
10696 var = NameBuff; | |
10697 } | |
10698 else if (var == NULL) | |
10699 var = (char_u *)""; | |
10700 | |
10701 /* A backslash is required before some characters. This is the reverse of | |
10702 * what happens in do_set(). */ | |
10703 buf = vim_strsave_escaped(var, escape_chars); | |
10704 | |
10705 if (buf == NULL) | |
10706 { | |
10707 vim_free(*file); | |
10708 *file = NULL; | |
10709 return FAIL; | |
10710 } | |
10711 | |
10712 #ifdef BACKSLASH_IN_FILENAME | |
10713 /* For MS-Windows et al. we don't double backslashes at the start and | |
10714 * before a file name character. */ | |
39 | 10715 for (var = buf; *var != NUL; mb_ptr_adv(var)) |
7 | 10716 if (var[0] == '\\' && var[1] == '\\' |
10717 && expand_option_idx >= 0 | |
10718 && (options[expand_option_idx].flags & P_EXPAND) | |
10719 && vim_isfilec(var[2]) | |
10720 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 10721 STRMOVE(var, var + 1); |
7 | 10722 #endif |
10723 | |
10724 *file[0] = buf; | |
10725 *num_file = 1; | |
10726 return OK; | |
10727 } | |
10728 #endif | |
10729 | |
10730 /* | |
10731 * Get the value for the numeric or string option *opp in a nice format into | |
10732 * NameBuff[]. Must not be called with a hidden option! | |
10733 */ | |
10734 static void | |
10735 option_value2string(opp, opt_flags) | |
10736 struct vimoption *opp; | |
10737 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ | |
10738 { | |
10739 char_u *varp; | |
10740 | |
10741 varp = get_varp_scope(opp, opt_flags); | |
10742 | |
10743 if (opp->flags & P_NUM) | |
10744 { | |
10745 long wc = 0; | |
10746 | |
10747 if (wc_use_keyname(varp, &wc)) | |
10748 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
10749 else if (wc != 0) | |
10750 STRCPY(NameBuff, transchar((int)wc)); | |
10751 else | |
10752 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
10753 } | |
10754 else /* P_STRING */ | |
10755 { | |
10756 varp = *(char_u **)(varp); | |
10757 if (varp == NULL) /* just in case */ | |
10758 NameBuff[0] = NUL; | |
10759 #ifdef FEAT_CRYPT | |
10760 /* don't show the actual value of 'key', only that it's set */ | |
840 | 10761 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 10762 STRCPY(NameBuff, "*****"); |
10763 #endif | |
10764 else if (opp->flags & P_EXPAND) | |
10765 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); | |
10766 /* Translate 'pastetoggle' into special key names */ | |
10767 else if ((char_u **)opp->var == &p_pt) | |
10768 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
10769 else | |
419 | 10770 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 10771 } |
10772 } | |
10773 | |
10774 /* | |
10775 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
10776 * printed as a keyname. | |
10777 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
10778 */ | |
10779 static int | |
10780 wc_use_keyname(varp, wcp) | |
10781 char_u *varp; | |
10782 long *wcp; | |
10783 { | |
10784 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
10785 { | |
10786 *wcp = *(long *)varp; | |
10787 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
10788 return TRUE; | |
10789 } | |
10790 return FALSE; | |
10791 } | |
10792 | |
10793 #ifdef FEAT_LANGMAP | |
10794 /* | |
1811 | 10795 * Any character has an equivalent 'langmap' character. This is used for |
10796 * keyboards that have a special language mode that sends characters above | |
10797 * 128 (although other characters can be translated too). The "to" field is a | |
10798 * Vim command character. This avoids having to switch the keyboard back to | |
10799 * ASCII mode when leaving Insert mode. | |
10800 * | |
10801 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim | |
10802 * commands. | |
10803 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of | |
10804 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >= | |
10805 * 256. | |
10806 */ | |
10807 # ifdef FEAT_MBYTE | |
10808 /* | |
10809 * With multi-byte support use growarray for 'langmap' chars >= 256 | |
10810 */ | |
10811 typedef struct | |
10812 { | |
10813 int from; | |
10814 int to; | |
10815 } langmap_entry_T; | |
10816 | |
10817 static garray_T langmap_mapga; | |
10818 static void langmap_set_entry __ARGS((int from, int to)); | |
10819 | |
10820 /* | |
10821 * Search for an entry in "langmap_mapga" for "from". If found set the "to" | |
10822 * field. If not found insert a new entry at the appropriate location. | |
10823 */ | |
10824 static void | |
10825 langmap_set_entry(from, to) | |
10826 int from; | |
10827 int to; | |
10828 { | |
10829 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); | |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
10830 int a = 0; |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
10831 int b = langmap_mapga.ga_len; |
1811 | 10832 |
10833 /* Do a binary search for an existing entry. */ | |
10834 while (a != b) | |
10835 { | |
10836 int i = (a + b) / 2; | |
10837 int d = entries[i].from - from; | |
10838 | |
10839 if (d == 0) | |
10840 { | |
10841 entries[i].to = to; | |
10842 return; | |
10843 } | |
10844 if (d < 0) | |
10845 a = i + 1; | |
10846 else | |
10847 b = i; | |
10848 } | |
10849 | |
10850 if (ga_grow(&langmap_mapga, 1) != OK) | |
10851 return; /* out of memory */ | |
10852 | |
10853 /* insert new entry at position "a" */ | |
10854 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a; | |
10855 mch_memmove(entries + 1, entries, | |
10856 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); | |
10857 ++langmap_mapga.ga_len; | |
10858 entries[0].from = from; | |
10859 entries[0].to = to; | |
10860 } | |
10861 | |
10862 /* | |
10863 * Apply 'langmap' to multi-byte character "c" and return the result. | |
10864 */ | |
10865 int | |
10866 langmap_adjust_mb(c) | |
10867 int c; | |
10868 { | |
10869 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); | |
10870 int a = 0; | |
10871 int b = langmap_mapga.ga_len; | |
10872 | |
10873 while (a != b) | |
10874 { | |
10875 int i = (a + b) / 2; | |
10876 int d = entries[i].from - c; | |
10877 | |
10878 if (d == 0) | |
10879 return entries[i].to; /* found matching entry */ | |
10880 if (d < 0) | |
10881 a = i + 1; | |
10882 else | |
10883 b = i; | |
10884 } | |
10885 return c; /* no entry found, return "c" unmodified */ | |
10886 } | |
10887 # endif | |
7 | 10888 |
10889 static void | |
10890 langmap_init() | |
10891 { | |
10892 int i; | |
10893 | |
1811 | 10894 for (i = 0; i < 256; i++) |
10895 langmap_mapchar[i] = i; /* we init with a one-to-one map */ | |
10896 # ifdef FEAT_MBYTE | |
10897 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8); | |
10898 # endif | |
7 | 10899 } |
10900 | |
10901 /* | |
10902 * Called when langmap option is set; the language map can be | |
10903 * changed at any time! | |
10904 */ | |
10905 static void | |
10906 langmap_set() | |
10907 { | |
10908 char_u *p; | |
10909 char_u *p2; | |
10910 int from, to; | |
10911 | |
1811 | 10912 #ifdef FEAT_MBYTE |
10913 ga_clear(&langmap_mapga); /* clear the previous map first */ | |
10914 #endif | |
10915 langmap_init(); /* back to one-to-one map */ | |
7 | 10916 |
10917 for (p = p_langmap; p[0] != NUL; ) | |
10918 { | |
39 | 10919 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; |
10920 mb_ptr_adv(p2)) | |
7 | 10921 { |
10922 if (p2[0] == '\\' && p2[1] != NUL) | |
10923 ++p2; | |
10924 } | |
10925 if (p2[0] == ';') | |
10926 ++p2; /* abcd;ABCD form, p2 points to A */ | |
10927 else | |
10928 p2 = NULL; /* aAbBcCdD form, p2 is NULL */ | |
10929 while (p[0]) | |
10930 { | |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10931 if (p[0] == ',') |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10932 { |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10933 ++p; |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10934 break; |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10935 } |
7 | 10936 if (p[0] == '\\' && p[1] != NUL) |
10937 ++p; | |
10938 #ifdef FEAT_MBYTE | |
10939 from = (*mb_ptr2char)(p); | |
10940 #else | |
10941 from = p[0]; | |
10942 #endif | |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10943 to = NUL; |
7 | 10944 if (p2 == NULL) |
10945 { | |
39 | 10946 mb_ptr_adv(p); |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10947 if (p[0] != ',') |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10948 { |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10949 if (p[0] == '\\') |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10950 ++p; |
7 | 10951 #ifdef FEAT_MBYTE |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10952 to = (*mb_ptr2char)(p); |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10953 #else |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10954 to = p[0]; |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10955 #endif |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10956 } |
7 | 10957 } |
10958 else | |
10959 { | |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10960 if (p2[0] != ',') |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10961 { |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10962 if (p2[0] == '\\') |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10963 ++p2; |
7 | 10964 #ifdef FEAT_MBYTE |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10965 to = (*mb_ptr2char)(p2); |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10966 #else |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10967 to = p2[0]; |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10968 #endif |
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10969 } |
7 | 10970 } |
10971 if (to == NUL) | |
10972 { | |
10973 EMSG2(_("E357: 'langmap': Matching character missing for %s"), | |
10974 transchar(from)); | |
10975 return; | |
10976 } | |
1811 | 10977 |
10978 #ifdef FEAT_MBYTE | |
10979 if (from >= 256) | |
10980 langmap_set_entry(from, to); | |
10981 else | |
10982 #endif | |
10983 langmap_mapchar[from & 255] = to; | |
7 | 10984 |
10985 /* Advance to next pair */ | |
39 | 10986 mb_ptr_adv(p); |
2144
2775dcd05603
updated for version 7.2.426
Bram Moolenaar <bram@zimbu.org>
parents:
2135
diff
changeset
|
10987 if (p2 != NULL) |
7 | 10988 { |
39 | 10989 mb_ptr_adv(p2); |
7 | 10990 if (*p == ';') |
10991 { | |
10992 p = p2; | |
10993 if (p[0] != NUL) | |
10994 { | |
10995 if (p[0] != ',') | |
10996 { | |
10997 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p); | |
10998 return; | |
10999 } | |
11000 ++p; | |
11001 } | |
11002 break; | |
11003 } | |
11004 } | |
11005 } | |
11006 } | |
11007 } | |
11008 #endif | |
11009 | |
11010 /* | |
11011 * Return TRUE if format option 'x' is in effect. | |
11012 * Take care of no formatting when 'paste' is set. | |
11013 */ | |
11014 int | |
11015 has_format_option(x) | |
11016 int x; | |
11017 { | |
11018 if (p_paste) | |
11019 return FALSE; | |
11020 return (vim_strchr(curbuf->b_p_fo, x) != NULL); | |
11021 } | |
11022 | |
11023 /* | |
11024 * Return TRUE if "x" is present in 'shortmess' option, or | |
11025 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
11026 */ | |
11027 int | |
11028 shortmess(x) | |
11029 int x; | |
11030 { | |
3384 | 11031 return p_shm != NULL && |
11032 ( vim_strchr(p_shm, x) != NULL | |
7 | 11033 || (vim_strchr(p_shm, 'a') != NULL |
11034 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
11035 } | |
11036 | |
11037 /* | |
11038 * paste_option_changed() - Called after p_paste was set or reset. | |
11039 */ | |
11040 static void | |
11041 paste_option_changed() | |
11042 { | |
11043 static int old_p_paste = FALSE; | |
11044 static int save_sm = 0; | |
11045 #ifdef FEAT_CMDL_INFO | |
11046 static int save_ru = 0; | |
11047 #endif | |
11048 #ifdef FEAT_RIGHTLEFT | |
11049 static int save_ri = 0; | |
11050 static int save_hkmap = 0; | |
11051 #endif | |
11052 buf_T *buf; | |
11053 | |
11054 if (p_paste) | |
11055 { | |
11056 /* | |
11057 * Paste switched from off to on. | |
11058 * Save the current values, so they can be restored later. | |
11059 */ | |
11060 if (!old_p_paste) | |
11061 { | |
11062 /* save options for each buffer */ | |
11063 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | |
11064 { | |
11065 buf->b_p_tw_nopaste = buf->b_p_tw; | |
11066 buf->b_p_wm_nopaste = buf->b_p_wm; | |
11067 buf->b_p_sts_nopaste = buf->b_p_sts; | |
11068 buf->b_p_ai_nopaste = buf->b_p_ai; | |
11069 } | |
11070 | |
11071 /* save global options */ | |
11072 save_sm = p_sm; | |
11073 #ifdef FEAT_CMDL_INFO | |
11074 save_ru = p_ru; | |
11075 #endif | |
11076 #ifdef FEAT_RIGHTLEFT | |
11077 save_ri = p_ri; | |
11078 save_hkmap = p_hkmap; | |
11079 #endif | |
11080 /* save global values for local buffer options */ | |
11081 p_tw_nopaste = p_tw; | |
11082 p_wm_nopaste = p_wm; | |
11083 p_sts_nopaste = p_sts; | |
11084 p_ai_nopaste = p_ai; | |
11085 } | |
11086 | |
11087 /* | |
11088 * Always set the option values, also when 'paste' is set when it is | |
11089 * already on. | |
11090 */ | |
11091 /* set options for each buffer */ | |
11092 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | |
11093 { | |
11094 buf->b_p_tw = 0; /* textwidth is 0 */ | |
11095 buf->b_p_wm = 0; /* wrapmargin is 0 */ | |
11096 buf->b_p_sts = 0; /* softtabstop is 0 */ | |
11097 buf->b_p_ai = 0; /* no auto-indent */ | |
11098 } | |
11099 | |
11100 /* set global options */ | |
11101 p_sm = 0; /* no showmatch */ | |
11102 #ifdef FEAT_CMDL_INFO | |
11103 # ifdef FEAT_WINDOWS | |
11104 if (p_ru) | |
11105 status_redraw_all(); /* redraw to remove the ruler */ | |
11106 # endif | |
11107 p_ru = 0; /* no ruler */ | |
11108 #endif | |
11109 #ifdef FEAT_RIGHTLEFT | |
11110 p_ri = 0; /* no reverse insert */ | |
11111 p_hkmap = 0; /* no Hebrew keyboard */ | |
11112 #endif | |
11113 /* set global values for local buffer options */ | |
11114 p_tw = 0; | |
11115 p_wm = 0; | |
11116 p_sts = 0; | |
11117 p_ai = 0; | |
11118 } | |
11119 | |
11120 /* | |
11121 * Paste switched from on to off: Restore saved values. | |
11122 */ | |
11123 else if (old_p_paste) | |
11124 { | |
11125 /* restore options for each buffer */ | |
11126 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | |
11127 { | |
11128 buf->b_p_tw = buf->b_p_tw_nopaste; | |
11129 buf->b_p_wm = buf->b_p_wm_nopaste; | |
11130 buf->b_p_sts = buf->b_p_sts_nopaste; | |
11131 buf->b_p_ai = buf->b_p_ai_nopaste; | |
11132 } | |
11133 | |
11134 /* restore global options */ | |
11135 p_sm = save_sm; | |
11136 #ifdef FEAT_CMDL_INFO | |
11137 # ifdef FEAT_WINDOWS | |
11138 if (p_ru != save_ru) | |
11139 status_redraw_all(); /* redraw to draw the ruler */ | |
11140 # endif | |
11141 p_ru = save_ru; | |
11142 #endif | |
11143 #ifdef FEAT_RIGHTLEFT | |
11144 p_ri = save_ri; | |
11145 p_hkmap = save_hkmap; | |
11146 #endif | |
11147 /* set global values for local buffer options */ | |
11148 p_tw = p_tw_nopaste; | |
11149 p_wm = p_wm_nopaste; | |
11150 p_sts = p_sts_nopaste; | |
11151 p_ai = p_ai_nopaste; | |
11152 } | |
11153 | |
11154 old_p_paste = p_paste; | |
11155 } | |
11156 | |
11157 /* | |
11158 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
11159 * | |
11160 * Reset 'compatible' and set the values for options that didn't get set yet | |
11161 * to the Vim defaults. | |
11162 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 11163 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 11164 */ |
11165 void | |
819 | 11166 vimrc_found(fname, envname) |
11167 char_u *fname; | |
11168 char_u *envname; | |
11169 { | |
11170 int opt_idx; | |
826 | 11171 int dofree = FALSE; |
819 | 11172 char_u *p; |
7 | 11173 |
11174 if (!option_was_set((char_u *)"cp")) | |
11175 { | |
11176 p_cp = FALSE; | |
11177 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) | |
11178 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) | |
11179 set_option_default(opt_idx, OPT_FREE, FALSE); | |
11180 didset_options(); | |
11181 } | |
819 | 11182 |
11183 if (fname != NULL) | |
11184 { | |
11185 p = vim_getenv(envname, &dofree); | |
11186 if (p == NULL) | |
11187 { | |
11188 /* Set $MYVIMRC to the first vimrc file found. */ | |
11189 p = FullName_save(fname, FALSE); | |
11190 if (p != NULL) | |
11191 { | |
11192 vim_setenv(envname, p); | |
11193 vim_free(p); | |
11194 } | |
11195 } | |
11196 else if (dofree) | |
11197 vim_free(p); | |
11198 } | |
7 | 11199 } |
11200 | |
11201 /* | |
11202 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
11203 */ | |
11204 void | |
11205 change_compatible(on) | |
11206 int on; | |
11207 { | |
838 | 11208 int opt_idx; |
11209 | |
7 | 11210 if (p_cp != on) |
11211 { | |
11212 p_cp = on; | |
11213 compatible_set(); | |
11214 } | |
838 | 11215 opt_idx = findoption((char_u *)"cp"); |
11216 if (opt_idx >= 0) | |
11217 options[opt_idx].flags |= P_WAS_SET; | |
7 | 11218 } |
11219 | |
11220 /* | |
11221 * Return TRUE when option "name" has been set. | |
11222 */ | |
11223 int | |
11224 option_was_set(name) | |
11225 char_u *name; | |
11226 { | |
11227 int idx; | |
11228 | |
11229 idx = findoption(name); | |
11230 if (idx < 0) /* unknown option */ | |
11231 return FALSE; | |
11232 if (options[idx].flags & P_WAS_SET) | |
11233 return TRUE; | |
11234 return FALSE; | |
11235 } | |
11236 | |
11237 /* | |
3980 | 11238 * Reset the flag indicating option "name" was set. |
11239 */ | |
11240 void | |
11241 reset_option_was_set(name) | |
11242 char_u *name; | |
11243 { | |
11244 int idx = findoption(name); | |
11245 | |
11246 if (idx >= 0) | |
11247 options[idx].flags &= ~P_WAS_SET; | |
11248 } | |
11249 | |
11250 /* | |
7 | 11251 * compatible_set() - Called when 'compatible' has been set or unset. |
11252 * | |
11253 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
11254 * flag) to a Vi compatible value. | |
11255 * When 'compatible' is unset: Set all options that have a different default | |
11256 * for Vim (without the P_VI_DEF flag) to that default. | |
11257 */ | |
11258 static void | |
11259 compatible_set() | |
11260 { | |
11261 int opt_idx; | |
11262 | |
11263 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) | |
11264 if ( ((options[opt_idx].flags & P_VIM) && p_cp) | |
11265 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
11266 set_option_default(opt_idx, OPT_FREE, p_cp); | |
11267 didset_options(); | |
11268 } | |
11269 | |
11270 #ifdef FEAT_LINEBREAK | |
11271 | |
11272 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) | |
11273 /* Borland C++ screws up loop optimisation here (negri) */ | |
133 | 11274 #pragma option -O-l |
7 | 11275 # endif |
11276 | |
11277 /* | |
11278 * fill_breakat_flags() -- called when 'breakat' changes value. | |
11279 */ | |
11280 static void | |
11281 fill_breakat_flags() | |
11282 { | |
500 | 11283 char_u *p; |
7 | 11284 int i; |
11285 | |
11286 for (i = 0; i < 256; i++) | |
11287 breakat_flags[i] = FALSE; | |
11288 | |
11289 if (p_breakat != NULL) | |
500 | 11290 for (p = p_breakat; *p; p++) |
11291 breakat_flags[*p] = TRUE; | |
7 | 11292 } |
11293 | |
11294 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) | |
133 | 11295 #pragma option -O.l |
7 | 11296 # endif |
11297 | |
11298 #endif | |
11299 | |
11300 /* | |
11301 * Check an option that can be a range of string values. | |
11302 * | |
11303 * Return OK for correct value, FAIL otherwise. | |
11304 * Empty is always OK. | |
11305 */ | |
11306 static int | |
11307 check_opt_strings(val, values, list) | |
11308 char_u *val; | |
11309 char **values; | |
11310 int list; /* when TRUE: accept a list of values */ | |
11311 { | |
11312 return opt_strings_flags(val, values, NULL, list); | |
11313 } | |
11314 | |
11315 /* | |
11316 * Handle an option that can be a range of string values. | |
11317 * Set a flag in "*flagp" for each string present. | |
11318 * | |
11319 * Return OK for correct value, FAIL otherwise. | |
11320 * Empty is always OK. | |
11321 */ | |
11322 static int | |
11323 opt_strings_flags(val, values, flagp, list) | |
11324 char_u *val; /* new value */ | |
11325 char **values; /* array of valid string values */ | |
11326 unsigned *flagp; | |
11327 int list; /* when TRUE: accept a list of values */ | |
11328 { | |
11329 int i; | |
11330 int len; | |
11331 unsigned new_flags = 0; | |
11332 | |
11333 while (*val) | |
11334 { | |
11335 for (i = 0; ; ++i) | |
11336 { | |
11337 if (values[i] == NULL) /* val not found in values[] */ | |
11338 return FAIL; | |
11339 | |
11340 len = (int)STRLEN(values[i]); | |
11341 if (STRNCMP(values[i], val, len) == 0 | |
11342 && ((list && val[len] == ',') || val[len] == NUL)) | |
11343 { | |
11344 val += len + (val[len] == ','); | |
11345 new_flags |= (1 << i); | |
11346 break; /* check next item in val list */ | |
11347 } | |
11348 } | |
11349 } | |
11350 if (flagp != NULL) | |
11351 *flagp = new_flags; | |
11352 | |
11353 return OK; | |
11354 } | |
11355 | |
11356 /* | |
11357 * Read the 'wildmode' option, fill wim_flags[]. | |
11358 */ | |
11359 static int | |
11360 check_opt_wim() | |
11361 { | |
11362 char_u new_wim_flags[4]; | |
11363 char_u *p; | |
11364 int i; | |
11365 int idx = 0; | |
11366 | |
11367 for (i = 0; i < 4; ++i) | |
11368 new_wim_flags[i] = 0; | |
11369 | |
11370 for (p = p_wim; *p; ++p) | |
11371 { | |
11372 for (i = 0; ASCII_ISALPHA(p[i]); ++i) | |
11373 ; | |
11374 if (p[i] != NUL && p[i] != ',' && p[i] != ':') | |
11375 return FAIL; | |
11376 if (i == 7 && STRNCMP(p, "longest", 7) == 0) | |
11377 new_wim_flags[idx] |= WIM_LONGEST; | |
11378 else if (i == 4 && STRNCMP(p, "full", 4) == 0) | |
11379 new_wim_flags[idx] |= WIM_FULL; | |
11380 else if (i == 4 && STRNCMP(p, "list", 4) == 0) | |
11381 new_wim_flags[idx] |= WIM_LIST; | |
11382 else | |
11383 return FAIL; | |
11384 p += i; | |
11385 if (*p == NUL) | |
11386 break; | |
11387 if (*p == ',') | |
11388 { | |
11389 if (idx == 3) | |
11390 return FAIL; | |
11391 ++idx; | |
11392 } | |
11393 } | |
11394 | |
11395 /* fill remaining entries with last flag */ | |
11396 while (idx < 3) | |
11397 { | |
11398 new_wim_flags[idx + 1] = new_wim_flags[idx]; | |
11399 ++idx; | |
11400 } | |
11401 | |
11402 /* only when there are no errors, wim_flags[] is changed */ | |
11403 for (i = 0; i < 4; ++i) | |
11404 wim_flags[i] = new_wim_flags[i]; | |
11405 return OK; | |
11406 } | |
11407 | |
11408 /* | |
11409 * Check if backspacing over something is allowed. | |
11410 */ | |
11411 int | |
11412 can_bs(what) | |
11413 int what; /* BS_INDENT, BS_EOL or BS_START */ | |
11414 { | |
11415 switch (*p_bs) | |
11416 { | |
11417 case '2': return TRUE; | |
11418 case '1': return (what != BS_START); | |
11419 case '0': return FALSE; | |
11420 } | |
11421 return vim_strchr(p_bs, what) != NULL; | |
11422 } | |
11423 | |
11424 /* | |
11425 * Save the current values of 'fileformat' and 'fileencoding', so that we know | |
11426 * the file must be considered changed when the value is different. | |
11427 */ | |
11428 void | |
11429 save_file_ff(buf) | |
11430 buf_T *buf; | |
11431 { | |
11432 buf->b_start_ffc = *buf->b_p_ff; | |
11433 buf->b_start_eol = buf->b_p_eol; | |
11434 #ifdef FEAT_MBYTE | |
1352 | 11435 buf->b_start_bomb = buf->b_p_bomb; |
11436 | |
7 | 11437 /* Only use free/alloc when necessary, they take time. */ |
11438 if (buf->b_start_fenc == NULL | |
11439 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) | |
11440 { | |
11441 vim_free(buf->b_start_fenc); | |
11442 buf->b_start_fenc = vim_strsave(buf->b_p_fenc); | |
11443 } | |
11444 #endif | |
11445 } | |
11446 | |
11447 /* | |
11448 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value | |
11449 * from when editing started (save_file_ff() called). | |
1352 | 11450 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was |
11451 * changed and 'binary' is not set. | |
2685 | 11452 * When "ignore_empty" is true don't consider a new, empty buffer to be |
11453 * changed. | |
7 | 11454 */ |
11455 int | |
2685 | 11456 file_ff_differs(buf, ignore_empty) |
7 | 11457 buf_T *buf; |
2685 | 11458 int ignore_empty; |
7 | 11459 { |
1319 | 11460 /* In a buffer that was never loaded the options are not valid. */ |
11461 if (buf->b_flags & BF_NEVERLOADED) | |
11462 return FALSE; | |
2685 | 11463 if (ignore_empty |
11464 && (buf->b_flags & BF_NEW) | |
7 | 11465 && buf->b_ml.ml_line_count == 1 |
11466 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) | |
11467 return FALSE; | |
11468 if (buf->b_start_ffc != *buf->b_p_ff) | |
11469 return TRUE; | |
11470 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol) | |
11471 return TRUE; | |
11472 #ifdef FEAT_MBYTE | |
1352 | 11473 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) |
11474 return TRUE; | |
7 | 11475 if (buf->b_start_fenc == NULL) |
11476 return (*buf->b_p_fenc != NUL); | |
11477 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); | |
11478 #else | |
11479 return FALSE; | |
11480 #endif | |
11481 } | |
11482 | |
11483 /* | |
11484 * return OK if "p" is a valid fileformat name, FAIL otherwise. | |
11485 */ | |
11486 int | |
11487 check_ff_value(p) | |
11488 char_u *p; | |
11489 { | |
11490 return check_opt_strings(p, p_ff_values, FALSE); | |
11491 } | |
3740 | 11492 |
11493 /* | |
11494 * Return the effective shiftwidth value for current buffer, using the | |
11495 * 'tabstop' value when 'shiftwidth' is zero. | |
11496 */ | |
11497 long | |
11498 get_sw_value() | |
11499 { | |
11500 return curbuf->b_p_sw ? curbuf->b_p_sw : curbuf->b_p_ts; | |
11501 } | |
3873 | 11502 |
11503 /* | |
11504 * Return the effective softtabstop value for the current buffer, using the | |
11505 * 'tabstop' value when 'softtabstop' is negative. | |
11506 */ | |
11507 long | |
11508 get_sts_value() | |
11509 { | |
11510 return curbuf->b_p_sts < 0 ? get_sw_value() : curbuf->b_p_sts; | |
11511 } | |
4029 | 11512 |
11513 /* | |
11514 * Check matchpairs option for "*initc". | |
11515 * If there is a match set "*initc" to the matching character and "*findc" to | |
11516 * the opposite character. Set "*backwards" to the direction. | |
11517 * When "switchit" is TRUE swap the direction. | |
11518 */ | |
11519 void | |
11520 find_mps_values(initc, findc, backwards, switchit) | |
11521 int *initc; | |
11522 int *findc; | |
11523 int *backwards; | |
11524 int switchit; | |
11525 { | |
11526 char_u *ptr; | |
11527 | |
11528 ptr = curbuf->b_p_mps; | |
11529 while (*ptr != NUL) | |
11530 { | |
11531 #ifdef FEAT_MBYTE | |
11532 if (has_mbyte) | |
11533 { | |
11534 char_u *prev; | |
11535 | |
11536 if (mb_ptr2char(ptr) == *initc) | |
11537 { | |
11538 if (switchit) | |
11539 { | |
11540 *findc = *initc; | |
11541 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); | |
11542 *backwards = TRUE; | |
11543 } | |
11544 else | |
11545 { | |
11546 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); | |
11547 *backwards = FALSE; | |
11548 } | |
11549 return; | |
11550 } | |
11551 prev = ptr; | |
11552 ptr += mb_ptr2len(ptr) + 1; | |
11553 if (mb_ptr2char(ptr) == *initc) | |
11554 { | |
11555 if (switchit) | |
11556 { | |
11557 *findc = *initc; | |
11558 *initc = mb_ptr2char(prev); | |
11559 *backwards = FALSE; | |
11560 } | |
11561 else | |
11562 { | |
11563 *findc = mb_ptr2char(prev); | |
11564 *backwards = TRUE; | |
11565 } | |
11566 return; | |
11567 } | |
11568 ptr += mb_ptr2len(ptr); | |
11569 } | |
11570 else | |
11571 #endif | |
11572 { | |
11573 if (*ptr == *initc) | |
11574 { | |
11575 if (switchit) | |
11576 { | |
11577 *backwards = TRUE; | |
11578 *findc = *initc; | |
11579 *initc = ptr[2]; | |
11580 } | |
11581 else | |
11582 { | |
11583 *backwards = FALSE; | |
11584 *findc = ptr[2]; | |
11585 } | |
11586 return; | |
11587 } | |
11588 ptr += 2; | |
11589 if (*ptr == *initc) | |
11590 { | |
11591 if (switchit) | |
11592 { | |
11593 *backwards = FALSE; | |
11594 *findc = *initc; | |
11595 *initc = ptr[-2]; | |
11596 } | |
11597 else | |
11598 { | |
11599 *backwards = TRUE; | |
11600 *findc = ptr[-2]; | |
11601 } | |
11602 return; | |
11603 } | |
11604 ++ptr; | |
11605 } | |
11606 if (*ptr == ',') | |
11607 ++ptr; | |
11608 } | |
11609 } |