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.
|
|
41 * PV_BOTH is added: global option which also has a local value.
|
|
42 */
|
|
43 #define PV_BOTH 0x1000
|
|
44 #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
|
|
45
|
|
46 typedef enum
|
|
47 {
|
|
48 PV_NONE = 0
|
|
49 , PV_AI
|
|
50 , PV_AR
|
|
51 , PV_ARAB
|
|
52 , PV_BH
|
|
53 , PV_BIN
|
|
54 , PV_BL
|
|
55 , PV_BOMB
|
|
56 , PV_BT
|
|
57 , PV_CI
|
|
58 , PV_CIN
|
|
59 , PV_CINK
|
|
60 , PV_CINO
|
|
61 , PV_CINW
|
|
62 , PV_CMS
|
|
63 , PV_COM
|
|
64 , PV_CPT
|
12
|
65 , PV_CFU
|
7
|
66 , PV_DEF
|
|
67 , PV_DICT
|
|
68 , PV_DIFF
|
|
69 , PV_EFM
|
|
70 , PV_EOL
|
|
71 , PV_EP
|
|
72 , PV_ET
|
|
73 , PV_FDC
|
|
74 , PV_FDE
|
|
75 , PV_FDI
|
|
76 , PV_FDL
|
|
77 , PV_FDM
|
|
78 , PV_FDN
|
|
79 , PV_FDT
|
|
80 , PV_FEN
|
|
81 , PV_FENC
|
|
82 , PV_FF
|
|
83 , PV_FML
|
|
84 , PV_FMR
|
41
|
85 , PV_FLP
|
7
|
86 , PV_FO
|
|
87 , PV_FT
|
|
88 , PV_GP
|
|
89 , PV_IMI
|
|
90 , PV_IMS
|
|
91 , PV_INC
|
|
92 , PV_INDE
|
|
93 , PV_INDK
|
|
94 , PV_INEX
|
|
95 , PV_INF
|
|
96 , PV_ISK
|
|
97 , PV_KEY
|
|
98 , PV_KMAP
|
|
99 , PV_KP
|
|
100 , PV_LBR
|
|
101 , PV_LISP
|
|
102 , PV_LIST
|
|
103 , PV_MA
|
|
104 , PV_ML
|
|
105 , PV_MOD
|
|
106 , PV_MP
|
|
107 , PV_MPS
|
|
108 , PV_NF
|
|
109 , PV_NU
|
13
|
110 , PV_NUW
|
7
|
111 , PV_OFT
|
|
112 , PV_PATH
|
|
113 , PV_PI
|
|
114 , PV_PVW
|
12
|
115 , PV_QE
|
7
|
116 , PV_RL
|
|
117 , PV_RLC
|
|
118 , PV_RO
|
|
119 , PV_SCBIND
|
|
120 , PV_SCROLL
|
|
121 , PV_SI
|
221
|
122 , PV_SN
|
|
123 , PV_SPELL
|
386
|
124 , PV_SPC
|
314
|
125 , PV_SPF
|
221
|
126 , PV_SPL
|
40
|
127 , PV_STL
|
7
|
128 , PV_STS
|
|
129 , PV_SUA
|
|
130 , PV_SW
|
|
131 , PV_SWF
|
410
|
132 , PV_SMC
|
7
|
133 , PV_SYN
|
|
134 , PV_TAGS
|
|
135 , PV_TS
|
|
136 , PV_TSR
|
|
137 , PV_TW
|
|
138 , PV_TX
|
|
139 , PV_WFH
|
|
140 , PV_WM
|
|
141 , PV_WRAP
|
|
142 } idopt_T;
|
|
143
|
|
144 /*
|
|
145 * Options local to a window have a value local to a buffer and global to all
|
|
146 * buffers. Indicate this by setting "var" to VAR_WIN.
|
|
147 */
|
|
148 #define VAR_WIN ((char_u *)-1)
|
|
149
|
|
150 /*
|
|
151 * These the global values for options which are also local to a buffer.
|
|
152 * Only to be used in option.c!
|
|
153 */
|
|
154 static int p_ai;
|
|
155 static int p_bin;
|
|
156 #ifdef FEAT_MBYTE
|
|
157 static int p_bomb;
|
|
158 #endif
|
|
159 #if defined(FEAT_QUICKFIX)
|
|
160 static char_u *p_bh;
|
|
161 static char_u *p_bt;
|
|
162 #endif
|
|
163 static int p_bl;
|
|
164 static int p_ci;
|
|
165 #ifdef FEAT_CINDENT
|
|
166 static int p_cin;
|
|
167 static char_u *p_cink;
|
|
168 static char_u *p_cino;
|
|
169 #endif
|
|
170 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
171 static char_u *p_cinw;
|
|
172 #endif
|
|
173 #ifdef FEAT_COMMENTS
|
|
174 static char_u *p_com;
|
|
175 #endif
|
|
176 #ifdef FEAT_FOLDING
|
|
177 static char_u *p_cms;
|
|
178 #endif
|
|
179 #ifdef FEAT_INS_EXPAND
|
|
180 static char_u *p_cpt;
|
|
181 #endif
|
12
|
182 #ifdef FEAT_COMPL_FUNC
|
|
183 static char_u *p_cfu;
|
|
184 #endif
|
7
|
185 static int p_eol;
|
|
186 static int p_et;
|
|
187 #ifdef FEAT_MBYTE
|
|
188 static char_u *p_fenc;
|
|
189 #endif
|
|
190 static char_u *p_ff;
|
|
191 static char_u *p_fo;
|
41
|
192 static char_u *p_flp;
|
7
|
193 #ifdef FEAT_AUTOCMD
|
|
194 static char_u *p_ft;
|
|
195 #endif
|
|
196 static long p_iminsert;
|
|
197 static long p_imsearch;
|
|
198 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
|
|
199 static char_u *p_inex;
|
|
200 #endif
|
|
201 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
202 static char_u *p_inde;
|
|
203 static char_u *p_indk;
|
|
204 #endif
|
|
205 static int p_inf;
|
|
206 static char_u *p_isk;
|
|
207 #ifdef FEAT_CRYPT
|
|
208 static char_u *p_key;
|
|
209 #endif
|
|
210 #ifdef FEAT_LISP
|
|
211 static int p_lisp;
|
|
212 #endif
|
|
213 static int p_ml;
|
|
214 static int p_ma;
|
|
215 static int p_mod;
|
|
216 static char_u *p_mps;
|
|
217 static char_u *p_nf;
|
|
218 #ifdef FEAT_OSFILETYPE
|
|
219 static char_u *p_oft;
|
|
220 #endif
|
|
221 static int p_pi;
|
12
|
222 #ifdef FEAT_TEXTOBJ
|
|
223 static char_u *p_qe;
|
|
224 #endif
|
7
|
225 static int p_ro;
|
|
226 #ifdef FEAT_SMARTINDENT
|
|
227 static int p_si;
|
|
228 #endif
|
|
229 #ifndef SHORT_FNAME
|
|
230 static int p_sn;
|
|
231 #endif
|
|
232 static long p_sts;
|
|
233 #if defined(FEAT_SEARCHPATH)
|
|
234 static char_u *p_sua;
|
|
235 #endif
|
|
236 static long p_sw;
|
|
237 static int p_swf;
|
|
238 #ifdef FEAT_SYN_HL
|
410
|
239 static long p_smc;
|
7
|
240 static char_u *p_syn;
|
386
|
241 static char_u *p_spc;
|
314
|
242 static char_u *p_spf;
|
221
|
243 static char_u *p_spl;
|
7
|
244 #endif
|
|
245 static long p_ts;
|
|
246 static long p_tw;
|
|
247 static int p_tx;
|
|
248 static long p_wm;
|
|
249 #ifdef FEAT_KEYMAP
|
|
250 static char_u *p_keymap;
|
|
251 #endif
|
|
252
|
|
253 /* Saved values for when 'bin' is set. */
|
|
254 static int p_et_nobin;
|
|
255 static int p_ml_nobin;
|
|
256 static long p_tw_nobin;
|
|
257 static long p_wm_nobin;
|
|
258
|
|
259 /* Saved values for when 'paste' is set */
|
|
260 static long p_tw_nopaste;
|
|
261 static long p_wm_nopaste;
|
|
262 static long p_sts_nopaste;
|
|
263 static int p_ai_nopaste;
|
|
264
|
|
265 struct vimoption
|
|
266 {
|
|
267 char *fullname; /* full option name */
|
|
268 char *shortname; /* permissible abbreviation */
|
|
269 long_u flags; /* see below */
|
|
270 char_u *var; /* global option: pointer to variable;
|
|
271 * window-local option: VAR_WIN;
|
|
272 * buffer-local option: global value */
|
|
273 idopt_T indir; /* global option: PV_NONE;
|
|
274 * local option: indirect option index */
|
|
275 char_u *def_val[2]; /* default values for variable (vi and vim) */
|
|
276 #ifdef FEAT_EVAL
|
|
277 scid_T scriptID; /* script in which the option was last set */
|
|
278 #endif
|
|
279 };
|
|
280
|
|
281 #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
|
|
282 #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
|
|
283
|
|
284 /*
|
|
285 * Flags
|
|
286 */
|
|
287 #define P_BOOL 0x01 /* the option is boolean */
|
|
288 #define P_NUM 0x02 /* the option is numeric */
|
|
289 #define P_STRING 0x04 /* the option is a string */
|
|
290 #define P_ALLOCED 0x08 /* the string option is in allocated memory,
|
|
291 must use vim_free() when assigning new
|
|
292 value. Not set if default is the same. */
|
|
293 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
|
|
294 never be used for local or hidden options! */
|
|
295 #define P_NODEFAULT 0x40 /* don't set to default value */
|
|
296 #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
|
|
297 use vim_free() when assigning new value */
|
|
298 #define P_WAS_SET 0x100 /* option has been set/reset */
|
|
299 #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
|
|
300 #define P_VI_DEF 0x400 /* Use Vi default for Vim */
|
|
301 #define P_VIM 0x800 /* Vim option, reset when 'cp' set */
|
|
302
|
|
303 /* when option changed, what to display: */
|
|
304 #define P_RSTAT 0x1000 /* redraw status lines */
|
|
305 #define P_RWIN 0x2000 /* redraw current window */
|
|
306 #define P_RBUF 0x4000 /* redraw current buffer */
|
|
307 #define P_RALL 0x6000 /* redraw all windows */
|
|
308 #define P_RCLR 0x7000 /* clear and redraw all */
|
|
309
|
|
310 #define P_COMMA 0x8000 /* comma separated list */
|
|
311 #define P_NODUP 0x10000L/* don't allow duplicate strings */
|
|
312 #define P_FLAGLIST 0x20000L/* list of single-char flags */
|
|
313
|
|
314 #define P_SECURE 0x40000L/* cannot change in modeline or secure mode */
|
|
315 #define P_GETTEXT 0x80000L/* expand default value with _() */
|
|
316 #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */
|
36
|
317 #define P_NFNAME 0x200000L/* only normal file name chars allowed */
|
7
|
318
|
|
319 /*
|
|
320 * options[] is initialized here.
|
|
321 * The order of the options MUST be alphabetic for ":set all" and findoption().
|
|
322 * All option names MUST start with a lowercase letter (for findoption()).
|
|
323 * Exception: "t_" options are at the end.
|
|
324 * The options with a NULL variable are 'hidden': a set command for them is
|
|
325 * ignored and they are not printed.
|
|
326 */
|
|
327 static struct vimoption
|
|
328 #ifdef FEAT_GUI_W16
|
|
329 _far
|
|
330 #endif
|
|
331 options[] =
|
|
332 {
|
|
333 {"aleph", "al", P_NUM|P_VI_DEF,
|
|
334 #ifdef FEAT_RIGHTLEFT
|
|
335 (char_u *)&p_aleph, PV_NONE,
|
|
336 #else
|
|
337 (char_u *)NULL, PV_NONE,
|
|
338 #endif
|
|
339 {
|
|
340 #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
|
|
341 (char_u *)128L,
|
|
342 #else
|
|
343 (char_u *)224L,
|
|
344 #endif
|
|
345 (char_u *)0L}},
|
|
346 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
|
|
347 #if defined(FEAT_GUI) && defined(MACOS_X)
|
|
348 (char_u *)&p_antialias, PV_NONE,
|
|
349 {(char_u *)FALSE, (char_u *)FALSE}
|
|
350 #else
|
|
351 (char_u *)NULL, PV_NONE,
|
|
352 {(char_u *)FALSE, (char_u *)FALSE}
|
|
353 #endif
|
|
354 },
|
|
355 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
|
|
356 #ifdef FEAT_ARABIC
|
|
357 (char_u *)VAR_WIN, PV_ARAB,
|
|
358 #else
|
|
359 (char_u *)NULL, PV_NONE,
|
|
360 #endif
|
|
361 {(char_u *)FALSE, (char_u *)0L}},
|
|
362 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
|
|
363 #ifdef FEAT_ARABIC
|
|
364 (char_u *)&p_arshape, PV_NONE,
|
|
365 #else
|
|
366 (char_u *)NULL, PV_NONE,
|
|
367 #endif
|
|
368 {(char_u *)TRUE, (char_u *)0L}},
|
|
369 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
|
|
370 #ifdef FEAT_RIGHTLEFT
|
|
371 (char_u *)&p_ari, PV_NONE,
|
|
372 #else
|
|
373 (char_u *)NULL, PV_NONE,
|
|
374 #endif
|
|
375 {(char_u *)FALSE, (char_u *)0L}},
|
|
376 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
|
|
377 #ifdef FEAT_FKMAP
|
|
378 (char_u *)&p_altkeymap, PV_NONE,
|
|
379 #else
|
|
380 (char_u *)NULL, PV_NONE,
|
|
381 #endif
|
|
382 {(char_u *)FALSE, (char_u *)0L}},
|
|
383 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
|
|
384 #if defined(FEAT_MBYTE)
|
|
385 (char_u *)&p_ambw, PV_NONE,
|
|
386 {(char_u *)"single", (char_u *)0L}
|
|
387 #else
|
|
388 (char_u *)NULL, PV_NONE,
|
|
389 {(char_u *)0L, (char_u *)0L}
|
|
390 #endif
|
|
391 },
|
|
392 #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
|
|
393 {"autochdir", "acd", P_BOOL|P_VI_DEF,
|
|
394 (char_u *)&p_acd, PV_NONE,
|
|
395 {(char_u *)FALSE, (char_u *)0L}},
|
|
396 #endif
|
|
397 {"autoindent", "ai", P_BOOL|P_VI_DEF,
|
|
398 (char_u *)&p_ai, PV_AI,
|
|
399 {(char_u *)FALSE, (char_u *)0L}},
|
|
400 {"autoprint", "ap", P_BOOL|P_VI_DEF,
|
|
401 (char_u *)NULL, PV_NONE,
|
|
402 {(char_u *)FALSE, (char_u *)0L}},
|
|
403 {"autoread", "ar", P_BOOL|P_VI_DEF,
|
|
404 (char_u *)&p_ar, OPT_BOTH(PV_AR),
|
|
405 {(char_u *)FALSE, (char_u *)0L}},
|
|
406 {"autowrite", "aw", P_BOOL|P_VI_DEF,
|
|
407 (char_u *)&p_aw, PV_NONE,
|
|
408 {(char_u *)FALSE, (char_u *)0L}},
|
|
409 {"autowriteall","awa", P_BOOL|P_VI_DEF,
|
|
410 (char_u *)&p_awa, PV_NONE,
|
|
411 {(char_u *)FALSE, (char_u *)0L}},
|
|
412 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
|
|
413 (char_u *)&p_bg, PV_NONE,
|
|
414 {
|
|
415 #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
|
|
416 (char_u *)"dark",
|
|
417 #else
|
|
418 (char_u *)"light",
|
|
419 #endif
|
|
420 (char_u *)0L}},
|
|
421 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
|
|
422 (char_u *)&p_bs, PV_NONE,
|
|
423 {(char_u *)"", (char_u *)0L}},
|
|
424 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
|
|
425 (char_u *)&p_bk, PV_NONE,
|
|
426 {(char_u *)FALSE, (char_u *)0L}},
|
|
427 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
|
|
428 (char_u *)&p_bkc, PV_NONE,
|
|
429 #ifdef UNIX
|
|
430 {(char_u *)"yes", (char_u *)"auto"}
|
|
431 #else
|
|
432 {(char_u *)"auto", (char_u *)"auto"}
|
|
433 #endif
|
|
434 },
|
|
435 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
|
|
436 (char_u *)&p_bdir, PV_NONE,
|
|
437 {(char_u *)DFLT_BDIR, (char_u *)0L}},
|
36
|
438 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
|
7
|
439 (char_u *)&p_bex, PV_NONE,
|
|
440 {
|
|
441 #ifdef VMS
|
|
442 (char_u *)"_",
|
|
443 #else
|
|
444 (char_u *)"~",
|
|
445 #endif
|
|
446 (char_u *)0L}},
|
|
447 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
|
|
448 #ifdef FEAT_WILDIGN
|
|
449 (char_u *)&p_bsk, PV_NONE,
|
|
450 {(char_u *)"", (char_u *)0L}
|
|
451 #else
|
|
452 (char_u *)NULL, PV_NONE,
|
|
453 {(char_u *)0L, (char_u *)0L}
|
|
454 #endif
|
|
455 },
|
|
456 #ifdef FEAT_BEVAL
|
|
457 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
|
|
458 (char_u *)&p_bdlay, PV_NONE,
|
|
459 {(char_u *)600L, (char_u *)0L}},
|
|
460 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
|
|
461 (char_u *)&p_beval, PV_NONE,
|
190
|
462 {(char_u *)FALSE, (char_u *)0L}},
|
|
463 # ifdef FEAT_EVAL
|
|
464 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
|
|
465 (char_u *)&p_bexpr, PV_NONE,
|
|
466 {(char_u *)"", (char_u *)0L}},
|
|
467 # endif
|
7
|
468 #endif
|
|
469 {"beautify", "bf", P_BOOL|P_VI_DEF,
|
|
470 (char_u *)NULL, PV_NONE,
|
|
471 {(char_u *)FALSE, (char_u *)0L}},
|
|
472 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
|
|
473 (char_u *)&p_bin, PV_BIN,
|
|
474 {(char_u *)FALSE, (char_u *)0L}},
|
|
475 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
|
|
476 #ifdef MSDOS
|
|
477 (char_u *)&p_biosk, PV_NONE,
|
|
478 #else
|
|
479 (char_u *)NULL, PV_NONE,
|
|
480 #endif
|
|
481 {(char_u *)TRUE, (char_u *)0L}},
|
|
482 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
|
|
483 #ifdef FEAT_MBYTE
|
|
484 (char_u *)&p_bomb, PV_BOMB,
|
|
485 #else
|
|
486 (char_u *)NULL, PV_NONE,
|
|
487 #endif
|
|
488 {(char_u *)FALSE, (char_u *)0L}},
|
|
489 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
|
|
490 #ifdef FEAT_LINEBREAK
|
|
491 (char_u *)&p_breakat, PV_NONE,
|
|
492 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
|
|
493 #else
|
|
494 (char_u *)NULL, PV_NONE,
|
|
495 {(char_u *)0L, (char_u *)0L}
|
|
496 #endif
|
|
497 },
|
|
498 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
|
|
499 #ifdef FEAT_BROWSE
|
|
500 (char_u *)&p_bsdir, PV_NONE,
|
|
501 {(char_u *)"last", (char_u *)0L}
|
|
502 #else
|
|
503 (char_u *)NULL, PV_NONE,
|
|
504 {(char_u *)0L, (char_u *)0L}
|
|
505 #endif
|
|
506 },
|
|
507 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
|
|
508 #if defined(FEAT_QUICKFIX)
|
|
509 (char_u *)&p_bh, PV_BH,
|
|
510 {(char_u *)"", (char_u *)0L}
|
|
511 #else
|
|
512 (char_u *)NULL, PV_NONE,
|
|
513 {(char_u *)0L, (char_u *)0L}
|
|
514 #endif
|
|
515 },
|
|
516 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
|
|
517 (char_u *)&p_bl, PV_BL,
|
|
518 {(char_u *)1L, (char_u *)0L}
|
|
519 },
|
|
520 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
|
|
521 #if defined(FEAT_QUICKFIX)
|
|
522 (char_u *)&p_bt, PV_BT,
|
|
523 {(char_u *)"", (char_u *)0L}
|
|
524 #else
|
|
525 (char_u *)NULL, PV_NONE,
|
|
526 {(char_u *)0L, (char_u *)0L}
|
|
527 #endif
|
|
528 },
|
|
529 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
530 (char_u *)&p_cmp, PV_NONE,
|
|
531 {(char_u *)"internal,keepascii", (char_u *)0L}
|
|
532 },
|
|
533 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
|
|
534 #ifdef FEAT_SEARCHPATH
|
|
535 (char_u *)&p_cdpath, PV_NONE,
|
|
536 {(char_u *)",,", (char_u *)0L}
|
|
537 #else
|
|
538 (char_u *)NULL, PV_NONE,
|
|
539 {(char_u *)0L, (char_u *)0L}
|
|
540 #endif
|
|
541 },
|
|
542 {"cedit", NULL, P_STRING,
|
|
543 #ifdef FEAT_CMDWIN
|
|
544 (char_u *)&p_cedit, PV_NONE,
|
|
545 {(char_u *)"", (char_u *)CTRL_F_STR}
|
|
546 #else
|
|
547 (char_u *)NULL, PV_NONE,
|
|
548 {(char_u *)0L, (char_u *)0L}
|
|
549 #endif
|
|
550 },
|
|
551 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
|
|
552 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
|
553 (char_u *)&p_ccv, PV_NONE,
|
|
554 {(char_u *)"", (char_u *)0L}
|
|
555 #else
|
|
556 (char_u *)NULL, PV_NONE,
|
|
557 {(char_u *)0L, (char_u *)0L}
|
|
558 #endif
|
|
559 },
|
|
560 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
|
|
561 #ifdef FEAT_CINDENT
|
|
562 (char_u *)&p_cin, PV_CIN,
|
|
563 #else
|
|
564 (char_u *)NULL, PV_NONE,
|
|
565 #endif
|
|
566 {(char_u *)FALSE, (char_u *)0L}},
|
|
567 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
568 #ifdef FEAT_CINDENT
|
|
569 (char_u *)&p_cink, PV_CINK,
|
|
570 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
|
|
571 #else
|
|
572 (char_u *)NULL, PV_NONE,
|
|
573 {(char_u *)0L, (char_u *)0L}
|
|
574 #endif
|
|
575 },
|
|
576 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
577 #ifdef FEAT_CINDENT
|
|
578 (char_u *)&p_cino, PV_CINO,
|
|
579 #else
|
|
580 (char_u *)NULL, PV_NONE,
|
|
581 #endif
|
|
582 {(char_u *)"", (char_u *)0L}},
|
|
583 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
584 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
585 (char_u *)&p_cinw, PV_CINW,
|
|
586 {(char_u *)"if,else,while,do,for,switch",
|
|
587 (char_u *)0L}
|
|
588 #else
|
|
589 (char_u *)NULL, PV_NONE,
|
|
590 {(char_u *)0L, (char_u *)0L}
|
|
591 #endif
|
|
592 },
|
|
593 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
594 #ifdef FEAT_CLIPBOARD
|
|
595 (char_u *)&p_cb, PV_NONE,
|
|
596 # ifdef FEAT_XCLIPBOARD
|
|
597 {(char_u *)"autoselect,exclude:cons\\|linux",
|
|
598 (char_u *)0L}
|
|
599 # else
|
|
600 {(char_u *)"", (char_u *)0L}
|
|
601 # endif
|
|
602 #else
|
|
603 (char_u *)NULL, PV_NONE,
|
|
604 {(char_u *)"", (char_u *)0L}
|
|
605 #endif
|
|
606 },
|
|
607 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
|
|
608 (char_u *)&p_ch, PV_NONE,
|
|
609 {(char_u *)1L, (char_u *)0L}},
|
|
610 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
|
|
611 #ifdef FEAT_CMDWIN
|
|
612 (char_u *)&p_cwh, PV_NONE,
|
|
613 #else
|
|
614 (char_u *)NULL, PV_NONE,
|
|
615 #endif
|
|
616 {(char_u *)7L, (char_u *)0L}},
|
|
617 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
|
|
618 (char_u *)&Columns, PV_NONE,
|
|
619 {(char_u *)80L, (char_u *)0L}},
|
|
620 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
621 #ifdef FEAT_COMMENTS
|
|
622 (char_u *)&p_com, PV_COM,
|
|
623 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
|
|
624 (char_u *)0L}
|
|
625 #else
|
|
626 (char_u *)NULL, PV_NONE,
|
|
627 {(char_u *)0L, (char_u *)0L}
|
|
628 #endif
|
|
629 },
|
|
630 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
631 #ifdef FEAT_FOLDING
|
|
632 (char_u *)&p_cms, PV_CMS,
|
|
633 {(char_u *)"/*%s*/", (char_u *)0L}
|
|
634 #else
|
|
635 (char_u *)NULL, PV_NONE,
|
|
636 {(char_u *)0L, (char_u *)0L}
|
|
637 #endif
|
|
638 },
|
|
639 {"compatible", "cp", P_BOOL|P_RALL,
|
|
640 (char_u *)&p_cp, PV_NONE,
|
|
641 {(char_u *)TRUE, (char_u *)FALSE}},
|
|
642 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
643 #ifdef FEAT_INS_EXPAND
|
|
644 (char_u *)&p_cpt, PV_CPT,
|
|
645 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
|
|
646 #else
|
|
647 (char_u *)NULL, PV_NONE,
|
|
648 {(char_u *)0L, (char_u *)0L}
|
|
649 #endif
|
|
650 },
|
12
|
651 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
|
|
652 #ifdef FEAT_COMPL_FUNC
|
|
653 (char_u *)&p_cfu, PV_CFU,
|
|
654 {(char_u *)"", (char_u *)0L}
|
|
655 #else
|
|
656 (char_u *)NULL, PV_NONE,
|
|
657 {(char_u *)0L, (char_u *)0L}
|
|
658 #endif
|
|
659 },
|
7
|
660 {"confirm", "cf", P_BOOL|P_VI_DEF,
|
|
661 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
|
|
662 (char_u *)&p_confirm, PV_NONE,
|
|
663 #else
|
|
664 (char_u *)NULL, PV_NONE,
|
|
665 #endif
|
|
666 {(char_u *)FALSE, (char_u *)0L}},
|
|
667 {"conskey", "consk",P_BOOL|P_VI_DEF,
|
|
668 #ifdef MSDOS
|
|
669 (char_u *)&p_consk, PV_NONE,
|
|
670 #else
|
|
671 (char_u *)NULL, PV_NONE,
|
|
672 #endif
|
|
673 {(char_u *)FALSE, (char_u *)0L}},
|
|
674 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
|
|
675 (char_u *)&p_ci, PV_CI,
|
|
676 {(char_u *)FALSE, (char_u *)0L}},
|
|
677 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
|
|
678 (char_u *)&p_cpo, PV_NONE,
|
164
|
679 {(char_u *)CPO_VI, (char_u *)CPO_VIM}},
|
7
|
680 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
|
|
681 #ifdef FEAT_CSCOPE
|
|
682 (char_u *)&p_cspc, PV_NONE,
|
|
683 #else
|
|
684 (char_u *)NULL, PV_NONE,
|
|
685 #endif
|
|
686 {(char_u *)0L, (char_u *)0L}},
|
|
687 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
688 #ifdef FEAT_CSCOPE
|
|
689 (char_u *)&p_csprg, PV_NONE,
|
|
690 {(char_u *)"cscope", (char_u *)0L}
|
|
691 #else
|
|
692 (char_u *)NULL, PV_NONE,
|
|
693 {(char_u *)0L, (char_u *)0L}
|
|
694 #endif
|
|
695 },
|
|
696 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
697 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
|
|
698 (char_u *)&p_csqf, PV_NONE,
|
|
699 {(char_u *)"", (char_u *)0L}
|
|
700 #else
|
|
701 (char_u *)NULL, PV_NONE,
|
|
702 {(char_u *)0L, (char_u *)0L}
|
|
703 #endif
|
|
704 },
|
|
705 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
|
|
706 #ifdef FEAT_CSCOPE
|
|
707 (char_u *)&p_cst, PV_NONE,
|
|
708 #else
|
|
709 (char_u *)NULL, PV_NONE,
|
|
710 #endif
|
|
711 {(char_u *)0L, (char_u *)0L}},
|
|
712 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
|
|
713 #ifdef FEAT_CSCOPE
|
|
714 (char_u *)&p_csto, PV_NONE,
|
|
715 #else
|
|
716 (char_u *)NULL, PV_NONE,
|
|
717 #endif
|
|
718 {(char_u *)0L, (char_u *)0L}},
|
|
719 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
|
|
720 #ifdef FEAT_CSCOPE
|
|
721 (char_u *)&p_csverbose, PV_NONE,
|
|
722 #else
|
|
723 (char_u *)NULL, PV_NONE,
|
|
724 #endif
|
|
725 {(char_u *)0L, (char_u *)0L}},
|
|
726 {"debug", NULL, P_STRING|P_VI_DEF,
|
|
727 (char_u *)&p_debug, PV_NONE,
|
|
728 {(char_u *)"", (char_u *)0L}},
|
|
729 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
730 #ifdef FEAT_FIND_ID
|
|
731 (char_u *)&p_def, OPT_BOTH(PV_DEF),
|
22
|
732 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
|
7
|
733 #else
|
|
734 (char_u *)NULL, PV_NONE,
|
|
735 {(char_u *)NULL, (char_u *)0L}
|
|
736 #endif
|
|
737 },
|
|
738 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
|
|
739 #ifdef FEAT_MBYTE
|
|
740 (char_u *)&p_deco, PV_NONE,
|
|
741 #else
|
|
742 (char_u *)NULL, PV_NONE,
|
|
743 #endif
|
|
744 {(char_u *)FALSE, (char_u *)0L}
|
|
745 },
|
|
746 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
|
|
747 #ifdef FEAT_INS_EXPAND
|
|
748 (char_u *)&p_dict, OPT_BOTH(PV_DICT),
|
|
749 #else
|
|
750 (char_u *)NULL, PV_NONE,
|
|
751 #endif
|
|
752 {(char_u *)"", (char_u *)0L}},
|
|
753 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
|
|
754 #ifdef FEAT_DIFF
|
|
755 (char_u *)VAR_WIN, PV_DIFF,
|
|
756 #else
|
|
757 (char_u *)NULL, PV_NONE,
|
|
758 #endif
|
|
759 {(char_u *)FALSE, (char_u *)0L}},
|
|
760 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE,
|
|
761 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
|
|
762 (char_u *)&p_dex, PV_NONE,
|
|
763 {(char_u *)"", (char_u *)0L}
|
|
764 #else
|
|
765 (char_u *)NULL, PV_NONE,
|
|
766 {(char_u *)0L, (char_u *)0L}
|
|
767 #endif
|
|
768 },
|
|
769 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
|
|
770 #ifdef FEAT_DIFF
|
|
771 (char_u *)&p_dip, PV_NONE,
|
|
772 {(char_u *)"filler", (char_u *)NULL}
|
|
773 #else
|
|
774 (char_u *)NULL, PV_NONE,
|
|
775 {(char_u *)"", (char_u *)NULL}
|
|
776 #endif
|
|
777 },
|
|
778 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
|
|
779 #ifdef FEAT_DIGRAPHS
|
|
780 (char_u *)&p_dg, PV_NONE,
|
|
781 #else
|
|
782 (char_u *)NULL, PV_NONE,
|
|
783 #endif
|
|
784 {(char_u *)FALSE, (char_u *)0L}},
|
|
785 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
|
|
786 (char_u *)&p_dir, PV_NONE,
|
|
787 {(char_u *)DFLT_DIR, (char_u *)0L}},
|
|
788 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
|
|
789 (char_u *)&p_dy, PV_NONE,
|
|
790 {(char_u *)"", (char_u *)0L}},
|
|
791 {"eadirection", "ead", P_STRING|P_VI_DEF,
|
|
792 #ifdef FEAT_VERTSPLIT
|
|
793 (char_u *)&p_ead, PV_NONE,
|
|
794 {(char_u *)"both", (char_u *)0L}
|
|
795 #else
|
|
796 (char_u *)NULL, PV_NONE,
|
|
797 {(char_u *)NULL, (char_u *)0L}
|
|
798 #endif
|
|
799 },
|
|
800 {"edcompatible","ed", P_BOOL|P_VI_DEF,
|
|
801 (char_u *)&p_ed, PV_NONE,
|
|
802 {(char_u *)FALSE, (char_u *)0L}},
|
|
803 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR,
|
|
804 #ifdef FEAT_MBYTE
|
|
805 (char_u *)&p_enc, PV_NONE,
|
|
806 {(char_u *)ENC_DFLT, (char_u *)0L}
|
|
807 #else
|
|
808 (char_u *)NULL, PV_NONE,
|
|
809 {(char_u *)0L, (char_u *)0L}
|
|
810 #endif
|
|
811 },
|
|
812 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
|
|
813 (char_u *)&p_eol, PV_EOL,
|
|
814 {(char_u *)TRUE, (char_u *)0L}},
|
|
815 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
|
|
816 (char_u *)&p_ea, PV_NONE,
|
|
817 {(char_u *)TRUE, (char_u *)0L}},
|
|
818 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
819 (char_u *)&p_ep, OPT_BOTH(PV_EP),
|
|
820 {(char_u *)"", (char_u *)0L}},
|
|
821 {"errorbells", "eb", P_BOOL|P_VI_DEF,
|
|
822 (char_u *)&p_eb, PV_NONE,
|
|
823 {(char_u *)FALSE, (char_u *)0L}},
|
|
824 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
825 #ifdef FEAT_QUICKFIX
|
|
826 (char_u *)&p_ef, PV_NONE,
|
|
827 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
|
|
828 #else
|
|
829 (char_u *)NULL, PV_NONE,
|
|
830 {(char_u *)NULL, (char_u *)0L}
|
|
831 #endif
|
|
832 },
|
|
833 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
834 #ifdef FEAT_QUICKFIX
|
|
835 (char_u *)&p_efm, OPT_BOTH(PV_EFM),
|
|
836 {(char_u *)DFLT_EFM, (char_u *)0L},
|
|
837 #else
|
|
838 (char_u *)NULL, PV_NONE,
|
|
839 {(char_u *)NULL, (char_u *)0L}
|
|
840 #endif
|
|
841 },
|
|
842 {"esckeys", "ek", P_BOOL|P_VIM,
|
|
843 (char_u *)&p_ek, PV_NONE,
|
|
844 {(char_u *)FALSE, (char_u *)TRUE}},
|
|
845 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
846 #ifdef FEAT_AUTOCMD
|
|
847 (char_u *)&p_ei, PV_NONE,
|
|
848 #else
|
|
849 (char_u *)NULL, PV_NONE,
|
|
850 #endif
|
|
851 {(char_u *)"", (char_u *)0L}},
|
|
852 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
|
|
853 (char_u *)&p_et, PV_ET,
|
|
854 {(char_u *)FALSE, (char_u *)0L}},
|
|
855 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
|
|
856 (char_u *)&p_exrc, PV_NONE,
|
|
857 {(char_u *)FALSE, (char_u *)0L}},
|
|
858 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
|
|
859 #ifdef FEAT_MBYTE
|
|
860 (char_u *)&p_fenc, PV_FENC,
|
|
861 {(char_u *)"", (char_u *)0L}
|
|
862 #else
|
|
863 (char_u *)NULL, PV_NONE,
|
|
864 {(char_u *)0L, (char_u *)0L}
|
|
865 #endif
|
|
866 },
|
|
867 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
|
|
868 #ifdef FEAT_MBYTE
|
|
869 (char_u *)&p_fencs, PV_NONE,
|
|
870 {(char_u *)"ucs-bom", (char_u *)0L}
|
|
871 #else
|
|
872 (char_u *)NULL, PV_NONE,
|
|
873 {(char_u *)0L, (char_u *)0L}
|
|
874 #endif
|
|
875 },
|
|
876 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC,
|
|
877 (char_u *)&p_ff, PV_FF,
|
|
878 {(char_u *)DFLT_FF, (char_u *)0L}},
|
|
879 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
|
|
880 (char_u *)&p_ffs, PV_NONE,
|
|
881 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}},
|
36
|
882 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
|
7
|
883 #ifdef FEAT_AUTOCMD
|
|
884 (char_u *)&p_ft, PV_FT,
|
|
885 {(char_u *)"", (char_u *)0L}
|
|
886 #else
|
|
887 (char_u *)NULL, PV_NONE,
|
|
888 {(char_u *)0L, (char_u *)0L}
|
|
889 #endif
|
|
890 },
|
|
891 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
|
|
892 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
893 (char_u *)&p_fcs, PV_NONE,
|
|
894 {(char_u *)"vert:|,fold:-", (char_u *)0L}
|
|
895 #else
|
|
896 (char_u *)NULL, PV_NONE,
|
|
897 {(char_u *)"", (char_u *)0L}
|
|
898 #endif
|
|
899 },
|
|
900 {"fkmap", "fk", P_BOOL|P_VI_DEF,
|
|
901 #ifdef FEAT_FKMAP
|
|
902 (char_u *)&p_fkmap, PV_NONE,
|
|
903 #else
|
|
904 (char_u *)NULL, PV_NONE,
|
|
905 #endif
|
|
906 {(char_u *)FALSE, (char_u *)0L}},
|
|
907 {"flash", "fl", P_BOOL|P_VI_DEF,
|
|
908 (char_u *)NULL, PV_NONE,
|
|
909 {(char_u *)FALSE, (char_u *)0L}},
|
|
910 #ifdef FEAT_FOLDING
|
|
911 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
|
|
912 (char_u *)&p_fcl, PV_NONE,
|
|
913 {(char_u *)"", (char_u *)0L}},
|
|
914 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
|
|
915 (char_u *)VAR_WIN, PV_FDC,
|
|
916 {(char_u *)FALSE, (char_u *)0L}},
|
|
917 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
|
|
918 (char_u *)VAR_WIN, PV_FEN,
|
|
919 {(char_u *)TRUE, (char_u *)0L}},
|
|
920 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
|
|
921 # ifdef FEAT_EVAL
|
|
922 (char_u *)VAR_WIN, PV_FDE,
|
|
923 {(char_u *)"0", (char_u *)NULL}
|
|
924 # else
|
|
925 (char_u *)NULL, PV_NONE,
|
|
926 {(char_u *)NULL, (char_u *)0L}
|
|
927 # endif
|
|
928 },
|
|
929 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
|
|
930 (char_u *)VAR_WIN, PV_FDI,
|
|
931 {(char_u *)"#", (char_u *)NULL}},
|
|
932 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
|
|
933 (char_u *)VAR_WIN, PV_FDL,
|
|
934 {(char_u *)0L, (char_u *)0L}},
|
|
935 {"foldlevelstart","fdls", P_NUM|P_VI_DEF,
|
|
936 (char_u *)&p_fdls, PV_NONE,
|
|
937 {(char_u *)-1L, (char_u *)0L}},
|
|
938 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
|
|
939 P_RWIN|P_COMMA|P_NODUP,
|
|
940 (char_u *)VAR_WIN, PV_FMR,
|
|
941 {(char_u *)"{{{,}}}", (char_u *)NULL}},
|
|
942 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
|
|
943 (char_u *)VAR_WIN, PV_FDM,
|
|
944 {(char_u *)"manual", (char_u *)NULL}},
|
|
945 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
|
|
946 (char_u *)VAR_WIN, PV_FML,
|
|
947 {(char_u *)1L, (char_u *)0L}},
|
|
948 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
|
|
949 (char_u *)VAR_WIN, PV_FDN,
|
|
950 {(char_u *)20L, (char_u *)0L}},
|
|
951 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
952 (char_u *)&p_fdo, PV_NONE,
|
|
953 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
|
|
954 (char_u *)0L}},
|
|
955 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
|
|
956 # ifdef FEAT_EVAL
|
|
957 (char_u *)VAR_WIN, PV_FDT,
|
|
958 {(char_u *)"foldtext()", (char_u *)NULL}
|
29
|
959 # else
|
7
|
960 (char_u *)NULL, PV_NONE,
|
|
961 {(char_u *)NULL, (char_u *)0L}
|
29
|
962 # endif
|
7
|
963 },
|
|
964 #endif
|
|
965 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
|
|
966 (char_u *)&p_fo, PV_FO,
|
|
967 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}},
|
41
|
968 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
969 (char_u *)&p_flp, PV_FLP,
|
|
970 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", (char_u *)0L}},
|
7
|
971 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
972 (char_u *)&p_fp, PV_NONE,
|
|
973 {(char_u *)"", (char_u *)0L}},
|
36
|
974 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
|
|
975 #ifdef HAVE_FSYNC
|
|
976 (char_u *)&p_fs, PV_NONE,
|
|
977 {(char_u *)TRUE, (char_u *)0L}
|
|
978 #else
|
|
979 (char_u *)NULL, PV_NONE,
|
|
980 {(char_u *)FALSE, (char_u *)0L}
|
|
981 #endif
|
|
982 },
|
7
|
983 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
|
|
984 (char_u *)&p_gd, PV_NONE,
|
|
985 {(char_u *)FALSE, (char_u *)0L}},
|
|
986 {"graphic", "gr", P_BOOL|P_VI_DEF,
|
|
987 (char_u *)NULL, PV_NONE,
|
|
988 {(char_u *)FALSE, (char_u *)0L}},
|
|
989 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
990 #ifdef FEAT_QUICKFIX
|
|
991 (char_u *)&p_gefm, PV_NONE,
|
|
992 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L},
|
|
993 #else
|
|
994 (char_u *)NULL, PV_NONE,
|
|
995 {(char_u *)NULL, (char_u *)0L}
|
|
996 #endif
|
|
997 },
|
|
998 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
999 #ifdef FEAT_QUICKFIX
|
|
1000 (char_u *)&p_gp, OPT_BOTH(PV_GP),
|
|
1001 {
|
|
1002 # ifdef WIN3264
|
|
1003 /* may be changed to "grep -n" in os_win32.c */
|
|
1004 (char_u *)"findstr /n",
|
|
1005 # else
|
|
1006 # ifdef UNIX
|
|
1007 /* Add an extra file name so that grep will always
|
|
1008 * insert a file name in the match line. */
|
|
1009 (char_u *)"grep -n $* /dev/null",
|
|
1010 # else
|
|
1011 # ifdef VMS
|
|
1012 (char_u *)"SEARCH/NUMBERS ",
|
|
1013 # else
|
|
1014 (char_u *)"grep -n ",
|
|
1015 #endif
|
|
1016 #endif
|
|
1017 # endif
|
|
1018 (char_u *)0L},
|
|
1019 #else
|
|
1020 (char_u *)NULL, PV_NONE,
|
|
1021 {(char_u *)NULL, (char_u *)0L}
|
|
1022 #endif
|
|
1023 },
|
|
1024 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1025 #ifdef CURSOR_SHAPE
|
|
1026 (char_u *)&p_guicursor, PV_NONE,
|
|
1027 {
|
|
1028 # ifdef FEAT_GUI
|
|
1029 (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",
|
|
1030 # else /* MSDOS or Win32 console */
|
|
1031 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
|
|
1032 # endif
|
|
1033 (char_u *)0L}
|
|
1034 #else
|
|
1035 (char_u *)NULL, PV_NONE,
|
|
1036 {(char_u *)NULL, (char_u *)0L}
|
|
1037 #endif
|
|
1038 },
|
|
1039 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
|
|
1040 #ifdef FEAT_GUI
|
|
1041 (char_u *)&p_guifont, PV_NONE,
|
|
1042 {(char_u *)"", (char_u *)0L}
|
|
1043 #else
|
|
1044 (char_u *)NULL, PV_NONE,
|
|
1045 {(char_u *)NULL, (char_u *)0L}
|
|
1046 #endif
|
|
1047 },
|
|
1048 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
|
|
1049 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
|
|
1050 (char_u *)&p_guifontset, PV_NONE,
|
|
1051 {(char_u *)"", (char_u *)0L}
|
|
1052 #else
|
|
1053 (char_u *)NULL, PV_NONE,
|
|
1054 {(char_u *)NULL, (char_u *)0L}
|
|
1055 #endif
|
|
1056 },
|
|
1057 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
|
|
1058 #if defined(FEAT_GUI) && defined(FEAT_MBYTE)
|
|
1059 (char_u *)&p_guifontwide, PV_NONE,
|
|
1060 {(char_u *)"", (char_u *)0L}
|
|
1061 #else
|
|
1062 (char_u *)NULL, PV_NONE,
|
|
1063 {(char_u *)NULL, (char_u *)0L}
|
|
1064 #endif
|
|
1065 },
|
|
1066 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
|
11
|
1067 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE)
|
7
|
1068 (char_u *)&p_ghr, PV_NONE,
|
|
1069 #else
|
|
1070 (char_u *)NULL, PV_NONE,
|
|
1071 #endif
|
|
1072 {(char_u *)50L, (char_u *)0L}},
|
|
1073 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
|
11
|
1074 #if defined(FEAT_GUI) || defined(FEAT_GUI_KDE)
|
7
|
1075 (char_u *)&p_go, PV_NONE,
|
|
1076 # if defined(UNIX) && !defined(MACOS)
|
|
1077 {(char_u *)"agimrLtT", (char_u *)0L}
|
|
1078 # else
|
|
1079 {(char_u *)"gmrLtT", (char_u *)0L}
|
|
1080 # endif
|
|
1081 #else
|
|
1082 (char_u *)NULL, PV_NONE,
|
|
1083 {(char_u *)NULL, (char_u *)0L}
|
|
1084 #endif
|
|
1085 },
|
|
1086 {"guipty", NULL, P_BOOL|P_VI_DEF,
|
|
1087 #if defined(FEAT_GUI)
|
|
1088 (char_u *)&p_guipty, PV_NONE,
|
|
1089 #else
|
|
1090 (char_u *)NULL, PV_NONE,
|
|
1091 #endif
|
|
1092 {(char_u *)TRUE, (char_u *)0L}},
|
|
1093 {"hardtabs", "ht", P_NUM|P_VI_DEF,
|
|
1094 (char_u *)NULL, PV_NONE,
|
|
1095 {(char_u *)0L, (char_u *)0L}},
|
|
1096 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
1097 (char_u *)&p_hf, PV_NONE,
|
|
1098 {(char_u *)DFLT_HELPFILE, (char_u *)0L}},
|
|
1099 {"helpheight", "hh", P_NUM|P_VI_DEF,
|
|
1100 #ifdef FEAT_WINDOWS
|
|
1101 (char_u *)&p_hh, PV_NONE,
|
|
1102 #else
|
|
1103 (char_u *)NULL, PV_NONE,
|
|
1104 #endif
|
|
1105 {(char_u *)20L, (char_u *)0L}},
|
|
1106 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
|
|
1107 #ifdef FEAT_MULTI_LANG
|
|
1108 (char_u *)&p_hlg, PV_NONE,
|
|
1109 {(char_u *)"", (char_u *)0L}
|
|
1110 #else
|
|
1111 (char_u *)NULL, PV_NONE,
|
|
1112 {(char_u *)0L, (char_u *)0L}
|
|
1113 #endif
|
|
1114 },
|
|
1115 {"hidden", "hid", P_BOOL|P_VI_DEF,
|
|
1116 (char_u *)&p_hid, PV_NONE,
|
|
1117 {(char_u *)FALSE, (char_u *)0L}},
|
|
1118 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
|
|
1119 (char_u *)&p_hl, PV_NONE,
|
386
|
1120 {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,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,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal",
|
7
|
1121 (char_u *)0L}},
|
|
1122 {"history", "hi", P_NUM|P_VIM,
|
|
1123 (char_u *)&p_hi, PV_NONE,
|
|
1124 {(char_u *)0L, (char_u *)20L}},
|
|
1125 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
|
|
1126 #ifdef FEAT_RIGHTLEFT
|
|
1127 (char_u *)&p_hkmap, PV_NONE,
|
|
1128 #else
|
|
1129 (char_u *)NULL, PV_NONE,
|
|
1130 #endif
|
|
1131 {(char_u *)FALSE, (char_u *)0L}},
|
|
1132 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
|
|
1133 #ifdef FEAT_RIGHTLEFT
|
|
1134 (char_u *)&p_hkmapp, PV_NONE,
|
|
1135 #else
|
|
1136 (char_u *)NULL, PV_NONE,
|
|
1137 #endif
|
|
1138 {(char_u *)FALSE, (char_u *)0L}},
|
|
1139 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
|
|
1140 (char_u *)&p_hls, PV_NONE,
|
|
1141 {(char_u *)FALSE, (char_u *)0L}},
|
|
1142 {"icon", NULL, P_BOOL|P_VI_DEF,
|
|
1143 #ifdef FEAT_TITLE
|
|
1144 (char_u *)&p_icon, PV_NONE,
|
|
1145 #else
|
|
1146 (char_u *)NULL, PV_NONE,
|
|
1147 #endif
|
|
1148 {(char_u *)FALSE, (char_u *)0L}},
|
|
1149 {"iconstring", NULL, P_STRING|P_VI_DEF,
|
|
1150 #ifdef FEAT_TITLE
|
|
1151 (char_u *)&p_iconstring, PV_NONE,
|
|
1152 #else
|
|
1153 (char_u *)NULL, PV_NONE,
|
|
1154 #endif
|
|
1155 {(char_u *)"", (char_u *)0L}},
|
|
1156 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
|
|
1157 (char_u *)&p_ic, PV_NONE,
|
|
1158 {(char_u *)FALSE, (char_u *)0L}},
|
|
1159 {"imactivatekey","imak",P_STRING|P_VI_DEF,
|
11
|
1160 #if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
|
7
|
1161 (char_u *)&p_imak, PV_NONE,
|
|
1162 #else
|
|
1163 (char_u *)NULL, PV_NONE,
|
|
1164 #endif
|
|
1165 {(char_u *)"", (char_u *)0L}},
|
|
1166 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
|
|
1167 #ifdef USE_IM_CONTROL
|
|
1168 (char_u *)&p_imcmdline, PV_NONE,
|
|
1169 #else
|
|
1170 (char_u *)NULL, PV_NONE,
|
|
1171 #endif
|
|
1172 {(char_u *)FALSE, (char_u *)0L}},
|
|
1173 {"imdisable", "imd", P_BOOL|P_VI_DEF,
|
|
1174 #ifdef USE_IM_CONTROL
|
|
1175 (char_u *)&p_imdisable, PV_NONE,
|
|
1176 #else
|
|
1177 (char_u *)NULL, PV_NONE,
|
|
1178 #endif
|
|
1179 #ifdef __sgi
|
|
1180 {(char_u *)TRUE, (char_u *)0L}
|
|
1181 #else
|
|
1182 {(char_u *)FALSE, (char_u *)0L}
|
|
1183 #endif
|
|
1184 },
|
|
1185 {"iminsert", "imi", P_NUM|P_VI_DEF,
|
|
1186 (char_u *)&p_iminsert, PV_IMI,
|
|
1187 #ifdef B_IMODE_IM
|
|
1188 {(char_u *)B_IMODE_IM, (char_u *)0L}
|
|
1189 #else
|
|
1190 {(char_u *)B_IMODE_NONE, (char_u *)0L}
|
|
1191 #endif
|
|
1192 },
|
|
1193 {"imsearch", "ims", P_NUM|P_VI_DEF,
|
|
1194 (char_u *)&p_imsearch, PV_IMS,
|
|
1195 #ifdef B_IMODE_IM
|
|
1196 {(char_u *)B_IMODE_IM, (char_u *)0L}
|
|
1197 #else
|
|
1198 {(char_u *)B_IMODE_NONE, (char_u *)0L}
|
|
1199 #endif
|
|
1200 },
|
|
1201 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
1202 #ifdef FEAT_FIND_ID
|
|
1203 (char_u *)&p_inc, OPT_BOTH(PV_INC),
|
|
1204 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
|
|
1205 #else
|
|
1206 (char_u *)NULL, PV_NONE,
|
|
1207 {(char_u *)0L, (char_u *)0L}
|
|
1208 #endif
|
|
1209 },
|
|
1210 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
1211 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
|
|
1212 (char_u *)&p_inex, PV_INEX,
|
|
1213 {(char_u *)"", (char_u *)0L}
|
|
1214 #else
|
|
1215 (char_u *)NULL, PV_NONE,
|
|
1216 {(char_u *)0L, (char_u *)0L}
|
|
1217 #endif
|
|
1218 },
|
|
1219 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
|
|
1220 (char_u *)&p_is, PV_NONE,
|
|
1221 {(char_u *)FALSE, (char_u *)0L}},
|
|
1222 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
|
|
1223 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
1224 (char_u *)&p_inde, PV_INDE,
|
|
1225 {(char_u *)"", (char_u *)0L}
|
|
1226 #else
|
|
1227 (char_u *)NULL, PV_NONE,
|
|
1228 {(char_u *)0L, (char_u *)0L}
|
|
1229 #endif
|
|
1230 },
|
|
1231 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1232 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
1233 (char_u *)&p_indk, PV_INDK,
|
|
1234 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
|
|
1235 #else
|
|
1236 (char_u *)NULL, PV_NONE,
|
|
1237 {(char_u *)0L, (char_u *)0L}
|
|
1238 #endif
|
|
1239 },
|
|
1240 {"infercase", "inf", P_BOOL|P_VI_DEF,
|
|
1241 (char_u *)&p_inf, PV_INF,
|
|
1242 {(char_u *)FALSE, (char_u *)0L}},
|
|
1243 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
|
|
1244 (char_u *)&p_im, PV_NONE,
|
|
1245 {(char_u *)FALSE, (char_u *)0L}},
|
|
1246 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1247 (char_u *)&p_isf, PV_NONE,
|
|
1248 {
|
|
1249 #ifdef BACKSLASH_IN_FILENAME
|
|
1250 /* Excluded are: & and ^ are special in cmd.exe
|
|
1251 * ( and ) are used in text separating fnames */
|
|
1252 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
|
|
1253 #else
|
|
1254 # ifdef AMIGA
|
|
1255 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
|
|
1256 # else
|
|
1257 # ifdef VMS
|
|
1258 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
|
|
1259 # else /* UNIX et al. */
|
|
1260 # ifdef EBCDIC
|
|
1261 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
|
|
1262 # else
|
|
1263 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
|
|
1264 # endif
|
|
1265 # endif
|
|
1266 # endif
|
|
1267 #endif
|
|
1268 (char_u *)0L}},
|
|
1269 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1270 (char_u *)&p_isi, PV_NONE,
|
|
1271 {
|
|
1272 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
|
|
1273 (char_u *)"@,48-57,_,128-167,224-235",
|
|
1274 #else
|
|
1275 # ifdef EBCDIC
|
|
1276 /* TODO: EBCDIC Check this! @ == isalpha()*/
|
|
1277 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
|
|
1278 "112-120,128,140-142,156,158,172,"
|
|
1279 "174,186,191,203-207,219-225,235-239,"
|
|
1280 "251-254",
|
|
1281 # else
|
|
1282 (char_u *)"@,48-57,_,192-255",
|
|
1283 # endif
|
|
1284 #endif
|
|
1285 (char_u *)0L}},
|
|
1286 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
|
|
1287 (char_u *)&p_isk, PV_ISK,
|
|
1288 {
|
|
1289 #ifdef EBCDIC
|
|
1290 (char_u *)"@,240-249,_",
|
|
1291 /* TODO: EBCDIC Check this! @ == isalpha()*/
|
|
1292 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
|
|
1293 "112-120,128,140-142,156,158,172,"
|
|
1294 "174,186,191,203-207,219-225,235-239,"
|
|
1295 "251-254",
|
|
1296 #else
|
|
1297 (char_u *)"@,48-57,_",
|
|
1298 # if defined(MSDOS) || defined(MSWIN) || defined(OS2)
|
|
1299 (char_u *)"@,48-57,_,128-167,224-235"
|
|
1300 # else
|
|
1301 (char_u *)"@,48-57,_,192-255"
|
|
1302 # endif
|
|
1303 #endif
|
|
1304 }},
|
|
1305 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
|
|
1306 (char_u *)&p_isp, PV_NONE,
|
|
1307 {
|
36
|
1308 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
|
|
1309 || (defined(MACOS) && !defined(MACOS_X)) \
|
7
|
1310 || defined(VMS)
|
|
1311 (char_u *)"@,~-255",
|
|
1312 #else
|
|
1313 # ifdef EBCDIC
|
|
1314 /* all chars above 63 are printable */
|
|
1315 (char_u *)"63-255",
|
|
1316 # else
|
|
1317 (char_u *)"@,161-255",
|
|
1318 # endif
|
|
1319 #endif
|
|
1320 (char_u *)0L}},
|
|
1321 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
|
|
1322 (char_u *)&p_js, PV_NONE,
|
|
1323 {(char_u *)TRUE, (char_u *)0L}},
|
|
1324 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
|
|
1325 #ifdef FEAT_CRYPT
|
|
1326 (char_u *)&p_key, PV_KEY,
|
|
1327 {(char_u *)"", (char_u *)0L}
|
|
1328 #else
|
|
1329 (char_u *)NULL, PV_NONE,
|
|
1330 {(char_u *)0L, (char_u *)0L}
|
|
1331 #endif
|
|
1332 },
|
36
|
1333 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME,
|
7
|
1334 #ifdef FEAT_KEYMAP
|
|
1335 (char_u *)&p_keymap, PV_KMAP,
|
|
1336 {(char_u *)"", (char_u *)0L}
|
|
1337 #else
|
|
1338 (char_u *)NULL, PV_NONE,
|
|
1339 {(char_u *)"", (char_u *)0L}
|
|
1340 #endif
|
|
1341 },
|
|
1342 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1343 #ifdef FEAT_VISUAL
|
|
1344 (char_u *)&p_km, PV_NONE,
|
|
1345 #else
|
|
1346 (char_u *)NULL, PV_NONE,
|
|
1347 #endif
|
|
1348 {(char_u *)"", (char_u *)0L}},
|
|
1349 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
1350 (char_u *)&p_kp, OPT_BOTH(PV_KP),
|
|
1351 {
|
|
1352 #if defined(MSDOS) || defined(MSWIN)
|
|
1353 (char_u *)":help",
|
|
1354 #else
|
|
1355 #ifdef VMS
|
|
1356 (char_u *)"help",
|
|
1357 #else
|
|
1358 # if defined(OS2)
|
|
1359 (char_u *)"view /",
|
|
1360 # else
|
|
1361 # ifdef USEMAN_S
|
|
1362 (char_u *)"man -s",
|
|
1363 # else
|
|
1364 (char_u *)"man",
|
|
1365 # endif
|
|
1366 # endif
|
|
1367 #endif
|
|
1368 #endif
|
|
1369 (char_u *)0L}},
|
|
1370 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1371 #ifdef FEAT_LANGMAP
|
|
1372 (char_u *)&p_langmap, PV_NONE,
|
|
1373 {(char_u *)"", /* unmatched } */
|
|
1374 #else
|
|
1375 (char_u *)NULL, PV_NONE,
|
|
1376 {(char_u *)NULL,
|
|
1377 #endif
|
|
1378 (char_u *)0L}},
|
36
|
1379 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
|
7
|
1380 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
|
|
1381 (char_u *)&p_lm, PV_NONE,
|
|
1382 #else
|
|
1383 (char_u *)NULL, PV_NONE,
|
|
1384 #endif
|
|
1385 {(char_u *)"", (char_u *)0L}},
|
|
1386 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
|
|
1387 #ifdef FEAT_WINDOWS
|
|
1388 (char_u *)&p_ls, PV_NONE,
|
|
1389 #else
|
|
1390 (char_u *)NULL, PV_NONE,
|
|
1391 #endif
|
|
1392 {(char_u *)1L, (char_u *)0L}},
|
|
1393 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
|
|
1394 (char_u *)&p_lz, PV_NONE,
|
|
1395 {(char_u *)FALSE, (char_u *)0L}},
|
|
1396 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
|
|
1397 #ifdef FEAT_LINEBREAK
|
|
1398 (char_u *)VAR_WIN, PV_LBR,
|
|
1399 #else
|
|
1400 (char_u *)NULL, PV_NONE,
|
|
1401 #endif
|
|
1402 {(char_u *)FALSE, (char_u *)0L}},
|
|
1403 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
|
|
1404 (char_u *)&Rows, PV_NONE,
|
|
1405 {
|
|
1406 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
|
|
1407 (char_u *)25L,
|
|
1408 #else
|
|
1409 (char_u *)24L,
|
|
1410 #endif
|
|
1411 (char_u *)0L}},
|
|
1412 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
|
|
1413 #ifdef FEAT_GUI
|
|
1414 (char_u *)&p_linespace, PV_NONE,
|
|
1415 #else
|
|
1416 (char_u *)NULL, PV_NONE,
|
|
1417 #endif
|
|
1418 #ifdef FEAT_GUI_W32
|
|
1419 {(char_u *)1L, (char_u *)0L}
|
|
1420 #else
|
|
1421 {(char_u *)0L, (char_u *)0L}
|
|
1422 #endif
|
|
1423 },
|
|
1424 {"lisp", NULL, P_BOOL|P_VI_DEF,
|
|
1425 #ifdef FEAT_LISP
|
|
1426 (char_u *)&p_lisp, PV_LISP,
|
|
1427 #else
|
|
1428 (char_u *)NULL, PV_NONE,
|
|
1429 #endif
|
|
1430 {(char_u *)FALSE, (char_u *)0L}},
|
|
1431 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1432 #ifdef FEAT_LISP
|
|
1433 (char_u *)&p_lispwords, PV_NONE,
|
|
1434 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
|
|
1435 #else
|
|
1436 (char_u *)NULL, PV_NONE,
|
|
1437 {(char_u *)"", (char_u *)0L}
|
|
1438 #endif
|
|
1439 },
|
|
1440 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
|
|
1441 (char_u *)VAR_WIN, PV_LIST,
|
|
1442 {(char_u *)FALSE, (char_u *)0L}},
|
|
1443 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
|
|
1444 (char_u *)&p_lcs, PV_NONE,
|
|
1445 {(char_u *)"eol:$", (char_u *)0L}},
|
|
1446 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
|
|
1447 (char_u *)&p_lpl, PV_NONE,
|
|
1448 {(char_u *)TRUE, (char_u *)0L}},
|
|
1449 {"magic", NULL, P_BOOL|P_VI_DEF,
|
|
1450 (char_u *)&p_magic, PV_NONE,
|
|
1451 {(char_u *)TRUE, (char_u *)0L}},
|
|
1452 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
1453 #ifdef FEAT_QUICKFIX
|
|
1454 (char_u *)&p_mef, PV_NONE,
|
|
1455 {(char_u *)"", (char_u *)0L}
|
|
1456 #else
|
|
1457 (char_u *)NULL, PV_NONE,
|
|
1458 {(char_u *)NULL, (char_u *)0L}
|
|
1459 #endif
|
|
1460 },
|
|
1461 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
1462 #ifdef FEAT_QUICKFIX
|
|
1463 (char_u *)&p_mp, OPT_BOTH(PV_MP),
|
|
1464 # ifdef VMS
|
|
1465 {(char_u *)"MMS", (char_u *)0L}
|
|
1466 # else
|
|
1467 {(char_u *)"make", (char_u *)0L}
|
|
1468 # endif
|
|
1469 #else
|
|
1470 (char_u *)NULL, PV_NONE,
|
|
1471 {(char_u *)NULL, (char_u *)0L}
|
|
1472 #endif
|
|
1473 },
|
|
1474 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1475 (char_u *)&p_mps, PV_MPS,
|
|
1476 {(char_u *)"(:),{:},[:]", (char_u *)0L}},
|
|
1477 {"matchtime", "mat", P_NUM|P_VI_DEF,
|
|
1478 (char_u *)&p_mat, PV_NONE,
|
|
1479 {(char_u *)5L, (char_u *)0L}},
|
|
1480 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
|
|
1481 #ifdef FEAT_EVAL
|
|
1482 (char_u *)&p_mfd, PV_NONE,
|
|
1483 #else
|
|
1484 (char_u *)NULL, PV_NONE,
|
|
1485 #endif
|
|
1486 {(char_u *)100L, (char_u *)0L}},
|
|
1487 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
|
|
1488 (char_u *)&p_mmd, PV_NONE,
|
|
1489 {(char_u *)1000L, (char_u *)0L}},
|
|
1490 {"maxmem", "mm", P_NUM|P_VI_DEF,
|
|
1491 (char_u *)&p_mm, PV_NONE,
|
|
1492 {(char_u *)DFLT_MAXMEM, (char_u *)0L}},
|
190
|
1493 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
|
|
1494 (char_u *)&p_mmp, PV_NONE,
|
|
1495 {(char_u *)1000L, (char_u *)0L}},
|
7
|
1496 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
|
|
1497 (char_u *)&p_mmt, PV_NONE,
|
|
1498 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}},
|
|
1499 {"menuitems", "mis", P_NUM|P_VI_DEF,
|
|
1500 #ifdef FEAT_MENU
|
|
1501 (char_u *)&p_mis, PV_NONE,
|
|
1502 #else
|
|
1503 (char_u *)NULL, PV_NONE,
|
|
1504 #endif
|
|
1505 {(char_u *)25L, (char_u *)0L}},
|
|
1506 {"mesg", NULL, P_BOOL|P_VI_DEF,
|
|
1507 (char_u *)NULL, PV_NONE,
|
|
1508 {(char_u *)FALSE, (char_u *)0L}},
|
|
1509 {"modeline", "ml", P_BOOL|P_VIM,
|
|
1510 (char_u *)&p_ml, PV_ML,
|
|
1511 {(char_u *)FALSE, (char_u *)TRUE}},
|
|
1512 {"modelines", "mls", P_NUM|P_VI_DEF,
|
|
1513 (char_u *)&p_mls, PV_NONE,
|
|
1514 {(char_u *)5L, (char_u *)0L}},
|
|
1515 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
|
|
1516 (char_u *)&p_ma, PV_MA,
|
|
1517 {(char_u *)TRUE, (char_u *)0L}},
|
|
1518 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
|
|
1519 (char_u *)&p_mod, PV_MOD,
|
|
1520 {(char_u *)FALSE, (char_u *)0L}},
|
|
1521 {"more", NULL, P_BOOL|P_VIM,
|
|
1522 (char_u *)&p_more, PV_NONE,
|
|
1523 {(char_u *)FALSE, (char_u *)TRUE}},
|
|
1524 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
|
|
1525 (char_u *)&p_mouse, PV_NONE,
|
|
1526 {
|
|
1527 #if defined(MSDOS) || defined(WIN3264)
|
|
1528 (char_u *)"a",
|
|
1529 #else
|
|
1530 (char_u *)"",
|
|
1531 #endif
|
|
1532 (char_u *)0L}},
|
|
1533 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
|
|
1534 #ifdef FEAT_GUI
|
|
1535 (char_u *)&p_mousef, PV_NONE,
|
|
1536 #else
|
|
1537 (char_u *)NULL, PV_NONE,
|
|
1538 #endif
|
|
1539 {(char_u *)FALSE, (char_u *)0L}},
|
|
1540 {"mousehide", "mh", P_BOOL|P_VI_DEF,
|
|
1541 #ifdef FEAT_GUI
|
|
1542 (char_u *)&p_mh, PV_NONE,
|
|
1543 #else
|
|
1544 (char_u *)NULL, PV_NONE,
|
|
1545 #endif
|
|
1546 {(char_u *)TRUE, (char_u *)0L}},
|
|
1547 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
|
|
1548 (char_u *)&p_mousem, PV_NONE,
|
|
1549 {
|
|
1550 #if defined(MSDOS) || defined(MSWIN)
|
|
1551 (char_u *)"popup",
|
|
1552 #else
|
|
1553 # if defined(MACOS)
|
|
1554 (char_u *)"popup_setpos",
|
|
1555 # else
|
|
1556 (char_u *)"extend",
|
|
1557 # endif
|
|
1558 #endif
|
|
1559 (char_u *)0L}},
|
|
1560 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1561 #ifdef FEAT_MOUSESHAPE
|
|
1562 (char_u *)&p_mouseshape, PV_NONE,
|
|
1563 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
|
|
1564 #else
|
|
1565 (char_u *)NULL, PV_NONE,
|
|
1566 {(char_u *)NULL, (char_u *)0L}
|
|
1567 #endif
|
|
1568 },
|
|
1569 {"mousetime", "mouset", P_NUM|P_VI_DEF,
|
|
1570 (char_u *)&p_mouset, PV_NONE,
|
|
1571 {(char_u *)500L, (char_u *)0L}},
|
14
|
1572 {"mzquantum", "mzq", P_NUM,
|
|
1573 #ifdef FEAT_MZSCHEME
|
|
1574 (char_u *)&p_mzq, PV_NONE,
|
|
1575 #else
|
|
1576 (char_u *)NULL, PV_NONE,
|
|
1577 #endif
|
|
1578 {(char_u *)100L, (char_u *)100L}},
|
7
|
1579 {"novice", NULL, P_BOOL|P_VI_DEF,
|
|
1580 (char_u *)NULL, PV_NONE,
|
|
1581 {(char_u *)FALSE, (char_u *)0L}},
|
|
1582 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1583 (char_u *)&p_nf, PV_NF,
|
|
1584 {(char_u *)"octal,hex", (char_u *)0L}},
|
|
1585 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
|
|
1586 (char_u *)VAR_WIN, PV_NU,
|
|
1587 {(char_u *)FALSE, (char_u *)0L}},
|
13
|
1588 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
|
|
1589 #ifdef FEAT_LINEBREAK
|
|
1590 (char_u *)VAR_WIN, PV_NUW,
|
|
1591 #else
|
|
1592 (char_u *)NULL, PV_NONE,
|
|
1593 #endif
|
|
1594 {(char_u *)8L, (char_u *)4L}},
|
7
|
1595 {"open", NULL, P_BOOL|P_VI_DEF,
|
|
1596 (char_u *)NULL, PV_NONE,
|
|
1597 {(char_u *)FALSE, (char_u *)0L}},
|
|
1598 {"optimize", "opt", P_BOOL|P_VI_DEF,
|
|
1599 (char_u *)NULL, PV_NONE,
|
|
1600 {(char_u *)FALSE, (char_u *)0L}},
|
|
1601 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
1602 #ifdef FEAT_OSFILETYPE
|
|
1603 (char_u *)&p_oft, PV_OFT,
|
|
1604 {(char_u *)DFLT_OFT, (char_u *)0L}
|
|
1605 #else
|
|
1606 (char_u *)NULL, PV_NONE,
|
|
1607 {(char_u *)0L, (char_u *)0L}
|
|
1608 #endif
|
|
1609 },
|
|
1610 {"paragraphs", "para", P_STRING|P_VI_DEF,
|
|
1611 (char_u *)&p_para, PV_NONE,
|
|
1612 {(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}},
|
|
1613 {"paste", NULL, P_BOOL|P_VI_DEF,
|
|
1614 (char_u *)&p_paste, PV_NONE,
|
|
1615 {(char_u *)FALSE, (char_u *)0L}},
|
|
1616 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
|
|
1617 (char_u *)&p_pt, PV_NONE,
|
|
1618 {(char_u *)"", (char_u *)0L}},
|
|
1619 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
|
|
1620 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
|
|
1621 (char_u *)&p_pex, PV_NONE,
|
|
1622 {(char_u *)"", (char_u *)0L}
|
|
1623 #else
|
|
1624 (char_u *)NULL, PV_NONE,
|
|
1625 {(char_u *)0L, (char_u *)0L}
|
|
1626 #endif
|
|
1627 },
|
36
|
1628 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
|
7
|
1629 (char_u *)&p_pm, PV_NONE,
|
|
1630 {(char_u *)"", (char_u *)0L}},
|
|
1631 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1632 (char_u *)&p_path, OPT_BOTH(PV_PATH),
|
|
1633 {
|
|
1634 #if defined AMIGA || defined MSDOS || defined MSWIN
|
|
1635 (char_u *)".,,",
|
|
1636 #else
|
|
1637 # if defined(__EMX__)
|
|
1638 (char_u *)".,/emx/include,,",
|
|
1639 # else /* Unix, probably */
|
|
1640 (char_u *)".,/usr/include,,",
|
|
1641 # endif
|
|
1642 #endif
|
|
1643 (char_u *)0L}},
|
|
1644 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
|
|
1645 (char_u *)&p_pi, PV_PI,
|
|
1646 {(char_u *)FALSE, (char_u *)0L}},
|
13
|
1647 {"previewheight", "pvh", P_NUM|P_VI_DEF,
|
7
|
1648 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
|
1649 (char_u *)&p_pvh, PV_NONE,
|
|
1650 #else
|
|
1651 (char_u *)NULL, PV_NONE,
|
|
1652 #endif
|
|
1653 {(char_u *)12L, (char_u *)0L}},
|
|
1654 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
|
|
1655 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
|
1656 (char_u *)VAR_WIN, PV_PVW,
|
|
1657 #else
|
|
1658 (char_u *)NULL, PV_NONE,
|
|
1659 #endif
|
|
1660 {(char_u *)FALSE, (char_u *)0L}},
|
36
|
1661 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
|
7
|
1662 #ifdef FEAT_PRINTER
|
|
1663 (char_u *)&p_pdev, PV_NONE,
|
|
1664 {(char_u *)"", (char_u *)0L}
|
|
1665 #else
|
|
1666 (char_u *)NULL, PV_NONE,
|
|
1667 {(char_u *)NULL, (char_u *)0L}
|
|
1668 #endif
|
|
1669 },
|
|
1670 {"printencoding", "penc", P_STRING|P_VI_DEF,
|
|
1671 #ifdef FEAT_POSTSCRIPT
|
|
1672 (char_u *)&p_penc, PV_NONE,
|
|
1673 {(char_u *)"", (char_u *)0L}
|
|
1674 #else
|
|
1675 (char_u *)NULL, PV_NONE,
|
|
1676 {(char_u *)NULL, (char_u *)0L}
|
|
1677 #endif
|
|
1678 },
|
|
1679 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
|
|
1680 #ifdef FEAT_POSTSCRIPT
|
|
1681 (char_u *)&p_pexpr, PV_NONE,
|
|
1682 {(char_u *)"", (char_u *)0L}
|
|
1683 #else
|
|
1684 (char_u *)NULL, PV_NONE,
|
|
1685 {(char_u *)NULL, (char_u *)0L}
|
|
1686 #endif
|
|
1687 },
|
|
1688 {"printfont", "pfn", P_STRING|P_VI_DEF,
|
|
1689 #ifdef FEAT_PRINTER
|
|
1690 (char_u *)&p_pfn, PV_NONE,
|
|
1691 {
|
|
1692 # ifdef MSWIN
|
|
1693 (char_u *)"Courier_New:h10",
|
|
1694 # else
|
|
1695 (char_u *)"courier",
|
|
1696 # endif
|
|
1697 (char_u *)0L}
|
|
1698 #else
|
|
1699 (char_u *)NULL, PV_NONE,
|
|
1700 {(char_u *)NULL, (char_u *)0L}
|
|
1701 #endif
|
|
1702 },
|
|
1703 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
|
|
1704 #ifdef FEAT_PRINTER
|
|
1705 (char_u *)&p_header, PV_NONE,
|
|
1706 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
|
|
1707 #else
|
|
1708 (char_u *)NULL, PV_NONE,
|
|
1709 {(char_u *)NULL, (char_u *)0L}
|
|
1710 #endif
|
|
1711 },
|
15
|
1712 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
|
|
1713 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
|
|
1714 (char_u *)&p_pmcs, PV_NONE,
|
|
1715 {(char_u *)"", (char_u *)0L}
|
|
1716 #else
|
|
1717 (char_u *)NULL, PV_NONE,
|
|
1718 {(char_u *)NULL, (char_u *)0L}
|
|
1719 #endif
|
|
1720 },
|
|
1721 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
|
|
1722 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
|
|
1723 (char_u *)&p_pmfn, PV_NONE,
|
|
1724 {(char_u *)"", (char_u *)0L}
|
|
1725 #else
|
|
1726 (char_u *)NULL, PV_NONE,
|
|
1727 {(char_u *)NULL, (char_u *)0L}
|
|
1728 #endif
|
|
1729 },
|
7
|
1730 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1731 #ifdef FEAT_PRINTER
|
|
1732 (char_u *)&p_popt, PV_NONE,
|
|
1733 {(char_u *)"", (char_u *)0L}
|
|
1734 #else
|
|
1735 (char_u *)NULL, PV_NONE,
|
|
1736 {(char_u *)NULL, (char_u *)0L}
|
|
1737 #endif
|
|
1738 },
|
|
1739 {"prompt", NULL, P_BOOL|P_VI_DEF,
|
168
|
1740 (char_u *)&p_prompt, PV_NONE,
|
|
1741 {(char_u *)TRUE, (char_u *)0L}},
|
12
|
1742 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
|
|
1743 #ifdef FEAT_TEXTOBJ
|
|
1744 (char_u *)&p_qe, PV_QE,
|
|
1745 {(char_u *)"\\", (char_u *)0L}
|
|
1746 #else
|
|
1747 (char_u *)NULL, PV_NONE,
|
|
1748 {(char_u *)NULL, (char_u *)0L}
|
|
1749 #endif
|
|
1750 },
|
7
|
1751 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
|
|
1752 (char_u *)&p_ro, PV_RO,
|
|
1753 {(char_u *)FALSE, (char_u *)0L}},
|
|
1754 {"redraw", NULL, P_BOOL|P_VI_DEF,
|
|
1755 (char_u *)NULL, PV_NONE,
|
|
1756 {(char_u *)FALSE, (char_u *)0L}},
|
|
1757 {"remap", NULL, P_BOOL|P_VI_DEF,
|
|
1758 (char_u *)&p_remap, PV_NONE,
|
|
1759 {(char_u *)TRUE, (char_u *)0L}},
|
|
1760 {"report", NULL, P_NUM|P_VI_DEF,
|
|
1761 (char_u *)&p_report, PV_NONE,
|
|
1762 {(char_u *)2L, (char_u *)0L}},
|
|
1763 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
|
|
1764 #ifdef WIN3264
|
|
1765 (char_u *)&p_rs, PV_NONE,
|
|
1766 #else
|
|
1767 (char_u *)NULL, PV_NONE,
|
|
1768 #endif
|
|
1769 {(char_u *)TRUE, (char_u *)0L}},
|
|
1770 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
|
|
1771 #ifdef FEAT_RIGHTLEFT
|
|
1772 (char_u *)&p_ri, PV_NONE,
|
|
1773 #else
|
|
1774 (char_u *)NULL, PV_NONE,
|
|
1775 #endif
|
|
1776 {(char_u *)FALSE, (char_u *)0L}},
|
|
1777 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
|
|
1778 #ifdef FEAT_RIGHTLEFT
|
|
1779 (char_u *)VAR_WIN, PV_RL,
|
|
1780 #else
|
|
1781 (char_u *)NULL, PV_NONE,
|
|
1782 #endif
|
|
1783 {(char_u *)FALSE, (char_u *)0L}},
|
|
1784 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
|
|
1785 #ifdef FEAT_RIGHTLEFT
|
|
1786 (char_u *)VAR_WIN, PV_RLC,
|
|
1787 {(char_u *)"search", (char_u *)NULL}
|
|
1788 #else
|
|
1789 (char_u *)NULL, PV_NONE,
|
|
1790 {(char_u *)NULL, (char_u *)0L}
|
|
1791 #endif
|
|
1792 },
|
|
1793 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
|
|
1794 #ifdef FEAT_CMDL_INFO
|
|
1795 (char_u *)&p_ru, PV_NONE,
|
|
1796 #else
|
|
1797 (char_u *)NULL, PV_NONE,
|
|
1798 #endif
|
|
1799 {(char_u *)FALSE, (char_u *)0L}},
|
|
1800 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
|
|
1801 #ifdef FEAT_STL_OPT
|
|
1802 (char_u *)&p_ruf, PV_NONE,
|
|
1803 #else
|
|
1804 (char_u *)NULL, PV_NONE,
|
|
1805 #endif
|
|
1806 {(char_u *)"", (char_u *)0L}},
|
|
1807 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
|
|
1808 (char_u *)&p_rtp, PV_NONE,
|
|
1809 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}},
|
|
1810 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
|
|
1811 (char_u *)VAR_WIN, PV_SCROLL,
|
|
1812 {(char_u *)12L, (char_u *)0L}},
|
|
1813 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
|
|
1814 #ifdef FEAT_SCROLLBIND
|
|
1815 (char_u *)VAR_WIN, PV_SCBIND,
|
|
1816 #else
|
|
1817 (char_u *)NULL, PV_NONE,
|
|
1818 #endif
|
|
1819 {(char_u *)FALSE, (char_u *)0L}},
|
|
1820 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
|
|
1821 (char_u *)&p_sj, PV_NONE,
|
|
1822 {(char_u *)1L, (char_u *)0L}},
|
|
1823 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
|
|
1824 (char_u *)&p_so, PV_NONE,
|
|
1825 {(char_u *)0L, (char_u *)0L}},
|
|
1826 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1827 #ifdef FEAT_SCROLLBIND
|
|
1828 (char_u *)&p_sbo, PV_NONE,
|
|
1829 {(char_u *)"ver,jump", (char_u *)0L}
|
|
1830 #else
|
|
1831 (char_u *)NULL, PV_NONE,
|
|
1832 {(char_u *)0L, (char_u *)0L}
|
|
1833 #endif
|
|
1834 },
|
|
1835 {"sections", "sect", P_STRING|P_VI_DEF,
|
|
1836 (char_u *)&p_sections, PV_NONE,
|
|
1837 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}},
|
|
1838 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
|
|
1839 (char_u *)&p_secure, PV_NONE,
|
|
1840 {(char_u *)FALSE, (char_u *)0L}},
|
|
1841 {"selection", "sel", P_STRING|P_VI_DEF,
|
|
1842 #ifdef FEAT_VISUAL
|
|
1843 (char_u *)&p_sel, PV_NONE,
|
|
1844 #else
|
|
1845 (char_u *)NULL, PV_NONE,
|
|
1846 #endif
|
|
1847 {(char_u *)"inclusive", (char_u *)0L}},
|
|
1848 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1849 #ifdef FEAT_VISUAL
|
|
1850 (char_u *)&p_slm, PV_NONE,
|
|
1851 #else
|
|
1852 (char_u *)NULL, PV_NONE,
|
|
1853 #endif
|
|
1854 {(char_u *)"", (char_u *)0L}},
|
|
1855 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
1856 #ifdef FEAT_SESSION
|
|
1857 (char_u *)&p_ssop, PV_NONE,
|
|
1858 {(char_u *)"blank,buffers,curdir,folds,help,options,winsize",
|
|
1859 (char_u *)0L}
|
|
1860 #else
|
|
1861 (char_u *)NULL, PV_NONE,
|
|
1862 {(char_u *)0L, (char_u *)0L}
|
|
1863 #endif
|
|
1864 },
|
|
1865 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
1866 (char_u *)&p_sh, PV_NONE,
|
|
1867 {
|
|
1868 #ifdef VMS
|
|
1869 (char_u *)"-",
|
|
1870 #else
|
|
1871 # if defined(MSDOS)
|
|
1872 (char_u *)"command",
|
|
1873 # else
|
|
1874 # if defined(WIN16)
|
|
1875 (char_u *)"command.com",
|
|
1876 # else
|
|
1877 # if defined(WIN3264)
|
|
1878 (char_u *)"", /* set in set_init_1() */
|
|
1879 # else
|
|
1880 # if defined(OS2)
|
|
1881 (char_u *)"cmd.exe",
|
|
1882 # else
|
|
1883 # if defined(ARCHIE)
|
|
1884 (char_u *)"gos",
|
|
1885 # else
|
|
1886 (char_u *)"sh",
|
|
1887 # endif
|
|
1888 # endif
|
|
1889 # endif
|
|
1890 # endif
|
|
1891 # endif
|
|
1892 #endif /* VMS */
|
|
1893 (char_u *)0L}},
|
|
1894 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
|
|
1895 (char_u *)&p_shcf, PV_NONE,
|
|
1896 {
|
|
1897 #if defined(MSDOS) || defined(MSWIN)
|
|
1898 (char_u *)"/c",
|
|
1899 #else
|
|
1900 # if defined(OS2)
|
|
1901 (char_u *)"/c",
|
|
1902 # else
|
|
1903 (char_u *)"-c",
|
|
1904 # endif
|
|
1905 #endif
|
|
1906 (char_u *)0L}},
|
|
1907 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
|
|
1908 #ifdef FEAT_QUICKFIX
|
|
1909 (char_u *)&p_sp, PV_NONE,
|
|
1910 {
|
|
1911 #if defined(UNIX) || defined(OS2)
|
|
1912 # ifdef ARCHIE
|
|
1913 (char_u *)"2>",
|
|
1914 # else
|
|
1915 (char_u *)"| tee",
|
|
1916 # endif
|
|
1917 #else
|
|
1918 (char_u *)">",
|
|
1919 #endif
|
|
1920 (char_u *)0L}
|
|
1921 #else
|
|
1922 (char_u *)NULL, PV_NONE,
|
|
1923 {(char_u *)0L, (char_u *)0L}
|
|
1924 #endif
|
|
1925 },
|
|
1926 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
|
|
1927 (char_u *)&p_shq, PV_NONE,
|
|
1928 {(char_u *)"", (char_u *)0L}},
|
|
1929 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
|
|
1930 (char_u *)&p_srr, PV_NONE,
|
|
1931 {(char_u *)">", (char_u *)0L}},
|
|
1932 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
|
|
1933 #ifdef BACKSLASH_IN_FILENAME
|
|
1934 (char_u *)&p_ssl, PV_NONE,
|
|
1935 #else
|
|
1936 (char_u *)NULL, PV_NONE,
|
|
1937 #endif
|
|
1938 {(char_u *)FALSE, (char_u *)0L}},
|
168
|
1939 {"shelltemp", "stmp", P_BOOL,
|
|
1940 (char_u *)&p_stmp, PV_NONE,
|
|
1941 {(char_u *)FALSE, (char_u *)TRUE}},
|
7
|
1942 {"shelltype", "st", P_NUM|P_VI_DEF,
|
|
1943 #ifdef AMIGA
|
|
1944 (char_u *)&p_st, PV_NONE,
|
|
1945 #else
|
|
1946 (char_u *)NULL, PV_NONE,
|
|
1947 #endif
|
|
1948 {(char_u *)0L, (char_u *)0L}},
|
|
1949 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
|
|
1950 (char_u *)&p_sxq, PV_NONE,
|
|
1951 {
|
|
1952 #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
|
|
1953 (char_u *)"\"",
|
|
1954 #else
|
|
1955 (char_u *)"",
|
|
1956 #endif
|
|
1957 (char_u *)0L}},
|
|
1958 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
|
|
1959 (char_u *)&p_sr, PV_NONE,
|
|
1960 {(char_u *)FALSE, (char_u *)0L}},
|
|
1961 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
|
|
1962 (char_u *)&p_sw, PV_SW,
|
|
1963 {(char_u *)8L, (char_u *)0L}},
|
|
1964 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
|
|
1965 (char_u *)&p_shm, PV_NONE,
|
|
1966 {(char_u *)"", (char_u *)"filnxtToO"}},
|
|
1967 {"shortname", "sn", P_BOOL|P_VI_DEF,
|
|
1968 #ifdef SHORT_FNAME
|
|
1969 (char_u *)NULL, PV_NONE,
|
|
1970 #else
|
|
1971 (char_u *)&p_sn, PV_SN,
|
|
1972 #endif
|
|
1973 {(char_u *)FALSE, (char_u *)0L}},
|
|
1974 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
|
|
1975 #ifdef FEAT_LINEBREAK
|
|
1976 (char_u *)&p_sbr, PV_NONE,
|
|
1977 #else
|
|
1978 (char_u *)NULL, PV_NONE,
|
|
1979 #endif
|
|
1980 {(char_u *)"", (char_u *)0L}},
|
|
1981 {"showcmd", "sc", P_BOOL|P_VIM,
|
|
1982 #ifdef FEAT_CMDL_INFO
|
|
1983 (char_u *)&p_sc, PV_NONE,
|
|
1984 #else
|
|
1985 (char_u *)NULL, PV_NONE,
|
|
1986 #endif
|
|
1987 {(char_u *)FALSE,
|
|
1988 #ifdef UNIX
|
|
1989 (char_u *)FALSE
|
|
1990 #else
|
|
1991 (char_u *)TRUE
|
|
1992 #endif
|
|
1993 }},
|
|
1994 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
|
|
1995 (char_u *)&p_sft, PV_NONE,
|
|
1996 {(char_u *)FALSE, (char_u *)0L}},
|
|
1997 {"showmatch", "sm", P_BOOL|P_VI_DEF,
|
|
1998 (char_u *)&p_sm, PV_NONE,
|
|
1999 {(char_u *)FALSE, (char_u *)0L}},
|
|
2000 {"showmode", "smd", P_BOOL|P_VIM,
|
|
2001 (char_u *)&p_smd, PV_NONE,
|
|
2002 {(char_u *)FALSE, (char_u *)TRUE}},
|
|
2003 {"sidescroll", "ss", P_NUM|P_VI_DEF,
|
|
2004 (char_u *)&p_ss, PV_NONE,
|
|
2005 {(char_u *)0L, (char_u *)0L}},
|
|
2006 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
|
|
2007 (char_u *)&p_siso, PV_NONE,
|
|
2008 {(char_u *)0L, (char_u *)0L}},
|
|
2009 {"slowopen", "slow", P_BOOL|P_VI_DEF,
|
|
2010 (char_u *)NULL, PV_NONE,
|
|
2011 {(char_u *)FALSE, (char_u *)0L}},
|
|
2012 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
|
|
2013 (char_u *)&p_scs, PV_NONE,
|
|
2014 {(char_u *)FALSE, (char_u *)0L}},
|
|
2015 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
|
|
2016 #ifdef FEAT_SMARTINDENT
|
|
2017 (char_u *)&p_si, PV_SI,
|
|
2018 #else
|
|
2019 (char_u *)NULL, PV_NONE,
|
|
2020 #endif
|
|
2021 {(char_u *)FALSE, (char_u *)0L}},
|
|
2022 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
|
|
2023 (char_u *)&p_sta, PV_NONE,
|
|
2024 {(char_u *)FALSE, (char_u *)0L}},
|
|
2025 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
|
|
2026 (char_u *)&p_sts, PV_STS,
|
|
2027 {(char_u *)0L, (char_u *)0L}},
|
|
2028 {"sourceany", NULL, P_BOOL|P_VI_DEF,
|
|
2029 (char_u *)NULL, PV_NONE,
|
|
2030 {(char_u *)FALSE, (char_u *)0L}},
|
221
|
2031 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
|
|
2032 #ifdef FEAT_SYN_HL
|
|
2033 (char_u *)VAR_WIN, PV_SPELL,
|
|
2034 #else
|
|
2035 (char_u *)NULL, PV_NONE,
|
|
2036 #endif
|
|
2037 {(char_u *)FALSE, (char_u *)0L}},
|
386
|
2038 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE|P_RBUF,
|
|
2039 #ifdef FEAT_SYN_HL
|
|
2040 (char_u *)&p_spc, PV_SPC,
|
389
|
2041 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
|
386
|
2042 #else
|
|
2043 (char_u *)NULL, PV_NONE,
|
|
2044 {(char_u *)0L, (char_u *)0L}
|
|
2045 #endif
|
|
2046 },
|
|
2047 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
|
314
|
2048 #ifdef FEAT_SYN_HL
|
|
2049 (char_u *)&p_spf, PV_SPF,
|
|
2050 {(char_u *)"", (char_u *)0L}
|
|
2051 #else
|
|
2052 (char_u *)NULL, PV_NONE,
|
|
2053 {(char_u *)0L, (char_u *)0L}
|
|
2054 #endif
|
|
2055 },
|
374
|
2056 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
|
221
|
2057 #ifdef FEAT_SYN_HL
|
|
2058 (char_u *)&p_spl, PV_SPL,
|
314
|
2059 {(char_u *)"en", (char_u *)0L}
|
221
|
2060 #else
|
|
2061 (char_u *)NULL, PV_NONE,
|
|
2062 {(char_u *)0L, (char_u *)0L}
|
|
2063 #endif
|
|
2064 },
|
374
|
2065 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
|
344
|
2066 #ifdef FEAT_SYN_HL
|
|
2067 (char_u *)&p_sps, PV_NONE,
|
|
2068 {(char_u *)"best", (char_u *)0L}
|
|
2069 #else
|
|
2070 (char_u *)NULL, PV_NONE,
|
|
2071 {(char_u *)0L, (char_u *)0L}
|
|
2072 #endif
|
|
2073 },
|
7
|
2074 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
|
|
2075 #ifdef FEAT_WINDOWS
|
|
2076 (char_u *)&p_sb, PV_NONE,
|
|
2077 #else
|
|
2078 (char_u *)NULL, PV_NONE,
|
|
2079 #endif
|
|
2080 {(char_u *)FALSE, (char_u *)0L}},
|
|
2081 {"splitright", "spr", P_BOOL|P_VI_DEF,
|
|
2082 #ifdef FEAT_VERTSPLIT
|
|
2083 (char_u *)&p_spr, PV_NONE,
|
|
2084 #else
|
|
2085 (char_u *)NULL, PV_NONE,
|
|
2086 #endif
|
|
2087 {(char_u *)FALSE, (char_u *)0L}},
|
|
2088 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
|
|
2089 (char_u *)&p_sol, PV_NONE,
|
|
2090 {(char_u *)TRUE, (char_u *)0L}},
|
|
2091 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
|
|
2092 #ifdef FEAT_STL_OPT
|
40
|
2093 (char_u *)&p_stl, OPT_BOTH(PV_STL),
|
7
|
2094 #else
|
|
2095 (char_u *)NULL, PV_NONE,
|
|
2096 #endif
|
|
2097 {(char_u *)"", (char_u *)0L}},
|
|
2098 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2099 (char_u *)&p_su, PV_NONE,
|
|
2100 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
|
|
2101 (char_u *)0L}},
|
|
2102 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
|
|
2103 #if defined(FEAT_SEARCHPATH)
|
|
2104 (char_u *)&p_sua, PV_SUA,
|
|
2105 {(char_u *)"", (char_u *)0L}
|
|
2106 #else
|
|
2107 (char_u *)NULL, PV_NONE,
|
|
2108 {(char_u *)0L, (char_u *)0L}
|
|
2109 #endif
|
|
2110 },
|
|
2111 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
|
|
2112 (char_u *)&p_swf, PV_SWF,
|
|
2113 {(char_u *)TRUE, (char_u *)0L}},
|
|
2114 {"swapsync", "sws", P_STRING|P_VI_DEF,
|
|
2115 (char_u *)&p_sws, PV_NONE,
|
|
2116 {(char_u *)"fsync", (char_u *)0L}},
|
|
2117 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2118 (char_u *)&p_swb, PV_NONE,
|
|
2119 {(char_u *)"", (char_u *)0L}},
|
410
|
2120 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
|
|
2121 #ifdef FEAT_SYN_HL
|
|
2122 (char_u *)&p_smc, PV_SMC,
|
|
2123 {(char_u *)3000L, (char_u *)0L}
|
|
2124 #else
|
|
2125 (char_u *)NULL, PV_NONE,
|
|
2126 {(char_u *)0L, (char_u *)0L}
|
|
2127 #endif
|
|
2128 },
|
36
|
2129 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
|
7
|
2130 #ifdef FEAT_SYN_HL
|
|
2131 (char_u *)&p_syn, PV_SYN,
|
|
2132 {(char_u *)"", (char_u *)0L}
|
|
2133 #else
|
|
2134 (char_u *)NULL, PV_NONE,
|
|
2135 {(char_u *)0L, (char_u *)0L}
|
|
2136 #endif
|
|
2137 },
|
|
2138 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
|
|
2139 (char_u *)&p_ts, PV_TS,
|
|
2140 {(char_u *)8L, (char_u *)0L}},
|
|
2141 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
|
|
2142 (char_u *)&p_tbs, PV_NONE,
|
|
2143 #ifdef VMS /* binary searching doesn't appear to work on VMS */
|
|
2144 {(char_u *)0L, (char_u *)0L}
|
|
2145 #else
|
|
2146 {(char_u *)TRUE, (char_u *)0L}
|
|
2147 #endif
|
|
2148 },
|
|
2149 {"taglength", "tl", P_NUM|P_VI_DEF,
|
|
2150 (char_u *)&p_tl, PV_NONE,
|
|
2151 {(char_u *)0L, (char_u *)0L}},
|
|
2152 {"tagrelative", "tr", P_BOOL|P_VIM,
|
|
2153 (char_u *)&p_tr, PV_NONE,
|
|
2154 {(char_u *)FALSE, (char_u *)TRUE}},
|
|
2155 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2156 (char_u *)&p_tags, OPT_BOTH(PV_TAGS),
|
|
2157 {
|
|
2158 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
|
|
2159 (char_u *)"./tags,./TAGS,tags,TAGS",
|
|
2160 #else
|
|
2161 (char_u *)"./tags,tags",
|
|
2162 #endif
|
|
2163 (char_u *)0L}},
|
|
2164 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
|
|
2165 (char_u *)&p_tgst, PV_NONE,
|
|
2166 {(char_u *)TRUE, (char_u *)0L}},
|
|
2167 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
|
|
2168 (char_u *)&T_NAME, PV_NONE,
|
|
2169 {(char_u *)"", (char_u *)0L}},
|
|
2170 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
|
|
2171 #ifdef FEAT_ARABIC
|
|
2172 (char_u *)&p_tbidi, PV_NONE,
|
|
2173 #else
|
|
2174 (char_u *)NULL, PV_NONE,
|
|
2175 #endif
|
|
2176 {(char_u *)FALSE, (char_u *)0L}},
|
|
2177 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
|
|
2178 #ifdef FEAT_MBYTE
|
|
2179 (char_u *)&p_tenc, PV_NONE,
|
|
2180 {(char_u *)"", (char_u *)0L}
|
|
2181 #else
|
|
2182 (char_u *)NULL, PV_NONE,
|
|
2183 {(char_u *)0L, (char_u *)0L}
|
|
2184 #endif
|
|
2185 },
|
|
2186 {"terse", NULL, P_BOOL|P_VI_DEF,
|
|
2187 (char_u *)&p_terse, PV_NONE,
|
|
2188 {(char_u *)FALSE, (char_u *)0L}},
|
|
2189 {"textauto", "ta", P_BOOL|P_VIM,
|
|
2190 (char_u *)&p_ta, PV_NONE,
|
|
2191 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}},
|
|
2192 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
|
|
2193 (char_u *)&p_tx, PV_TX,
|
|
2194 {
|
|
2195 #ifdef USE_CRNL
|
|
2196 (char_u *)TRUE,
|
|
2197 #else
|
|
2198 (char_u *)FALSE,
|
|
2199 #endif
|
|
2200 (char_u *)0L}},
|
|
2201 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM,
|
|
2202 (char_u *)&p_tw, PV_TW,
|
|
2203 {(char_u *)0L, (char_u *)0L}},
|
|
2204 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2205 #ifdef FEAT_INS_EXPAND
|
|
2206 (char_u *)&p_tsr, OPT_BOTH(PV_TSR),
|
|
2207 #else
|
|
2208 (char_u *)NULL, PV_NONE,
|
|
2209 #endif
|
|
2210 {(char_u *)"", (char_u *)0L}},
|
|
2211 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
|
|
2212 (char_u *)&p_to, PV_NONE,
|
|
2213 {(char_u *)FALSE, (char_u *)0L}},
|
|
2214 {"timeout", "to", P_BOOL|P_VI_DEF,
|
|
2215 (char_u *)&p_timeout, PV_NONE,
|
|
2216 {(char_u *)TRUE, (char_u *)0L}},
|
|
2217 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
|
|
2218 (char_u *)&p_tm, PV_NONE,
|
|
2219 {(char_u *)1000L, (char_u *)0L}},
|
|
2220 {"title", NULL, P_BOOL|P_VI_DEF,
|
|
2221 #ifdef FEAT_TITLE
|
|
2222 (char_u *)&p_title, PV_NONE,
|
|
2223 #else
|
|
2224 (char_u *)NULL, PV_NONE,
|
|
2225 #endif
|
|
2226 {(char_u *)FALSE, (char_u *)0L}},
|
|
2227 {"titlelen", NULL, P_NUM|P_VI_DEF,
|
|
2228 #ifdef FEAT_TITLE
|
|
2229 (char_u *)&p_titlelen, PV_NONE,
|
|
2230 #else
|
|
2231 (char_u *)NULL, PV_NONE,
|
|
2232 #endif
|
|
2233 {(char_u *)85L, (char_u *)0L}},
|
36
|
2234 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE,
|
7
|
2235 #ifdef FEAT_TITLE
|
|
2236 (char_u *)&p_titleold, PV_NONE,
|
|
2237 {(char_u *)N_("Thanks for flying Vim"),
|
|
2238 (char_u *)0L}
|
|
2239 #else
|
|
2240 (char_u *)NULL, PV_NONE,
|
|
2241 {(char_u *)0L, (char_u *)0L}
|
|
2242 #endif
|
|
2243 },
|
|
2244 {"titlestring", NULL, P_STRING|P_VI_DEF,
|
|
2245 #ifdef FEAT_TITLE
|
|
2246 (char_u *)&p_titlestring, PV_NONE,
|
|
2247 #else
|
|
2248 (char_u *)NULL, PV_NONE,
|
|
2249 #endif
|
|
2250 {(char_u *)"", (char_u *)0L}},
|
|
2251 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
|
|
2252 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
|
|
2253 (char_u *)&p_toolbar, PV_NONE,
|
|
2254 {(char_u *)"icons,tooltips", (char_u *)0L}},
|
|
2255 #endif
|
|
2256 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
2257 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
|
|
2258 (char_u *)&p_tbis, PV_NONE,
|
|
2259 {(char_u *)"small", (char_u *)0L}},
|
|
2260 #endif
|
|
2261 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
|
|
2262 (char_u *)&p_ttimeout, PV_NONE,
|
|
2263 {(char_u *)FALSE, (char_u *)0L}},
|
|
2264 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
|
|
2265 (char_u *)&p_ttm, PV_NONE,
|
|
2266 {(char_u *)-1L, (char_u *)0L}},
|
|
2267 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
|
|
2268 (char_u *)&p_tbi, PV_NONE,
|
|
2269 {(char_u *)TRUE, (char_u *)0L}},
|
|
2270 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
|
|
2271 (char_u *)&p_tf, PV_NONE,
|
|
2272 {(char_u *)FALSE, (char_u *)0L}},
|
|
2273 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
|
|
2274 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
|
|
2275 (char_u *)&p_ttym, PV_NONE,
|
|
2276 #else
|
|
2277 (char_u *)NULL, PV_NONE,
|
|
2278 #endif
|
|
2279 {(char_u *)"", (char_u *)0L}},
|
|
2280 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
|
|
2281 (char_u *)&p_ttyscroll, PV_NONE,
|
|
2282 {(char_u *)999L, (char_u *)0L}},
|
|
2283 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
|
|
2284 (char_u *)&T_NAME, PV_NONE,
|
|
2285 {(char_u *)"", (char_u *)0L}},
|
|
2286 {"undolevels", "ul", P_NUM|P_VI_DEF,
|
|
2287 (char_u *)&p_ul, PV_NONE,
|
|
2288 {
|
|
2289 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
|
|
2290 (char_u *)1000L,
|
|
2291 #else
|
|
2292 (char_u *)100L,
|
|
2293 #endif
|
|
2294 (char_u *)0L}},
|
|
2295 {"updatecount", "uc", P_NUM|P_VI_DEF,
|
|
2296 (char_u *)&p_uc, PV_NONE,
|
|
2297 {(char_u *)200L, (char_u *)0L}},
|
|
2298 {"updatetime", "ut", P_NUM|P_VI_DEF,
|
|
2299 (char_u *)&p_ut, PV_NONE,
|
|
2300 {(char_u *)4000L, (char_u *)0L}},
|
|
2301 {"verbose", "vbs", P_NUM|P_VI_DEF,
|
|
2302 (char_u *)&p_verbose, PV_NONE,
|
|
2303 {(char_u *)0L, (char_u *)0L}},
|
294
|
2304 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
2305 (char_u *)&p_vfile, PV_NONE,
|
|
2306 {(char_u *)"", (char_u *)0L}},
|
7
|
2307 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
|
2308 #ifdef FEAT_SESSION
|
|
2309 (char_u *)&p_vdir, PV_NONE,
|
|
2310 {(char_u *)DFLT_VDIR, (char_u *)0L}
|
|
2311 #else
|
|
2312 (char_u *)NULL, PV_NONE,
|
|
2313 {(char_u *)0L, (char_u *)0L}
|
|
2314 #endif
|
|
2315 },
|
|
2316 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2317 #ifdef FEAT_SESSION
|
|
2318 (char_u *)&p_vop, PV_NONE,
|
|
2319 {(char_u *)"folds,options,cursor", (char_u *)0L}
|
|
2320 #else
|
|
2321 (char_u *)NULL, PV_NONE,
|
|
2322 {(char_u *)0L, (char_u *)0L}
|
|
2323 #endif
|
|
2324 },
|
|
2325 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
|
|
2326 #ifdef FEAT_VIMINFO
|
|
2327 (char_u *)&p_viminfo, PV_NONE,
|
|
2328 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
|
|
2329 {(char_u *)"", (char_u *)"'20,<50,s10,h,rA:,rB:"}
|
|
2330 #else
|
|
2331 # ifdef AMIGA
|
|
2332 {(char_u *)"",
|
|
2333 (char_u *)"'20,<50,s10,h,rdf0:,rdf1:,rdf2:"}
|
|
2334 # else
|
|
2335 {(char_u *)"", (char_u *)"'20,<50,s10,h"}
|
|
2336 # endif
|
|
2337 #endif
|
|
2338 #else
|
|
2339 (char_u *)NULL, PV_NONE,
|
|
2340 {(char_u *)0L, (char_u *)0L}
|
|
2341 #endif
|
|
2342 },
|
|
2343 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM,
|
|
2344 #ifdef FEAT_VIRTUALEDIT
|
|
2345 (char_u *)&p_ve, PV_NONE,
|
|
2346 {(char_u *)"", (char_u *)""}
|
|
2347 #else
|
|
2348 (char_u *)NULL, PV_NONE,
|
|
2349 {(char_u *)0L, (char_u *)0L}
|
|
2350 #endif
|
|
2351 },
|
|
2352 {"visualbell", "vb", P_BOOL|P_VI_DEF,
|
|
2353 (char_u *)&p_vb, PV_NONE,
|
|
2354 {(char_u *)FALSE, (char_u *)0L}},
|
|
2355 {"w300", NULL, P_NUM|P_VI_DEF,
|
|
2356 (char_u *)NULL, PV_NONE,
|
|
2357 {(char_u *)0L, (char_u *)0L}},
|
|
2358 {"w1200", NULL, P_NUM|P_VI_DEF,
|
|
2359 (char_u *)NULL, PV_NONE,
|
|
2360 {(char_u *)0L, (char_u *)0L}},
|
|
2361 {"w9600", NULL, P_NUM|P_VI_DEF,
|
|
2362 (char_u *)NULL, PV_NONE,
|
|
2363 {(char_u *)0L, (char_u *)0L}},
|
|
2364 {"warn", NULL, P_BOOL|P_VI_DEF,
|
|
2365 (char_u *)&p_warn, PV_NONE,
|
|
2366 {(char_u *)TRUE, (char_u *)0L}},
|
|
2367 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
|
|
2368 (char_u *)&p_wiv, PV_NONE,
|
|
2369 {(char_u *)FALSE, (char_u *)0L}},
|
|
2370 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
|
|
2371 (char_u *)&p_ww, PV_NONE,
|
|
2372 {(char_u *)"", (char_u *)"b,s"}},
|
|
2373 {"wildchar", "wc", P_NUM|P_VIM,
|
|
2374 (char_u *)&p_wc, PV_NONE,
|
|
2375 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}},
|
|
2376 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
|
|
2377 (char_u *)&p_wcm, PV_NONE,
|
|
2378 {(char_u *)0L, (char_u *)0L}},
|
|
2379 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2380 #ifdef FEAT_WILDIGN
|
|
2381 (char_u *)&p_wig, PV_NONE,
|
|
2382 #else
|
|
2383 (char_u *)NULL, PV_NONE,
|
|
2384 #endif
|
|
2385 {(char_u *)"", (char_u *)0L}},
|
|
2386 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
|
|
2387 #ifdef FEAT_WILDMENU
|
|
2388 (char_u *)&p_wmnu, PV_NONE,
|
|
2389 #else
|
|
2390 (char_u *)NULL, PV_NONE,
|
|
2391 #endif
|
|
2392 {(char_u *)FALSE, (char_u *)0L}},
|
|
2393 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
|
|
2394 (char_u *)&p_wim, PV_NONE,
|
|
2395 {(char_u *)"full", (char_u *)0L}},
|
40
|
2396 {"wildoptions", "wop", P_STRING|P_VI_DEF,
|
|
2397 #ifdef FEAT_CMDL_COMPL
|
|
2398 (char_u *)&p_wop, PV_NONE,
|
|
2399 {(char_u *)"", (char_u *)0L}
|
|
2400 #else
|
|
2401 (char_u *)NULL, PV_NONE,
|
|
2402 {(char_u *)NULL, (char_u *)0L}
|
|
2403 #endif
|
|
2404 },
|
7
|
2405 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
|
|
2406 #ifdef FEAT_WAK
|
|
2407 (char_u *)&p_wak, PV_NONE,
|
|
2408 {(char_u *)"menu", (char_u *)0L}
|
|
2409 #else
|
|
2410 (char_u *)NULL, PV_NONE,
|
|
2411 {(char_u *)NULL, (char_u *)0L}
|
|
2412 #endif
|
|
2413 },
|
|
2414 {"window", "wi", P_NUM|P_VI_DEF,
|
164
|
2415 (char_u *)&p_window, PV_NONE,
|
7
|
2416 {(char_u *)0L, (char_u *)0L}},
|
|
2417 {"winheight", "wh", P_NUM|P_VI_DEF,
|
|
2418 #ifdef FEAT_WINDOWS
|
|
2419 (char_u *)&p_wh, PV_NONE,
|
|
2420 #else
|
|
2421 (char_u *)NULL, PV_NONE,
|
|
2422 #endif
|
|
2423 {(char_u *)1L, (char_u *)0L}},
|
|
2424 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
|
|
2425 #if defined(FEAT_WINDOWS)
|
|
2426 (char_u *)VAR_WIN, PV_WFH,
|
|
2427 #else
|
|
2428 (char_u *)NULL, PV_NONE,
|
|
2429 #endif
|
|
2430 {(char_u *)FALSE, (char_u *)0L}},
|
|
2431 {"winminheight", "wmh", P_NUM|P_VI_DEF,
|
|
2432 #ifdef FEAT_WINDOWS
|
|
2433 (char_u *)&p_wmh, PV_NONE,
|
|
2434 #else
|
|
2435 (char_u *)NULL, PV_NONE,
|
|
2436 #endif
|
|
2437 {(char_u *)1L, (char_u *)0L}},
|
|
2438 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
|
|
2439 #ifdef FEAT_VERTSPLIT
|
|
2440 (char_u *)&p_wmw, PV_NONE,
|
|
2441 #else
|
|
2442 (char_u *)NULL, PV_NONE,
|
|
2443 #endif
|
|
2444 {(char_u *)1L, (char_u *)0L}},
|
|
2445 {"winwidth", "wiw", P_NUM|P_VI_DEF,
|
|
2446 #ifdef FEAT_VERTSPLIT
|
|
2447 (char_u *)&p_wiw, PV_NONE,
|
|
2448 #else
|
|
2449 (char_u *)NULL, PV_NONE,
|
|
2450 #endif
|
|
2451 {(char_u *)20L, (char_u *)0L}},
|
|
2452 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
|
|
2453 (char_u *)VAR_WIN, PV_WRAP,
|
|
2454 {(char_u *)TRUE, (char_u *)0L}},
|
|
2455 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
|
|
2456 (char_u *)&p_wm, PV_WM,
|
|
2457 {(char_u *)0L, (char_u *)0L}},
|
|
2458 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
|
|
2459 (char_u *)&p_ws, PV_NONE,
|
|
2460 {(char_u *)TRUE, (char_u *)0L}},
|
|
2461 {"write", NULL, P_BOOL|P_VI_DEF,
|
|
2462 (char_u *)&p_write, PV_NONE,
|
|
2463 {(char_u *)TRUE, (char_u *)0L}},
|
|
2464 {"writeany", "wa", P_BOOL|P_VI_DEF,
|
|
2465 (char_u *)&p_wa, PV_NONE,
|
|
2466 {(char_u *)FALSE, (char_u *)0L}},
|
|
2467 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
|
|
2468 (char_u *)&p_wb, PV_NONE,
|
|
2469 {
|
|
2470 #ifdef FEAT_WRITEBACKUP
|
|
2471 (char_u *)TRUE,
|
|
2472 #else
|
|
2473 (char_u *)FALSE,
|
|
2474 #endif
|
|
2475 (char_u *)0L}},
|
|
2476 {"writedelay", "wd", P_NUM|P_VI_DEF,
|
|
2477 (char_u *)&p_wd, PV_NONE,
|
|
2478 {(char_u *)0L, (char_u *)0L}},
|
|
2479
|
|
2480 /* terminal output codes */
|
36
|
2481 #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
|
7
|
2482 (char_u *)&vvv, PV_NONE, \
|
|
2483 {(char_u *)"", (char_u *)0L}},
|
|
2484
|
|
2485 p_term("t_AB", T_CAB)
|
|
2486 p_term("t_AF", T_CAF)
|
|
2487 p_term("t_AL", T_CAL)
|
|
2488 p_term("t_al", T_AL)
|
|
2489 p_term("t_bc", T_BC)
|
|
2490 p_term("t_cd", T_CD)
|
|
2491 p_term("t_ce", T_CE)
|
|
2492 p_term("t_cl", T_CL)
|
|
2493 p_term("t_cm", T_CM)
|
|
2494 p_term("t_Co", T_CCO)
|
|
2495 p_term("t_CS", T_CCS)
|
|
2496 p_term("t_cs", T_CS)
|
|
2497 #ifdef FEAT_VERTSPLIT
|
|
2498 p_term("t_CV", T_CSV)
|
|
2499 #endif
|
|
2500 p_term("t_ut", T_UT)
|
|
2501 p_term("t_da", T_DA)
|
|
2502 p_term("t_db", T_DB)
|
|
2503 p_term("t_DL", T_CDL)
|
|
2504 p_term("t_dl", T_DL)
|
|
2505 p_term("t_fs", T_FS)
|
|
2506 p_term("t_IE", T_CIE)
|
|
2507 p_term("t_IS", T_CIS)
|
|
2508 p_term("t_ke", T_KE)
|
|
2509 p_term("t_ks", T_KS)
|
|
2510 p_term("t_le", T_LE)
|
|
2511 p_term("t_mb", T_MB)
|
|
2512 p_term("t_md", T_MD)
|
|
2513 p_term("t_me", T_ME)
|
|
2514 p_term("t_mr", T_MR)
|
|
2515 p_term("t_ms", T_MS)
|
|
2516 p_term("t_nd", T_ND)
|
|
2517 p_term("t_op", T_OP)
|
|
2518 p_term("t_RI", T_CRI)
|
|
2519 p_term("t_RV", T_CRV)
|
|
2520 p_term("t_Sb", T_CSB)
|
|
2521 p_term("t_Sf", T_CSF)
|
|
2522 p_term("t_se", T_SE)
|
|
2523 p_term("t_so", T_SO)
|
|
2524 p_term("t_sr", T_SR)
|
|
2525 p_term("t_ts", T_TS)
|
|
2526 p_term("t_te", T_TE)
|
|
2527 p_term("t_ti", T_TI)
|
|
2528 p_term("t_ue", T_UE)
|
|
2529 p_term("t_us", T_US)
|
|
2530 p_term("t_vb", T_VB)
|
|
2531 p_term("t_ve", T_VE)
|
|
2532 p_term("t_vi", T_VI)
|
|
2533 p_term("t_vs", T_VS)
|
|
2534 p_term("t_WP", T_CWP)
|
|
2535 p_term("t_WS", T_CWS)
|
36
|
2536 p_term("t_SI", T_CSI)
|
|
2537 p_term("t_EI", T_CEI)
|
7
|
2538 p_term("t_xs", T_XS)
|
|
2539 p_term("t_ZH", T_CZH)
|
|
2540 p_term("t_ZR", T_CZR)
|
|
2541
|
|
2542 /* terminal key codes are not in here */
|
|
2543
|
|
2544 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL}} /* end marker */
|
|
2545 };
|
|
2546
|
|
2547 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
|
|
2548
|
|
2549 #ifdef FEAT_MBYTE
|
|
2550 static char *(p_ambw_values[]) = {"single", "double", NULL};
|
|
2551 #endif
|
|
2552 static char *(p_bg_values[]) = {"light", "dark", NULL};
|
|
2553 static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
|
|
2554 static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
|
40
|
2555 #ifdef FEAT_CMDL_COMPL
|
|
2556 static char *(p_wop_values[]) = {"tagfile", NULL};
|
|
2557 #endif
|
7
|
2558 #ifdef FEAT_WAK
|
|
2559 static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
|
|
2560 #endif
|
|
2561 static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
|
|
2562 #ifdef FEAT_VISUAL
|
|
2563 static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
|
|
2564 static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
|
|
2565 #endif
|
|
2566 #ifdef FEAT_VISUAL
|
|
2567 static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
|
|
2568 #endif
|
|
2569 #ifdef FEAT_BROWSE
|
|
2570 static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
|
|
2571 #endif
|
|
2572 #ifdef FEAT_SCROLLBIND
|
|
2573 static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
|
|
2574 #endif
|
|
2575 static char *(p_swb_values[]) = {"useopen", "split", NULL};
|
168
|
2576 static char *(p_debug_values[]) = {"msg", "beep", NULL};
|
7
|
2577 #ifdef FEAT_VERTSPLIT
|
|
2578 static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
|
|
2579 #endif
|
|
2580 #if defined(FEAT_QUICKFIX)
|
17
|
2581 # ifdef FEAT_AUTOCMD
|
|
2582 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
|
|
2583 # else
|
7
|
2584 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
|
17
|
2585 # endif
|
7
|
2586 static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
|
|
2587 #endif
|
|
2588 static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
|
|
2589 #ifdef FEAT_FOLDING
|
|
2590 static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
|
|
2591 #ifdef FEAT_DIFF
|
|
2592 "diff",
|
|
2593 #endif
|
|
2594 NULL};
|
|
2595 static char *(p_fcl_values[]) = {"all", NULL};
|
|
2596 #endif
|
|
2597
|
|
2598 static void set_option_default __ARGS((int, int opt_flags, int compatible));
|
|
2599 static void set_options_default __ARGS((int opt_flags));
|
|
2600 static char_u *illegal_char __ARGS((char_u *, int));
|
|
2601 static int string_to_key __ARGS((char_u *arg));
|
|
2602 #ifdef FEAT_CMDWIN
|
|
2603 static char_u *check_cedit __ARGS((void));
|
|
2604 #endif
|
|
2605 #ifdef FEAT_TITLE
|
|
2606 static void did_set_title __ARGS((int icon));
|
|
2607 #endif
|
|
2608 static char_u *option_expand __ARGS((int opt_idx, char_u *val));
|
|
2609 static void didset_options __ARGS((void));
|
|
2610 static void check_string_option __ARGS((char_u **pp));
|
|
2611 static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
|
|
2612 static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
|
|
2613 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));
|
|
2614 static char_u *set_chars_option __ARGS((char_u **varp));
|
|
2615 #ifdef FEAT_CLIPBOARD
|
|
2616 static char_u *check_clipboard_option __ARGS((void));
|
|
2617 #endif
|
386
|
2618 #ifdef FEAT_SYN_HL
|
389
|
2619 static char_u *compile_cap_prog __ARGS((buf_T *buf));
|
386
|
2620 #endif
|
7
|
2621 static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
|
274
|
2622 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
|
2623 static void check_redraw __ARGS((long_u flags));
|
|
2624 static int findoption __ARGS((char_u *));
|
|
2625 static int find_key_option __ARGS((char_u *));
|
|
2626 static void showoptions __ARGS((int all, int opt_flags));
|
|
2627 static int optval_default __ARGS((struct vimoption *, char_u *varp));
|
|
2628 static void showoneopt __ARGS((struct vimoption *, int opt_flags));
|
|
2629 static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
|
|
2630 static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
|
|
2631 static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
|
|
2632 static int istermoption __ARGS((struct vimoption *));
|
|
2633 static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
|
|
2634 static char_u *get_varp __ARGS((struct vimoption *));
|
|
2635 static void option_value2string __ARGS((struct vimoption *, int opt_flags));
|
|
2636 static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
|
|
2637 #ifdef FEAT_LANGMAP
|
|
2638 static void langmap_init __ARGS((void));
|
|
2639 static void langmap_set __ARGS((void));
|
|
2640 #endif
|
|
2641 static void paste_option_changed __ARGS((void));
|
|
2642 static void compatible_set __ARGS((void));
|
|
2643 #ifdef FEAT_LINEBREAK
|
|
2644 static void fill_breakat_flags __ARGS((void));
|
|
2645 #endif
|
|
2646 static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
|
|
2647 static int check_opt_strings __ARGS((char_u *val, char **values, int));
|
|
2648 static int check_opt_wim __ARGS((void));
|
|
2649
|
|
2650 /*
|
|
2651 * Initialize the options, first part.
|
|
2652 *
|
|
2653 * Called only once from main(), just after creating the first buffer.
|
|
2654 */
|
|
2655 void
|
|
2656 set_init_1()
|
|
2657 {
|
|
2658 char_u *p;
|
|
2659 int opt_idx;
|
|
2660 long n;
|
|
2661
|
|
2662 #ifdef FEAT_LANGMAP
|
|
2663 langmap_init();
|
|
2664 #endif
|
|
2665
|
|
2666 /* Be Vi compatible by default */
|
|
2667 p_cp = TRUE;
|
|
2668
|
164
|
2669 /* Use POSIX compatibility when $VIM_POSIX is set. */
|
|
2670 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
|
168
|
2671 {
|
164
|
2672 set_string_default("cpo", (char_u *)CPO_ALL);
|
168
|
2673 set_string_default("shm", (char_u *)"A");
|
|
2674 }
|
164
|
2675
|
7
|
2676 /*
|
|
2677 * Find default value for 'shell' option.
|
161
|
2678 * Don't use it if it is empty.
|
7
|
2679 */
|
161
|
2680 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
|
7
|
2681 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
|
|
2682 # ifdef __EMX__
|
161
|
2683 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
|
7
|
2684 # endif
|
161
|
2685 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
|
7
|
2686 # ifdef WIN3264
|
161
|
2687 || ((p = default_shell()) != NULL && *p != NUL)
|
7
|
2688 # endif
|
|
2689 #endif
|
161
|
2690 )
|
7
|
2691 set_string_default("sh", p);
|
|
2692
|
|
2693 #ifdef FEAT_WILDIGN
|
|
2694 /*
|
|
2695 * Set the default for 'backupskip' to include environment variables for
|
|
2696 * temp files.
|
|
2697 */
|
|
2698 {
|
|
2699 # ifdef UNIX
|
|
2700 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
|
|
2701 # else
|
|
2702 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
|
|
2703 # endif
|
170
|
2704 int len;
|
|
2705 garray_T ga;
|
|
2706 int mustfree;
|
7
|
2707
|
|
2708 ga_init2(&ga, 1, 100);
|
|
2709 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
|
|
2710 {
|
170
|
2711 mustfree = FALSE;
|
7
|
2712 # ifdef UNIX
|
|
2713 if (*names[n] == NUL)
|
|
2714 p = (char_u *)"/tmp";
|
|
2715 else
|
|
2716 # endif
|
170
|
2717 p = vim_getenv((char_u *)names[n], &mustfree);
|
7
|
2718 if (p != NULL && *p != NUL)
|
|
2719 {
|
|
2720 /* First time count the NUL, otherwise count the ','. */
|
|
2721 len = STRLEN(p) + 3;
|
|
2722 if (ga_grow(&ga, len) == OK)
|
|
2723 {
|
|
2724 if (ga.ga_len > 0)
|
|
2725 STRCAT(ga.ga_data, ",");
|
|
2726 STRCAT(ga.ga_data, p);
|
|
2727 add_pathsep(ga.ga_data);
|
|
2728 STRCAT(ga.ga_data, "*");
|
|
2729 ga.ga_len += len;
|
|
2730 }
|
|
2731 }
|
170
|
2732 if (mustfree)
|
|
2733 vim_free(p);
|
7
|
2734 }
|
|
2735 if (ga.ga_data != NULL)
|
|
2736 {
|
|
2737 set_string_default("bsk", ga.ga_data);
|
|
2738 vim_free(ga.ga_data);
|
|
2739 }
|
|
2740 }
|
|
2741 #endif
|
|
2742
|
|
2743 /*
|
|
2744 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
|
|
2745 */
|
|
2746 opt_idx = findoption((char_u *)"maxmemtot");
|
|
2747 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
|
|
2748 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
|
|
2749 #endif
|
|
2750 {
|
|
2751 #ifdef HAVE_AVAIL_MEM
|
|
2752 /* Use amount of memory available at this moment. */
|
|
2753 n = (mch_avail_mem(FALSE) >> 11);
|
|
2754 #else
|
|
2755 # ifdef HAVE_TOTAL_MEM
|
|
2756 /* Use amount of memory available to Vim. */
|
|
2757 n = (mch_total_mem(FALSE) >> 11);
|
|
2758 # else
|
|
2759 n = (0x7fffffff >> 11);
|
|
2760 # endif
|
|
2761 #endif
|
|
2762 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
|
|
2763 opt_idx = findoption((char_u *)"maxmem");
|
|
2764 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
|
|
2765 if ((long)options[opt_idx].def_val[VI_DEFAULT] > n
|
|
2766 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
|
|
2767 #endif
|
|
2768 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
|
|
2769 }
|
|
2770
|
|
2771 #ifdef FEAT_GUI_W32
|
|
2772 /* force 'shortname' for Win32s */
|
|
2773 if (gui_is_win32s())
|
|
2774 options[findoption((char_u *)"shortname")].def_val[VI_DEFAULT] =
|
|
2775 (char_u *)TRUE;
|
|
2776 #endif
|
|
2777
|
|
2778 #ifdef FEAT_SEARCHPATH
|
|
2779 {
|
|
2780 char_u *cdpath;
|
|
2781 char_u *buf;
|
|
2782 int i;
|
|
2783 int j;
|
170
|
2784 int mustfree = FALSE;
|
7
|
2785
|
|
2786 /* Initialize the 'cdpath' option's default value. */
|
170
|
2787 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
|
7
|
2788 if (cdpath != NULL)
|
|
2789 {
|
|
2790 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
|
|
2791 if (buf != NULL)
|
|
2792 {
|
|
2793 buf[0] = ','; /* start with ",", current dir first */
|
|
2794 j = 1;
|
|
2795 for (i = 0; cdpath[i] != NUL; ++i)
|
|
2796 {
|
|
2797 if (vim_ispathlistsep(cdpath[i]))
|
|
2798 buf[j++] = ',';
|
|
2799 else
|
|
2800 {
|
|
2801 if (cdpath[i] == ' ' || cdpath[i] == ',')
|
|
2802 buf[j++] = '\\';
|
|
2803 buf[j++] = cdpath[i];
|
|
2804 }
|
|
2805 }
|
|
2806 buf[j] = NUL;
|
|
2807 opt_idx = findoption((char_u *)"cdpath");
|
|
2808 options[opt_idx].def_val[VI_DEFAULT] = buf;
|
|
2809 options[opt_idx].flags |= P_DEF_ALLOCED;
|
|
2810 }
|
170
|
2811 if (mustfree)
|
|
2812 vim_free(cdpath);
|
7
|
2813 }
|
|
2814 }
|
|
2815 #endif
|
|
2816
|
|
2817 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
|
|
2818 /* Set print encoding on platforms that don't default to latin1 */
|
|
2819 set_string_default("penc",
|
|
2820 # if defined(MSWIN) || defined(OS2)
|
|
2821 (char_u *)"cp1252"
|
|
2822 # else
|
|
2823 # ifdef VMS
|
|
2824 (char_u *)"dec-mcs"
|
|
2825 # else
|
|
2826 # ifdef EBCDIC
|
|
2827 (char_u *)"ebcdic-uk"
|
|
2828 # else
|
|
2829 # ifdef MAC
|
|
2830 (char_u *)"mac-roman"
|
|
2831 # else /* HPUX */
|
|
2832 (char_u *)"hp-roman8"
|
|
2833 # endif
|
|
2834 # endif
|
|
2835 # endif
|
|
2836 # endif
|
|
2837 );
|
|
2838 #endif
|
|
2839
|
|
2840 #ifdef FEAT_POSTSCRIPT
|
|
2841 /* 'printexpr' must be allocated to be able to evaluate it. */
|
|
2842 set_string_default("pexpr",
|
8
|
2843 # if defined(MSWIN) || defined(MSDOS) || defined(OS2)
|
|
2844 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
|
7
|
2845 # else
|
|
2846 # ifdef VMS
|
|
2847 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
|
|
2848
|
|
2849 # else
|
|
2850 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
|
|
2851 # endif
|
|
2852 # endif
|
|
2853 );
|
|
2854 #endif
|
|
2855
|
|
2856 /*
|
|
2857 * Set all the options (except the terminal options) to their default
|
|
2858 * value. Also set the global value for local options.
|
|
2859 */
|
|
2860 set_options_default(0);
|
|
2861
|
|
2862 #ifdef FEAT_GUI
|
|
2863 if (found_reverse_arg)
|
|
2864 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
|
|
2865 #endif
|
|
2866
|
|
2867 curbuf->b_p_initialized = TRUE;
|
|
2868 curbuf->b_p_ar = -1; /* no local 'autoread' value */
|
|
2869 check_buf_options(curbuf);
|
|
2870 check_win_options(curwin);
|
|
2871 check_options();
|
|
2872
|
|
2873 /* Must be before option_expand(), because that one needs vim_isIDc() */
|
|
2874 didset_options();
|
|
2875
|
227
|
2876 #ifdef FEAT_SYN_HL
|
|
2877 /* Use the current chartab for the generic chartab. */
|
|
2878 init_spell_chartab();
|
|
2879 #endif
|
|
2880
|
7
|
2881 #ifdef FEAT_LINEBREAK
|
|
2882 /*
|
|
2883 * initialize the table for 'breakat'.
|
|
2884 */
|
|
2885 fill_breakat_flags();
|
|
2886 #endif
|
|
2887
|
|
2888 /*
|
|
2889 * Expand environment variables and things like "~" for the defaults.
|
|
2890 * If option_expand() returns non-NULL the variable is expanded. This can
|
|
2891 * only happen for non-indirect options.
|
|
2892 * Also set the default to the expanded value, so ":set" does not list
|
|
2893 * them.
|
|
2894 * Don't set the P_ALLOCED flag, because we don't want to free the
|
|
2895 * default.
|
|
2896 */
|
|
2897 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
|
|
2898 {
|
|
2899 if ((options[opt_idx].flags & P_GETTEXT)
|
|
2900 && options[opt_idx].var != NULL)
|
|
2901 p = (char_u *)_(*(char **)options[opt_idx].var);
|
|
2902 else
|
|
2903 p = option_expand(opt_idx, NULL);
|
|
2904 if (p != NULL && (p = vim_strsave(p)) != NULL)
|
|
2905 {
|
|
2906 *(char_u **)options[opt_idx].var = p;
|
|
2907 /* VIMEXP
|
|
2908 * Defaults for all expanded options are currently the same for Vi
|
|
2909 * and Vim. When this changes, add some code here! Also need to
|
|
2910 * split P_DEF_ALLOCED in two.
|
|
2911 */
|
|
2912 if (options[opt_idx].flags & P_DEF_ALLOCED)
|
|
2913 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
|
|
2914 options[opt_idx].def_val[VI_DEFAULT] = p;
|
|
2915 options[opt_idx].flags |= P_DEF_ALLOCED;
|
|
2916 }
|
|
2917 }
|
|
2918
|
|
2919 /* Initialize the highlight_attr[] table. */
|
|
2920 highlight_changed();
|
|
2921
|
|
2922 save_file_ff(curbuf); /* Buffer is unchanged */
|
|
2923
|
|
2924 /* Parse default for 'wildmode' */
|
|
2925 check_opt_wim();
|
|
2926
|
|
2927 #if defined(FEAT_ARABIC)
|
|
2928 /* Detect use of mlterm.
|
|
2929 * Mlterm is a terminal emulator akin to xterm that has some special
|
|
2930 * abilities (bidi namely).
|
|
2931 * NOTE: mlterm's author is being asked to 'set' a variable
|
|
2932 * instead of an environment variable due to inheritance.
|
|
2933 */
|
|
2934 if (mch_getenv((char_u *)"MLTERM") != NULL)
|
|
2935 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
|
|
2936 #endif
|
|
2937
|
|
2938 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
2939 /* Parse default for 'fillchars'. */
|
|
2940 (void)set_chars_option(&p_fcs);
|
|
2941 #endif
|
|
2942
|
|
2943 #ifdef FEAT_CLIPBOARD
|
|
2944 /* Parse default for 'clipboard' */
|
|
2945 (void)check_clipboard_option();
|
|
2946 #endif
|
|
2947
|
|
2948 #ifdef FEAT_MBYTE
|
|
2949 # if defined(WIN3264) && defined(FEAT_GETTEXT)
|
|
2950 /*
|
|
2951 * If $LANG isn't set, try to get a good value for it. This makes the
|
|
2952 * right language be used automatically. Don't do this for English.
|
|
2953 */
|
|
2954 if (mch_getenv((char_u *)"LANG") == NULL)
|
|
2955 {
|
|
2956 char buf[20];
|
|
2957
|
|
2958 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
|
|
2959 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
|
|
2960 * only the first two. */
|
|
2961 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
|
|
2962 (LPTSTR)buf, 20);
|
|
2963 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
|
|
2964 {
|
|
2965 /* There are a few exceptions (probably more) */
|
|
2966 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
|
|
2967 STRCPY(buf, "zh_TW");
|
|
2968 else if (STRNICMP(buf, "chs", 3) == 0
|
|
2969 || STRNICMP(buf, "zhc", 3) == 0)
|
|
2970 STRCPY(buf, "zh_CN");
|
|
2971 else if (STRNICMP(buf, "jp", 2) == 0)
|
|
2972 STRCPY(buf, "ja");
|
|
2973 else
|
|
2974 buf[2] = NUL; /* truncate to two-letter code */
|
|
2975 vim_setenv("LANG", buf);
|
|
2976 }
|
|
2977 }
|
168
|
2978 # else
|
|
2979 # ifdef MACOS
|
|
2980 if (mch_getenv((char_u *)"LANG") == NULL)
|
|
2981 {
|
|
2982 char buf[20];
|
|
2983 if (LocaleRefGetPartString(NULL,
|
|
2984 kLocaleLanguageMask | kLocaleLanguageVariantMask |
|
|
2985 kLocaleRegionMask | kLocaleRegionVariantMask,
|
|
2986 sizeof buf, buf) == noErr && *buf)
|
|
2987 {
|
|
2988 vim_setenv("LANG", buf);
|
|
2989 # ifdef HAVE_LOCALE_H
|
|
2990 setlocale(LC_ALL, "");
|
|
2991 # endif
|
|
2992 }
|
|
2993 }
|
|
2994 # endif
|
7
|
2995 # endif
|
|
2996
|
|
2997 /* enc_locale() will try to find the encoding of the current locale. */
|
|
2998 p = enc_locale();
|
|
2999 if (p != NULL)
|
|
3000 {
|
|
3001 char_u *save_enc;
|
|
3002
|
|
3003 /* Try setting 'encoding' and check if the value is valid.
|
|
3004 * If not, go back to the default "latin1". */
|
|
3005 save_enc = p_enc;
|
|
3006 p_enc = p;
|
|
3007 if (mb_init() == NULL)
|
|
3008 {
|
|
3009 opt_idx = findoption((char_u *)"encoding");
|
|
3010 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
|
|
3011 options[opt_idx].flags |= P_DEF_ALLOCED;
|
|
3012
|
24
|
3013 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
|
|
3014 || defined(VMS)
|
|
3015 if (STRCMP(p_enc, "latin1") == 0
|
|
3016 # ifdef FEAT_MBYTE
|
|
3017 || enc_utf8
|
|
3018 # endif
|
|
3019 )
|
|
3020 {
|
|
3021 /* Adjust the default for 'isprint' to match latin1. */
|
|
3022 set_string_option_direct((char_u *)"isp", -1,
|
|
3023 (char_u *)"@,161-255", OPT_FREE);
|
|
3024 (void)init_chartab();
|
|
3025 }
|
|
3026 #endif
|
|
3027
|
7
|
3028 # if defined(WIN3264) && !defined(FEAT_GUI)
|
|
3029 /* Win32 console: When GetACP() returns a different value from
|
|
3030 * GetConsoleCP() set 'termencoding'. */
|
|
3031 if (GetACP() != GetConsoleCP())
|
|
3032 {
|
|
3033 char buf[50];
|
|
3034
|
|
3035 sprintf(buf, "cp%ld", (long)GetConsoleCP());
|
|
3036 p_tenc = vim_strsave((char_u *)buf);
|
|
3037 if (p_tenc != NULL)
|
|
3038 {
|
|
3039 opt_idx = findoption((char_u *)"termencoding");
|
|
3040 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
|
|
3041 options[opt_idx].flags |= P_DEF_ALLOCED;
|
|
3042 convert_setup(&input_conv, p_tenc, p_enc);
|
|
3043 convert_setup(&output_conv, p_enc, p_tenc);
|
|
3044 }
|
|
3045 else
|
|
3046 p_tenc = empty_option;
|
|
3047 }
|
|
3048 # endif
|
170
|
3049 # if defined(WIN3264) && defined(FEAT_MBYTE)
|
|
3050 /* $HOME may have characters in active code page. */
|
|
3051 init_homedir();
|
|
3052 # endif
|
7
|
3053 }
|
|
3054 else
|
|
3055 {
|
|
3056 vim_free(p_enc);
|
|
3057 p_enc = save_enc;
|
|
3058 }
|
|
3059 }
|
|
3060 #endif
|
|
3061
|
|
3062 #ifdef FEAT_MULTI_LANG
|
|
3063 /* Set the default for 'helplang'. */
|
|
3064 set_helplang_default(get_mess_lang());
|
|
3065 #endif
|
|
3066 }
|
|
3067
|
|
3068 /*
|
|
3069 * Set an option to its default value.
|
|
3070 * This does not take care of side effects!
|
|
3071 */
|
|
3072 static void
|
|
3073 set_option_default(opt_idx, opt_flags, compatible)
|
|
3074 int opt_idx;
|
|
3075 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
|
|
3076 int compatible; /* use Vi default value */
|
|
3077 {
|
|
3078 char_u *varp; /* pointer to variable for current option */
|
|
3079 int dvi; /* index in def_val[] */
|
|
3080 long_u flags;
|
|
3081 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
|
|
3082
|
|
3083 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
|
|
3084 flags = options[opt_idx].flags;
|
320
|
3085 if (varp != NULL) /* skip hidden option, nothing to do for it */
|
7
|
3086 {
|
|
3087 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
|
|
3088 if (flags & P_STRING)
|
|
3089 {
|
|
3090 /* Use set_string_option_direct() for local options to handle
|
|
3091 * freeing and allocating the value. */
|
|
3092 if (options[opt_idx].indir != PV_NONE)
|
|
3093 set_string_option_direct(NULL, opt_idx,
|
|
3094 options[opt_idx].def_val[dvi], opt_flags);
|
|
3095 else
|
|
3096 {
|
|
3097 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
|
|
3098 free_string_option(*(char_u **)(varp));
|
|
3099 *(char_u **)varp = options[opt_idx].def_val[dvi];
|
|
3100 options[opt_idx].flags &= ~P_ALLOCED;
|
|
3101 }
|
|
3102 }
|
|
3103 else if (flags & P_NUM)
|
|
3104 {
|
|
3105 if (varp == (char_u *)PV_SCROLL)
|
|
3106 win_comp_scroll(curwin);
|
|
3107 else
|
|
3108 {
|
|
3109 *(long *)varp = (long)options[opt_idx].def_val[dvi];
|
|
3110 /* May also set global value for local option. */
|
|
3111 if (both)
|
|
3112 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
|
|
3113 *(long *)varp;
|
|
3114 }
|
|
3115 }
|
|
3116 else /* P_BOOL */
|
|
3117 {
|
|
3118 /* the cast to long is required for Manx C */
|
|
3119 *(int *)varp = (int)(long)options[opt_idx].def_val[dvi];
|
|
3120 /* May also set global value for local option. */
|
|
3121 if (both)
|
|
3122 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
|
|
3123 *(int *)varp;
|
|
3124 }
|
|
3125 }
|
|
3126
|
|
3127 #ifdef FEAT_EVAL
|
|
3128 /* Remember where the option was set. */
|
|
3129 options[opt_idx].scriptID = current_SID;
|
|
3130 #endif
|
|
3131 }
|
|
3132
|
|
3133 /*
|
|
3134 * Set all options (except terminal options) to their default value.
|
|
3135 */
|
|
3136 static void
|
|
3137 set_options_default(opt_flags)
|
|
3138 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
|
|
3139 {
|
|
3140 int i;
|
|
3141 #ifdef FEAT_WINDOWS
|
|
3142 win_T *wp;
|
|
3143 #endif
|
|
3144
|
|
3145 for (i = 0; !istermoption(&options[i]); i++)
|
|
3146 if (!(options[i].flags & P_NODEFAULT))
|
|
3147 set_option_default(i, opt_flags, p_cp);
|
|
3148
|
|
3149 #ifdef FEAT_WINDOWS
|
|
3150 /* The 'scroll' option must be computed for all windows. */
|
|
3151 for (wp = firstwin; wp != NULL; wp = wp->w_next)
|
|
3152 win_comp_scroll(wp);
|
|
3153 #else
|
|
3154 win_comp_scroll(curwin);
|
|
3155 #endif
|
|
3156 }
|
|
3157
|
|
3158 /*
|
|
3159 * Set the Vi-default value of a string option.
|
|
3160 * Used for 'sh', 'backupskip' and 'term'.
|
|
3161 */
|
|
3162 void
|
|
3163 set_string_default(name, val)
|
|
3164 char *name;
|
|
3165 char_u *val;
|
|
3166 {
|
|
3167 char_u *p;
|
|
3168 int opt_idx;
|
|
3169
|
|
3170 p = vim_strsave(val);
|
|
3171 if (p != NULL) /* we don't want a NULL */
|
|
3172 {
|
|
3173 opt_idx = findoption((char_u *)name);
|
|
3174 if (options[opt_idx].flags & P_DEF_ALLOCED)
|
|
3175 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
|
|
3176 options[opt_idx].def_val[VI_DEFAULT] = p;
|
|
3177 options[opt_idx].flags |= P_DEF_ALLOCED;
|
|
3178 }
|
|
3179 }
|
|
3180
|
|
3181 /*
|
|
3182 * Set the Vi-default value of a number option.
|
|
3183 * Used for 'lines' and 'columns'.
|
|
3184 */
|
|
3185 void
|
|
3186 set_number_default(name, val)
|
|
3187 char *name;
|
|
3188 long val;
|
|
3189 {
|
|
3190 options[findoption((char_u *)name)].def_val[VI_DEFAULT] = (char_u *)val;
|
|
3191 }
|
|
3192
|
359
|
3193 #if defined(EXITFREE) || defined(PROTO)
|
|
3194 /*
|
|
3195 * Free all options.
|
|
3196 */
|
|
3197 void
|
|
3198 free_all_options()
|
|
3199 {
|
|
3200 int i;
|
|
3201
|
|
3202 for (i = 0; !istermoption(&options[i]); i++)
|
|
3203 {
|
|
3204 if (options[i].indir == PV_NONE)
|
|
3205 {
|
|
3206 /* global option: free value and default value. */
|
|
3207 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
|
|
3208 free_string_option(*(char_u **)options[i].var);
|
|
3209 if (options[i].flags & P_DEF_ALLOCED)
|
|
3210 free_string_option(options[i].def_val[VI_DEFAULT]);
|
|
3211 }
|
|
3212 else if (options[i].var != VAR_WIN
|
|
3213 && (options[i].flags & P_STRING))
|
|
3214 /* buffer-local option: free global value */
|
|
3215 free_string_option(*(char_u **)options[i].var);
|
|
3216 }
|
|
3217 }
|
|
3218 #endif
|
|
3219
|
|
3220
|
7
|
3221 /*
|
|
3222 * Initialize the options, part two: After getting Rows and Columns and
|
|
3223 * setting 'term'.
|
|
3224 */
|
|
3225 void
|
|
3226 set_init_2()
|
|
3227 {
|
164
|
3228 int idx;
|
|
3229
|
7
|
3230 /*
|
|
3231 * 'scroll' defaults to half the window height. Note that this default is
|
|
3232 * wrong when the window height changes.
|
|
3233 */
|
164
|
3234 set_number_default("scroll", (long_u)Rows >> 1);
|
168
|
3235 idx = findoption((char_u *)"scroll");
|
|
3236 if (!(options[idx].flags & P_WAS_SET))
|
|
3237 set_option_default(idx, OPT_LOCAL, p_cp);
|
7
|
3238 comp_col();
|
|
3239
|
164
|
3240 /*
|
|
3241 * 'window' is only for backwards compatibility with Vi.
|
|
3242 * Default is Rows - 1.
|
|
3243 */
|
|
3244 idx = findoption((char_u *)"wi");
|
|
3245 if (!(options[idx].flags & P_WAS_SET))
|
|
3246 p_window = Rows - 1;
|
|
3247 set_number_default("window", Rows - 1);
|
|
3248
|
7
|
3249 #if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
|
|
3250 {
|
|
3251 /*
|
|
3252 * If 'background' wasn't set by the user, try guessing the value,
|
|
3253 * depending on the terminal name. Only need to check for terminals
|
173
|
3254 * with a dark background, that can handle color. Recognized are:
|
|
3255 * "linux" Linux console
|
|
3256 * "screen.linux" Linux console with screen
|
179
|
3257 * "cygwin" Cygwin shell
|
7
|
3258 */
|
164
|
3259 idx = findoption((char_u *)"bg");
|
173
|
3260 if (!(options[idx].flags & P_WAS_SET)
|
|
3261 && (STRCMP(T_NAME, "linux") == 0
|
179
|
3262 || STRCMP(T_NAME, "screen.linux") == 0
|
|
3263 || STRCMP(T_NAME, "cygwin") == 0))
|
164
|
3264 {
|
|
3265 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE);
|
7
|
3266 /* don't mark it as set, when starting the GUI it may be changed
|
|
3267 * again */
|
164
|
3268 options[idx].flags &= ~P_WAS_SET;
|
7
|
3269 }
|
|
3270 }
|
|
3271 #endif
|
|
3272 }
|
|
3273
|
|
3274 /*
|
|
3275 * Initialize the options, part three: After reading the .vimrc
|
|
3276 */
|
|
3277 void
|
|
3278 set_init_3()
|
|
3279 {
|
|
3280 #if defined(UNIX) || defined(OS2) || defined(WIN3264)
|
|
3281 /*
|
|
3282 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
|
|
3283 * This is done after other initializations, where 'shell' might have been
|
|
3284 * set, but only if they have not been set before.
|
|
3285 */
|
|
3286 char_u *p;
|
|
3287 int idx_srr;
|
|
3288 int do_srr;
|
|
3289 #ifdef FEAT_QUICKFIX
|
|
3290 int idx_sp;
|
|
3291 int do_sp;
|
|
3292 #endif
|
|
3293
|
|
3294 idx_srr = findoption((char_u *)"srr");
|
|
3295 do_srr = !(options[idx_srr].flags & P_WAS_SET);
|
|
3296 #ifdef FEAT_QUICKFIX
|
|
3297 idx_sp = findoption((char_u *)"sp");
|
|
3298 do_sp = !(options[idx_sp].flags & P_WAS_SET);
|
|
3299 #endif
|
|
3300
|
|
3301 /*
|
|
3302 * Isolate the name of the shell:
|
|
3303 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
|
|
3304 * - Remove any argument. E.g., "csh -f" -> "csh".
|
|
3305 */
|
|
3306 p = gettail(p_sh);
|
|
3307 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
|
|
3308 if (p != NULL)
|
|
3309 {
|
|
3310 /*
|
|
3311 * Default for p_sp is "| tee", for p_srr is ">".
|
|
3312 * For known shells it is changed here to include stderr.
|
|
3313 */
|
|
3314 if ( fnamecmp(p, "csh") == 0
|
|
3315 || fnamecmp(p, "tcsh") == 0
|
|
3316 # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
|
|
3317 || fnamecmp(p, "csh.exe") == 0
|
|
3318 || fnamecmp(p, "tcsh.exe") == 0
|
|
3319 # endif
|
|
3320 )
|
|
3321 {
|
|
3322 #if defined(FEAT_QUICKFIX)
|
|
3323 if (do_sp)
|
|
3324 {
|
|
3325 # ifdef WIN3264
|
|
3326 p_sp = (char_u *)">&";
|
|
3327 # else
|
|
3328 p_sp = (char_u *)"|& tee";
|
|
3329 # endif
|
|
3330 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
|
|
3331 }
|
|
3332 #endif
|
|
3333 if (do_srr)
|
|
3334 {
|
|
3335 p_srr = (char_u *)">&";
|
|
3336 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
|
|
3337 }
|
|
3338 }
|
|
3339 else
|
|
3340 # ifndef OS2 /* Always use bourne shell style redirection if we reach this */
|
|
3341 if ( fnamecmp(p, "sh") == 0
|
|
3342 || fnamecmp(p, "ksh") == 0
|
|
3343 || fnamecmp(p, "zsh") == 0
|
|
3344 || fnamecmp(p, "bash") == 0
|
|
3345 # ifdef WIN3264
|
|
3346 || fnamecmp(p, "cmd") == 0
|
|
3347 || fnamecmp(p, "sh.exe") == 0
|
|
3348 || fnamecmp(p, "ksh.exe") == 0
|
|
3349 || fnamecmp(p, "zsh.exe") == 0
|
|
3350 || fnamecmp(p, "bash.exe") == 0
|
|
3351 || fnamecmp(p, "cmd.exe") == 0
|
|
3352 # endif
|
|
3353 )
|
|
3354 # endif
|
|
3355 {
|
|
3356 #if defined(FEAT_QUICKFIX)
|
|
3357 if (do_sp)
|
|
3358 {
|
|
3359 # ifdef WIN3264
|
|
3360 p_sp = (char_u *)">%s 2>&1";
|
|
3361 # else
|
|
3362 p_sp = (char_u *)"2>&1| tee";
|
|
3363 # endif
|
|
3364 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
|
|
3365 }
|
|
3366 #endif
|
|
3367 if (do_srr)
|
|
3368 {
|
|
3369 p_srr = (char_u *)">%s 2>&1";
|
|
3370 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
|
|
3371 }
|
|
3372 }
|
|
3373 vim_free(p);
|
|
3374 }
|
|
3375 #endif
|
|
3376
|
|
3377 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
|
|
3378 /*
|
|
3379 * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
|
|
3380 * This is done after other initializations, where 'shell' might have been
|
|
3381 * set, but only if they have not been set before. Default for p_shcf is
|
|
3382 * "/c", for p_shq is "". For "sh" like shells it is changed here to
|
|
3383 * "-c" and "\"", but not for DJGPP, because it starts the shell without
|
|
3384 * command.com. And for Win32 we need to set p_sxq instead.
|
|
3385 */
|
10
|
3386 if (strstr((char *)gettail(p_sh), "sh") != NULL)
|
7
|
3387 {
|
|
3388 int idx3;
|
|
3389
|
|
3390 idx3 = findoption((char_u *)"shcf");
|
|
3391 if (!(options[idx3].flags & P_WAS_SET))
|
|
3392 {
|
|
3393 p_shcf = (char_u *)"-c";
|
|
3394 options[idx3].def_val[VI_DEFAULT] = p_shcf;
|
|
3395 }
|
|
3396
|
|
3397 # ifndef DJGPP
|
|
3398 # ifdef WIN3264
|
|
3399 /* Somehow Win32 requires the quotes around the redirection too */
|
|
3400 idx3 = findoption((char_u *)"sxq");
|
|
3401 if (!(options[idx3].flags & P_WAS_SET))
|
|
3402 {
|
|
3403 p_sxq = (char_u *)"\"";
|
|
3404 options[idx3].def_val[VI_DEFAULT] = p_sxq;
|
|
3405 }
|
|
3406 # else
|
|
3407 idx3 = findoption((char_u *)"shq");
|
|
3408 if (!(options[idx3].flags & P_WAS_SET))
|
|
3409 {
|
|
3410 p_shq = (char_u *)"\"";
|
|
3411 options[idx3].def_val[VI_DEFAULT] = p_shq;
|
|
3412 }
|
|
3413 # endif
|
|
3414 # endif
|
|
3415 }
|
|
3416 #endif
|
|
3417
|
|
3418 #ifdef FEAT_TITLE
|
|
3419 set_title_defaults();
|
|
3420 #endif
|
|
3421 }
|
|
3422
|
|
3423 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
|
|
3424 /*
|
|
3425 * When 'helplang' is still at its default value, set it to "lang".
|
|
3426 * Only the first two characters of "lang" are used.
|
|
3427 */
|
|
3428 void
|
|
3429 set_helplang_default(lang)
|
|
3430 char_u *lang;
|
|
3431 {
|
|
3432 int idx;
|
|
3433
|
|
3434 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
|
|
3435 return;
|
|
3436 idx = findoption((char_u *)"hlg");
|
|
3437 if (!(options[idx].flags & P_WAS_SET))
|
|
3438 {
|
|
3439 if (options[idx].flags & P_ALLOCED)
|
|
3440 free_string_option(p_hlg);
|
|
3441 p_hlg = vim_strsave(lang);
|
|
3442 if (p_hlg == NULL)
|
|
3443 p_hlg = empty_option;
|
|
3444 else
|
18
|
3445 {
|
|
3446 /* zh_CN becomes "cn", zh_TW becomes "tw". */
|
|
3447 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
|
|
3448 {
|
|
3449 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
|
|
3450 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
|
|
3451 }
|
7
|
3452 p_hlg[2] = NUL;
|
18
|
3453 }
|
7
|
3454 options[idx].flags |= P_ALLOCED;
|
|
3455 }
|
|
3456 }
|
|
3457 #endif
|
|
3458
|
|
3459 #ifdef FEAT_GUI
|
|
3460 static char_u *gui_bg_default __ARGS((void));
|
|
3461
|
|
3462 static char_u *
|
|
3463 gui_bg_default()
|
|
3464 {
|
|
3465 if (gui_get_lightness(gui.back_pixel) < 127)
|
|
3466 return (char_u *)"dark";
|
|
3467 return (char_u *)"light";
|
|
3468 }
|
|
3469
|
|
3470 /*
|
|
3471 * Option initializations that can only be done after opening the GUI window.
|
|
3472 */
|
|
3473 void
|
|
3474 init_gui_options()
|
|
3475 {
|
|
3476 /* Set the 'background' option according to the lightness of the
|
|
3477 * background color, unless the user has set it already. */
|
|
3478 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
|
|
3479 {
|
|
3480 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
|
|
3481 highlight_changed();
|
|
3482 }
|
|
3483 }
|
|
3484 #endif
|
|
3485
|
|
3486 #ifdef FEAT_TITLE
|
|
3487 /*
|
|
3488 * 'title' and 'icon' only default to true if they have not been set or reset
|
|
3489 * in .vimrc and we can read the old value.
|
|
3490 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
|
|
3491 * they can be reset. This reduces startup time when using X on a remote
|
|
3492 * machine.
|
|
3493 */
|
|
3494 void
|
|
3495 set_title_defaults()
|
|
3496 {
|
|
3497 int idx1;
|
|
3498 long val;
|
|
3499
|
|
3500 /*
|
|
3501 * If GUI is (going to be) used, we can always set the window title and
|
|
3502 * icon name. Saves a bit of time, because the X11 display server does
|
|
3503 * not need to be contacted.
|
|
3504 */
|
|
3505 idx1 = findoption((char_u *)"title");
|
|
3506 if (!(options[idx1].flags & P_WAS_SET))
|
|
3507 {
|
|
3508 #ifdef FEAT_GUI
|
|
3509 if (gui.starting || gui.in_use)
|
|
3510 val = TRUE;
|
|
3511 else
|
|
3512 #endif
|
|
3513 val = mch_can_restore_title();
|
|
3514 options[idx1].def_val[VI_DEFAULT] = (char_u *)val;
|
|
3515 p_title = val;
|
|
3516 }
|
|
3517 idx1 = findoption((char_u *)"icon");
|
|
3518 if (!(options[idx1].flags & P_WAS_SET))
|
|
3519 {
|
|
3520 #ifdef FEAT_GUI
|
|
3521 if (gui.starting || gui.in_use)
|
|
3522 val = TRUE;
|
|
3523 else
|
|
3524 #endif
|
|
3525 val = mch_can_restore_icon();
|
|
3526 options[idx1].def_val[VI_DEFAULT] = (char_u *)val;
|
|
3527 p_icon = val;
|
|
3528 }
|
|
3529 }
|
|
3530 #endif
|
|
3531
|
|
3532 /*
|
|
3533 * Parse 'arg' for option settings.
|
|
3534 *
|
|
3535 * 'arg' may be IObuff, but only when no errors can be present and option
|
|
3536 * does not need to be expanded with option_expand().
|
|
3537 * "opt_flags":
|
|
3538 * 0 for ":set"
|
|
3539 * OPT_GLOBAL for ":setglobal"
|
|
3540 * OPT_LOCAL for ":setlocal" and a modeline
|
|
3541 * OPT_MODELINE for a modeline
|
|
3542 *
|
|
3543 * returns FAIL if an error is detected, OK otherwise
|
|
3544 */
|
|
3545 int
|
|
3546 do_set(arg, opt_flags)
|
|
3547 char_u *arg; /* option string (may be written to!) */
|
|
3548 int opt_flags;
|
|
3549 {
|
|
3550 int opt_idx;
|
|
3551 char_u *errmsg;
|
|
3552 char_u errbuf[80];
|
|
3553 char_u *startarg;
|
|
3554 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
|
|
3555 int nextchar; /* next non-white char after option name */
|
|
3556 int afterchar; /* character just after option name */
|
|
3557 int len;
|
|
3558 int i;
|
|
3559 long value;
|
|
3560 int key;
|
|
3561 long_u flags; /* flags for current option */
|
|
3562 char_u *varp = NULL; /* pointer to variable for current option */
|
|
3563 int did_show = FALSE; /* already showed one value */
|
|
3564 int adding; /* "opt+=arg" */
|
|
3565 int prepending; /* "opt^=arg" */
|
|
3566 int removing; /* "opt-=arg" */
|
|
3567 int cp_val = 0;
|
|
3568 char_u key_name[2];
|
|
3569
|
|
3570 if (*arg == NUL)
|
|
3571 {
|
|
3572 showoptions(0, opt_flags);
|
168
|
3573 did_show = TRUE;
|
|
3574 goto theend;
|
7
|
3575 }
|
|
3576
|
|
3577 while (*arg != NUL) /* loop to process all options */
|
|
3578 {
|
|
3579 errmsg = NULL;
|
|
3580 startarg = arg; /* remember for error message */
|
|
3581
|
36
|
3582 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
|
|
3583 && !(opt_flags & OPT_MODELINE))
|
7
|
3584 {
|
|
3585 /*
|
|
3586 * ":set all" show all options.
|
|
3587 * ":set all&" set all options to their default value.
|
|
3588 */
|
|
3589 arg += 3;
|
|
3590 if (*arg == '&')
|
|
3591 {
|
|
3592 ++arg;
|
|
3593 /* Only for :set command set global value of local options. */
|
|
3594 set_options_default(OPT_FREE | opt_flags);
|
|
3595 }
|
|
3596 else
|
168
|
3597 {
|
7
|
3598 showoptions(1, opt_flags);
|
168
|
3599 did_show = TRUE;
|
|
3600 }
|
7
|
3601 }
|
36
|
3602 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
|
7
|
3603 {
|
|
3604 showoptions(2, opt_flags);
|
|
3605 show_termcodes();
|
168
|
3606 did_show = TRUE;
|
7
|
3607 arg += 7;
|
|
3608 }
|
|
3609 else
|
|
3610 {
|
|
3611 prefix = 1;
|
|
3612 if (STRNCMP(arg, "no", 2) == 0)
|
|
3613 {
|
|
3614 prefix = 0;
|
|
3615 arg += 2;
|
|
3616 }
|
|
3617 else if (STRNCMP(arg, "inv", 3) == 0)
|
|
3618 {
|
|
3619 prefix = 2;
|
|
3620 arg += 3;
|
|
3621 }
|
|
3622
|
|
3623 /* find end of name */
|
|
3624 key = 0;
|
|
3625 if (*arg == '<')
|
|
3626 {
|
|
3627 nextchar = 0;
|
|
3628 opt_idx = -1;
|
|
3629 /* look out for <t_>;> */
|
|
3630 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
|
|
3631 len = 5;
|
|
3632 else
|
|
3633 {
|
|
3634 len = 1;
|
|
3635 while (arg[len] != NUL && arg[len] != '>')
|
|
3636 ++len;
|
|
3637 }
|
|
3638 if (arg[len] != '>')
|
|
3639 {
|
|
3640 errmsg = e_invarg;
|
|
3641 goto skip;
|
|
3642 }
|
|
3643 arg[len] = NUL; /* put NUL after name */
|
|
3644 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
|
|
3645 opt_idx = findoption(arg + 1);
|
|
3646 arg[len++] = '>'; /* restore '>' */
|
|
3647 if (opt_idx == -1)
|
|
3648 key = find_key_option(arg + 1);
|
|
3649 }
|
|
3650 else
|
|
3651 {
|
|
3652 len = 0;
|
|
3653 /*
|
|
3654 * The two characters after "t_" may not be alphanumeric.
|
|
3655 */
|
|
3656 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
|
|
3657 len = 4;
|
|
3658 else
|
|
3659 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
|
|
3660 ++len;
|
|
3661 nextchar = arg[len];
|
|
3662 arg[len] = NUL; /* put NUL after name */
|
|
3663 opt_idx = findoption(arg);
|
|
3664 arg[len] = nextchar; /* restore nextchar */
|
|
3665 if (opt_idx == -1)
|
|
3666 key = find_key_option(arg);
|
|
3667 }
|
|
3668
|
|
3669 /* remember character after option name */
|
|
3670 afterchar = arg[len];
|
|
3671
|
|
3672 /* skip white space, allow ":set ai ?" */
|
|
3673 while (vim_iswhite(arg[len]))
|
|
3674 ++len;
|
|
3675
|
|
3676 adding = FALSE;
|
|
3677 prepending = FALSE;
|
|
3678 removing = FALSE;
|
|
3679 if (arg[len] != NUL && arg[len + 1] == '=')
|
|
3680 {
|
|
3681 if (arg[len] == '+')
|
|
3682 {
|
|
3683 adding = TRUE; /* "+=" */
|
|
3684 ++len;
|
|
3685 }
|
|
3686 else if (arg[len] == '^')
|
|
3687 {
|
|
3688 prepending = TRUE; /* "^=" */
|
|
3689 ++len;
|
|
3690 }
|
|
3691 else if (arg[len] == '-')
|
|
3692 {
|
|
3693 removing = TRUE; /* "-=" */
|
|
3694 ++len;
|
|
3695 }
|
|
3696 }
|
|
3697 nextchar = arg[len];
|
|
3698
|
|
3699 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
|
|
3700 {
|
|
3701 errmsg = (char_u *)N_("E518: Unknown option");
|
|
3702 goto skip;
|
|
3703 }
|
|
3704
|
|
3705 if (opt_idx >= 0)
|
|
3706 {
|
|
3707 if (options[opt_idx].var == NULL) /* hidden option: skip */
|
|
3708 {
|
|
3709 /* Only give an error message when requesting the value of
|
|
3710 * a hidden option, ignore setting it. */
|
|
3711 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
|
|
3712 && (!(options[opt_idx].flags & P_BOOL)
|
|
3713 || nextchar == '?'))
|
|
3714 errmsg = (char_u *)N_("E519: Option not supported");
|
|
3715 goto skip;
|
|
3716 }
|
|
3717
|
|
3718 flags = options[opt_idx].flags;
|
|
3719 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
|
|
3720 }
|
|
3721 else
|
|
3722 {
|
|
3723 flags = P_STRING;
|
|
3724 if (key < 0)
|
|
3725 {
|
|
3726 key_name[0] = KEY2TERMCAP0(key);
|
|
3727 key_name[1] = KEY2TERMCAP1(key);
|
|
3728 }
|
|
3729 else
|
|
3730 {
|
|
3731 key_name[0] = KS_KEY;
|
|
3732 key_name[1] = (key & 0xff);
|
|
3733 }
|
|
3734 }
|
|
3735
|
|
3736 /* Disallow changing some options from modelines */
|
|
3737 if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE))
|
|
3738 {
|
|
3739 errmsg = (char_u *)_("E520: Not allowed in a modeline");
|
|
3740 goto skip;
|
|
3741 }
|
|
3742
|
23
|
3743 /* Skip all options that are not window-local (used when showing
|
|
3744 * an already loaded buffer in a window). */
|
|
3745 if ((opt_flags & OPT_WINONLY)
|
|
3746 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
|
|
3747 goto skip;
|
|
3748
|
7
|
3749 #ifdef HAVE_SANDBOX
|
|
3750 /* Disallow changing some options in the sandbox */
|
|
3751 if (sandbox > 0 && (flags & P_SECURE))
|
|
3752 {
|
|
3753 errmsg = (char_u *)_(e_sandbox);
|
|
3754 goto skip;
|
|
3755 }
|
|
3756 #endif
|
|
3757
|
|
3758 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
|
|
3759 {
|
|
3760 arg += len;
|
|
3761 cp_val = p_cp;
|
|
3762 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
|
|
3763 {
|
|
3764 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
|
|
3765 {
|
|
3766 cp_val = FALSE;
|
|
3767 arg += 3;
|
|
3768 }
|
|
3769 else /* "opt&vi": set to Vi default */
|
|
3770 {
|
|
3771 cp_val = TRUE;
|
|
3772 arg += 2;
|
|
3773 }
|
|
3774 }
|
|
3775 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
|
|
3776 && arg[1] != NUL && !vim_iswhite(arg[1]))
|
|
3777 {
|
|
3778 errmsg = e_trailing;
|
|
3779 goto skip;
|
|
3780 }
|
|
3781 }
|
|
3782
|
|
3783 /*
|
|
3784 * allow '=' and ':' as MSDOS command.com allows only one
|
|
3785 * '=' character per "set" command line. grrr. (jw)
|
|
3786 */
|
|
3787 if (nextchar == '?'
|
|
3788 || (prefix == 1
|
|
3789 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
|
|
3790 && !(flags & P_BOOL)))
|
|
3791 {
|
|
3792 /*
|
|
3793 * print value
|
|
3794 */
|
|
3795 if (did_show)
|
|
3796 msg_putchar('\n'); /* cursor below last one */
|
|
3797 else
|
|
3798 {
|
|
3799 gotocmdline(TRUE); /* cursor at status line */
|
|
3800 did_show = TRUE; /* remember that we did a line */
|
|
3801 }
|
|
3802 if (opt_idx >= 0)
|
|
3803 {
|
|
3804 showoneopt(&options[opt_idx], opt_flags);
|
|
3805 #ifdef FEAT_EVAL
|
|
3806 if (p_verbose > 0)
|
|
3807 {
|
|
3808 if (options[opt_idx].scriptID != 0)
|
|
3809 {
|
294
|
3810 verbose_enter();
|
7
|
3811 MSG_PUTS(_("\n\tLast set from "));
|
|
3812 MSG_PUTS(get_scriptname(options[opt_idx].scriptID));
|
294
|
3813 verbose_leave();
|
7
|
3814 }
|
|
3815 }
|
|
3816 #endif
|
|
3817 }
|
|
3818 else
|
|
3819 {
|
|
3820 char_u *p;
|
|
3821
|
|
3822 p = find_termcode(key_name);
|
|
3823 if (p == NULL)
|
|
3824 {
|
|
3825 errmsg = (char_u *)N_("E518: Unknown option");
|
|
3826 goto skip;
|
|
3827 }
|
|
3828 else
|
|
3829 (void)show_one_termcode(key_name, p, TRUE);
|
|
3830 }
|
|
3831 if (nextchar != '?'
|
|
3832 && nextchar != NUL && !vim_iswhite(afterchar))
|
|
3833 errmsg = e_trailing;
|
|
3834 }
|
|
3835 else
|
|
3836 {
|
|
3837 if (flags & P_BOOL) /* boolean */
|
|
3838 {
|
|
3839 if (nextchar == '=' || nextchar == ':')
|
|
3840 {
|
|
3841 errmsg = e_invarg;
|
|
3842 goto skip;
|
|
3843 }
|
|
3844
|
|
3845 /*
|
|
3846 * ":set opt!": invert
|
|
3847 * ":set opt&": reset to default value
|
|
3848 * ":set opt<": reset to global value
|
|
3849 */
|
|
3850 if (nextchar == '!')
|
|
3851 value = *(int *)(varp) ^ 1;
|
|
3852 else if (nextchar == '&')
|
|
3853 value = (int)(long)options[opt_idx].def_val[
|
|
3854 ((flags & P_VI_DEF) || cp_val)
|
|
3855 ? VI_DEFAULT : VIM_DEFAULT];
|
|
3856 else if (nextchar == '<')
|
|
3857 {
|
|
3858 /* For 'autoread' -1 means to use global value. */
|
|
3859 if ((int *)varp == &curbuf->b_p_ar
|
|
3860 && opt_flags == OPT_LOCAL)
|
|
3861 value = -1;
|
|
3862 else
|
|
3863 value = *(int *)get_varp_scope(&(options[opt_idx]),
|
|
3864 OPT_GLOBAL);
|
|
3865 }
|
|
3866 else
|
|
3867 {
|
|
3868 /*
|
|
3869 * ":set invopt": invert
|
|
3870 * ":set opt" or ":set noopt": set or reset
|
|
3871 */
|
|
3872 if (nextchar != NUL && !vim_iswhite(afterchar))
|
|
3873 {
|
|
3874 errmsg = e_trailing;
|
|
3875 goto skip;
|
|
3876 }
|
|
3877 if (prefix == 2) /* inv */
|
|
3878 value = *(int *)(varp) ^ 1;
|
|
3879 else
|
|
3880 value = prefix;
|
|
3881 }
|
|
3882
|
|
3883 errmsg = set_bool_option(opt_idx, varp, (int)value,
|
|
3884 opt_flags);
|
|
3885 }
|
|
3886 else /* numeric or string */
|
|
3887 {
|
|
3888 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
|
|
3889 || prefix != 1)
|
|
3890 {
|
|
3891 errmsg = e_invarg;
|
|
3892 goto skip;
|
|
3893 }
|
|
3894
|
|
3895 if (flags & P_NUM) /* numeric */
|
|
3896 {
|
|
3897 /*
|
|
3898 * Different ways to set a number option:
|
|
3899 * & set to default value
|
|
3900 * < set to global value
|
|
3901 * <xx> accept special key codes for 'wildchar'
|
|
3902 * c accept any non-digit for 'wildchar'
|
|
3903 * [-]0-9 set number
|
|
3904 * other error
|
|
3905 */
|
|
3906 ++arg;
|
|
3907 if (nextchar == '&')
|
|
3908 value = (long)options[opt_idx].def_val[
|
|
3909 ((flags & P_VI_DEF) || cp_val)
|
|
3910 ? VI_DEFAULT : VIM_DEFAULT];
|
|
3911 else if (nextchar == '<')
|
|
3912 value = *(long *)get_varp_scope(&(options[opt_idx]),
|
|
3913 OPT_GLOBAL);
|
|
3914 else if (((long *)varp == &p_wc
|
|
3915 || (long *)varp == &p_wcm)
|
|
3916 && (*arg == '<'
|
|
3917 || *arg == '^'
|
|
3918 || ((!arg[1] || vim_iswhite(arg[1]))
|
|
3919 && !VIM_ISDIGIT(*arg))))
|
|
3920 {
|
|
3921 value = string_to_key(arg);
|
|
3922 if (value == 0 && (long *)varp != &p_wcm)
|
|
3923 {
|
|
3924 errmsg = e_invarg;
|
|
3925 goto skip;
|
|
3926 }
|
|
3927 }
|
|
3928 /* allow negative numbers (for 'undolevels') */
|
|
3929 else if (*arg == '-' || VIM_ISDIGIT(*arg))
|
|
3930 {
|
|
3931 i = 0;
|
|
3932 if (*arg == '-')
|
|
3933 i = 1;
|
|
3934 #ifdef HAVE_STRTOL
|
|
3935 value = strtol((char *)arg, NULL, 0);
|
|
3936 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
|
|
3937 i += 2;
|
|
3938 #else
|
|
3939 value = atol((char *)arg);
|
|
3940 #endif
|
|
3941 while (VIM_ISDIGIT(arg[i]))
|
|
3942 ++i;
|
|
3943 if (arg[i] != NUL && !vim_iswhite(arg[i]))
|
|
3944 {
|
|
3945 errmsg = e_invarg;
|
|
3946 goto skip;
|
|
3947 }
|
|
3948 }
|
|
3949 else
|
|
3950 {
|
|
3951 errmsg = (char_u *)N_("E521: Number required after =");
|
|
3952 goto skip;
|
|
3953 }
|
|
3954
|
|
3955 if (adding)
|
|
3956 value = *(long *)varp + value;
|
|
3957 if (prepending)
|
|
3958 value = *(long *)varp * value;
|
|
3959 if (removing)
|
|
3960 value = *(long *)varp - value;
|
|
3961 errmsg = set_num_option(opt_idx, varp, value,
|
274
|
3962 errbuf, sizeof(errbuf), opt_flags);
|
7
|
3963 }
|
|
3964 else if (opt_idx >= 0) /* string */
|
|
3965 {
|
|
3966 char_u *save_arg = NULL;
|
|
3967 char_u *s = NULL;
|
|
3968 char_u *oldval; /* previous value if *varp */
|
|
3969 char_u *newval;
|
|
3970 char_u *origval;
|
|
3971 unsigned newlen;
|
|
3972 int comma;
|
|
3973 int bs;
|
|
3974 int new_value_alloced; /* new string option
|
|
3975 was allocated */
|
|
3976
|
|
3977 /* When using ":set opt=val" for a global option
|
|
3978 * with a local value the local value will be
|
|
3979 * reset, use the global value here. */
|
|
3980 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
3981 && (int)options[opt_idx].indir >= PV_BOTH)
|
|
3982 varp = options[opt_idx].var;
|
|
3983
|
|
3984 /* The old value is kept until we are sure that the
|
|
3985 * new value is valid. */
|
|
3986 oldval = *(char_u **)varp;
|
|
3987 if (nextchar == '&') /* set to default val */
|
|
3988 {
|
|
3989 newval = options[opt_idx].def_val[
|
|
3990 ((flags & P_VI_DEF) || cp_val)
|
|
3991 ? VI_DEFAULT : VIM_DEFAULT];
|
|
3992 if ((char_u **)varp == &p_bg)
|
|
3993 {
|
|
3994 /* guess the value of 'background' */
|
|
3995 #ifdef FEAT_GUI
|
|
3996 if (gui.in_use)
|
|
3997 newval = gui_bg_default();
|
|
3998 else
|
|
3999 #endif
|
|
4000 if (STRCMP(T_NAME, "linux") == 0)
|
|
4001 newval = (char_u *)"dark";
|
|
4002 }
|
|
4003
|
|
4004 /* expand environment variables and ~ (since the
|
|
4005 * default value was already expanded, only
|
|
4006 * required when an environment variable was set
|
|
4007 * later */
|
|
4008 if (newval == NULL)
|
|
4009 newval = empty_option;
|
|
4010 else
|
|
4011 {
|
|
4012 s = option_expand(opt_idx, newval);
|
|
4013 if (s == NULL)
|
|
4014 s = newval;
|
|
4015 newval = vim_strsave(s);
|
|
4016 }
|
|
4017 new_value_alloced = TRUE;
|
|
4018 }
|
|
4019 else if (nextchar == '<') /* set to global val */
|
|
4020 {
|
|
4021 newval = vim_strsave(*(char_u **)get_varp_scope(
|
|
4022 &(options[opt_idx]), OPT_GLOBAL));
|
|
4023 new_value_alloced = TRUE;
|
|
4024 }
|
|
4025 else
|
|
4026 {
|
|
4027 ++arg; /* jump to after the '=' or ':' */
|
|
4028
|
|
4029 /*
|
|
4030 * Set 'keywordprg' to ":help" if an empty
|
|
4031 * value was passed to :set by the user.
|
|
4032 * Misuse errbuf[] for the resulting string.
|
|
4033 */
|
|
4034 if (varp == (char_u *)&p_kp
|
|
4035 && (*arg == NUL || *arg == ' '))
|
|
4036 {
|
|
4037 STRCPY(errbuf, ":help");
|
|
4038 save_arg = arg;
|
|
4039 arg = errbuf;
|
|
4040 }
|
|
4041 /*
|
|
4042 * Convert 'whichwrap' number to string, for
|
|
4043 * backwards compatibility with Vim 3.0.
|
|
4044 * Misuse errbuf[] for the resulting string.
|
|
4045 */
|
|
4046 else if (varp == (char_u *)&p_ww
|
|
4047 && VIM_ISDIGIT(*arg))
|
|
4048 {
|
|
4049 *errbuf = NUL;
|
|
4050 i = getdigits(&arg);
|
|
4051 if (i & 1)
|
|
4052 STRCAT(errbuf, "b,");
|
|
4053 if (i & 2)
|
|
4054 STRCAT(errbuf, "s,");
|
|
4055 if (i & 4)
|
|
4056 STRCAT(errbuf, "h,l,");
|
|
4057 if (i & 8)
|
|
4058 STRCAT(errbuf, "<,>,");
|
|
4059 if (i & 16)
|
|
4060 STRCAT(errbuf, "[,],");
|
|
4061 if (*errbuf != NUL) /* remove trailing , */
|
|
4062 errbuf[STRLEN(errbuf) - 1] = NUL;
|
|
4063 save_arg = arg;
|
|
4064 arg = errbuf;
|
|
4065 }
|
|
4066 /*
|
|
4067 * Remove '>' before 'dir' and 'bdir', for
|
|
4068 * backwards compatibility with version 3.0
|
|
4069 */
|
|
4070 else if ( *arg == '>'
|
|
4071 && (varp == (char_u *)&p_dir
|
|
4072 || varp == (char_u *)&p_bdir))
|
|
4073 {
|
|
4074 ++arg;
|
|
4075 }
|
|
4076
|
|
4077 /* When setting the local value of a global
|
|
4078 * option, the old value may be the global value. */
|
|
4079 if ((int)options[opt_idx].indir >= PV_BOTH
|
|
4080 && (opt_flags & OPT_LOCAL))
|
|
4081 origval = *(char_u **)get_varp(
|
|
4082 &options[opt_idx]);
|
|
4083 else
|
|
4084 origval = oldval;
|
|
4085
|
|
4086 /*
|
|
4087 * Copy the new string into allocated memory.
|
|
4088 * Can't use set_string_option_direct(), because
|
|
4089 * we need to remove the backslashes.
|
|
4090 */
|
|
4091 /* get a bit too much */
|
|
4092 newlen = (unsigned)STRLEN(arg) + 1;
|
|
4093 if (adding || prepending || removing)
|
|
4094 newlen += (unsigned)STRLEN(origval) + 1;
|
|
4095 newval = alloc(newlen);
|
|
4096 if (newval == NULL) /* out of mem, don't change */
|
|
4097 break;
|
|
4098 s = newval;
|
|
4099
|
|
4100 /*
|
|
4101 * Copy the string, skip over escaped chars.
|
|
4102 * For MS-DOS and WIN32 backslashes before normal
|
|
4103 * file name characters are not removed, and keep
|
|
4104 * backslash at start, for "\\machine\path", but
|
|
4105 * do remove it for "\\\\machine\\path".
|
|
4106 * The reverse is found in ExpandOldSetting().
|
|
4107 */
|
|
4108 while (*arg && !vim_iswhite(*arg))
|
|
4109 {
|
|
4110 if (*arg == '\\' && arg[1] != NUL
|
|
4111 #ifdef BACKSLASH_IN_FILENAME
|
|
4112 && !((flags & P_EXPAND)
|
|
4113 && vim_isfilec(arg[1])
|
|
4114 && (arg[1] != '\\'
|
|
4115 || (s == newval
|
|
4116 && arg[2] != '\\')))
|
|
4117 #endif
|
|
4118 )
|
|
4119 ++arg; /* remove backslash */
|
|
4120 #ifdef FEAT_MBYTE
|
|
4121 if (has_mbyte
|
|
4122 && (i = (*mb_ptr2len_check)(arg)) > 1)
|
|
4123 {
|
|
4124 /* copy multibyte char */
|
|
4125 mch_memmove(s, arg, (size_t)i);
|
|
4126 arg += i;
|
|
4127 s += i;
|
|
4128 }
|
|
4129 else
|
|
4130 #endif
|
|
4131 *s++ = *arg++;
|
|
4132 }
|
|
4133 *s = NUL;
|
|
4134
|
|
4135 /*
|
|
4136 * Expand environment variables and ~.
|
|
4137 * Don't do it when adding without inserting a
|
|
4138 * comma.
|
|
4139 */
|
|
4140 if (!(adding || prepending || removing)
|
|
4141 || (flags & P_COMMA))
|
|
4142 {
|
|
4143 s = option_expand(opt_idx, newval);
|
|
4144 if (s != NULL)
|
|
4145 {
|
|
4146 vim_free(newval);
|
|
4147 newlen = (unsigned)STRLEN(s) + 1;
|
|
4148 if (adding || prepending || removing)
|
|
4149 newlen += (unsigned)STRLEN(origval) + 1;
|
|
4150 newval = alloc(newlen);
|
|
4151 if (newval == NULL)
|
|
4152 break;
|
|
4153 STRCPY(newval, s);
|
|
4154 }
|
|
4155 }
|
|
4156
|
|
4157 /* locate newval[] in origval[] when removing it
|
|
4158 * and when adding to avoid duplicates */
|
|
4159 i = 0; /* init for GCC */
|
|
4160 if (removing || (flags & P_NODUP))
|
|
4161 {
|
|
4162 i = (int)STRLEN(newval);
|
|
4163 bs = 0;
|
|
4164 for (s = origval; *s; ++s)
|
|
4165 {
|
|
4166 if ((!(flags & P_COMMA)
|
|
4167 || s == origval
|
|
4168 || (s[-1] == ',' && !(bs & 1)))
|
|
4169 && STRNCMP(s, newval, i) == 0
|
|
4170 && (!(flags & P_COMMA)
|
|
4171 || s[i] == ','
|
|
4172 || s[i] == NUL))
|
|
4173 break;
|
|
4174 /* Count backspaces. Only a comma with an
|
|
4175 * even number of backspaces before it is
|
|
4176 * recognized as a separator */
|
|
4177 if (s > origval && s[-1] == '\\')
|
|
4178 ++bs;
|
|
4179 else
|
|
4180 bs = 0;
|
|
4181 }
|
|
4182
|
|
4183 /* do not add if already there */
|
|
4184 if ((adding || prepending) && *s)
|
|
4185 {
|
|
4186 prepending = FALSE;
|
|
4187 adding = FALSE;
|
|
4188 STRCPY(newval, origval);
|
|
4189 }
|
|
4190 }
|
|
4191
|
|
4192 /* concatenate the two strings; add a ',' if
|
|
4193 * needed */
|
|
4194 if (adding || prepending)
|
|
4195 {
|
|
4196 comma = ((flags & P_COMMA) && *origval != NUL
|
|
4197 && *newval != NUL);
|
|
4198 if (adding)
|
|
4199 {
|
|
4200 i = (int)STRLEN(origval);
|
|
4201 mch_memmove(newval + i + comma, newval,
|
|
4202 STRLEN(newval) + 1);
|
|
4203 mch_memmove(newval, origval, (size_t)i);
|
|
4204 }
|
|
4205 else
|
|
4206 {
|
|
4207 i = (int)STRLEN(newval);
|
|
4208 mch_memmove(newval + i + comma, origval,
|
|
4209 STRLEN(origval) + 1);
|
|
4210 }
|
|
4211 if (comma)
|
|
4212 newval[i] = ',';
|
|
4213 }
|
|
4214
|
|
4215 /* Remove newval[] from origval[]. (Note: "i" has
|
|
4216 * been set above and is used here). */
|
|
4217 if (removing)
|
|
4218 {
|
|
4219 STRCPY(newval, origval);
|
|
4220 if (*s)
|
|
4221 {
|
|
4222 /* may need to remove a comma */
|
|
4223 if (flags & P_COMMA)
|
|
4224 {
|
|
4225 if (s == origval)
|
|
4226 {
|
|
4227 /* include comma after string */
|
|
4228 if (s[i] == ',')
|
|
4229 ++i;
|
|
4230 }
|
|
4231 else
|
|
4232 {
|
|
4233 /* include comma before string */
|
|
4234 --s;
|
|
4235 ++i;
|
|
4236 }
|
|
4237 }
|
|
4238 mch_memmove(newval + (s - origval), s + i,
|
|
4239 STRLEN(s + i) + 1);
|
|
4240 }
|
|
4241 }
|
|
4242
|
|
4243 if (flags & P_FLAGLIST)
|
|
4244 {
|
|
4245 /* Remove flags that appear twice. */
|
|
4246 for (s = newval; *s; ++s)
|
|
4247 if ((!(flags & P_COMMA) || *s != ',')
|
|
4248 && vim_strchr(s + 1, *s) != NULL)
|
|
4249 {
|
|
4250 STRCPY(s, s + 1);
|
|
4251 --s;
|
|
4252 }
|
|
4253 }
|
|
4254
|
|
4255 if (save_arg != NULL) /* number for 'whichwrap' */
|
|
4256 arg = save_arg;
|
|
4257 new_value_alloced = TRUE;
|
|
4258 }
|
|
4259
|
|
4260 /* Set the new value. */
|
|
4261 *(char_u **)(varp) = newval;
|
|
4262
|
|
4263 /* Handle side effects, and set the global value for
|
|
4264 * ":set" on local options. */
|
|
4265 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
|
|
4266 new_value_alloced, oldval, errbuf, opt_flags);
|
|
4267
|
|
4268 /* If error detected, print the error message. */
|
|
4269 if (errmsg != NULL)
|
|
4270 goto skip;
|
|
4271 }
|
|
4272 else /* key code option */
|
|
4273 {
|
|
4274 char_u *p;
|
|
4275
|
|
4276 if (nextchar == '&')
|
|
4277 {
|
|
4278 if (add_termcap_entry(key_name, TRUE) == FAIL)
|
|
4279 errmsg = (char_u *)N_("E522: Not found in termcap");
|
|
4280 }
|
|
4281 else
|
|
4282 {
|
|
4283 ++arg; /* jump to after the '=' or ':' */
|
|
4284 for (p = arg; *p && !vim_iswhite(*p); ++p)
|
|
4285 if (*p == '\\' && p[1] != NUL)
|
|
4286 ++p;
|
|
4287 nextchar = *p;
|
|
4288 *p = NUL;
|
|
4289 add_termcode(key_name, arg, FALSE);
|
|
4290 *p = nextchar;
|
|
4291 }
|
|
4292 if (full_screen)
|
|
4293 ttest(FALSE);
|
|
4294 redraw_all_later(CLEAR);
|
|
4295 }
|
|
4296 }
|
|
4297 if (opt_idx >= 0)
|
|
4298 options[opt_idx].flags |= P_WAS_SET;
|
|
4299 }
|
|
4300
|
|
4301 skip:
|
|
4302 /*
|
|
4303 * Advance to next argument.
|
|
4304 * - skip until a blank found, taking care of backslashes
|
|
4305 * - skip blanks
|
|
4306 * - skip one "=val" argument (for hidden options ":set gfn =xx")
|
|
4307 */
|
|
4308 for (i = 0; i < 2 ; ++i)
|
|
4309 {
|
|
4310 while (*arg != NUL && !vim_iswhite(*arg))
|
|
4311 if (*arg++ == '\\' && *arg != NUL)
|
|
4312 ++arg;
|
|
4313 arg = skipwhite(arg);
|
|
4314 if (*arg != '=')
|
|
4315 break;
|
|
4316 }
|
|
4317 }
|
|
4318
|
|
4319 if (errmsg != NULL)
|
|
4320 {
|
419
|
4321 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
|
7
|
4322 i = STRLEN(IObuff) + 2;
|
|
4323 if (i + (arg - startarg) < IOSIZE)
|
|
4324 {
|
|
4325 /* append the argument with the error */
|
|
4326 STRCAT(IObuff, ": ");
|
|
4327 mch_memmove(IObuff + i, startarg, (arg - startarg));
|
|
4328 IObuff[i + (arg - startarg)] = NUL;
|
|
4329 }
|
|
4330 /* make sure all characters are printable */
|
|
4331 trans_characters(IObuff, IOSIZE);
|
|
4332
|
|
4333 ++no_wait_return; /* wait_return done later */
|
|
4334 emsg(IObuff); /* show error highlighted */
|
|
4335 --no_wait_return;
|
|
4336
|
|
4337 return FAIL;
|
|
4338 }
|
|
4339
|
|
4340 arg = skipwhite(arg);
|
|
4341 }
|
|
4342
|
168
|
4343 theend:
|
|
4344 if (silent_mode && did_show)
|
|
4345 {
|
|
4346 /* After displaying option values in silent mode. */
|
|
4347 silent_mode = FALSE;
|
|
4348 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
|
|
4349 msg_putchar('\n');
|
|
4350 cursor_on(); /* msg_start() switches it off */
|
|
4351 out_flush();
|
|
4352 silent_mode = TRUE;
|
|
4353 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
|
|
4354 }
|
|
4355
|
7
|
4356 return OK;
|
|
4357 }
|
|
4358
|
|
4359 static char_u *
|
|
4360 illegal_char(errbuf, c)
|
|
4361 char_u *errbuf;
|
|
4362 int c;
|
|
4363 {
|
|
4364 if (errbuf == NULL)
|
|
4365 return (char_u *)"";
|
|
4366 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
|
274
|
4367 (char *)transchar(c));
|
7
|
4368 return errbuf;
|
|
4369 }
|
|
4370
|
|
4371 /*
|
|
4372 * Convert a key name or string into a key value.
|
|
4373 * Used for 'wildchar' and 'cedit' options.
|
|
4374 */
|
|
4375 static int
|
|
4376 string_to_key(arg)
|
|
4377 char_u *arg;
|
|
4378 {
|
|
4379 if (*arg == '<')
|
|
4380 return find_key_option(arg + 1);
|
|
4381 if (*arg == '^')
|
|
4382 return Ctrl_chr(arg[1]);
|
|
4383 return *arg;
|
|
4384 }
|
|
4385
|
|
4386 #ifdef FEAT_CMDWIN
|
|
4387 /*
|
|
4388 * Check value of 'cedit' and set cedit_key.
|
|
4389 * Returns NULL if value is OK, error message otherwise.
|
|
4390 */
|
|
4391 static char_u *
|
|
4392 check_cedit()
|
|
4393 {
|
|
4394 int n;
|
|
4395
|
|
4396 if (*p_cedit == NUL)
|
|
4397 cedit_key = -1;
|
|
4398 else
|
|
4399 {
|
|
4400 n = string_to_key(p_cedit);
|
|
4401 if (vim_isprintc(n))
|
|
4402 return e_invarg;
|
|
4403 cedit_key = n;
|
|
4404 }
|
|
4405 return NULL;
|
|
4406 }
|
|
4407 #endif
|
|
4408
|
|
4409 #ifdef FEAT_TITLE
|
|
4410 /*
|
|
4411 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
|
|
4412 * maketitle() to create and display it.
|
|
4413 * When switching the title or icon off, call mch_restore_title() to get
|
|
4414 * the old value back.
|
|
4415 */
|
|
4416 static void
|
|
4417 did_set_title(icon)
|
|
4418 int icon; /* Did set icon instead of title */
|
|
4419 {
|
|
4420 if (starting != NO_SCREEN
|
|
4421 #ifdef FEAT_GUI
|
|
4422 && !gui.starting
|
|
4423 #endif
|
|
4424 )
|
|
4425 {
|
|
4426 maketitle();
|
|
4427 if (icon)
|
|
4428 {
|
|
4429 if (!p_icon)
|
|
4430 mch_restore_title(2);
|
|
4431 }
|
|
4432 else
|
|
4433 {
|
|
4434 if (!p_title)
|
|
4435 mch_restore_title(1);
|
|
4436 }
|
|
4437 }
|
|
4438 }
|
|
4439 #endif
|
|
4440
|
|
4441 /*
|
|
4442 * set_options_bin - called when 'bin' changes value.
|
|
4443 */
|
|
4444 void
|
|
4445 set_options_bin(oldval, newval, opt_flags)
|
|
4446 int oldval;
|
|
4447 int newval;
|
|
4448 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
4449 {
|
|
4450 /*
|
|
4451 * The option values that are changed when 'bin' changes are
|
|
4452 * copied when 'bin is set and restored when 'bin' is reset.
|
|
4453 */
|
|
4454 if (newval)
|
|
4455 {
|
|
4456 if (!oldval) /* switched on */
|
|
4457 {
|
|
4458 if (!(opt_flags & OPT_GLOBAL))
|
|
4459 {
|
|
4460 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
|
|
4461 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
|
|
4462 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
|
|
4463 curbuf->b_p_et_nobin = curbuf->b_p_et;
|
|
4464 }
|
|
4465 if (!(opt_flags & OPT_LOCAL))
|
|
4466 {
|
|
4467 p_tw_nobin = p_tw;
|
|
4468 p_wm_nobin = p_wm;
|
|
4469 p_ml_nobin = p_ml;
|
|
4470 p_et_nobin = p_et;
|
|
4471 }
|
|
4472 }
|
|
4473
|
|
4474 if (!(opt_flags & OPT_GLOBAL))
|
|
4475 {
|
|
4476 curbuf->b_p_tw = 0; /* no automatic line wrap */
|
|
4477 curbuf->b_p_wm = 0; /* no automatic line wrap */
|
|
4478 curbuf->b_p_ml = 0; /* no modelines */
|
|
4479 curbuf->b_p_et = 0; /* no expandtab */
|
|
4480 }
|
|
4481 if (!(opt_flags & OPT_LOCAL))
|
|
4482 {
|
|
4483 p_tw = 0;
|
|
4484 p_wm = 0;
|
|
4485 p_ml = FALSE;
|
|
4486 p_et = FALSE;
|
|
4487 p_bin = TRUE; /* needed when called for the "-b" argument */
|
|
4488 }
|
|
4489 }
|
|
4490 else if (oldval) /* switched off */
|
|
4491 {
|
|
4492 if (!(opt_flags & OPT_GLOBAL))
|
|
4493 {
|
|
4494 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
|
|
4495 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
|
|
4496 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
|
|
4497 curbuf->b_p_et = curbuf->b_p_et_nobin;
|
|
4498 }
|
|
4499 if (!(opt_flags & OPT_LOCAL))
|
|
4500 {
|
|
4501 p_tw = p_tw_nobin;
|
|
4502 p_wm = p_wm_nobin;
|
|
4503 p_ml = p_ml_nobin;
|
|
4504 p_et = p_et_nobin;
|
|
4505 }
|
|
4506 }
|
|
4507 }
|
|
4508
|
|
4509 #ifdef FEAT_VIMINFO
|
|
4510 /*
|
|
4511 * Find the parameter represented by the given character (eg ', :, ", or /),
|
|
4512 * and return its associated value in the 'viminfo' string.
|
|
4513 * Only works for number parameters, not for 'r' or 'n'.
|
23
|
4514 * If the parameter is not specified in the string or there is no following
|
|
4515 * number, return -1.
|
7
|
4516 */
|
|
4517 int
|
|
4518 get_viminfo_parameter(type)
|
|
4519 int type;
|
|
4520 {
|
|
4521 char_u *p;
|
|
4522
|
|
4523 p = find_viminfo_parameter(type);
|
|
4524 if (p != NULL && VIM_ISDIGIT(*p))
|
|
4525 return atoi((char *)p);
|
|
4526 return -1;
|
|
4527 }
|
|
4528
|
|
4529 /*
|
|
4530 * Find the parameter represented by the given character (eg ''', ':', '"', or
|
|
4531 * '/') in the 'viminfo' option and return a pointer to the string after it.
|
|
4532 * Return NULL if the parameter is not specified in the string.
|
|
4533 */
|
|
4534 char_u *
|
|
4535 find_viminfo_parameter(type)
|
|
4536 int type;
|
|
4537 {
|
|
4538 char_u *p;
|
|
4539
|
|
4540 for (p = p_viminfo; *p; ++p)
|
|
4541 {
|
|
4542 if (*p == type)
|
|
4543 return p + 1;
|
|
4544 if (*p == 'n') /* 'n' is always the last one */
|
|
4545 break;
|
|
4546 p = vim_strchr(p, ','); /* skip until next ',' */
|
|
4547 if (p == NULL) /* hit the end without finding parameter */
|
|
4548 break;
|
|
4549 }
|
|
4550 return NULL;
|
|
4551 }
|
|
4552 #endif
|
|
4553
|
|
4554 /*
|
|
4555 * Expand environment variables for some string options.
|
|
4556 * These string options cannot be indirect!
|
|
4557 * If "val" is NULL expand the current value of the option.
|
|
4558 * Return pointer to NameBuff, or NULL when not expanded.
|
|
4559 */
|
|
4560 static char_u *
|
|
4561 option_expand(opt_idx, val)
|
|
4562 int opt_idx;
|
|
4563 char_u *val;
|
|
4564 {
|
|
4565 /* if option doesn't need expansion nothing to do */
|
|
4566 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
|
|
4567 return NULL;
|
|
4568
|
|
4569 /* If val is longer than MAXPATHL no meaningful expansion can be done,
|
|
4570 * expand_env() would truncate the string. */
|
|
4571 if (val != NULL && STRLEN(val) > MAXPATHL)
|
|
4572 return NULL;
|
|
4573
|
|
4574 if (val == NULL)
|
|
4575 val = *(char_u **)options[opt_idx].var;
|
|
4576
|
|
4577 /*
|
|
4578 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
|
|
4579 * Escape spaces when expanding 'tags', they are used to separate file
|
|
4580 * names.
|
374
|
4581 * For 'spellsuggest' expand after "file:".
|
7
|
4582 */
|
|
4583 expand_env_esc(val, NameBuff, MAXPATHL,
|
374
|
4584 (char_u **)options[opt_idx].var == &p_tags,
|
|
4585 #ifdef FEAT_SYN_HL
|
|
4586 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
|
|
4587 #endif
|
|
4588 NULL);
|
7
|
4589 if (STRCMP(NameBuff, val) == 0) /* they are the same */
|
|
4590 return NULL;
|
|
4591
|
|
4592 return NameBuff;
|
|
4593 }
|
|
4594
|
|
4595 /*
|
|
4596 * After setting various option values: recompute variables that depend on
|
|
4597 * option values.
|
|
4598 */
|
|
4599 static void
|
|
4600 didset_options()
|
|
4601 {
|
|
4602 /* initialize the table for 'iskeyword' et.al. */
|
|
4603 (void)init_chartab();
|
|
4604
|
|
4605 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
|
|
4606 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
|
|
4607 #ifdef FEAT_SESSION
|
|
4608 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
|
|
4609 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
|
|
4610 #endif
|
|
4611 #ifdef FEAT_FOLDING
|
|
4612 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
|
|
4613 #endif
|
|
4614 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
|
|
4615 #ifdef FEAT_VIRTUALEDIT
|
|
4616 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
|
|
4617 #endif
|
|
4618 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
|
|
4619 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
|
|
4620 #endif
|
344
|
4621 #ifdef FEAT_SYN_HL
|
374
|
4622 (void)spell_check_sps();
|
389
|
4623 (void)compile_cap_prog(curbuf);
|
344
|
4624 #endif
|
7
|
4625 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
|
|
4626 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
|
|
4627 #endif
|
|
4628 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
4629 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
|
|
4630 #endif
|
|
4631 #ifdef FEAT_CMDWIN
|
|
4632 /* set cedit_key */
|
|
4633 (void)check_cedit();
|
|
4634 #endif
|
|
4635 }
|
|
4636
|
|
4637 /*
|
|
4638 * Check for string options that are NULL (normally only termcap options).
|
|
4639 */
|
|
4640 void
|
|
4641 check_options()
|
|
4642 {
|
|
4643 int opt_idx;
|
|
4644
|
|
4645 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
|
|
4646 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
|
|
4647 check_string_option((char_u **)get_varp(&(options[opt_idx])));
|
|
4648 }
|
|
4649
|
|
4650 /*
|
|
4651 * Check string options in a buffer for NULL value.
|
|
4652 */
|
|
4653 void
|
|
4654 check_buf_options(buf)
|
|
4655 buf_T *buf;
|
|
4656 {
|
|
4657 #if defined(FEAT_QUICKFIX)
|
|
4658 check_string_option(&buf->b_p_bh);
|
|
4659 check_string_option(&buf->b_p_bt);
|
|
4660 #endif
|
|
4661 #ifdef FEAT_MBYTE
|
|
4662 check_string_option(&buf->b_p_fenc);
|
|
4663 #endif
|
|
4664 check_string_option(&buf->b_p_ff);
|
|
4665 #ifdef FEAT_FIND_ID
|
|
4666 check_string_option(&buf->b_p_def);
|
|
4667 check_string_option(&buf->b_p_inc);
|
|
4668 # ifdef FEAT_EVAL
|
|
4669 check_string_option(&buf->b_p_inex);
|
|
4670 # endif
|
|
4671 #endif
|
|
4672 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
4673 check_string_option(&buf->b_p_inde);
|
|
4674 check_string_option(&buf->b_p_indk);
|
|
4675 #endif
|
|
4676 #ifdef FEAT_CRYPT
|
|
4677 check_string_option(&buf->b_p_key);
|
|
4678 #endif
|
|
4679 check_string_option(&buf->b_p_kp);
|
|
4680 check_string_option(&buf->b_p_mps);
|
|
4681 check_string_option(&buf->b_p_fo);
|
41
|
4682 check_string_option(&buf->b_p_flp);
|
7
|
4683 check_string_option(&buf->b_p_isk);
|
|
4684 #ifdef FEAT_COMMENTS
|
|
4685 check_string_option(&buf->b_p_com);
|
|
4686 #endif
|
|
4687 #ifdef FEAT_FOLDING
|
|
4688 check_string_option(&buf->b_p_cms);
|
|
4689 #endif
|
|
4690 check_string_option(&buf->b_p_nf);
|
12
|
4691 #ifdef FEAT_TEXTOBJ
|
|
4692 check_string_option(&buf->b_p_qe);
|
|
4693 #endif
|
7
|
4694 #ifdef FEAT_SYN_HL
|
|
4695 check_string_option(&buf->b_p_syn);
|
386
|
4696 check_string_option(&buf->b_p_spc);
|
314
|
4697 check_string_option(&buf->b_p_spf);
|
221
|
4698 check_string_option(&buf->b_p_spl);
|
7
|
4699 #endif
|
|
4700 #ifdef FEAT_SEARCHPATH
|
|
4701 check_string_option(&buf->b_p_sua);
|
|
4702 #endif
|
|
4703 #ifdef FEAT_CINDENT
|
|
4704 check_string_option(&buf->b_p_cink);
|
|
4705 check_string_option(&buf->b_p_cino);
|
|
4706 #endif
|
|
4707 #ifdef FEAT_AUTOCMD
|
|
4708 check_string_option(&buf->b_p_ft);
|
|
4709 #endif
|
|
4710 #ifdef FEAT_OSFILETYPE
|
|
4711 check_string_option(&buf->b_p_oft);
|
|
4712 #endif
|
|
4713 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
4714 check_string_option(&buf->b_p_cinw);
|
|
4715 #endif
|
|
4716 #ifdef FEAT_INS_EXPAND
|
|
4717 check_string_option(&buf->b_p_cpt);
|
|
4718 #endif
|
12
|
4719 #ifdef FEAT_COMPL_FUNC
|
|
4720 check_string_option(&buf->b_p_cfu);
|
|
4721 #endif
|
7
|
4722 #ifdef FEAT_KEYMAP
|
|
4723 check_string_option(&buf->b_p_keymap);
|
|
4724 #endif
|
|
4725 #ifdef FEAT_QUICKFIX
|
|
4726 check_string_option(&buf->b_p_gp);
|
|
4727 check_string_option(&buf->b_p_mp);
|
|
4728 check_string_option(&buf->b_p_efm);
|
|
4729 #endif
|
|
4730 check_string_option(&buf->b_p_ep);
|
|
4731 check_string_option(&buf->b_p_path);
|
|
4732 check_string_option(&buf->b_p_tags);
|
|
4733 #ifdef FEAT_INS_EXPAND
|
|
4734 check_string_option(&buf->b_p_dict);
|
|
4735 check_string_option(&buf->b_p_tsr);
|
|
4736 #endif
|
|
4737 }
|
|
4738
|
|
4739 /*
|
|
4740 * Free the string allocated for an option.
|
|
4741 * Checks for the string being empty_option. This may happen if we're out of
|
|
4742 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
|
|
4743 * check_options().
|
|
4744 * Does NOT check for P_ALLOCED flag!
|
|
4745 */
|
|
4746 void
|
|
4747 free_string_option(p)
|
|
4748 char_u *p;
|
|
4749 {
|
|
4750 if (p != empty_option)
|
|
4751 vim_free(p);
|
|
4752 }
|
|
4753
|
|
4754 void
|
|
4755 clear_string_option(pp)
|
|
4756 char_u **pp;
|
|
4757 {
|
|
4758 if (*pp != empty_option)
|
|
4759 vim_free(*pp);
|
|
4760 *pp = empty_option;
|
|
4761 }
|
|
4762
|
|
4763 static void
|
|
4764 check_string_option(pp)
|
|
4765 char_u **pp;
|
|
4766 {
|
|
4767 if (*pp == NULL)
|
|
4768 *pp = empty_option;
|
|
4769 }
|
|
4770
|
|
4771 /*
|
|
4772 * Mark a terminal option as allocated, found by a pointer into term_strings[].
|
|
4773 */
|
|
4774 void
|
|
4775 set_term_option_alloced(p)
|
|
4776 char_u **p;
|
|
4777 {
|
|
4778 int opt_idx;
|
|
4779
|
|
4780 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
|
|
4781 if (options[opt_idx].var == (char_u *)p)
|
|
4782 {
|
|
4783 options[opt_idx].flags |= P_ALLOCED;
|
|
4784 return;
|
|
4785 }
|
|
4786 return; /* cannot happen: didn't find it! */
|
|
4787 }
|
|
4788
|
|
4789 /*
|
|
4790 * Set a string option to a new value (without checking the effect).
|
|
4791 * The string is copied into allocated memory.
|
|
4792 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
|
|
4793 */
|
|
4794 void
|
|
4795 set_string_option_direct(name, opt_idx, val, opt_flags)
|
|
4796 char_u *name;
|
|
4797 int opt_idx;
|
|
4798 char_u *val;
|
|
4799 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
|
|
4800 {
|
|
4801 char_u *s;
|
|
4802 char_u **varp;
|
|
4803 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
|
|
4804
|
|
4805 if (opt_idx == -1) /* use name */
|
|
4806 {
|
|
4807 opt_idx = findoption(name);
|
|
4808 if (opt_idx == -1) /* not found (should not happen) */
|
|
4809 return;
|
|
4810 }
|
|
4811
|
|
4812 if (options[opt_idx].var == NULL) /* can't set hidden option */
|
|
4813 return;
|
|
4814
|
|
4815 s = vim_strsave(val);
|
|
4816 if (s != NULL)
|
|
4817 {
|
|
4818 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
|
|
4819 both ? OPT_LOCAL : opt_flags);
|
|
4820 if ((opt_flags & OPT_FREE) && (options[opt_idx].flags & P_ALLOCED))
|
|
4821 free_string_option(*varp);
|
|
4822 *varp = s;
|
|
4823
|
|
4824 /* For buffer/window local option may also set the global value. */
|
|
4825 if (both)
|
|
4826 set_string_option_global(opt_idx, varp);
|
|
4827
|
|
4828 options[opt_idx].flags |= P_ALLOCED;
|
|
4829
|
|
4830 /* When setting both values of a global option with a local value,
|
|
4831 * make the local value empty, so that the global value is used. */
|
|
4832 if ((int)options[opt_idx].indir >= PV_BOTH && both)
|
|
4833 {
|
|
4834 free_string_option(*varp);
|
|
4835 *varp = empty_option;
|
|
4836 }
|
|
4837 }
|
|
4838 }
|
|
4839
|
|
4840 /*
|
|
4841 * Set global value for string option when it's a local option.
|
|
4842 */
|
|
4843 static void
|
|
4844 set_string_option_global(opt_idx, varp)
|
|
4845 int opt_idx; /* option index */
|
|
4846 char_u **varp; /* pointer to option variable */
|
|
4847 {
|
|
4848 char_u **p, *s;
|
|
4849
|
|
4850 /* the global value is always allocated */
|
|
4851 if (options[opt_idx].var == VAR_WIN)
|
|
4852 p = (char_u **)GLOBAL_WO(varp);
|
|
4853 else
|
|
4854 p = (char_u **)options[opt_idx].var;
|
|
4855 if (options[opt_idx].indir != PV_NONE
|
|
4856 && p != varp
|
|
4857 && (s = vim_strsave(*varp)) != NULL)
|
|
4858 {
|
|
4859 free_string_option(*p);
|
|
4860 *p = s;
|
|
4861 }
|
|
4862 }
|
|
4863
|
|
4864 /*
|
|
4865 * Set a string option to a new value, and handle the effects.
|
|
4866 */
|
|
4867 static void
|
|
4868 set_string_option(opt_idx, value, opt_flags)
|
|
4869 int opt_idx;
|
|
4870 char_u *value;
|
|
4871 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
4872 {
|
|
4873 char_u *s;
|
|
4874 char_u **varp;
|
|
4875 char_u *oldval;
|
|
4876
|
|
4877 if (options[opt_idx].var == NULL) /* don't set hidden option */
|
|
4878 return;
|
|
4879
|
|
4880 s = vim_strsave(value);
|
|
4881 if (s != NULL)
|
|
4882 {
|
|
4883 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
|
|
4884 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
4885 ? ((int)options[opt_idx].indir >= PV_BOTH
|
|
4886 ? OPT_GLOBAL : OPT_LOCAL)
|
|
4887 : opt_flags);
|
|
4888 oldval = *varp;
|
|
4889 *varp = s;
|
|
4890 options[opt_idx].flags |= P_WAS_SET;
|
|
4891 (void)did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
|
4892 opt_flags);
|
|
4893 }
|
|
4894 }
|
|
4895
|
|
4896 /*
|
|
4897 * Handle string options that need some action to perform when changed.
|
|
4898 * Returns NULL for success, or an error message for an error.
|
|
4899 */
|
|
4900 static char_u *
|
|
4901 did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
|
|
4902 opt_flags)
|
|
4903 int opt_idx; /* index in options[] table */
|
|
4904 char_u **varp; /* pointer to the option variable */
|
|
4905 int new_value_alloced; /* new value was allocated */
|
|
4906 char_u *oldval; /* previous value of the option */
|
|
4907 char_u *errbuf; /* buffer for errors, or NULL */
|
|
4908 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
4909 {
|
|
4910 char_u *errmsg = NULL;
|
|
4911 char_u *s, *p;
|
|
4912 int did_chartab = FALSE;
|
|
4913 char_u **gvarp;
|
24
|
4914 int free_oldval = (options[opt_idx].flags & P_ALLOCED);
|
7
|
4915
|
|
4916 /* Get the global option to compare with, otherwise we would have to check
|
|
4917 * two values for all local options. */
|
|
4918 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
|
|
4919
|
|
4920 /* Disallow changing some options from secure mode */
|
|
4921 if ((secure
|
|
4922 #ifdef HAVE_SANDBOX
|
|
4923 || sandbox != 0
|
|
4924 #endif
|
|
4925 ) && (options[opt_idx].flags & P_SECURE))
|
|
4926 {
|
|
4927 errmsg = e_secure;
|
|
4928 }
|
|
4929
|
36
|
4930 /* Check for a "normal" file name in some options. Disallow a path
|
|
4931 * separator (slash and/or backslash), wildcards and characters that are
|
|
4932 * often illegal in a file name. */
|
|
4933 else if ((options[opt_idx].flags & P_NFNAME)
|
39
|
4934 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
|
36
|
4935 {
|
|
4936 errmsg = e_invarg;
|
|
4937 }
|
|
4938
|
7
|
4939 /* 'term' */
|
|
4940 else if (varp == &T_NAME)
|
|
4941 {
|
|
4942 if (T_NAME[0] == NUL)
|
|
4943 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
|
|
4944 #ifdef FEAT_GUI
|
|
4945 if (gui.in_use)
|
|
4946 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
|
|
4947 else if (term_is_gui(T_NAME))
|
|
4948 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
|
|
4949 #endif
|
|
4950 else if (set_termname(T_NAME) == FAIL)
|
|
4951 errmsg = (char_u *)N_("E522: Not found in termcap");
|
|
4952 else
|
|
4953 /* Screen colors may have changed. */
|
|
4954 redraw_later_clear();
|
|
4955 }
|
|
4956
|
|
4957 /* 'backupcopy' */
|
|
4958 else if (varp == &p_bkc)
|
|
4959 {
|
|
4960 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
|
|
4961 errmsg = e_invarg;
|
|
4962 if (((bkc_flags & BKC_AUTO) != 0)
|
|
4963 + ((bkc_flags & BKC_YES) != 0)
|
|
4964 + ((bkc_flags & BKC_NO) != 0) != 1)
|
|
4965 {
|
|
4966 /* Must have exactly one of "auto", "yes" and "no". */
|
|
4967 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
|
|
4968 errmsg = e_invarg;
|
|
4969 }
|
|
4970 }
|
|
4971
|
|
4972 /* 'backupext' and 'patchmode' */
|
|
4973 else if (varp == &p_bex || varp == &p_pm)
|
|
4974 {
|
|
4975 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
|
|
4976 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
|
|
4977 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
|
|
4978 }
|
|
4979
|
|
4980 /*
|
|
4981 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
|
|
4982 * If the new option is invalid, use old value. 'lisp' option: refill
|
|
4983 * chartab[] for '-' char
|
|
4984 */
|
|
4985 else if ( varp == &p_isi
|
|
4986 || varp == &(curbuf->b_p_isk)
|
|
4987 || varp == &p_isp
|
|
4988 || varp == &p_isf)
|
|
4989 {
|
|
4990 if (init_chartab() == FAIL)
|
|
4991 {
|
|
4992 did_chartab = TRUE; /* need to restore it below */
|
|
4993 errmsg = e_invarg; /* error in value */
|
|
4994 }
|
|
4995 }
|
|
4996
|
|
4997 /* 'helpfile' */
|
|
4998 else if (varp == &p_hf)
|
|
4999 {
|
|
5000 /* May compute new values for $VIM and $VIMRUNTIME */
|
|
5001 if (didset_vim)
|
|
5002 {
|
|
5003 vim_setenv((char_u *)"VIM", (char_u *)"");
|
|
5004 didset_vim = FALSE;
|
|
5005 }
|
|
5006 if (didset_vimruntime)
|
|
5007 {
|
|
5008 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
|
|
5009 didset_vimruntime = FALSE;
|
|
5010 }
|
|
5011 }
|
|
5012
|
|
5013 #ifdef FEAT_MULTI_LANG
|
|
5014 /* 'helplang' */
|
|
5015 else if (varp == &p_hlg)
|
|
5016 {
|
|
5017 /* Check for "", "ab", "ab,cd", etc. */
|
|
5018 for (s = p_hlg; *s != NUL; s += 3)
|
|
5019 {
|
|
5020 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
|
|
5021 {
|
|
5022 errmsg = e_invarg;
|
|
5023 break;
|
|
5024 }
|
|
5025 if (s[2] == NUL)
|
|
5026 break;
|
|
5027 }
|
|
5028 }
|
|
5029 #endif
|
|
5030
|
|
5031 /* 'highlight' */
|
|
5032 else if (varp == &p_hl)
|
|
5033 {
|
|
5034 if (highlight_changed() == FAIL)
|
|
5035 errmsg = e_invarg; /* invalid flags */
|
|
5036 }
|
|
5037
|
|
5038 /* 'nrformats' */
|
|
5039 else if (gvarp == &p_nf)
|
|
5040 {
|
|
5041 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
|
|
5042 errmsg = e_invarg;
|
|
5043 }
|
|
5044
|
|
5045 #ifdef FEAT_SESSION
|
|
5046 /* 'sessionoptions' */
|
|
5047 else if (varp == &p_ssop)
|
|
5048 {
|
|
5049 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
|
|
5050 errmsg = e_invarg;
|
|
5051 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
|
|
5052 {
|
|
5053 /* Don't allow both "sesdir" and "curdir". */
|
|
5054 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
|
|
5055 errmsg = e_invarg;
|
|
5056 }
|
|
5057 }
|
|
5058 /* 'viewoptions' */
|
|
5059 else if (varp == &p_vop)
|
|
5060 {
|
|
5061 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
|
|
5062 errmsg = e_invarg;
|
|
5063 }
|
|
5064 #endif
|
|
5065
|
|
5066 /* 'scrollopt' */
|
|
5067 #ifdef FEAT_SCROLLBIND
|
|
5068 else if (varp == &p_sbo)
|
|
5069 {
|
|
5070 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
|
|
5071 errmsg = e_invarg;
|
|
5072 }
|
|
5073 #endif
|
|
5074
|
|
5075 /* 'ambiwidth' */
|
|
5076 #ifdef FEAT_MBYTE
|
|
5077 else if (varp == &p_ambw)
|
|
5078 {
|
|
5079 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
|
|
5080 errmsg = e_invarg;
|
|
5081 }
|
|
5082 #endif
|
|
5083
|
|
5084 /* 'background' */
|
|
5085 else if (varp == &p_bg)
|
|
5086 {
|
|
5087 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
|
|
5088 {
|
|
5089 #ifdef FEAT_EVAL
|
|
5090 int dark = (*p_bg == 'd');
|
|
5091 #endif
|
|
5092
|
|
5093 init_highlight(FALSE, FALSE);
|
|
5094
|
|
5095 #ifdef FEAT_EVAL
|
|
5096 if (dark != (*p_bg == 'd')
|
|
5097 && get_var_value((char_u *)"g:colors_name") != NULL)
|
|
5098 {
|
|
5099 /* The color scheme must have set 'background' back to another
|
|
5100 * value, that's not what we want here. Disable the color
|
|
5101 * scheme and set the colors again. */
|
148
|
5102 do_unlet((char_u *)"g:colors_name", TRUE);
|
7
|
5103 free_string_option(p_bg);
|
|
5104 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
|
|
5105 check_string_option(&p_bg);
|
|
5106 init_highlight(FALSE, FALSE);
|
|
5107 }
|
|
5108 #endif
|
|
5109 }
|
|
5110 else
|
|
5111 errmsg = e_invarg;
|
|
5112 }
|
|
5113
|
|
5114 /* 'wildmode' */
|
|
5115 else if (varp == &p_wim)
|
|
5116 {
|
|
5117 if (check_opt_wim() == FAIL)
|
|
5118 errmsg = e_invarg;
|
|
5119 }
|
|
5120
|
40
|
5121 #ifdef FEAT_CMDL_COMPL
|
|
5122 /* 'wildoptions' */
|
|
5123 else if (varp == &p_wop)
|
|
5124 {
|
|
5125 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
|
|
5126 errmsg = e_invarg;
|
|
5127 }
|
|
5128 #endif
|
|
5129
|
7
|
5130 #ifdef FEAT_WAK
|
|
5131 /* 'winaltkeys' */
|
|
5132 else if (varp == &p_wak)
|
|
5133 {
|
|
5134 if (*p_wak == NUL
|
|
5135 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
|
|
5136 errmsg = e_invarg;
|
|
5137 # ifdef FEAT_MENU
|
|
5138 # ifdef FEAT_GUI_MOTIF
|
|
5139 else if (gui.in_use)
|
|
5140 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
|
|
5141 # else
|
|
5142 # ifdef FEAT_GUI_GTK
|
|
5143 else if (gui.in_use)
|
|
5144 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
|
|
5145 # endif
|
|
5146 # endif
|
|
5147 # endif
|
|
5148 }
|
|
5149 #endif
|
|
5150
|
|
5151 #ifdef FEAT_AUTOCMD
|
|
5152 /* 'eventignore' */
|
|
5153 else if (varp == &p_ei)
|
|
5154 {
|
|
5155 if (check_ei() == FAIL)
|
|
5156 errmsg = e_invarg;
|
|
5157 }
|
|
5158 #endif
|
|
5159
|
|
5160 #ifdef FEAT_MBYTE
|
|
5161 /* 'encoding' and 'fileencoding' */
|
|
5162 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
|
|
5163 {
|
|
5164 if (gvarp == &p_fenc)
|
|
5165 {
|
|
5166 if (!curbuf->b_p_ma)
|
|
5167 errmsg = e_modifiable;
|
|
5168 else if (vim_strchr(*varp, ',') != NULL)
|
|
5169 /* No comma allowed in 'fileencoding'; catches confusing it
|
|
5170 * with 'fileencodings'. */
|
|
5171 errmsg = e_invarg;
|
39
|
5172 else
|
|
5173 {
|
7
|
5174 # ifdef FEAT_TITLE
|
|
5175 /* May show a "+" in the title now. */
|
|
5176 need_maketitle = TRUE;
|
|
5177 # endif
|
39
|
5178 /* Add 'fileencoding' to the swap file. */
|
|
5179 ml_setflags(curbuf);
|
|
5180 }
|
7
|
5181 }
|
|
5182 if (errmsg == NULL)
|
|
5183 {
|
|
5184 /* canonize the value, so that STRCMP() can be used on it */
|
|
5185 p = enc_canonize(*varp);
|
|
5186 if (p != NULL)
|
|
5187 {
|
|
5188 vim_free(*varp);
|
|
5189 *varp = p;
|
|
5190 }
|
|
5191 if (varp == &p_enc)
|
|
5192 {
|
|
5193 errmsg = mb_init();
|
|
5194 # ifdef FEAT_TITLE
|
|
5195 need_maketitle = TRUE;
|
|
5196 # endif
|
|
5197 }
|
|
5198 }
|
|
5199
|
|
5200 # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
5201 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
|
|
5202 {
|
|
5203 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
|
|
5204 if (STRCMP(p_tenc, "utf-8") != 0)
|
|
5205 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
|
|
5206 }
|
|
5207 # endif
|
|
5208
|
|
5209 if (errmsg == NULL)
|
|
5210 {
|
|
5211 # ifdef FEAT_KEYMAP
|
|
5212 /* When 'keymap' is used and 'encoding' changes, reload the keymap
|
|
5213 * (with another encoding). */
|
|
5214 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
|
|
5215 (void)keymap_init();
|
|
5216 # endif
|
|
5217
|
|
5218 /* When 'termencoding' is not empty and 'encoding' changes or when
|
|
5219 * 'termencoding' changes, need to setup for keyboard input and
|
|
5220 * display output conversion. */
|
|
5221 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
|
|
5222 {
|
|
5223 convert_setup(&input_conv, p_tenc, p_enc);
|
|
5224 convert_setup(&output_conv, p_enc, p_tenc);
|
|
5225 }
|
170
|
5226
|
|
5227 # if defined(WIN3264) && defined(FEAT_MBYTE)
|
|
5228 /* $HOME may have characters in active code page. */
|
|
5229 if (varp == &p_enc)
|
|
5230 init_homedir();
|
|
5231 # endif
|
7
|
5232 }
|
|
5233 }
|
|
5234 #endif
|
|
5235
|
|
5236 #if defined(FEAT_POSTSCRIPT)
|
|
5237 else if (varp == &p_penc)
|
|
5238 {
|
|
5239 /* Canonize printencoding if VIM standard one */
|
|
5240 p = enc_canonize(p_penc);
|
|
5241 if (p != NULL)
|
|
5242 {
|
|
5243 vim_free(p_penc);
|
|
5244 p_penc = p;
|
|
5245 }
|
|
5246 else
|
|
5247 {
|
|
5248 /* Ensure lower case and '-' for '_' */
|
|
5249 for (s = p_penc; *s != NUL; s++)
|
|
5250 {
|
|
5251 if (*s == '_')
|
|
5252 *s = '-';
|
|
5253 else
|
|
5254 *s = TOLOWER_ASC(*s);
|
|
5255 }
|
|
5256 }
|
|
5257 }
|
|
5258 #endif
|
|
5259
|
11
|
5260 #if defined(FEAT_XIM) && ( defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) )
|
7
|
5261 else if (varp == &p_imak)
|
|
5262 {
|
|
5263 if (gui.in_use && !im_xim_isvalid_imactivate())
|
|
5264 errmsg = e_invarg;
|
|
5265 }
|
|
5266 #endif
|
|
5267
|
|
5268 #ifdef FEAT_KEYMAP
|
|
5269 else if (varp == &curbuf->b_p_keymap)
|
|
5270 {
|
|
5271 /* load or unload key mapping tables */
|
|
5272 errmsg = keymap_init();
|
|
5273
|
|
5274 /* When successfully installed a new keymap switch on using it. */
|
|
5275 if (*curbuf->b_p_keymap != NUL && errmsg == NULL)
|
|
5276 {
|
|
5277 curbuf->b_p_iminsert = B_IMODE_LMAP;
|
|
5278 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
|
|
5279 curbuf->b_p_imsearch = B_IMODE_LMAP;
|
|
5280 set_iminsert_global();
|
|
5281 set_imsearch_global();
|
|
5282 # ifdef FEAT_WINDOWS
|
|
5283 status_redraw_curbuf();
|
|
5284 # endif
|
|
5285 }
|
|
5286 }
|
|
5287 #endif
|
|
5288
|
|
5289 /* 'fileformat' */
|
|
5290 else if (gvarp == &p_ff)
|
|
5291 {
|
|
5292 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
|
|
5293 errmsg = e_modifiable;
|
|
5294 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
|
|
5295 errmsg = e_invarg;
|
|
5296 else
|
|
5297 {
|
|
5298 /* may also change 'textmode' */
|
|
5299 if (get_fileformat(curbuf) == EOL_DOS)
|
|
5300 curbuf->b_p_tx = TRUE;
|
|
5301 else
|
|
5302 curbuf->b_p_tx = FALSE;
|
|
5303 #ifdef FEAT_TITLE
|
|
5304 need_maketitle = TRUE;
|
|
5305 #endif
|
39
|
5306 /* update flag in swap file */
|
|
5307 ml_setflags(curbuf);
|
7
|
5308 }
|
|
5309 }
|
|
5310
|
|
5311 /* 'fileformats' */
|
|
5312 else if (varp == &p_ffs)
|
|
5313 {
|
|
5314 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
|
|
5315 errmsg = e_invarg;
|
|
5316 else
|
|
5317 {
|
|
5318 /* also change 'textauto' */
|
|
5319 if (*p_ffs == NUL)
|
|
5320 p_ta = FALSE;
|
|
5321 else
|
|
5322 p_ta = TRUE;
|
|
5323 }
|
|
5324 }
|
|
5325
|
|
5326 #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST)
|
|
5327 /* 'cryptkey' */
|
|
5328 else if (gvarp == &p_key)
|
|
5329 {
|
|
5330 /* Make sure the ":set" command doesn't show the new value in the
|
|
5331 * history. */
|
|
5332 remove_key_from_history();
|
|
5333 }
|
|
5334 #endif
|
|
5335
|
|
5336 /* 'matchpairs' */
|
|
5337 else if (gvarp == &p_mps)
|
|
5338 {
|
|
5339 /* Check for "x:y,x:y" */
|
|
5340 for (p = *varp; *p != NUL; p += 4)
|
|
5341 {
|
|
5342 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
|
|
5343 {
|
|
5344 errmsg = e_invarg;
|
|
5345 break;
|
|
5346 }
|
|
5347 if (p[3] == NUL)
|
|
5348 break;
|
|
5349 }
|
|
5350 }
|
|
5351
|
|
5352 #ifdef FEAT_COMMENTS
|
|
5353 /* 'comments' */
|
|
5354 else if (gvarp == &p_com)
|
|
5355 {
|
|
5356 for (s = *varp; *s; )
|
|
5357 {
|
|
5358 while (*s && *s != ':')
|
|
5359 {
|
|
5360 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
|
|
5361 && !VIM_ISDIGIT(*s) && *s != '-')
|
|
5362 {
|
|
5363 errmsg = illegal_char(errbuf, *s);
|
|
5364 break;
|
|
5365 }
|
|
5366 ++s;
|
|
5367 }
|
|
5368 if (*s++ == NUL)
|
|
5369 errmsg = (char_u *)N_("E524: Missing colon");
|
|
5370 else if (*s == ',' || *s == NUL)
|
|
5371 errmsg = (char_u *)N_("E525: Zero length string");
|
|
5372 if (errmsg != NULL)
|
|
5373 break;
|
|
5374 while (*s && *s != ',')
|
|
5375 {
|
|
5376 if (*s == '\\' && s[1] != NUL)
|
|
5377 ++s;
|
|
5378 ++s;
|
|
5379 }
|
|
5380 s = skip_to_option_part(s);
|
|
5381 }
|
|
5382 }
|
|
5383 #endif
|
|
5384
|
|
5385 /* 'listchars' */
|
|
5386 else if (varp == &p_lcs)
|
|
5387 {
|
|
5388 errmsg = set_chars_option(varp);
|
|
5389 }
|
|
5390
|
|
5391 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
5392 /* 'fillchars' */
|
|
5393 else if (varp == &p_fcs)
|
|
5394 {
|
|
5395 errmsg = set_chars_option(varp);
|
|
5396 }
|
|
5397 #endif
|
|
5398
|
|
5399 #ifdef FEAT_CMDWIN
|
|
5400 /* 'cedit' */
|
|
5401 else if (varp == &p_cedit)
|
|
5402 {
|
|
5403 errmsg = check_cedit();
|
|
5404 }
|
|
5405 #endif
|
|
5406
|
294
|
5407 /* 'verbosefile' */
|
|
5408 else if (varp == &p_vfile)
|
|
5409 {
|
|
5410 verbose_stop();
|
|
5411 if (*p_vfile != NUL && verbose_open() == FAIL)
|
|
5412 errmsg = e_invarg;
|
|
5413 }
|
|
5414
|
7
|
5415 #ifdef FEAT_VIMINFO
|
|
5416 /* 'viminfo' */
|
|
5417 else if (varp == &p_viminfo)
|
|
5418 {
|
|
5419 for (s = p_viminfo; *s;)
|
|
5420 {
|
|
5421 /* Check it's a valid character */
|
|
5422 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
|
|
5423 {
|
|
5424 errmsg = illegal_char(errbuf, *s);
|
|
5425 break;
|
|
5426 }
|
|
5427 if (*s == 'n') /* name is always last one */
|
|
5428 {
|
|
5429 break;
|
|
5430 }
|
|
5431 else if (*s == 'r') /* skip until next ',' */
|
|
5432 {
|
|
5433 while (*++s && *s != ',')
|
|
5434 ;
|
|
5435 }
|
23
|
5436 else if (*s == '%')
|
|
5437 {
|
|
5438 /* optional number */
|
|
5439 while (vim_isdigit(*++s))
|
|
5440 ;
|
|
5441 }
|
|
5442 else if (*s == '!' || *s == 'h' || *s == 'c')
|
7
|
5443 ++s; /* no extra chars */
|
|
5444 else /* must have a number */
|
|
5445 {
|
|
5446 while (vim_isdigit(*++s))
|
|
5447 ;
|
|
5448
|
|
5449 if (!VIM_ISDIGIT(*(s - 1)))
|
|
5450 {
|
|
5451 if (errbuf != NULL)
|
|
5452 {
|
133
|
5453 sprintf((char *)errbuf,
|
|
5454 _("E526: Missing number after <%s>"),
|
7
|
5455 transchar_byte(*(s - 1)));
|
|
5456 errmsg = errbuf;
|
|
5457 }
|
|
5458 else
|
|
5459 errmsg = (char_u *)"";
|
|
5460 break;
|
|
5461 }
|
|
5462 }
|
|
5463 if (*s == ',')
|
|
5464 ++s;
|
|
5465 else if (*s)
|
|
5466 {
|
|
5467 if (errbuf != NULL)
|
|
5468 errmsg = (char_u *)N_("E527: Missing comma");
|
|
5469 else
|
|
5470 errmsg = (char_u *)"";
|
|
5471 break;
|
|
5472 }
|
|
5473 }
|
|
5474 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
|
|
5475 errmsg = (char_u *)N_("E528: Must specify a ' value");
|
|
5476 }
|
|
5477 #endif /* FEAT_VIMINFO */
|
|
5478
|
|
5479 /* terminal options */
|
|
5480 else if (istermoption(&options[opt_idx]) && full_screen)
|
|
5481 {
|
|
5482 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
|
|
5483 if (varp == &T_CCO)
|
|
5484 {
|
|
5485 t_colors = atoi((char *)T_CCO);
|
|
5486 if (t_colors <= 1)
|
|
5487 {
|
|
5488 if (new_value_alloced)
|
|
5489 vim_free(T_CCO);
|
|
5490 T_CCO = empty_option;
|
|
5491 }
|
|
5492 /* We now have a different color setup, initialize it again. */
|
|
5493 init_highlight(TRUE, FALSE);
|
|
5494 }
|
|
5495 ttest(FALSE);
|
|
5496 if (varp == &T_ME)
|
|
5497 {
|
|
5498 out_str(T_ME);
|
|
5499 redraw_later(CLEAR);
|
|
5500 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
|
|
5501 /* Since t_me has been set, this probably means that the user
|
|
5502 * wants to use this as default colors. Need to reset default
|
|
5503 * background/foreground colors. */
|
|
5504 mch_set_normal_colors();
|
|
5505 #endif
|
|
5506 }
|
|
5507 }
|
|
5508
|
|
5509 #ifdef FEAT_LINEBREAK
|
|
5510 /* 'showbreak' */
|
|
5511 else if (varp == &p_sbr)
|
|
5512 {
|
|
5513 for (s = p_sbr; *s; )
|
|
5514 {
|
|
5515 if (ptr2cells(s) != 1)
|
|
5516 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
|
39
|
5517 mb_ptr_adv(s);
|
7
|
5518 }
|
|
5519 }
|
|
5520 #endif
|
|
5521
|
|
5522 #ifdef FEAT_GUI
|
|
5523 /* 'guifont' */
|
|
5524 else if (varp == &p_guifont)
|
|
5525 {
|
|
5526 if (gui.in_use)
|
|
5527 {
|
|
5528 p = p_guifont;
|
11
|
5529 # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
|
7
|
5530 /*
|
|
5531 * Put up a font dialog and let the user select a new value.
|
|
5532 * If this is cancelled go back to the old value but don't
|
|
5533 * give an error message.
|
|
5534 */
|
|
5535 if (STRCMP(p, "*") == 0)
|
|
5536 {
|
|
5537 p = gui_mch_font_dialog(oldval);
|
|
5538
|
|
5539 if (new_value_alloced)
|
|
5540 free_string_option(p_guifont);
|
|
5541
|
|
5542 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
|
|
5543 new_value_alloced = TRUE;
|
|
5544 }
|
|
5545 # endif
|
|
5546 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
|
|
5547 {
|
|
5548 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
|
|
5549 if (STRCMP(p_guifont, "*") == 0)
|
|
5550 {
|
|
5551 /* Dialog was cancelled: Keep the old value without giving
|
|
5552 * an error message. */
|
|
5553 if (new_value_alloced)
|
|
5554 free_string_option(p_guifont);
|
|
5555 p_guifont = vim_strsave(oldval);
|
|
5556 new_value_alloced = TRUE;
|
|
5557 }
|
|
5558 else
|
|
5559 # endif
|
|
5560 errmsg = (char_u *)N_("E596: Invalid font(s)");
|
|
5561 }
|
|
5562 }
|
|
5563 }
|
|
5564 # ifdef FEAT_XFONTSET
|
|
5565 else if (varp == &p_guifontset)
|
|
5566 {
|
|
5567 if (STRCMP(p_guifontset, "*") == 0)
|
|
5568 errmsg = (char_u *)N_("E597: can't select fontset");
|
|
5569 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
|
|
5570 errmsg = (char_u *)N_("E598: Invalid fontset");
|
|
5571 }
|
|
5572 # endif
|
|
5573 # ifdef FEAT_MBYTE
|
|
5574 else if (varp == &p_guifontwide)
|
|
5575 {
|
|
5576 if (STRCMP(p_guifontwide, "*") == 0)
|
|
5577 errmsg = (char_u *)N_("E533: can't select wide font");
|
|
5578 else if (gui_get_wide_font() == FAIL)
|
|
5579 errmsg = (char_u *)N_("E534: Invalid wide font");
|
|
5580 }
|
|
5581 # endif
|
|
5582 #endif
|
|
5583
|
|
5584 #ifdef CURSOR_SHAPE
|
|
5585 /* 'guicursor' */
|
|
5586 else if (varp == &p_guicursor)
|
|
5587 errmsg = parse_shape_opt(SHAPE_CURSOR);
|
|
5588 #endif
|
|
5589
|
|
5590 #ifdef FEAT_MOUSESHAPE
|
|
5591 /* 'mouseshape' */
|
|
5592 else if (varp == &p_mouseshape)
|
|
5593 {
|
|
5594 errmsg = parse_shape_opt(SHAPE_MOUSE);
|
|
5595 update_mouseshape(-1);
|
|
5596 }
|
|
5597 #endif
|
|
5598
|
|
5599 #ifdef FEAT_PRINTER
|
|
5600 else if (varp == &p_popt)
|
21
|
5601 errmsg = parse_list_options(p_popt, printer_opts,
|
|
5602 OPT_PRINT_NUM_OPTIONS);
|
15
|
5603
|
16
|
5604 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
|
15
|
5605 else if (varp == &p_pmfn)
|
21
|
5606 errmsg = parse_list_options(p_pmfn, mbfont_opts,
|
|
5607 OPT_MBFONT_NUM_OPTIONS);
|
15
|
5608 # endif
|
7
|
5609 #endif
|
|
5610
|
|
5611 #ifdef FEAT_LANGMAP
|
|
5612 /* 'langmap' */
|
|
5613 else if (varp == &p_langmap)
|
|
5614 langmap_set();
|
|
5615 #endif
|
|
5616
|
|
5617 #ifdef FEAT_LINEBREAK
|
|
5618 /* 'breakat' */
|
|
5619 else if (varp == &p_breakat)
|
|
5620 fill_breakat_flags();
|
|
5621 #endif
|
|
5622
|
|
5623 #ifdef FEAT_TITLE
|
|
5624 /* 'titlestring' and 'iconstring' */
|
|
5625 else if (varp == &p_titlestring || varp == &p_iconstring)
|
|
5626 {
|
|
5627 # ifdef FEAT_STL_OPT
|
|
5628 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
|
|
5629
|
|
5630 /* NULL => statusline syntax */
|
|
5631 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
|
|
5632 stl_syntax |= flagval;
|
|
5633 else
|
|
5634 stl_syntax &= ~flagval;
|
|
5635 # endif
|
|
5636 did_set_title(varp == &p_iconstring);
|
|
5637
|
|
5638 }
|
|
5639 #endif
|
|
5640
|
|
5641 #ifdef FEAT_GUI
|
|
5642 /* 'guioptions' */
|
|
5643 else if (varp == &p_go)
|
|
5644 gui_init_which_components(oldval);
|
|
5645 #endif
|
|
5646
|
|
5647 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
|
|
5648 /* 'ttymouse' */
|
|
5649 else if (varp == &p_ttym)
|
|
5650 {
|
190
|
5651 /* Switch the mouse off before changing the escape sequences used for
|
|
5652 * that. */
|
|
5653 mch_setmouse(FALSE);
|
7
|
5654 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
|
|
5655 errmsg = e_invarg;
|
|
5656 else
|
|
5657 check_mouse_termcode();
|
227
|
5658 if (termcap_active)
|
|
5659 setmouse(); /* may switch it on again */
|
7
|
5660 }
|
|
5661 #endif
|
|
5662
|
|
5663 #ifdef FEAT_VISUAL
|
|
5664 /* 'selection' */
|
|
5665 else if (varp == &p_sel)
|
|
5666 {
|
|
5667 if (*p_sel == NUL
|
|
5668 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
|
|
5669 errmsg = e_invarg;
|
|
5670 }
|
|
5671
|
|
5672 /* 'selectmode' */
|
|
5673 else if (varp == &p_slm)
|
|
5674 {
|
|
5675 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
|
|
5676 errmsg = e_invarg;
|
|
5677 }
|
|
5678 #endif
|
|
5679
|
|
5680 #ifdef FEAT_BROWSE
|
|
5681 /* 'browsedir' */
|
|
5682 else if (varp == &p_bsdir)
|
|
5683 {
|
|
5684 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
|
|
5685 && !mch_isdir(p_bsdir))
|
|
5686 errmsg = e_invarg;
|
|
5687 }
|
|
5688 #endif
|
|
5689
|
|
5690 #ifdef FEAT_VISUAL
|
|
5691 /* 'keymodel' */
|
|
5692 else if (varp == &p_km)
|
|
5693 {
|
|
5694 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
|
|
5695 errmsg = e_invarg;
|
|
5696 else
|
|
5697 {
|
|
5698 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
|
|
5699 km_startsel = (vim_strchr(p_km, 'a') != NULL);
|
|
5700 }
|
|
5701 }
|
|
5702 #endif
|
|
5703
|
|
5704 /* 'mousemodel' */
|
|
5705 else if (varp == &p_mousem)
|
|
5706 {
|
|
5707 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
|
|
5708 errmsg = e_invarg;
|
|
5709 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
|
|
5710 else if (*p_mousem != *oldval)
|
|
5711 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
|
|
5712 * to create or delete the popup menus. */
|
|
5713 gui_motif_update_mousemodel(root_menu);
|
|
5714 #endif
|
|
5715 }
|
|
5716
|
|
5717 /* 'switchbuf' */
|
|
5718 else if (varp == &p_swb)
|
|
5719 {
|
|
5720 if (check_opt_strings(p_swb, p_swb_values, TRUE) != OK)
|
|
5721 errmsg = e_invarg;
|
|
5722 }
|
|
5723
|
|
5724 /* 'debug' */
|
|
5725 else if (varp == &p_debug)
|
|
5726 {
|
|
5727 if (check_opt_strings(p_debug, p_debug_values, FALSE) != OK)
|
|
5728 errmsg = e_invarg;
|
|
5729 }
|
|
5730
|
|
5731 /* 'display' */
|
|
5732 else if (varp == &p_dy)
|
|
5733 {
|
|
5734 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
|
|
5735 errmsg = e_invarg;
|
|
5736 else
|
|
5737 (void)init_chartab();
|
|
5738
|
|
5739 }
|
|
5740
|
|
5741 #ifdef FEAT_VERTSPLIT
|
|
5742 /* 'eadirection' */
|
|
5743 else if (varp == &p_ead)
|
|
5744 {
|
|
5745 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
|
|
5746 errmsg = e_invarg;
|
|
5747 }
|
|
5748 #endif
|
|
5749
|
|
5750 #ifdef FEAT_CLIPBOARD
|
|
5751 /* 'clipboard' */
|
|
5752 else if (varp == &p_cb)
|
|
5753 errmsg = check_clipboard_option();
|
|
5754 #endif
|
|
5755
|
221
|
5756 #ifdef FEAT_SYN_HL
|
323
|
5757 /* When 'spelllang' or 'spellfile' is set and there is a window for this
|
|
5758 * buffer in which 'spell' is set load the wordlists. */
|
|
5759 else if (varp == &(curbuf->b_p_spl) || varp == &(curbuf->b_p_spf))
|
221
|
5760 {
|
258
|
5761 win_T *wp;
|
323
|
5762 int l;
|
|
5763
|
|
5764 if (varp == &(curbuf->b_p_spf))
|
|
5765 {
|
|
5766 l = STRLEN(curbuf->b_p_spf);
|
|
5767 if (l > 0 && (l < 4 || STRCMP(curbuf->b_p_spf + l - 4,
|
|
5768 ".add") != 0))
|
|
5769 errmsg = e_invarg;
|
|
5770 }
|
|
5771
|
|
5772 if (errmsg == NULL)
|
|
5773 {
|
|
5774 FOR_ALL_WINDOWS(wp)
|
|
5775 if (wp->w_buffer == curbuf && wp->w_p_spell)
|
|
5776 {
|
|
5777 errmsg = did_set_spelllang(curbuf);
|
258
|
5778 # ifdef FEAT_WINDOWS
|
323
|
5779 break;
|
258
|
5780 # endif
|
323
|
5781 }
|
|
5782 }
|
221
|
5783 }
|
386
|
5784 /* When 'spellcapcheck' is set compile the regexp program. */
|
|
5785 else if (varp == &(curbuf->b_p_spc))
|
|
5786 {
|
389
|
5787 errmsg = compile_cap_prog(curbuf);
|
386
|
5788 }
|
344
|
5789 /* 'spellsuggest' */
|
|
5790 else if (varp == &p_sps)
|
|
5791 {
|
374
|
5792 if (spell_check_sps() != OK)
|
344
|
5793 errmsg = e_invarg;
|
|
5794 }
|
221
|
5795 #endif
|
|
5796
|
7
|
5797 #ifdef FEAT_AUTOCMD
|
|
5798 # ifdef FEAT_SYN_HL
|
|
5799 /* When 'syntax' is set, load the syntax of that name */
|
|
5800 else if (varp == &(curbuf->b_p_syn))
|
|
5801 {
|
|
5802 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
|
|
5803 curbuf->b_fname, TRUE, curbuf);
|
|
5804 }
|
|
5805 # endif
|
|
5806
|
|
5807 /* When 'filetype' is set, trigger the FileType autocommands of that name */
|
|
5808 else if (varp == &(curbuf->b_p_ft))
|
|
5809 {
|
|
5810 did_filetype = TRUE;
|
|
5811 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
|
|
5812 curbuf->b_fname, TRUE, curbuf);
|
|
5813 }
|
|
5814 #endif
|
|
5815
|
|
5816 #ifdef FEAT_QUICKFIX
|
|
5817 /* When 'bufhidden' is set, check for valid value. */
|
|
5818 else if (gvarp == &p_bh)
|
|
5819 {
|
|
5820 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
|
|
5821 errmsg = e_invarg;
|
|
5822 }
|
|
5823
|
|
5824 /* When 'buftype' is set, check for valid value. */
|
|
5825 else if (gvarp == &p_bt)
|
|
5826 {
|
|
5827 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
|
|
5828 errmsg = e_invarg;
|
|
5829 else
|
|
5830 {
|
|
5831 # ifdef FEAT_WINDOWS
|
|
5832 if (curwin->w_status_height)
|
|
5833 {
|
|
5834 curwin->w_redr_status = TRUE;
|
|
5835 redraw_later(VALID);
|
|
5836 }
|
|
5837 # endif
|
|
5838 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
|
|
5839 }
|
|
5840 }
|
|
5841 #endif
|
|
5842
|
|
5843 #ifdef FEAT_STL_OPT
|
|
5844 /* 'statusline' or 'rulerformat' */
|
40
|
5845 else if (gvarp == &p_stl || varp == &p_ruf)
|
7
|
5846 {
|
|
5847 int wid;
|
|
5848
|
|
5849 if (varp == &p_ruf) /* reset ru_wid first */
|
|
5850 ru_wid = 0;
|
|
5851 s = *varp;
|
|
5852 if (varp == &p_ruf && *s == '%')
|
|
5853 {
|
|
5854 /* set ru_wid if 'ruf' starts with "%99(" */
|
|
5855 if (*++s == '-') /* ignore a '-' */
|
|
5856 s++;
|
|
5857 wid = getdigits(&s);
|
|
5858 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
|
|
5859 ru_wid = wid;
|
|
5860 else
|
|
5861 errmsg = check_stl_option(p_ruf);
|
|
5862 }
|
|
5863 else
|
|
5864 errmsg = check_stl_option(s);
|
40
|
5865 if (varp == &p_ruf && errmsg == NULL)
|
7
|
5866 comp_col();
|
|
5867 }
|
|
5868 #endif
|
|
5869
|
|
5870 #ifdef FEAT_INS_EXPAND
|
|
5871 /* check if it is a valid value for 'complete' -- Acevedo */
|
|
5872 else if (gvarp == &p_cpt)
|
|
5873 {
|
|
5874 for (s = *varp; *s;)
|
|
5875 {
|
|
5876 while(*s == ',' || *s == ' ')
|
|
5877 s++;
|
|
5878 if (!*s)
|
|
5879 break;
|
|
5880 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
|
|
5881 {
|
|
5882 errmsg = illegal_char(errbuf, *s);
|
|
5883 break;
|
|
5884 }
|
|
5885 if (*++s != NUL && *s != ',' && *s != ' ')
|
|
5886 {
|
|
5887 if (s[-1] == 'k' || s[-1] == 's')
|
|
5888 {
|
|
5889 /* skip optional filename after 'k' and 's' */
|
|
5890 while (*s && *s != ',' && *s != ' ')
|
|
5891 {
|
|
5892 if (*s == '\\')
|
|
5893 ++s;
|
|
5894 ++s;
|
|
5895 }
|
|
5896 }
|
|
5897 else
|
|
5898 {
|
|
5899 if (errbuf != NULL)
|
|
5900 {
|
|
5901 sprintf((char *)errbuf,
|
|
5902 _("E535: Illegal character after <%c>"),
|
|
5903 *--s);
|
|
5904 errmsg = errbuf;
|
|
5905 }
|
|
5906 else
|
|
5907 errmsg = (char_u *)"";
|
|
5908 break;
|
|
5909 }
|
|
5910 }
|
|
5911 }
|
|
5912 }
|
|
5913 #endif /* FEAT_INS_EXPAND */
|
|
5914
|
|
5915
|
|
5916 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
|
|
5917 else if (varp == &p_toolbar)
|
|
5918 {
|
|
5919 if (opt_strings_flags(p_toolbar, p_toolbar_values,
|
|
5920 &toolbar_flags, TRUE) != OK)
|
|
5921 errmsg = e_invarg;
|
|
5922 else
|
|
5923 {
|
|
5924 out_flush();
|
|
5925 gui_mch_show_toolbar((toolbar_flags &
|
|
5926 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
|
|
5927 }
|
|
5928 }
|
|
5929 #endif
|
|
5930
|
|
5931 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
5932 /* 'toolbariconsize': GTK+ 2 only */
|
|
5933 else if (varp == &p_tbis)
|
|
5934 {
|
|
5935 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
|
|
5936 errmsg = e_invarg;
|
|
5937 else
|
|
5938 {
|
|
5939 out_flush();
|
|
5940 gui_mch_show_toolbar((toolbar_flags &
|
|
5941 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
|
|
5942 }
|
|
5943 }
|
|
5944 #endif
|
|
5945
|
|
5946 /* 'pastetoggle': translate key codes like in a mapping */
|
|
5947 else if (varp == &p_pt)
|
|
5948 {
|
|
5949 if (*p_pt)
|
|
5950 {
|
|
5951 (void)replace_termcodes(p_pt, &p, TRUE, TRUE);
|
|
5952 if (p != NULL)
|
|
5953 {
|
|
5954 if (new_value_alloced)
|
|
5955 free_string_option(p_pt);
|
|
5956 p_pt = p;
|
|
5957 new_value_alloced = TRUE;
|
|
5958 }
|
|
5959 }
|
|
5960 }
|
|
5961
|
|
5962 /* 'backspace' */
|
|
5963 else if (varp == &p_bs)
|
|
5964 {
|
|
5965 if (VIM_ISDIGIT(*p_bs))
|
|
5966 {
|
|
5967 if (*p_bs >'2' || p_bs[1] != NUL)
|
|
5968 errmsg = e_invarg;
|
|
5969 }
|
|
5970 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
|
|
5971 errmsg = e_invarg;
|
|
5972 }
|
|
5973
|
|
5974 /* 'casemap' */
|
|
5975 else if (varp == &p_cmp)
|
|
5976 {
|
|
5977 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
|
|
5978 errmsg = e_invarg;
|
|
5979 }
|
|
5980
|
|
5981 #ifdef FEAT_DIFF
|
|
5982 /* 'diffopt' */
|
|
5983 else if (varp == &p_dip)
|
|
5984 {
|
|
5985 if (diffopt_changed() == FAIL)
|
|
5986 errmsg = e_invarg;
|
|
5987 }
|
|
5988 #endif
|
|
5989
|
|
5990 #ifdef FEAT_FOLDING
|
|
5991 /* 'foldmethod' */
|
|
5992 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
|
|
5993 {
|
|
5994 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
|
|
5995 || *curwin->w_p_fdm == NUL)
|
|
5996 errmsg = e_invarg;
|
|
5997 else
|
|
5998 foldUpdateAll(curwin);
|
|
5999 }
|
|
6000 # ifdef FEAT_EVAL
|
|
6001 /* 'foldexpr' */
|
|
6002 else if (varp == &curwin->w_p_fde)
|
|
6003 {
|
|
6004 if (foldmethodIsExpr(curwin))
|
|
6005 foldUpdateAll(curwin);
|
|
6006 }
|
|
6007 # endif
|
|
6008 /* 'foldmarker' */
|
|
6009 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
|
|
6010 {
|
|
6011 p = vim_strchr(*varp, ',');
|
|
6012 if (p == NULL)
|
|
6013 errmsg = (char_u *)N_("E536: comma required");
|
|
6014 else if (p == *varp || p[1] == NUL)
|
|
6015 errmsg = e_invarg;
|
|
6016 else if (foldmethodIsMarker(curwin))
|
|
6017 foldUpdateAll(curwin);
|
|
6018 }
|
|
6019 /* 'commentstring' */
|
|
6020 else if (gvarp == &p_cms)
|
|
6021 {
|
|
6022 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
|
|
6023 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
|
|
6024 }
|
|
6025 /* 'foldopen' */
|
|
6026 else if (varp == &p_fdo)
|
|
6027 {
|
|
6028 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
|
|
6029 errmsg = e_invarg;
|
|
6030 }
|
|
6031 /* 'foldclose' */
|
|
6032 else if (varp == &p_fcl)
|
|
6033 {
|
|
6034 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
|
|
6035 errmsg = e_invarg;
|
|
6036 }
|
|
6037 #endif
|
|
6038
|
|
6039 #ifdef FEAT_VIRTUALEDIT
|
|
6040 /* 'virtualedit' */
|
|
6041 else if (varp == &p_ve)
|
|
6042 {
|
|
6043 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
|
|
6044 errmsg = e_invarg;
|
|
6045 else if (STRCMP(p_ve, oldval) != 0)
|
|
6046 {
|
|
6047 /* Recompute cursor position in case the new 've' setting
|
|
6048 * changes something. */
|
|
6049 validate_virtcol();
|
|
6050 coladvance(curwin->w_virtcol);
|
|
6051 }
|
|
6052 }
|
|
6053 #endif
|
|
6054
|
|
6055 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
|
|
6056 else if (varp == &p_csqf)
|
|
6057 {
|
|
6058 if (p_csqf != NULL)
|
|
6059 {
|
|
6060 p = p_csqf;
|
|
6061 while (*p != NUL)
|
|
6062 {
|
|
6063 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
|
|
6064 || p[1] == NUL
|
|
6065 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
|
|
6066 || (p[2] != NUL && p[2] != ','))
|
|
6067 {
|
|
6068 errmsg = e_invarg;
|
|
6069 break;
|
|
6070 }
|
|
6071 else if (p[2] == NUL)
|
|
6072 break;
|
|
6073 else
|
|
6074 p += 3;
|
|
6075 }
|
|
6076 }
|
|
6077 }
|
|
6078 #endif
|
|
6079
|
|
6080 /* Options that are a list of flags. */
|
|
6081 else
|
|
6082 {
|
|
6083 p = NULL;
|
|
6084 if (varp == &p_ww)
|
|
6085 p = (char_u *)WW_ALL;
|
|
6086 if (varp == &p_shm)
|
|
6087 p = (char_u *)SHM_ALL;
|
|
6088 else if (varp == &(p_cpo))
|
|
6089 p = (char_u *)CPO_ALL;
|
|
6090 else if (varp == &(curbuf->b_p_fo))
|
|
6091 p = (char_u *)FO_ALL;
|
|
6092 else if (varp == &p_mouse)
|
|
6093 {
|
|
6094 #ifdef FEAT_MOUSE
|
|
6095 p = (char_u *)MOUSE_ALL;
|
|
6096 #else
|
|
6097 if (*p_mouse != NUL)
|
|
6098 errmsg = (char_u *)N_("E538: No mouse support");
|
|
6099 #endif
|
|
6100 }
|
|
6101 #if defined(FEAT_GUI)
|
|
6102 else if (varp == &p_go)
|
|
6103 p = (char_u *)GO_ALL;
|
|
6104 #endif
|
|
6105 if (p != NULL)
|
|
6106 {
|
|
6107 for (s = *varp; *s; ++s)
|
|
6108 if (vim_strchr(p, *s) == NULL)
|
|
6109 {
|
|
6110 errmsg = illegal_char(errbuf, *s);
|
|
6111 break;
|
|
6112 }
|
|
6113 }
|
|
6114 }
|
|
6115
|
|
6116 /*
|
|
6117 * If error detected, restore the previous value.
|
|
6118 */
|
|
6119 if (errmsg != NULL)
|
|
6120 {
|
|
6121 if (new_value_alloced)
|
|
6122 free_string_option(*varp);
|
|
6123 *varp = oldval;
|
|
6124 /*
|
|
6125 * When resetting some values, need to act on it.
|
|
6126 */
|
|
6127 if (did_chartab)
|
|
6128 (void)init_chartab();
|
|
6129 if (varp == &p_hl)
|
|
6130 (void)highlight_changed();
|
|
6131 }
|
|
6132 else
|
|
6133 {
|
|
6134 #ifdef FEAT_EVAL
|
|
6135 /* Remember where the option was set. */
|
|
6136 options[opt_idx].scriptID = current_SID;
|
|
6137 #endif
|
|
6138 /*
|
|
6139 * Free string options that are in allocated memory.
|
24
|
6140 * Use "free_oldval", because recursiveness may change the flags under
|
|
6141 * our fingers (esp. init_highlight()).
|
7
|
6142 */
|
24
|
6143 if (free_oldval)
|
7
|
6144 free_string_option(oldval);
|
|
6145 if (new_value_alloced)
|
|
6146 options[opt_idx].flags |= P_ALLOCED;
|
|
6147 else
|
|
6148 options[opt_idx].flags &= ~P_ALLOCED;
|
|
6149
|
|
6150 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
6151 && (int)options[opt_idx].indir >= PV_BOTH)
|
|
6152 {
|
|
6153 /* global option with local value set to use global value; free
|
|
6154 * the local value and make it empty */
|
|
6155 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
|
|
6156 free_string_option(*(char_u **)p);
|
|
6157 *(char_u **)p = empty_option;
|
|
6158 }
|
|
6159
|
|
6160 /* May set global value for local option. */
|
|
6161 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
|
|
6162 set_string_option_global(opt_idx, varp);
|
|
6163 }
|
|
6164
|
|
6165 #ifdef FEAT_MOUSE
|
|
6166 if (varp == &p_mouse)
|
|
6167 {
|
|
6168 # ifdef FEAT_MOUSE_TTY
|
|
6169 if (*p_mouse == NUL)
|
|
6170 mch_setmouse(FALSE); /* switch mouse off */
|
|
6171 else
|
|
6172 # endif
|
|
6173 setmouse(); /* in case 'mouse' changed */
|
|
6174 }
|
|
6175 #endif
|
|
6176
|
|
6177 if (curwin->w_curswant != MAXCOL)
|
|
6178 curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */
|
|
6179 check_redraw(options[opt_idx].flags);
|
|
6180
|
|
6181 return errmsg;
|
|
6182 }
|
|
6183
|
|
6184 /*
|
|
6185 * Handle setting 'listchars' or 'fillchars'.
|
|
6186 * Returns error message, NULL if it's OK.
|
|
6187 */
|
|
6188 static char_u *
|
|
6189 set_chars_option(varp)
|
|
6190 char_u **varp;
|
|
6191 {
|
|
6192 int round, i, len, entries;
|
|
6193 char_u *p, *s;
|
|
6194 int c1, c2 = 0;
|
|
6195 struct charstab
|
|
6196 {
|
|
6197 int *cp;
|
|
6198 char *name;
|
|
6199 };
|
|
6200 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6201 static struct charstab filltab[] =
|
|
6202 {
|
|
6203 {&fill_stl, "stl"},
|
|
6204 {&fill_stlnc, "stlnc"},
|
|
6205 {&fill_vert, "vert"},
|
|
6206 {&fill_fold, "fold"},
|
|
6207 {&fill_diff, "diff"},
|
|
6208 };
|
|
6209 #endif
|
|
6210 static struct charstab lcstab[] =
|
|
6211 {
|
|
6212 {&lcs_eol, "eol"},
|
|
6213 {&lcs_ext, "extends"},
|
12
|
6214 {&lcs_nbsp, "nbsp"},
|
7
|
6215 {&lcs_prec, "precedes"},
|
|
6216 {&lcs_tab2, "tab"},
|
|
6217 {&lcs_trail, "trail"},
|
|
6218 };
|
|
6219 struct charstab *tab;
|
|
6220
|
|
6221 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6222 if (varp == &p_lcs)
|
|
6223 #endif
|
|
6224 {
|
|
6225 tab = lcstab;
|
|
6226 entries = sizeof(lcstab) / sizeof(struct charstab);
|
|
6227 }
|
|
6228 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6229 else
|
|
6230 {
|
|
6231 tab = filltab;
|
|
6232 entries = sizeof(filltab) / sizeof(struct charstab);
|
|
6233 }
|
|
6234 #endif
|
|
6235
|
|
6236 /* first round: check for valid value, second round: assign values */
|
|
6237 for (round = 0; round <= 1; ++round)
|
|
6238 {
|
|
6239 if (round)
|
|
6240 {
|
|
6241 /* After checking that the value is valid: set defaults: space for
|
|
6242 * 'fillchars', NUL for 'listchars' */
|
|
6243 for (i = 0; i < entries; ++i)
|
|
6244 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
|
|
6245 if (varp == &p_lcs)
|
|
6246 lcs_tab1 = NUL;
|
|
6247 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6248 else
|
|
6249 fill_diff = '-';
|
|
6250 #endif
|
|
6251 }
|
|
6252 p = *varp;
|
|
6253 while (*p)
|
|
6254 {
|
|
6255 for (i = 0; i < entries; ++i)
|
|
6256 {
|
|
6257 len = (int)STRLEN(tab[i].name);
|
|
6258 if (STRNCMP(p, tab[i].name, len) == 0
|
|
6259 && p[len] == ':'
|
|
6260 && p[len + 1] != NUL)
|
|
6261 {
|
|
6262 s = p + len + 1;
|
|
6263 #ifdef FEAT_MBYTE
|
|
6264 c1 = mb_ptr2char_adv(&s);
|
|
6265 #else
|
|
6266 c1 = *s++;
|
|
6267 #endif
|
|
6268 if (tab[i].cp == &lcs_tab2)
|
|
6269 {
|
|
6270 if (*s == NUL)
|
|
6271 continue;
|
|
6272 #ifdef FEAT_MBYTE
|
|
6273 c2 = mb_ptr2char_adv(&s);
|
|
6274 #else
|
|
6275 c2 = *s++;
|
|
6276 #endif
|
|
6277 }
|
|
6278 if (*s == ',' || *s == NUL)
|
|
6279 {
|
|
6280 if (round)
|
|
6281 {
|
|
6282 if (tab[i].cp == &lcs_tab2)
|
|
6283 {
|
|
6284 lcs_tab1 = c1;
|
|
6285 lcs_tab2 = c2;
|
|
6286 }
|
|
6287 else
|
|
6288 *(tab[i].cp) = c1;
|
|
6289
|
|
6290 }
|
|
6291 p = s;
|
|
6292 break;
|
|
6293 }
|
|
6294 }
|
|
6295 }
|
|
6296
|
|
6297 if (i == entries)
|
|
6298 return e_invarg;
|
|
6299 if (*p == ',')
|
|
6300 ++p;
|
|
6301 }
|
|
6302 }
|
|
6303
|
|
6304 return NULL; /* no error */
|
|
6305 }
|
|
6306
|
|
6307 #ifdef FEAT_STL_OPT
|
|
6308 /*
|
|
6309 * Check validity of options with the 'statusline' format.
|
|
6310 * Return error message or NULL.
|
|
6311 */
|
|
6312 char_u *
|
|
6313 check_stl_option(s)
|
|
6314 char_u *s;
|
|
6315 {
|
|
6316 int itemcnt = 0;
|
|
6317 int groupdepth = 0;
|
|
6318 static char_u errbuf[80];
|
|
6319
|
|
6320 while (*s && itemcnt < STL_MAX_ITEM)
|
|
6321 {
|
|
6322 /* Check for valid keys after % sequences */
|
|
6323 while (*s && *s != '%')
|
|
6324 s++;
|
|
6325 if (!*s)
|
|
6326 break;
|
|
6327 s++;
|
|
6328 if (*s != '%' && *s != ')')
|
|
6329 ++itemcnt;
|
|
6330 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
|
|
6331 {
|
|
6332 s++;
|
|
6333 continue;
|
|
6334 }
|
|
6335 if (*s == ')')
|
|
6336 {
|
|
6337 s++;
|
|
6338 if (--groupdepth < 0)
|
|
6339 break;
|
|
6340 continue;
|
|
6341 }
|
|
6342 if (*s == '-')
|
|
6343 s++;
|
|
6344 while (VIM_ISDIGIT(*s))
|
|
6345 s++;
|
|
6346 if (*s == STL_HIGHLIGHT)
|
|
6347 continue;
|
|
6348 if (*s == '.')
|
|
6349 {
|
|
6350 s++;
|
|
6351 while (*s && VIM_ISDIGIT(*s))
|
|
6352 s++;
|
|
6353 }
|
|
6354 if (*s == '(')
|
|
6355 {
|
|
6356 groupdepth++;
|
|
6357 continue;
|
|
6358 }
|
|
6359 if (vim_strchr(STL_ALL, *s) == NULL)
|
|
6360 {
|
|
6361 return illegal_char(errbuf, *s);
|
|
6362 }
|
|
6363 if (*s == '{')
|
|
6364 {
|
|
6365 s++;
|
|
6366 while (*s != '}' && *s)
|
|
6367 s++;
|
|
6368 if (*s != '}')
|
|
6369 return (char_u *)N_("E540: Unclosed expression sequence");
|
|
6370 }
|
|
6371 }
|
|
6372 if (itemcnt >= STL_MAX_ITEM)
|
|
6373 return (char_u *)N_("E541: too many items");
|
|
6374 if (groupdepth != 0)
|
|
6375 return (char_u *)N_("E542: unbalanced groups");
|
|
6376 return NULL;
|
|
6377 }
|
|
6378 #endif
|
|
6379
|
|
6380 #ifdef FEAT_CLIPBOARD
|
|
6381 /*
|
|
6382 * Extract the items in the 'clipboard' option and set global values.
|
|
6383 */
|
|
6384 static char_u *
|
|
6385 check_clipboard_option()
|
|
6386 {
|
|
6387 int new_unnamed = FALSE;
|
|
6388 int new_autoselect = FALSE;
|
|
6389 int new_autoselectml = FALSE;
|
|
6390 regprog_T *new_exclude_prog = NULL;
|
|
6391 char_u *errmsg = NULL;
|
|
6392 char_u *p;
|
|
6393
|
|
6394 for (p = p_cb; *p != NUL; )
|
|
6395 {
|
|
6396 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
|
|
6397 {
|
|
6398 new_unnamed = TRUE;
|
|
6399 p += 7;
|
|
6400 }
|
|
6401 else if (STRNCMP(p, "autoselect", 10) == 0
|
|
6402 && (p[10] == ',' || p[10] == NUL))
|
|
6403 {
|
|
6404 new_autoselect = TRUE;
|
|
6405 p += 10;
|
|
6406 }
|
|
6407 else if (STRNCMP(p, "autoselectml", 12) == 0
|
|
6408 && (p[12] == ',' || p[12] == NUL))
|
|
6409 {
|
|
6410 new_autoselectml = TRUE;
|
|
6411 p += 12;
|
|
6412 }
|
|
6413 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
|
|
6414 {
|
|
6415 p += 8;
|
|
6416 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
|
|
6417 if (new_exclude_prog == NULL)
|
|
6418 errmsg = e_invarg;
|
|
6419 break;
|
|
6420 }
|
|
6421 else
|
|
6422 {
|
|
6423 errmsg = e_invarg;
|
|
6424 break;
|
|
6425 }
|
|
6426 if (*p == ',')
|
|
6427 ++p;
|
|
6428 }
|
|
6429 if (errmsg == NULL)
|
|
6430 {
|
|
6431 clip_unnamed = new_unnamed;
|
|
6432 clip_autoselect = new_autoselect;
|
|
6433 clip_autoselectml = new_autoselectml;
|
|
6434 vim_free(clip_exclude_prog);
|
|
6435 clip_exclude_prog = new_exclude_prog;
|
|
6436 }
|
|
6437 else
|
|
6438 vim_free(new_exclude_prog);
|
|
6439
|
|
6440 return errmsg;
|
|
6441 }
|
|
6442 #endif
|
|
6443
|
386
|
6444 #ifdef FEAT_SYN_HL
|
|
6445 /*
|
|
6446 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
|
|
6447 * Return error message when failed, NULL when OK.
|
|
6448 */
|
|
6449 static char_u *
|
389
|
6450 compile_cap_prog(buf)
|
|
6451 buf_T *buf;
|
386
|
6452 {
|
389
|
6453 regprog_T *rp = buf->b_cap_prog;
|
|
6454
|
|
6455 if (*buf->b_p_spc == NUL)
|
|
6456 {
|
|
6457 buf->b_cap_prog = NULL;
|
386
|
6458 vim_free(rp);
|
|
6459 return NULL;
|
|
6460 }
|
|
6461
|
|
6462 /* Prepend a ^ so that we only match at one column */
|
389
|
6463 vim_snprintf((char *)IObuff, IOSIZE, "^%s", buf->b_p_spc);
|
|
6464 buf->b_cap_prog = vim_regcomp(IObuff, RE_MAGIC);
|
|
6465 if (buf->b_cap_prog == NULL)
|
|
6466 {
|
|
6467 buf->b_cap_prog = rp;
|
386
|
6468 return e_invarg;
|
|
6469 }
|
|
6470
|
|
6471 vim_free(rp);
|
|
6472 return NULL;
|
|
6473 }
|
|
6474 #endif
|
|
6475
|
7
|
6476 /*
|
|
6477 * Set the value of a boolean option, and take care of side effects.
|
|
6478 * Returns NULL for success, or an error message for an error.
|
|
6479 */
|
|
6480 static char_u *
|
|
6481 set_bool_option(opt_idx, varp, value, opt_flags)
|
|
6482 int opt_idx; /* index in options[] table */
|
|
6483 char_u *varp; /* pointer to the option variable */
|
|
6484 int value; /* new value */
|
|
6485 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
6486 {
|
|
6487 int old_value = *(int *)varp;
|
|
6488
|
|
6489 #ifdef FEAT_GUI
|
|
6490 need_mouse_correct = TRUE;
|
|
6491 #endif
|
|
6492
|
|
6493 /* Disallow changing some options from secure mode */
|
|
6494 if ((secure
|
|
6495 #ifdef HAVE_SANDBOX
|
|
6496 || sandbox != 0
|
|
6497 #endif
|
|
6498 ) && (options[opt_idx].flags & P_SECURE))
|
|
6499 return e_secure;
|
|
6500
|
|
6501 *(int *)varp = value; /* set the new value */
|
|
6502 #ifdef FEAT_EVAL
|
|
6503 /* Remember where the option was set. */
|
|
6504 options[opt_idx].scriptID = current_SID;
|
|
6505 #endif
|
|
6506
|
|
6507 /* May set global value for local option. */
|
|
6508 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
6509 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
|
|
6510
|
|
6511 /*
|
|
6512 * Handle side effects of changing a bool option.
|
|
6513 */
|
|
6514
|
|
6515 /* 'compatible' */
|
|
6516 if ((int *)varp == &p_cp)
|
|
6517 {
|
|
6518 compatible_set();
|
|
6519 }
|
|
6520
|
|
6521 /* when 'readonly' is reset globally, also reset readonlymode */
|
|
6522 else if ((int *)varp == &curbuf->b_p_ro)
|
|
6523 {
|
|
6524 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
|
|
6525 readonlymode = FALSE;
|
|
6526 #ifdef FEAT_TITLE
|
|
6527 need_maketitle = TRUE;
|
|
6528 #endif
|
|
6529 }
|
|
6530
|
|
6531 #ifdef FEAT_TITLE
|
|
6532 /* when 'modifiable' is changed, redraw the window title */
|
|
6533 else if ((int *)varp == &curbuf->b_p_ma)
|
|
6534 need_maketitle = TRUE;
|
|
6535 /* when 'endofline' is changed, redraw the window title */
|
|
6536 else if ((int *)varp == &curbuf->b_p_eol)
|
|
6537 need_maketitle = TRUE;
|
|
6538 #endif
|
|
6539
|
|
6540 /* when 'bin' is set also set some other options */
|
|
6541 else if ((int *)varp == &curbuf->b_p_bin)
|
|
6542 {
|
|
6543 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
|
|
6544 #ifdef FEAT_TITLE
|
|
6545 need_maketitle = TRUE;
|
|
6546 #endif
|
|
6547 }
|
|
6548
|
|
6549 #ifdef FEAT_AUTOCMD
|
|
6550 /* when 'buflisted' changes, trigger autocommands */
|
|
6551 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
|
|
6552 {
|
|
6553 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
|
|
6554 NULL, NULL, TRUE, curbuf);
|
|
6555 }
|
|
6556 #endif
|
|
6557
|
|
6558 /* when 'swf' is set, create swapfile, when reset remove swapfile */
|
|
6559 else if ((int *)varp == &curbuf->b_p_swf)
|
|
6560 {
|
|
6561 if (curbuf->b_p_swf && p_uc)
|
|
6562 ml_open_file(curbuf); /* create the swap file */
|
|
6563 else
|
|
6564 mf_close_file(curbuf, TRUE); /* remove the swap file */
|
|
6565 }
|
|
6566
|
|
6567 /* when 'terse' is set change 'shortmess' */
|
|
6568 else if ((int *)varp == &p_terse)
|
|
6569 {
|
|
6570 char_u *p;
|
|
6571
|
|
6572 p = vim_strchr(p_shm, SHM_SEARCH);
|
|
6573
|
|
6574 /* insert 's' in p_shm */
|
|
6575 if (p_terse && p == NULL)
|
|
6576 {
|
|
6577 STRCPY(IObuff, p_shm);
|
|
6578 STRCAT(IObuff, "s");
|
|
6579 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE);
|
|
6580 }
|
|
6581 /* remove 's' from p_shm */
|
|
6582 else if (!p_terse && p != NULL)
|
|
6583 mch_memmove(p, p + 1, STRLEN(p));
|
|
6584 }
|
|
6585
|
|
6586 /* when 'paste' is set or reset also change other options */
|
|
6587 else if ((int *)varp == &p_paste)
|
|
6588 {
|
|
6589 paste_option_changed();
|
|
6590 }
|
|
6591
|
|
6592 /* when 'insertmode' is set from an autocommand need to do work here */
|
|
6593 else if ((int *)varp == &p_im)
|
|
6594 {
|
|
6595 if (p_im)
|
|
6596 {
|
|
6597 if ((State & INSERT) == 0)
|
|
6598 need_start_insertmode = TRUE;
|
|
6599 stop_insert_mode = FALSE;
|
|
6600 }
|
|
6601 else
|
|
6602 {
|
|
6603 need_start_insertmode = FALSE;
|
|
6604 stop_insert_mode = TRUE;
|
|
6605 if (p_smd && restart_edit != 0)
|
|
6606 clear_cmdline = TRUE; /* remove "(insert)" */
|
|
6607 restart_edit = 0;
|
|
6608 }
|
|
6609 }
|
|
6610
|
|
6611 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
|
|
6612 else if ((int *)varp == &p_ic && p_hls)
|
|
6613 {
|
|
6614 redraw_all_later(NOT_VALID);
|
|
6615 }
|
|
6616
|
|
6617 #ifdef FEAT_SEARCH_EXTRA
|
|
6618 /* when 'hlsearch' is set or reset: reset no_hlsearch */
|
|
6619 else if ((int *)varp == &p_hls)
|
|
6620 {
|
|
6621 no_hlsearch = FALSE;
|
|
6622 }
|
|
6623 #endif
|
|
6624
|
|
6625 #ifdef FEAT_SCROLLBIND
|
|
6626 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
|
|
6627 * at the end of normal_cmd() */
|
|
6628 else if ((int *)varp == &curwin->w_p_scb)
|
|
6629 {
|
|
6630 if (curwin->w_p_scb)
|
|
6631 do_check_scrollbind(FALSE);
|
|
6632 }
|
|
6633 #endif
|
|
6634
|
|
6635 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
|
6636 /* There can be only one window with 'previewwindow' set. */
|
|
6637 else if ((int *)varp == &curwin->w_p_pvw)
|
|
6638 {
|
|
6639 if (curwin->w_p_pvw)
|
|
6640 {
|
|
6641 win_T *win;
|
|
6642
|
|
6643 for (win = firstwin; win != NULL; win = win->w_next)
|
|
6644 if (win->w_p_pvw && win != curwin)
|
|
6645 {
|
|
6646 curwin->w_p_pvw = FALSE;
|
|
6647 return (char_u *)N_("E590: A preview window already exists");
|
|
6648 }
|
|
6649 }
|
|
6650 }
|
|
6651 #endif
|
|
6652
|
|
6653 /* when 'textmode' is set or reset also change 'fileformat' */
|
|
6654 else if ((int *)varp == &curbuf->b_p_tx)
|
|
6655 {
|
|
6656 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
|
|
6657 }
|
|
6658
|
|
6659 /* when 'textauto' is set or reset also change 'fileformats' */
|
|
6660 else if ((int *)varp == &p_ta)
|
|
6661 {
|
|
6662 set_string_option_direct((char_u *)"ffs", -1,
|
|
6663 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
|
|
6664 OPT_FREE | opt_flags);
|
|
6665 }
|
|
6666
|
|
6667 /*
|
|
6668 * When 'lisp' option changes include/exclude '-' in
|
|
6669 * keyword characters.
|
|
6670 */
|
|
6671 #ifdef FEAT_LISP
|
|
6672 else if (varp == (char_u *)&(curbuf->b_p_lisp))
|
|
6673 {
|
|
6674 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
|
|
6675 }
|
|
6676 #endif
|
|
6677
|
|
6678 #ifdef FEAT_TITLE
|
|
6679 /* when 'title' changed, may need to change the title; same for 'icon' */
|
|
6680 else if ((int *)varp == &p_title)
|
|
6681 {
|
|
6682 did_set_title(FALSE);
|
|
6683 }
|
|
6684
|
|
6685 else if ((int *)varp == &p_icon)
|
|
6686 {
|
|
6687 did_set_title(TRUE);
|
|
6688 }
|
|
6689 #endif
|
|
6690
|
|
6691 else if ((int *)varp == &curbuf->b_changed)
|
|
6692 {
|
|
6693 if (!value)
|
|
6694 save_file_ff(curbuf); /* Buffer is unchanged */
|
|
6695 #ifdef FEAT_TITLE
|
|
6696 need_maketitle = TRUE;
|
|
6697 #endif
|
|
6698 #ifdef FEAT_AUTOCMD
|
|
6699 modified_was_set = value;
|
|
6700 #endif
|
|
6701 }
|
|
6702
|
|
6703 #ifdef BACKSLASH_IN_FILENAME
|
|
6704 else if ((int *)varp == &p_ssl)
|
|
6705 {
|
|
6706 if (p_ssl)
|
|
6707 {
|
|
6708 psepc = '/';
|
|
6709 psepcN = '\\';
|
|
6710 pseps[0] = '/';
|
|
6711 }
|
|
6712 else
|
|
6713 {
|
|
6714 psepc = '\\';
|
|
6715 psepcN = '/';
|
|
6716 pseps[0] = '\\';
|
|
6717 }
|
|
6718
|
|
6719 /* need to adjust the file name arguments and buffer names. */
|
|
6720 buflist_slash_adjust();
|
|
6721 alist_slash_adjust();
|
|
6722 # ifdef FEAT_EVAL
|
|
6723 scriptnames_slash_adjust();
|
|
6724 # endif
|
|
6725 }
|
|
6726 #endif
|
|
6727
|
|
6728 /* If 'wrap' is set, set w_leftcol to zero. */
|
|
6729 else if ((int *)varp == &curwin->w_p_wrap)
|
|
6730 {
|
|
6731 if (curwin->w_p_wrap)
|
|
6732 curwin->w_leftcol = 0;
|
|
6733 }
|
|
6734
|
|
6735 #ifdef FEAT_WINDOWS
|
|
6736 else if ((int *)varp == &p_ea)
|
|
6737 {
|
|
6738 if (p_ea && !old_value)
|
|
6739 win_equal(curwin, FALSE, 0);
|
|
6740 }
|
|
6741 #endif
|
|
6742
|
|
6743 else if ((int *)varp == &p_wiv)
|
|
6744 {
|
|
6745 /*
|
|
6746 * When 'weirdinvert' changed, set/reset 't_xs'.
|
|
6747 * Then set 'weirdinvert' according to value of 't_xs'.
|
|
6748 */
|
|
6749 if (p_wiv && !old_value)
|
|
6750 T_XS = (char_u *)"y";
|
|
6751 else if (!p_wiv && old_value)
|
|
6752 T_XS = empty_option;
|
|
6753 p_wiv = (*T_XS != NUL);
|
|
6754 }
|
|
6755
|
190
|
6756 #ifdef FEAT_BEVAL
|
7
|
6757 else if ((int *)varp == &p_beval)
|
|
6758 {
|
|
6759 if (p_beval == TRUE)
|
|
6760 gui_mch_enable_beval_area(balloonEval);
|
|
6761 else
|
|
6762 gui_mch_disable_beval_area(balloonEval);
|
|
6763 }
|
|
6764
|
190
|
6765 # if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
|
7
|
6766 else if ((int *)varp == &p_acd)
|
|
6767 {
|
|
6768 if (p_acd && curbuf->b_ffname != NULL
|
|
6769 && vim_chdirfile(curbuf->b_ffname) == OK)
|
|
6770 shorten_fnames(TRUE);
|
|
6771 }
|
190
|
6772 # endif
|
7
|
6773 #endif
|
|
6774
|
|
6775 #ifdef FEAT_DIFF
|
|
6776 /* 'diff' */
|
|
6777 else if ((int *)varp == &curwin->w_p_diff)
|
|
6778 {
|
16
|
6779 /* May add or remove the buffer from the list of diff buffers. */
|
|
6780 diff_buf_adjust(curwin);
|
|
6781 # ifdef FEAT_FOLDING
|
7
|
6782 if (foldmethodIsDiff(curwin))
|
|
6783 foldUpdateAll(curwin);
|
16
|
6784 # endif
|
7
|
6785 }
|
|
6786 #endif
|
|
6787
|
|
6788 #ifdef USE_IM_CONTROL
|
|
6789 /* 'imdisable' */
|
|
6790 else if ((int *)varp == &p_imdisable)
|
|
6791 {
|
|
6792 /* Only de-activate it here, it will be enabled when changing mode. */
|
|
6793 if (p_imdisable)
|
|
6794 im_set_active(FALSE);
|
|
6795 }
|
|
6796 #endif
|
|
6797
|
258
|
6798 #ifdef FEAT_SYN_HL
|
|
6799 /* 'spell' */
|
|
6800 else if ((int *)varp == &curwin->w_p_spell)
|
|
6801 {
|
|
6802 if (curwin->w_p_spell)
|
|
6803 {
|
|
6804 char_u *errmsg = did_set_spelllang(curbuf);
|
320
|
6805
|
258
|
6806 if (errmsg != NULL)
|
|
6807 EMSG(_(errmsg));
|
|
6808 }
|
|
6809 }
|
|
6810 #endif
|
|
6811
|
7
|
6812 #ifdef FEAT_FKMAP
|
|
6813 else if ((int *)varp == &p_altkeymap)
|
|
6814 {
|
|
6815 if (old_value != p_altkeymap)
|
|
6816 {
|
|
6817 if (!p_altkeymap)
|
|
6818 {
|
|
6819 p_hkmap = p_fkmap;
|
|
6820 p_fkmap = 0;
|
|
6821 }
|
|
6822 else
|
|
6823 {
|
|
6824 p_fkmap = p_hkmap;
|
|
6825 p_hkmap = 0;
|
|
6826 }
|
|
6827 (void)init_chartab();
|
|
6828 }
|
|
6829 }
|
|
6830
|
|
6831 /*
|
|
6832 * In case some second language keymapping options have changed, check
|
|
6833 * and correct the setting in a consistent way.
|
|
6834 */
|
|
6835
|
|
6836 /*
|
|
6837 * If hkmap or fkmap are set, reset Arabic keymapping.
|
|
6838 */
|
|
6839 if ((p_hkmap || p_fkmap) && p_altkeymap)
|
|
6840 {
|
|
6841 p_altkeymap = p_fkmap;
|
|
6842 # ifdef FEAT_ARABIC
|
|
6843 curwin->w_p_arab = FALSE;
|
|
6844 # endif
|
|
6845 (void)init_chartab();
|
|
6846 }
|
|
6847
|
|
6848 /*
|
|
6849 * If hkmap set, reset Farsi keymapping.
|
|
6850 */
|
|
6851 if (p_hkmap && p_altkeymap)
|
|
6852 {
|
|
6853 p_altkeymap = 0;
|
|
6854 p_fkmap = 0;
|
|
6855 # ifdef FEAT_ARABIC
|
|
6856 curwin->w_p_arab = FALSE;
|
|
6857 # endif
|
|
6858 (void)init_chartab();
|
|
6859 }
|
|
6860
|
|
6861 /*
|
|
6862 * If fkmap set, reset Hebrew keymapping.
|
|
6863 */
|
|
6864 if (p_fkmap && !p_altkeymap)
|
|
6865 {
|
|
6866 p_altkeymap = 1;
|
|
6867 p_hkmap = 0;
|
|
6868 # ifdef FEAT_ARABIC
|
|
6869 curwin->w_p_arab = FALSE;
|
|
6870 # endif
|
|
6871 (void)init_chartab();
|
|
6872 }
|
|
6873 #endif
|
|
6874
|
|
6875 #ifdef FEAT_ARABIC
|
|
6876 if ((int *)varp == &curwin->w_p_arab)
|
|
6877 {
|
|
6878 if (curwin->w_p_arab)
|
|
6879 {
|
|
6880 /*
|
|
6881 * 'arabic' is set, handle various sub-settings.
|
|
6882 */
|
|
6883 if (!p_tbidi)
|
|
6884 {
|
|
6885 /* set rightleft mode */
|
|
6886 if (!curwin->w_p_rl)
|
|
6887 {
|
|
6888 curwin->w_p_rl = TRUE;
|
|
6889 changed_window_setting();
|
|
6890 }
|
|
6891
|
|
6892 /* Enable Arabic shaping (major part of what Arabic requires) */
|
|
6893 if (!p_arshape)
|
|
6894 {
|
|
6895 p_arshape = TRUE;
|
|
6896 redraw_later_clear();
|
|
6897 }
|
|
6898 }
|
|
6899
|
|
6900 /* Arabic requires a utf-8 encoding, inform the user if its not
|
|
6901 * set. */
|
|
6902 if (STRCMP(p_enc, "utf-8") != 0)
|
16
|
6903 {
|
|
6904 msg_source(hl_attr(HLF_W));
|
7
|
6905 MSG_ATTR(_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"),
|
|
6906 hl_attr(HLF_W));
|
16
|
6907 }
|
7
|
6908
|
|
6909 # ifdef FEAT_MBYTE
|
|
6910 /* set 'delcombine' */
|
|
6911 p_deco = TRUE;
|
|
6912 # endif
|
|
6913
|
|
6914 # ifdef FEAT_KEYMAP
|
|
6915 /* Force-set the necessary keymap for arabic */
|
|
6916 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
|
|
6917 OPT_LOCAL);
|
|
6918 # endif
|
|
6919 # ifdef FEAT_FKMAP
|
|
6920 p_altkeymap = 0;
|
|
6921 p_hkmap = 0;
|
|
6922 p_fkmap = 0;
|
|
6923 (void)init_chartab();
|
|
6924 # endif
|
|
6925 }
|
|
6926 else
|
|
6927 {
|
|
6928 /*
|
|
6929 * 'arabic' is reset, handle various sub-settings.
|
|
6930 */
|
|
6931 if (!p_tbidi)
|
|
6932 {
|
|
6933 /* reset rightleft mode */
|
|
6934 if (curwin->w_p_rl)
|
|
6935 {
|
|
6936 curwin->w_p_rl = FALSE;
|
|
6937 changed_window_setting();
|
|
6938 }
|
|
6939
|
|
6940 /* 'arabicshape' isn't reset, it is a global option and
|
|
6941 * another window may still need it "on". */
|
|
6942 }
|
|
6943
|
|
6944 /* 'delcombine' isn't reset, it is a global option and another
|
|
6945 * window may still want it "on". */
|
|
6946
|
|
6947 # ifdef FEAT_KEYMAP
|
|
6948 /* Revert to the default keymap */
|
|
6949 curbuf->b_p_iminsert = B_IMODE_NONE;
|
|
6950 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
|
|
6951 # endif
|
|
6952 }
|
|
6953 }
|
|
6954 #endif
|
|
6955
|
|
6956 /*
|
|
6957 * End of handling side effects for bool options.
|
|
6958 */
|
|
6959
|
|
6960 options[opt_idx].flags |= P_WAS_SET;
|
|
6961
|
|
6962 comp_col(); /* in case 'ruler' or 'showcmd' changed */
|
|
6963 if (curwin->w_curswant != MAXCOL)
|
|
6964 curwin->w_set_curswant = TRUE; /* in case 'list' changed */
|
|
6965 check_redraw(options[opt_idx].flags);
|
|
6966
|
|
6967 return NULL;
|
|
6968 }
|
|
6969
|
|
6970 /*
|
|
6971 * Set the value of a number option, and take care of side effects.
|
|
6972 * Returns NULL for success, or an error message for an error.
|
|
6973 */
|
|
6974 static char_u *
|
274
|
6975 set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
|
7
|
6976 int opt_idx; /* index in options[] table */
|
|
6977 char_u *varp; /* pointer to the option variable */
|
|
6978 long value; /* new value */
|
|
6979 char_u *errbuf; /* buffer for error messages */
|
274
|
6980 size_t errbuflen; /* length of "errbuf" */
|
7
|
6981 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
|
|
6982 OPT_MODELINE */
|
|
6983 {
|
|
6984 char_u *errmsg = NULL;
|
|
6985 long old_value = *(long *)varp;
|
|
6986 long old_Rows = Rows; /* remember old Rows */
|
|
6987 long old_Columns = Columns; /* remember old Columns */
|
|
6988 long *pp = (long *)varp;
|
|
6989
|
|
6990 #ifdef FEAT_GUI
|
|
6991 need_mouse_correct = TRUE;
|
|
6992 #endif
|
|
6993
|
|
6994 *pp = value;
|
|
6995 #ifdef FEAT_EVAL
|
|
6996 /* Remember where the option was set. */
|
|
6997 options[opt_idx].scriptID = current_SID;
|
|
6998 #endif
|
|
6999
|
|
7000 if (curbuf->b_p_sw <= 0)
|
|
7001 {
|
|
7002 errmsg = e_positive;
|
|
7003 curbuf->b_p_sw = curbuf->b_p_ts;
|
|
7004 }
|
|
7005
|
|
7006 /*
|
|
7007 * Number options that need some action when changed
|
|
7008 */
|
|
7009 #ifdef FEAT_WINDOWS
|
|
7010 if (pp == &p_wh || pp == &p_hh)
|
|
7011 {
|
|
7012 if (p_wh < 1)
|
|
7013 {
|
|
7014 errmsg = e_positive;
|
|
7015 p_wh = 1;
|
|
7016 }
|
|
7017 if (p_wmh > p_wh)
|
|
7018 {
|
|
7019 errmsg = e_winheight;
|
|
7020 p_wh = p_wmh;
|
|
7021 }
|
|
7022 if (p_hh < 0)
|
|
7023 {
|
|
7024 errmsg = e_positive;
|
|
7025 p_hh = 0;
|
|
7026 }
|
|
7027
|
|
7028 /* Change window height NOW */
|
|
7029 if (lastwin != firstwin)
|
|
7030 {
|
|
7031 if (pp == &p_wh && curwin->w_height < p_wh)
|
|
7032 win_setheight((int)p_wh);
|
|
7033 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
|
|
7034 win_setheight((int)p_hh);
|
|
7035 }
|
|
7036 }
|
|
7037
|
|
7038 /* 'winminheight' */
|
|
7039 else if (pp == &p_wmh)
|
|
7040 {
|
|
7041 if (p_wmh < 0)
|
|
7042 {
|
|
7043 errmsg = e_positive;
|
|
7044 p_wmh = 0;
|
|
7045 }
|
|
7046 if (p_wmh > p_wh)
|
|
7047 {
|
|
7048 errmsg = e_winheight;
|
|
7049 p_wmh = p_wh;
|
|
7050 }
|
|
7051 win_setminheight();
|
|
7052 }
|
|
7053
|
|
7054 # ifdef FEAT_VERTSPLIT
|
13
|
7055 else if (pp == &p_wiw)
|
7
|
7056 {
|
|
7057 if (p_wiw < 1)
|
|
7058 {
|
|
7059 errmsg = e_positive;
|
|
7060 p_wiw = 1;
|
|
7061 }
|
|
7062 if (p_wmw > p_wiw)
|
|
7063 {
|
|
7064 errmsg = e_winwidth;
|
|
7065 p_wiw = p_wmw;
|
|
7066 }
|
|
7067
|
|
7068 /* Change window width NOW */
|
|
7069 if (lastwin != firstwin && curwin->w_width < p_wiw)
|
|
7070 win_setwidth((int)p_wiw);
|
|
7071 }
|
|
7072
|
|
7073 /* 'winminwidth' */
|
|
7074 else if (pp == &p_wmw)
|
|
7075 {
|
|
7076 if (p_wmw < 0)
|
|
7077 {
|
|
7078 errmsg = e_positive;
|
|
7079 p_wmw = 0;
|
|
7080 }
|
|
7081 if (p_wmw > p_wiw)
|
|
7082 {
|
|
7083 errmsg = e_winwidth;
|
|
7084 p_wmw = p_wiw;
|
|
7085 }
|
|
7086 win_setminheight();
|
|
7087 }
|
|
7088 # endif
|
|
7089
|
|
7090 #endif
|
|
7091
|
|
7092 #ifdef FEAT_WINDOWS
|
|
7093 /* (re)set last window status line */
|
|
7094 else if (pp == &p_ls)
|
|
7095 {
|
|
7096 last_status(FALSE);
|
|
7097 }
|
|
7098 #endif
|
|
7099
|
|
7100 #ifdef FEAT_GUI
|
|
7101 else if (pp == &p_linespace)
|
|
7102 {
|
|
7103 if (gui.in_use && gui_mch_adjust_charsize() == OK)
|
|
7104 gui_set_shellsize(FALSE, FALSE);
|
|
7105 }
|
|
7106 #endif
|
|
7107
|
|
7108 #ifdef FEAT_FOLDING
|
|
7109 /* 'foldlevel' */
|
|
7110 else if (pp == &curwin->w_p_fdl)
|
|
7111 {
|
|
7112 if (curwin->w_p_fdl < 0)
|
|
7113 curwin->w_p_fdl = 0;
|
|
7114 newFoldLevel();
|
|
7115 }
|
|
7116
|
|
7117 /* 'foldminlevel' */
|
|
7118 else if (pp == &curwin->w_p_fml)
|
|
7119 {
|
|
7120 foldUpdateAll(curwin);
|
|
7121 }
|
|
7122
|
|
7123 /* 'foldnestmax' */
|
|
7124 else if (pp == &curwin->w_p_fdn)
|
|
7125 {
|
|
7126 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
|
|
7127 foldUpdateAll(curwin);
|
|
7128 }
|
|
7129
|
|
7130 /* 'foldcolumn' */
|
|
7131 else if (pp == &curwin->w_p_fdc)
|
|
7132 {
|
|
7133 if (curwin->w_p_fdc < 0)
|
|
7134 {
|
|
7135 errmsg = e_positive;
|
|
7136 curwin->w_p_fdc = 0;
|
|
7137 }
|
|
7138 else if (curwin->w_p_fdc > 12)
|
|
7139 {
|
|
7140 errmsg = e_invarg;
|
|
7141 curwin->w_p_fdc = 12;
|
|
7142 }
|
|
7143 }
|
|
7144
|
|
7145 /* 'shiftwidth' or 'tabstop' */
|
|
7146 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
|
|
7147 {
|
|
7148 if (foldmethodIsIndent(curwin))
|
|
7149 foldUpdateAll(curwin);
|
|
7150 }
|
|
7151 #endif /* FEAT_FOLDING */
|
|
7152
|
|
7153 else if (pp == &curbuf->b_p_iminsert)
|
|
7154 {
|
|
7155 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
|
|
7156 {
|
|
7157 errmsg = e_invarg;
|
|
7158 curbuf->b_p_iminsert = B_IMODE_NONE;
|
|
7159 }
|
|
7160 p_iminsert = curbuf->b_p_iminsert;
|
|
7161 if (termcap_active) /* don't do this in the alternate screen */
|
|
7162 showmode();
|
|
7163 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
|
|
7164 /* Show/unshow value of 'keymap' in status lines. */
|
|
7165 status_redraw_curbuf();
|
|
7166 #endif
|
|
7167 }
|
|
7168
|
164
|
7169 else if (pp == &p_window)
|
|
7170 {
|
|
7171 if (p_window < 1)
|
|
7172 p_window = 1;
|
|
7173 else if (p_window >= Rows)
|
|
7174 p_window = Rows - 1;
|
|
7175 }
|
|
7176
|
7
|
7177 else if (pp == &curbuf->b_p_imsearch)
|
|
7178 {
|
|
7179 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
|
|
7180 {
|
|
7181 errmsg = e_invarg;
|
|
7182 curbuf->b_p_imsearch = B_IMODE_NONE;
|
|
7183 }
|
|
7184 p_imsearch = curbuf->b_p_imsearch;
|
|
7185 }
|
|
7186
|
|
7187 #ifdef FEAT_TITLE
|
|
7188 /* if 'titlelen' has changed, redraw the title */
|
|
7189 else if (pp == &p_titlelen)
|
|
7190 {
|
|
7191 if (p_titlelen < 0)
|
|
7192 {
|
|
7193 errmsg = e_positive;
|
|
7194 p_titlelen = 85;
|
|
7195 }
|
|
7196 if (starting != NO_SCREEN && old_value != p_titlelen)
|
|
7197 need_maketitle = TRUE;
|
|
7198 }
|
|
7199 #endif
|
|
7200
|
|
7201 /* if p_ch changed value, change the command line height */
|
|
7202 else if (pp == &p_ch)
|
|
7203 {
|
|
7204 if (p_ch < 1)
|
|
7205 {
|
|
7206 errmsg = e_positive;
|
|
7207 p_ch = 1;
|
|
7208 }
|
|
7209
|
|
7210 /* Only compute the new window layout when startup has been
|
|
7211 * completed. Otherwise the frame sizes may be wrong. */
|
|
7212 if (p_ch != old_value && full_screen
|
|
7213 #ifdef FEAT_GUI
|
|
7214 && !gui.starting
|
|
7215 #endif
|
|
7216 )
|
|
7217 command_height(old_value);
|
|
7218 }
|
|
7219
|
|
7220 /* when 'updatecount' changes from zero to non-zero, open swap files */
|
|
7221 else if (pp == &p_uc)
|
|
7222 {
|
|
7223 if (p_uc < 0)
|
|
7224 {
|
|
7225 errmsg = e_positive;
|
|
7226 p_uc = 100;
|
|
7227 }
|
|
7228 if (p_uc && !old_value)
|
|
7229 ml_open_files();
|
|
7230 }
|
16
|
7231 #ifdef MZSCHEME_GUI_THREADS
|
14
|
7232 else if (pp == &p_mzq)
|
|
7233 mzvim_reset_timer();
|
|
7234 #endif
|
7
|
7235
|
|
7236 /* sync undo before 'undolevels' changes */
|
|
7237 else if (pp == &p_ul)
|
|
7238 {
|
|
7239 /* use the old value, otherwise u_sync() may not work properly */
|
|
7240 p_ul = old_value;
|
|
7241 u_sync();
|
|
7242 p_ul = value;
|
|
7243 }
|
|
7244
|
13
|
7245 #ifdef FEAT_LINEBREAK
|
|
7246 /* 'numberwidth' must be positive */
|
|
7247 else if (pp == &curwin->w_p_nuw)
|
|
7248 {
|
|
7249 if (curwin->w_p_nuw < 1)
|
|
7250 {
|
|
7251 errmsg = e_positive;
|
|
7252 curwin->w_p_nuw = 1;
|
|
7253 }
|
|
7254 if (curwin->w_p_nuw > 10)
|
|
7255 {
|
|
7256 errmsg = e_invarg;
|
|
7257 curwin->w_p_nuw = 10;
|
|
7258 }
|
|
7259 curwin->w_nrwidth_line_count = 0;
|
|
7260 }
|
|
7261 #endif
|
|
7262
|
7
|
7263 /*
|
|
7264 * Check the bounds for numeric options here
|
|
7265 */
|
|
7266 if (Rows < min_rows() && full_screen)
|
|
7267 {
|
|
7268 if (errbuf != NULL)
|
|
7269 {
|
274
|
7270 vim_snprintf((char *)errbuf, errbuflen,
|
|
7271 _("E593: Need at least %d lines"), min_rows());
|
7
|
7272 errmsg = errbuf;
|
|
7273 }
|
|
7274 Rows = min_rows();
|
|
7275 }
|
|
7276 if (Columns < MIN_COLUMNS && full_screen)
|
|
7277 {
|
|
7278 if (errbuf != NULL)
|
|
7279 {
|
274
|
7280 vim_snprintf((char *)errbuf, errbuflen,
|
|
7281 _("E594: Need at least %d columns"), MIN_COLUMNS);
|
7
|
7282 errmsg = errbuf;
|
|
7283 }
|
|
7284 Columns = MIN_COLUMNS;
|
|
7285 }
|
|
7286
|
|
7287 #ifdef DJGPP
|
|
7288 /* avoid a crash by checking for a too large value of 'columns' */
|
|
7289 if (old_Columns != Columns && full_screen && term_console)
|
|
7290 mch_check_columns();
|
|
7291 #endif
|
|
7292
|
|
7293 /*
|
|
7294 * If the screen (shell) height has been changed, assume it is the
|
|
7295 * physical screenheight.
|
|
7296 */
|
|
7297 if (old_Rows != Rows || old_Columns != Columns)
|
|
7298 {
|
|
7299 /* Changing the screen size is not allowed while updating the screen. */
|
|
7300 if (updating_screen)
|
|
7301 *pp = old_value;
|
|
7302 else if (full_screen
|
|
7303 #ifdef FEAT_GUI
|
|
7304 && !gui.starting
|
|
7305 #endif
|
|
7306 )
|
|
7307 set_shellsize((int)Columns, (int)Rows, TRUE);
|
|
7308 else
|
|
7309 {
|
|
7310 /* Postpone the resizing; check the size and cmdline position for
|
|
7311 * messages. */
|
|
7312 check_shellsize();
|
|
7313 if (cmdline_row > Rows - p_ch && Rows > p_ch)
|
|
7314 cmdline_row = Rows - p_ch;
|
|
7315 }
|
164
|
7316 if (p_window >= Rows)
|
|
7317 p_window = Rows - 1;
|
7
|
7318 }
|
|
7319
|
|
7320 if (curbuf->b_p_sts < 0)
|
|
7321 {
|
|
7322 errmsg = e_positive;
|
|
7323 curbuf->b_p_sts = 0;
|
|
7324 }
|
|
7325 if (curbuf->b_p_ts <= 0)
|
|
7326 {
|
|
7327 errmsg = e_positive;
|
|
7328 curbuf->b_p_ts = 8;
|
|
7329 }
|
|
7330 if (curbuf->b_p_tw < 0)
|
|
7331 {
|
|
7332 errmsg = e_positive;
|
|
7333 curbuf->b_p_tw = 0;
|
|
7334 }
|
|
7335 if (p_tm < 0)
|
|
7336 {
|
|
7337 errmsg = e_positive;
|
|
7338 p_tm = 0;
|
|
7339 }
|
|
7340 if ((curwin->w_p_scr <= 0
|
|
7341 || (curwin->w_p_scr > curwin->w_height
|
|
7342 && curwin->w_height > 0))
|
|
7343 && full_screen)
|
|
7344 {
|
|
7345 if (pp == &(curwin->w_p_scr))
|
|
7346 {
|
|
7347 if (curwin->w_p_scr != 0)
|
|
7348 errmsg = e_scroll;
|
|
7349 win_comp_scroll(curwin);
|
|
7350 }
|
|
7351 /* If 'scroll' became invalid because of a side effect silently adjust
|
|
7352 * it. */
|
|
7353 else if (curwin->w_p_scr <= 0)
|
|
7354 curwin->w_p_scr = 1;
|
|
7355 else /* curwin->w_p_scr > curwin->w_height */
|
|
7356 curwin->w_p_scr = curwin->w_height;
|
|
7357 }
|
|
7358 if (p_report < 0)
|
|
7359 {
|
|
7360 errmsg = e_positive;
|
|
7361 p_report = 1;
|
|
7362 }
|
|
7363 if ((p_sj < 0 || p_sj >= Rows) && full_screen)
|
|
7364 {
|
|
7365 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
|
|
7366 p_sj = Rows / 2;
|
|
7367 else
|
|
7368 {
|
|
7369 errmsg = e_scroll;
|
|
7370 p_sj = 1;
|
|
7371 }
|
|
7372 }
|
|
7373 if (p_so < 0 && full_screen)
|
|
7374 {
|
|
7375 errmsg = e_scroll;
|
|
7376 p_so = 0;
|
|
7377 }
|
|
7378 if (p_siso < 0 && full_screen)
|
|
7379 {
|
|
7380 errmsg = e_positive;
|
|
7381 p_siso = 0;
|
|
7382 }
|
|
7383 #ifdef FEAT_CMDWIN
|
|
7384 if (p_cwh < 1)
|
|
7385 {
|
|
7386 errmsg = e_positive;
|
|
7387 p_cwh = 1;
|
|
7388 }
|
|
7389 #endif
|
|
7390 if (p_ut < 0)
|
|
7391 {
|
|
7392 errmsg = e_positive;
|
|
7393 p_ut = 2000;
|
|
7394 }
|
|
7395 if (p_ss < 0)
|
|
7396 {
|
|
7397 errmsg = e_positive;
|
|
7398 p_ss = 0;
|
|
7399 }
|
|
7400
|
|
7401 /* May set global value for local option. */
|
|
7402 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
7403 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
|
|
7404
|
|
7405 options[opt_idx].flags |= P_WAS_SET;
|
|
7406
|
|
7407 comp_col(); /* in case 'columns' or 'ls' changed */
|
|
7408 if (curwin->w_curswant != MAXCOL)
|
|
7409 curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */
|
|
7410 check_redraw(options[opt_idx].flags);
|
|
7411
|
|
7412 return errmsg;
|
|
7413 }
|
|
7414
|
|
7415 /*
|
|
7416 * Called after an option changed: check if something needs to be redrawn.
|
|
7417 */
|
|
7418 static void
|
|
7419 check_redraw(flags)
|
|
7420 long_u flags;
|
|
7421 {
|
|
7422 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
|
|
7423 int clear = (flags & P_RCLR) == P_RCLR;
|
|
7424 int all = ((flags & P_RALL) == P_RALL || clear);
|
|
7425
|
|
7426 #ifdef FEAT_WINDOWS
|
|
7427 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
|
|
7428 status_redraw_all();
|
|
7429 #endif
|
|
7430
|
|
7431 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
|
|
7432 changed_window_setting();
|
|
7433 if (flags & P_RBUF)
|
|
7434 redraw_curbuf_later(NOT_VALID);
|
|
7435 if (clear)
|
|
7436 redraw_all_later(CLEAR);
|
|
7437 else if (all)
|
|
7438 redraw_all_later(NOT_VALID);
|
|
7439 }
|
|
7440
|
|
7441 /*
|
|
7442 * Find index for option 'arg'.
|
|
7443 * Return -1 if not found.
|
|
7444 */
|
|
7445 static int
|
|
7446 findoption(arg)
|
|
7447 char_u *arg;
|
|
7448 {
|
|
7449 int opt_idx;
|
|
7450 char *s, *p;
|
|
7451 static short quick_tab[27] = {0, 0}; /* quick access table */
|
|
7452 int is_term_opt;
|
|
7453
|
|
7454 /*
|
|
7455 * For first call: Initialize the quick-access table.
|
|
7456 * It contains the index for the first option that starts with a certain
|
|
7457 * letter. There are 26 letters, plus the first "t_" option.
|
|
7458 */
|
|
7459 if (quick_tab[1] == 0)
|
|
7460 {
|
|
7461 p = options[0].fullname;
|
|
7462 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
|
|
7463 {
|
|
7464 if (s[0] != p[0])
|
|
7465 {
|
|
7466 if (s[0] == 't' && s[1] == '_')
|
|
7467 quick_tab[26] = opt_idx;
|
|
7468 else
|
|
7469 quick_tab[CharOrdLow(s[0])] = opt_idx;
|
|
7470 }
|
|
7471 p = s;
|
|
7472 }
|
|
7473 }
|
|
7474
|
|
7475 /*
|
|
7476 * Check for name starting with an illegal character.
|
|
7477 */
|
|
7478 #ifdef EBCDIC
|
|
7479 if (!islower(arg[0]))
|
|
7480 #else
|
|
7481 if (arg[0] < 'a' || arg[0] > 'z')
|
|
7482 #endif
|
|
7483 return -1;
|
|
7484
|
|
7485 is_term_opt = (arg[0] == 't' && arg[1] == '_');
|
|
7486 if (is_term_opt)
|
|
7487 opt_idx = quick_tab[26];
|
|
7488 else
|
|
7489 opt_idx = quick_tab[CharOrdLow(arg[0])];
|
|
7490 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
|
|
7491 {
|
|
7492 if (STRCMP(arg, s) == 0) /* match full name */
|
|
7493 break;
|
|
7494 }
|
|
7495 if (s == NULL && !is_term_opt)
|
|
7496 {
|
|
7497 opt_idx = quick_tab[CharOrdLow(arg[0])];
|
|
7498 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
|
|
7499 {
|
|
7500 s = options[opt_idx].shortname;
|
|
7501 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
|
|
7502 break;
|
|
7503 s = NULL;
|
|
7504 }
|
|
7505 }
|
|
7506 if (s == NULL)
|
|
7507 opt_idx = -1;
|
|
7508 return opt_idx;
|
|
7509 }
|
|
7510
|
14
|
7511 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
|
7
|
7512 /*
|
|
7513 * Get the value for an option.
|
|
7514 *
|
|
7515 * Returns:
|
|
7516 * Number or Toggle option: 1, *numval gets value.
|
|
7517 * String option: 0, *stringval gets allocated string.
|
|
7518 * Hidden Number or Toggle option: -1.
|
|
7519 * hidden String option: -2.
|
|
7520 * unknown option: -3.
|
|
7521 */
|
|
7522 int
|
|
7523 get_option_value(name, numval, stringval, opt_flags)
|
|
7524 char_u *name;
|
|
7525 long *numval;
|
|
7526 char_u **stringval; /* NULL when only checking existance */
|
|
7527 int opt_flags;
|
|
7528 {
|
|
7529 int opt_idx;
|
|
7530 char_u *varp;
|
|
7531
|
|
7532 opt_idx = findoption(name);
|
|
7533 if (opt_idx < 0) /* unknown option */
|
|
7534 return -3;
|
|
7535
|
|
7536 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
|
|
7537
|
|
7538 if (options[opt_idx].flags & P_STRING)
|
|
7539 {
|
|
7540 if (varp == NULL) /* hidden option */
|
|
7541 return -2;
|
|
7542 if (stringval != NULL)
|
|
7543 {
|
|
7544 #ifdef FEAT_CRYPT
|
|
7545 /* never return the value of the crypt key */
|
|
7546 if ((char_u **)varp == &curbuf->b_p_key)
|
|
7547 *stringval = vim_strsave((char_u *)"*****");
|
|
7548 else
|
|
7549 #endif
|
|
7550 *stringval = vim_strsave(*(char_u **)(varp));
|
|
7551 }
|
|
7552 return 0;
|
|
7553 }
|
|
7554
|
|
7555 if (varp == NULL) /* hidden option */
|
|
7556 return -1;
|
|
7557 if (options[opt_idx].flags & P_NUM)
|
|
7558 *numval = *(long *)varp;
|
|
7559 else
|
|
7560 {
|
|
7561 /* Special case: 'modified' is b_changed, but we also want to consider
|
|
7562 * it set when 'ff' or 'fenc' changed. */
|
|
7563 if ((int *)varp == &curbuf->b_changed)
|
|
7564 *numval = curbufIsChanged();
|
|
7565 else
|
|
7566 *numval = *(int *)varp;
|
|
7567 }
|
|
7568 return 1;
|
|
7569 }
|
|
7570 #endif
|
|
7571
|
|
7572 /*
|
|
7573 * Set the value of option "name".
|
|
7574 * Use "string" for string options, use "number" for other options.
|
|
7575 */
|
|
7576 void
|
|
7577 set_option_value(name, number, string, opt_flags)
|
|
7578 char_u *name;
|
|
7579 long number;
|
|
7580 char_u *string;
|
|
7581 int opt_flags; /* OPT_LOCAL or 0 (both) */
|
|
7582 {
|
|
7583 int opt_idx;
|
|
7584 char_u *varp;
|
|
7585 int flags;
|
|
7586
|
|
7587 opt_idx = findoption(name);
|
|
7588 if (opt_idx == -1)
|
|
7589 EMSG2(_("E355: Unknown option: %s"), name);
|
|
7590 else
|
|
7591 {
|
|
7592 flags = options[opt_idx].flags;
|
|
7593 #ifdef HAVE_SANDBOX
|
|
7594 /* Disallow changing some options in the sandbox */
|
|
7595 if (sandbox > 0 && (flags & P_SECURE))
|
|
7596 EMSG(_(e_sandbox));
|
|
7597 else
|
|
7598 #endif
|
|
7599 if (flags & P_STRING)
|
|
7600 set_string_option(opt_idx, string, opt_flags);
|
|
7601 else
|
|
7602 {
|
|
7603 varp = get_varp(&options[opt_idx]);
|
|
7604 if (varp != NULL) /* hidden option is not changed */
|
|
7605 {
|
|
7606 if (flags & P_NUM)
|
274
|
7607 (void)set_num_option(opt_idx, varp, number,
|
|
7608 NULL, 0, opt_flags);
|
7
|
7609 else
|
|
7610 (void)set_bool_option(opt_idx, varp, (int)number, opt_flags);
|
|
7611 }
|
|
7612 }
|
|
7613 }
|
|
7614 }
|
|
7615
|
|
7616 /*
|
|
7617 * Get the terminal code for a terminal option.
|
|
7618 * Returns NULL when not found.
|
|
7619 */
|
|
7620 char_u *
|
|
7621 get_term_code(tname)
|
|
7622 char_u *tname;
|
|
7623 {
|
|
7624 int opt_idx;
|
|
7625 char_u *varp;
|
|
7626
|
|
7627 if (tname[0] != 't' || tname[1] != '_' ||
|
|
7628 tname[2] == NUL || tname[3] == NUL)
|
|
7629 return NULL;
|
|
7630 if ((opt_idx = findoption(tname)) >= 0)
|
|
7631 {
|
|
7632 varp = get_varp(&(options[opt_idx]));
|
|
7633 if (varp != NULL)
|
|
7634 varp = *(char_u **)(varp);
|
|
7635 return varp;
|
|
7636 }
|
|
7637 return find_termcode(tname + 2);
|
|
7638 }
|
|
7639
|
|
7640 char_u *
|
|
7641 get_highlight_default()
|
|
7642 {
|
|
7643 int i;
|
|
7644
|
|
7645 i = findoption((char_u *)"hl");
|
|
7646 if (i >= 0)
|
|
7647 return options[i].def_val[VI_DEFAULT];
|
|
7648 return (char_u *)NULL;
|
|
7649 }
|
|
7650
|
39
|
7651 #if defined(FEAT_MBYTE) || defined(PROTO)
|
|
7652 char_u *
|
|
7653 get_encoding_default()
|
|
7654 {
|
|
7655 int i;
|
|
7656
|
|
7657 i = findoption((char_u *)"enc");
|
|
7658 if (i >= 0)
|
|
7659 return options[i].def_val[VI_DEFAULT];
|
|
7660 return (char_u *)NULL;
|
|
7661 }
|
|
7662 #endif
|
|
7663
|
7
|
7664 /*
|
|
7665 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
|
|
7666 */
|
|
7667 static int
|
|
7668 find_key_option(arg)
|
|
7669 char_u *arg;
|
|
7670 {
|
|
7671 int key;
|
|
7672 int modifiers;
|
|
7673
|
|
7674 /*
|
|
7675 * Don't use get_special_key_code() for t_xx, we don't want it to call
|
|
7676 * add_termcap_entry().
|
|
7677 */
|
|
7678 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
|
|
7679 key = TERMCAP2KEY(arg[2], arg[3]);
|
|
7680 else
|
|
7681 {
|
|
7682 --arg; /* put arg at the '<' */
|
|
7683 modifiers = 0;
|
|
7684 key = find_special_key(&arg, &modifiers, TRUE);
|
|
7685 if (modifiers) /* can't handle modifiers here */
|
|
7686 key = 0;
|
|
7687 }
|
|
7688 return key;
|
|
7689 }
|
|
7690
|
|
7691 /*
|
|
7692 * if 'all' == 0: show changed options
|
|
7693 * if 'all' == 1: show all normal options
|
|
7694 * if 'all' == 2: show all terminal options
|
|
7695 */
|
|
7696 static void
|
|
7697 showoptions(all, opt_flags)
|
|
7698 int all;
|
|
7699 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
7700 {
|
|
7701 struct vimoption *p;
|
|
7702 int col;
|
|
7703 int isterm;
|
|
7704 char_u *varp;
|
|
7705 struct vimoption **items;
|
|
7706 int item_count;
|
|
7707 int run;
|
|
7708 int row, rows;
|
|
7709 int cols;
|
|
7710 int i;
|
|
7711 int len;
|
|
7712
|
|
7713 #define INC 20
|
|
7714 #define GAP 3
|
|
7715
|
|
7716 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
|
|
7717 PARAM_COUNT));
|
|
7718 if (items == NULL)
|
|
7719 return;
|
|
7720
|
|
7721 /* Highlight title */
|
|
7722 if (all == 2)
|
|
7723 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
|
|
7724 else if (opt_flags & OPT_GLOBAL)
|
|
7725 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
|
|
7726 else if (opt_flags & OPT_LOCAL)
|
|
7727 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
|
|
7728 else
|
|
7729 MSG_PUTS_TITLE(_("\n--- Options ---"));
|
|
7730
|
|
7731 /*
|
|
7732 * do the loop two times:
|
|
7733 * 1. display the short items
|
|
7734 * 2. display the long items (only strings and numbers)
|
|
7735 */
|
|
7736 for (run = 1; run <= 2 && !got_int; ++run)
|
|
7737 {
|
|
7738 /*
|
|
7739 * collect the items in items[]
|
|
7740 */
|
|
7741 item_count = 0;
|
|
7742 for (p = &options[0]; p->fullname != NULL; p++)
|
|
7743 {
|
|
7744 varp = NULL;
|
|
7745 isterm = istermoption(p);
|
|
7746 if (opt_flags != 0)
|
|
7747 {
|
|
7748 if (p->indir != PV_NONE && !isterm)
|
|
7749 varp = get_varp_scope(p, opt_flags);
|
|
7750 }
|
|
7751 else
|
|
7752 varp = get_varp(p);
|
|
7753 if (varp != NULL
|
|
7754 && ((all == 2 && isterm)
|
|
7755 || (all == 1 && !isterm)
|
|
7756 || (all == 0 && !optval_default(p, varp))))
|
|
7757 {
|
|
7758 if (p->flags & P_BOOL)
|
|
7759 len = 1; /* a toggle option fits always */
|
|
7760 else
|
|
7761 {
|
|
7762 option_value2string(p, opt_flags);
|
|
7763 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
|
|
7764 }
|
|
7765 if ((len <= INC - GAP && run == 1) ||
|
|
7766 (len > INC - GAP && run == 2))
|
|
7767 items[item_count++] = p;
|
|
7768 }
|
|
7769 }
|
|
7770
|
|
7771 /*
|
|
7772 * display the items
|
|
7773 */
|
|
7774 if (run == 1)
|
|
7775 {
|
|
7776 cols = (Columns + GAP - 3) / INC;
|
|
7777 if (cols == 0)
|
|
7778 cols = 1;
|
|
7779 rows = (item_count + cols - 1) / cols;
|
|
7780 }
|
|
7781 else /* run == 2 */
|
|
7782 rows = item_count;
|
|
7783 for (row = 0; row < rows && !got_int; ++row)
|
|
7784 {
|
|
7785 msg_putchar('\n'); /* go to next line */
|
|
7786 if (got_int) /* 'q' typed in more */
|
|
7787 break;
|
|
7788 col = 0;
|
|
7789 for (i = row; i < item_count; i += rows)
|
|
7790 {
|
|
7791 msg_col = col; /* make columns */
|
|
7792 showoneopt(items[i], opt_flags);
|
|
7793 col += INC;
|
|
7794 }
|
|
7795 out_flush();
|
|
7796 ui_breakcheck();
|
|
7797 }
|
|
7798 }
|
|
7799 vim_free(items);
|
|
7800 }
|
|
7801
|
|
7802 /*
|
|
7803 * Return TRUE if option "p" has its default value.
|
|
7804 */
|
|
7805 static int
|
|
7806 optval_default(p, varp)
|
|
7807 struct vimoption *p;
|
|
7808 char_u *varp;
|
|
7809 {
|
|
7810 int dvi;
|
|
7811
|
|
7812 if (varp == NULL)
|
|
7813 return TRUE; /* hidden option is always at default */
|
|
7814 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
|
|
7815 if (p->flags & P_NUM)
|
|
7816 return (*(long *)varp == (long)p->def_val[dvi]);
|
|
7817 if (p->flags & P_BOOL)
|
|
7818 /* the cast to long is required for Manx C */
|
|
7819 return (*(int *)varp == (int)(long)p->def_val[dvi]);
|
|
7820 /* P_STRING */
|
|
7821 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
|
|
7822 }
|
|
7823
|
|
7824 /*
|
|
7825 * showoneopt: show the value of one option
|
|
7826 * must not be called with a hidden option!
|
|
7827 */
|
|
7828 static void
|
|
7829 showoneopt(p, opt_flags)
|
|
7830 struct vimoption *p;
|
|
7831 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
|
|
7832 {
|
168
|
7833 char_u *varp;
|
|
7834 int save_silent = silent_mode;
|
|
7835
|
|
7836 silent_mode = FALSE;
|
|
7837 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
|
7
|
7838
|
|
7839 varp = get_varp_scope(p, opt_flags);
|
|
7840
|
|
7841 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
|
|
7842 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
|
|
7843 ? !curbufIsChanged() : !*(int *)varp))
|
|
7844 MSG_PUTS("no");
|
|
7845 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
|
|
7846 MSG_PUTS("--");
|
|
7847 else
|
|
7848 MSG_PUTS(" ");
|
|
7849 MSG_PUTS(p->fullname);
|
|
7850 if (!(p->flags & P_BOOL))
|
|
7851 {
|
|
7852 msg_putchar('=');
|
|
7853 /* put value string in NameBuff */
|
|
7854 option_value2string(p, opt_flags);
|
|
7855 msg_outtrans(NameBuff);
|
|
7856 }
|
168
|
7857
|
|
7858 silent_mode = save_silent;
|
|
7859 info_message = FALSE;
|
7
|
7860 }
|
|
7861
|
|
7862 /*
|
|
7863 * Write modified options as ":set" commands to a file.
|
|
7864 *
|
|
7865 * There are three values for "opt_flags":
|
|
7866 * OPT_GLOBAL: Write global option values and fresh values of
|
|
7867 * buffer-local options (used for start of a session
|
|
7868 * file).
|
|
7869 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
|
|
7870 * curwin (used for a vimrc file).
|
|
7871 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
|
|
7872 * and local values for window-local options of
|
|
7873 * curwin. Local values are also written when at the
|
|
7874 * default value, because a modeline or autocommand
|
|
7875 * may have set them when doing ":edit file" and the
|
|
7876 * user has set them back at the default or fresh
|
|
7877 * value.
|
|
7878 * When "local_only" is TRUE, don't write fresh
|
|
7879 * values, only local values (for ":mkview").
|
|
7880 * (fresh value = value used for a new buffer or window for a local option).
|
|
7881 *
|
|
7882 * Return FAIL on error, OK otherwise.
|
|
7883 */
|
|
7884 int
|
|
7885 makeset(fd, opt_flags, local_only)
|
|
7886 FILE *fd;
|
|
7887 int opt_flags;
|
|
7888 int local_only;
|
|
7889 {
|
|
7890 struct vimoption *p;
|
|
7891 char_u *varp; /* currently used value */
|
|
7892 char_u *varp_fresh; /* local value */
|
|
7893 char_u *varp_local = NULL; /* fresh value */
|
|
7894 char *cmd;
|
|
7895 int round;
|
|
7896
|
|
7897 /*
|
|
7898 * The options that don't have a default (terminal name, columns, lines)
|
|
7899 * are never written. Terminal options are also not written.
|
|
7900 */
|
|
7901 for (p = &options[0]; !istermoption(p); p++)
|
|
7902 if (!(p->flags & P_NO_MKRC) && !istermoption(p))
|
|
7903 {
|
|
7904 /* skip global option when only doing locals */
|
|
7905 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
|
|
7906 continue;
|
|
7907
|
|
7908 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
|
|
7909 * file, they are always buffer-specific. */
|
|
7910 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
|
|
7911 continue;
|
|
7912
|
|
7913 /* Global values are only written when not at the default value. */
|
|
7914 varp = get_varp_scope(p, opt_flags);
|
|
7915 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
|
|
7916 continue;
|
|
7917
|
|
7918 round = 2;
|
|
7919 if (p->indir != PV_NONE)
|
|
7920 {
|
|
7921 if (p->var == VAR_WIN)
|
|
7922 {
|
|
7923 /* skip window-local option when only doing globals */
|
|
7924 if (!(opt_flags & OPT_LOCAL))
|
|
7925 continue;
|
|
7926 /* When fresh value of window-local option is not at the
|
|
7927 * default, need to write it too. */
|
|
7928 if (!(opt_flags & OPT_GLOBAL) && !local_only)
|
|
7929 {
|
|
7930 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
|
|
7931 if (!optval_default(p, varp_fresh))
|
|
7932 {
|
|
7933 round = 1;
|
|
7934 varp_local = varp;
|
|
7935 varp = varp_fresh;
|
|
7936 }
|
|
7937 }
|
|
7938 }
|
|
7939 }
|
|
7940
|
|
7941 /* Round 1: fresh value for window-local options.
|
|
7942 * Round 2: other values */
|
|
7943 for ( ; round <= 2; varp = varp_local, ++round)
|
|
7944 {
|
|
7945 if (round == 1 || (opt_flags & OPT_GLOBAL))
|
|
7946 cmd = "set";
|
|
7947 else
|
|
7948 cmd = "setlocal";
|
|
7949
|
|
7950 if (p->flags & P_BOOL)
|
|
7951 {
|
|
7952 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
|
|
7953 return FAIL;
|
|
7954 }
|
|
7955 else if (p->flags & P_NUM)
|
|
7956 {
|
|
7957 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
|
|
7958 return FAIL;
|
|
7959 }
|
|
7960 else /* P_STRING */
|
|
7961 {
|
|
7962 /* Don't set 'syntax' and 'filetype' again if the value is
|
|
7963 * already right, avoids reloading the syntax file. */
|
|
7964 if (p->indir == PV_SYN || p->indir == PV_FT)
|
|
7965 {
|
|
7966 if (fprintf(fd, "if &%s != '%s'", p->fullname,
|
|
7967 *(char_u **)(varp)) < 0
|
|
7968 || put_eol(fd) < 0)
|
|
7969 return FAIL;
|
|
7970 }
|
|
7971 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
|
|
7972 (p->flags & P_EXPAND) != 0) == FAIL)
|
|
7973 return FAIL;
|
|
7974 if (p->indir == PV_SYN || p->indir == PV_FT)
|
|
7975 {
|
|
7976 if (put_line(fd, "endif") == FAIL)
|
|
7977 return FAIL;
|
|
7978 }
|
|
7979 }
|
|
7980 }
|
|
7981 }
|
|
7982 return OK;
|
|
7983 }
|
|
7984
|
|
7985 #if defined(FEAT_FOLDING) || defined(PROTO)
|
|
7986 /*
|
|
7987 * Generate set commands for the local fold options only. Used when
|
|
7988 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
|
|
7989 */
|
|
7990 int
|
|
7991 makefoldset(fd)
|
|
7992 FILE *fd;
|
|
7993 {
|
|
7994 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
|
|
7995 # ifdef FEAT_EVAL
|
|
7996 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
|
|
7997 == FAIL
|
|
7998 # endif
|
|
7999 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
|
|
8000 == FAIL
|
|
8001 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
|
|
8002 == FAIL
|
|
8003 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
|
|
8004 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
|
|
8005 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
|
|
8006 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
|
|
8007 )
|
|
8008 return FAIL;
|
|
8009
|
|
8010 return OK;
|
|
8011 }
|
|
8012 #endif
|
|
8013
|
|
8014 static int
|
|
8015 put_setstring(fd, cmd, name, valuep, expand)
|
|
8016 FILE *fd;
|
|
8017 char *cmd;
|
|
8018 char *name;
|
|
8019 char_u **valuep;
|
|
8020 int expand;
|
|
8021 {
|
|
8022 char_u *s;
|
|
8023 char_u buf[MAXPATHL];
|
|
8024
|
|
8025 if (fprintf(fd, "%s %s=", cmd, name) < 0)
|
|
8026 return FAIL;
|
|
8027 if (*valuep != NULL)
|
|
8028 {
|
|
8029 /* Output 'pastetoggle' as key names. For other
|
|
8030 * options some characters have to be escaped with
|
|
8031 * CTRL-V or backslash */
|
|
8032 if (valuep == &p_pt)
|
|
8033 {
|
|
8034 s = *valuep;
|
|
8035 while (*s != NUL)
|
|
8036 if (fputs((char *)str2special(&s, FALSE), fd) < 0)
|
|
8037 return FAIL;
|
|
8038 }
|
|
8039 else if (expand)
|
|
8040 {
|
|
8041 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
|
|
8042 if (put_escstr(fd, buf, 2) == FAIL)
|
|
8043 return FAIL;
|
|
8044 }
|
|
8045 else if (put_escstr(fd, *valuep, 2) == FAIL)
|
|
8046 return FAIL;
|
|
8047 }
|
|
8048 if (put_eol(fd) < 0)
|
|
8049 return FAIL;
|
|
8050 return OK;
|
|
8051 }
|
|
8052
|
|
8053 static int
|
|
8054 put_setnum(fd, cmd, name, valuep)
|
|
8055 FILE *fd;
|
|
8056 char *cmd;
|
|
8057 char *name;
|
|
8058 long *valuep;
|
|
8059 {
|
|
8060 long wc;
|
|
8061
|
|
8062 if (fprintf(fd, "%s %s=", cmd, name) < 0)
|
|
8063 return FAIL;
|
|
8064 if (wc_use_keyname((char_u *)valuep, &wc))
|
|
8065 {
|
|
8066 /* print 'wildchar' and 'wildcharm' as a key name */
|
|
8067 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
|
|
8068 return FAIL;
|
|
8069 }
|
|
8070 else if (fprintf(fd, "%ld", *valuep) < 0)
|
|
8071 return FAIL;
|
|
8072 if (put_eol(fd) < 0)
|
|
8073 return FAIL;
|
|
8074 return OK;
|
|
8075 }
|
|
8076
|
|
8077 static int
|
|
8078 put_setbool(fd, cmd, name, value)
|
|
8079 FILE *fd;
|
|
8080 char *cmd;
|
|
8081 char *name;
|
|
8082 int value;
|
|
8083 {
|
|
8084 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
|
|
8085 || put_eol(fd) < 0)
|
|
8086 return FAIL;
|
|
8087 return OK;
|
|
8088 }
|
|
8089
|
|
8090 /*
|
|
8091 * Clear all the terminal options.
|
|
8092 * If the option has been allocated, free the memory.
|
|
8093 * Terminal options are never hidden or indirect.
|
|
8094 */
|
|
8095 void
|
|
8096 clear_termoptions()
|
|
8097 {
|
|
8098 /*
|
|
8099 * Reset a few things before clearing the old options. This may cause
|
|
8100 * outputting a few things that the terminal doesn't understand, but the
|
|
8101 * screen will be cleared later, so this is OK.
|
|
8102 */
|
|
8103 #ifdef FEAT_MOUSE_TTY
|
|
8104 mch_setmouse(FALSE); /* switch mouse off */
|
|
8105 #endif
|
|
8106 #ifdef FEAT_TITLE
|
|
8107 mch_restore_title(3); /* restore window titles */
|
|
8108 #endif
|
|
8109 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
|
|
8110 /* When starting the GUI close the display opened for the clipboard.
|
|
8111 * After restoring the title, because that will need the display. */
|
|
8112 if (gui.starting)
|
|
8113 clear_xterm_clip();
|
|
8114 #endif
|
|
8115 #ifdef WIN3264
|
|
8116 /*
|
|
8117 * Check if this is allowed now.
|
|
8118 */
|
|
8119 if (can_end_termcap_mode(FALSE) == TRUE)
|
|
8120 #endif
|
|
8121 stoptermcap(); /* stop termcap mode */
|
|
8122
|
359
|
8123 free_termoptions();
|
|
8124 }
|
|
8125
|
|
8126 void
|
|
8127 free_termoptions()
|
|
8128 {
|
|
8129 struct vimoption *p;
|
|
8130
|
7
|
8131 for (p = &options[0]; p->fullname != NULL; p++)
|
|
8132 if (istermoption(p))
|
|
8133 {
|
|
8134 if (p->flags & P_ALLOCED)
|
|
8135 free_string_option(*(char_u **)(p->var));
|
|
8136 if (p->flags & P_DEF_ALLOCED)
|
|
8137 free_string_option(p->def_val[VI_DEFAULT]);
|
|
8138 *(char_u **)(p->var) = empty_option;
|
|
8139 p->def_val[VI_DEFAULT] = empty_option;
|
|
8140 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
|
|
8141 }
|
|
8142 clear_termcodes();
|
|
8143 }
|
|
8144
|
|
8145 /*
|
|
8146 * Set the terminal option defaults to the current value.
|
|
8147 * Used after setting the terminal name.
|
|
8148 */
|
|
8149 void
|
|
8150 set_term_defaults()
|
|
8151 {
|
|
8152 struct vimoption *p;
|
|
8153
|
|
8154 for (p = &options[0]; p->fullname != NULL; p++)
|
|
8155 {
|
|
8156 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
|
|
8157 {
|
|
8158 if (p->flags & P_DEF_ALLOCED)
|
|
8159 {
|
|
8160 free_string_option(p->def_val[VI_DEFAULT]);
|
|
8161 p->flags &= ~P_DEF_ALLOCED;
|
|
8162 }
|
|
8163 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
|
|
8164 if (p->flags & P_ALLOCED)
|
|
8165 {
|
|
8166 p->flags |= P_DEF_ALLOCED;
|
|
8167 p->flags &= ~P_ALLOCED; /* don't free the value now */
|
|
8168 }
|
|
8169 }
|
|
8170 }
|
|
8171 }
|
|
8172
|
|
8173 /*
|
|
8174 * return TRUE if 'p' starts with 't_'
|
|
8175 */
|
|
8176 static int
|
|
8177 istermoption(p)
|
|
8178 struct vimoption *p;
|
|
8179 {
|
|
8180 return (p->fullname[0] == 't' && p->fullname[1] == '_');
|
|
8181 }
|
|
8182
|
|
8183 /*
|
|
8184 * Compute columns for ruler and shown command. 'sc_col' is also used to
|
|
8185 * decide what the maximum length of a message on the status line can be.
|
|
8186 * If there is a status line for the last window, 'sc_col' is independent
|
|
8187 * of 'ru_col'.
|
|
8188 */
|
|
8189
|
|
8190 #define COL_RULER 17 /* columns needed by standard ruler */
|
|
8191
|
|
8192 void
|
|
8193 comp_col()
|
|
8194 {
|
|
8195 #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
|
|
8196 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
|
|
8197
|
|
8198 sc_col = 0;
|
|
8199 ru_col = 0;
|
|
8200 if (p_ru)
|
|
8201 {
|
|
8202 #ifdef FEAT_STL_OPT
|
|
8203 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
|
|
8204 #else
|
|
8205 ru_col = COL_RULER + 1;
|
|
8206 #endif
|
|
8207 /* no last status line, adjust sc_col */
|
|
8208 if (!last_has_status)
|
|
8209 sc_col = ru_col;
|
|
8210 }
|
|
8211 if (p_sc)
|
|
8212 {
|
|
8213 sc_col += SHOWCMD_COLS;
|
|
8214 if (!p_ru || last_has_status) /* no need for separating space */
|
|
8215 ++sc_col;
|
|
8216 }
|
|
8217 sc_col = Columns - sc_col;
|
|
8218 ru_col = Columns - ru_col;
|
|
8219 if (sc_col <= 0) /* screen too narrow, will become a mess */
|
|
8220 sc_col = 1;
|
|
8221 if (ru_col <= 0)
|
|
8222 ru_col = 1;
|
|
8223 #else
|
|
8224 sc_col = Columns;
|
|
8225 ru_col = Columns;
|
|
8226 #endif
|
|
8227 }
|
|
8228
|
|
8229 /*
|
|
8230 * Get pointer to option variable, depending on local or global scope.
|
|
8231 */
|
|
8232 static char_u *
|
|
8233 get_varp_scope(p, opt_flags)
|
|
8234 struct vimoption *p;
|
|
8235 int opt_flags;
|
|
8236 {
|
|
8237 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
|
|
8238 {
|
|
8239 if (p->var == VAR_WIN)
|
|
8240 return (char_u *)GLOBAL_WO(get_varp(p));
|
|
8241 return p->var;
|
|
8242 }
|
|
8243 if ((opt_flags & OPT_LOCAL) && (int)p->indir >= PV_BOTH)
|
|
8244 {
|
|
8245 switch ((int)p->indir)
|
|
8246 {
|
|
8247 #ifdef FEAT_QUICKFIX
|
|
8248 case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp);
|
|
8249 case OPT_BOTH(PV_MP): return (char_u *)&(curbuf->b_p_mp);
|
|
8250 case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm);
|
|
8251 #endif
|
|
8252 case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep);
|
|
8253 case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp);
|
|
8254 case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path);
|
|
8255 case OPT_BOTH(PV_AR): return (char_u *)&(curbuf->b_p_ar);
|
|
8256 case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags);
|
|
8257 #ifdef FEAT_FIND_ID
|
|
8258 case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def);
|
|
8259 case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc);
|
|
8260 #endif
|
|
8261 #ifdef FEAT_INS_EXPAND
|
|
8262 case OPT_BOTH(PV_DICT): return (char_u *)&(curbuf->b_p_dict);
|
|
8263 case OPT_BOTH(PV_TSR): return (char_u *)&(curbuf->b_p_tsr);
|
|
8264 #endif
|
40
|
8265 #ifdef FEAT_STL_OPT
|
|
8266 case OPT_BOTH(PV_STL): return (char_u *)&(curwin->w_p_stl);
|
|
8267 #endif
|
7
|
8268 }
|
|
8269 return NULL; /* "cannot happen" */
|
|
8270 }
|
|
8271 return get_varp(p);
|
|
8272 }
|
|
8273
|
|
8274 /*
|
|
8275 * Get pointer to option variable.
|
|
8276 */
|
|
8277 static char_u *
|
|
8278 get_varp(p)
|
|
8279 struct vimoption *p;
|
|
8280 {
|
|
8281 /* hidden option, always return NULL */
|
|
8282 if (p->var == NULL)
|
|
8283 return NULL;
|
|
8284
|
|
8285 switch ((int)p->indir)
|
|
8286 {
|
|
8287 case PV_NONE: return p->var;
|
|
8288
|
|
8289 /* global option with local value: use local value if it's been set */
|
|
8290 case OPT_BOTH(PV_EP): return *curbuf->b_p_ep != NUL
|
|
8291 ? (char_u *)&curbuf->b_p_ep : p->var;
|
|
8292 case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL
|
|
8293 ? (char_u *)&curbuf->b_p_kp : p->var;
|
|
8294 case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL
|
|
8295 ? (char_u *)&(curbuf->b_p_path) : p->var;
|
|
8296 case OPT_BOTH(PV_AR): return curbuf->b_p_ar >= 0
|
|
8297 ? (char_u *)&(curbuf->b_p_ar) : p->var;
|
|
8298 case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL
|
|
8299 ? (char_u *)&(curbuf->b_p_tags) : p->var;
|
|
8300 #ifdef FEAT_FIND_ID
|
|
8301 case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL
|
|
8302 ? (char_u *)&(curbuf->b_p_def) : p->var;
|
|
8303 case OPT_BOTH(PV_INC): return *curbuf->b_p_inc != NUL
|
|
8304 ? (char_u *)&(curbuf->b_p_inc) : p->var;
|
|
8305 #endif
|
|
8306 #ifdef FEAT_INS_EXPAND
|
|
8307 case OPT_BOTH(PV_DICT): return *curbuf->b_p_dict != NUL
|
|
8308 ? (char_u *)&(curbuf->b_p_dict) : p->var;
|
|
8309 case OPT_BOTH(PV_TSR): return *curbuf->b_p_tsr != NUL
|
|
8310 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
|
|
8311 #endif
|
|
8312 #ifdef FEAT_QUICKFIX
|
|
8313 case OPT_BOTH(PV_GP): return *curbuf->b_p_gp != NUL
|
|
8314 ? (char_u *)&(curbuf->b_p_gp) : p->var;
|
|
8315 case OPT_BOTH(PV_MP): return *curbuf->b_p_mp != NUL
|
|
8316 ? (char_u *)&(curbuf->b_p_mp) : p->var;
|
|
8317 case OPT_BOTH(PV_EFM): return *curbuf->b_p_efm != NUL
|
|
8318 ? (char_u *)&(curbuf->b_p_efm) : p->var;
|
|
8319 #endif
|
40
|
8320 #ifdef FEAT_STL_OPT
|
|
8321 case OPT_BOTH(PV_STL): return *curwin->w_p_stl != NUL
|
|
8322 ? (char_u *)&(curwin->w_p_stl) : p->var;
|
|
8323 #endif
|
7
|
8324
|
|
8325 #ifdef FEAT_ARABIC
|
|
8326 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
|
|
8327 #endif
|
|
8328 case PV_LIST: return (char_u *)&(curwin->w_p_list);
|
221
|
8329 #ifdef FEAT_SYN_HL
|
|
8330 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
|
|
8331 #endif
|
7
|
8332 #ifdef FEAT_DIFF
|
|
8333 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
|
|
8334 #endif
|
|
8335 #ifdef FEAT_FOLDING
|
|
8336 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
|
|
8337 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
|
|
8338 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
|
|
8339 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
|
|
8340 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
|
|
8341 case PV_FML: return (char_u *)&(curwin->w_p_fml);
|
|
8342 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
|
|
8343 # ifdef FEAT_EVAL
|
|
8344 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
|
|
8345 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
|
|
8346 # endif
|
|
8347 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
|
|
8348 #endif
|
|
8349 case PV_NU: return (char_u *)&(curwin->w_p_nu);
|
13
|
8350 #ifdef FEAT_LINEBREAK
|
|
8351 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
|
|
8352 #endif
|
7
|
8353 #if defined(FEAT_WINDOWS)
|
|
8354 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
|
|
8355 #endif
|
|
8356 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
|
8357 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
|
|
8358 #endif
|
|
8359 #ifdef FEAT_RIGHTLEFT
|
|
8360 case PV_RL: return (char_u *)&(curwin->w_p_rl);
|
|
8361 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
|
|
8362 #endif
|
|
8363 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
|
|
8364 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
|
|
8365 #ifdef FEAT_LINEBREAK
|
|
8366 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
|
|
8367 #endif
|
|
8368 #ifdef FEAT_SCROLLBIND
|
|
8369 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
|
|
8370 #endif
|
|
8371
|
|
8372 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
|
|
8373 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
|
|
8374 #ifdef FEAT_MBYTE
|
|
8375 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
|
|
8376 #endif
|
|
8377 #if defined(FEAT_QUICKFIX)
|
|
8378 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
|
|
8379 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
|
|
8380 #endif
|
|
8381 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
|
|
8382 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
|
|
8383 #ifdef FEAT_CINDENT
|
|
8384 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
|
|
8385 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
|
|
8386 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
|
|
8387 #endif
|
|
8388 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
8389 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
|
|
8390 #endif
|
|
8391 #ifdef FEAT_COMMENTS
|
|
8392 case PV_COM: return (char_u *)&(curbuf->b_p_com);
|
|
8393 #endif
|
|
8394 #ifdef FEAT_FOLDING
|
|
8395 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
|
|
8396 #endif
|
|
8397 #ifdef FEAT_INS_EXPAND
|
|
8398 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
|
|
8399 #endif
|
12
|
8400 #ifdef FEAT_COMPL_FUNC
|
|
8401 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
|
|
8402 #endif
|
7
|
8403 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
|
|
8404 case PV_ET: return (char_u *)&(curbuf->b_p_et);
|
|
8405 #ifdef FEAT_MBYTE
|
|
8406 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
|
|
8407 #endif
|
|
8408 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
|
|
8409 #ifdef FEAT_AUTOCMD
|
|
8410 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
|
|
8411 #endif
|
|
8412 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
|
41
|
8413 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
|
7
|
8414 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
|
|
8415 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
|
|
8416 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
|
|
8417 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
|
|
8418 #ifdef FEAT_FIND_ID
|
|
8419 # ifdef FEAT_EVAL
|
|
8420 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
|
|
8421 # endif
|
|
8422 #endif
|
|
8423 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
8424 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
|
|
8425 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
|
|
8426 #endif
|
|
8427 #ifdef FEAT_CRYPT
|
|
8428 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
|
|
8429 #endif
|
|
8430 #ifdef FEAT_LISP
|
|
8431 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
|
|
8432 #endif
|
|
8433 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
|
|
8434 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
|
|
8435 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
|
|
8436 case PV_MOD: return (char_u *)&(curbuf->b_changed);
|
|
8437 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
|
|
8438 #ifdef FEAT_OSFILETYPE
|
|
8439 case PV_OFT: return (char_u *)&(curbuf->b_p_oft);
|
|
8440 #endif
|
|
8441 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
|
12
|
8442 #ifdef FEAT_TEXTOBJ
|
|
8443 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
|
|
8444 #endif
|
7
|
8445 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
|
|
8446 #ifdef FEAT_SMARTINDENT
|
|
8447 case PV_SI: return (char_u *)&(curbuf->b_p_si);
|
|
8448 #endif
|
|
8449 #ifndef SHORT_FNAME
|
|
8450 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
|
|
8451 #endif
|
|
8452 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
|
|
8453 #ifdef FEAT_SEARCHPATH
|
|
8454 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
|
|
8455 #endif
|
|
8456 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
|
|
8457 #ifdef FEAT_SYN_HL
|
410
|
8458 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
|
7
|
8459 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
|
386
|
8460 case PV_SPC: return (char_u *)&(curbuf->b_p_spc);
|
314
|
8461 case PV_SPF: return (char_u *)&(curbuf->b_p_spf);
|
221
|
8462 case PV_SPL: return (char_u *)&(curbuf->b_p_spl);
|
7
|
8463 #endif
|
|
8464 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
|
|
8465 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
|
|
8466 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
|
|
8467 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
|
|
8468 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
|
|
8469 #ifdef FEAT_KEYMAP
|
|
8470 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
|
|
8471 #endif
|
|
8472 default: EMSG(_("E356: get_varp ERROR"));
|
|
8473 }
|
|
8474 /* always return a valid pointer to avoid a crash! */
|
|
8475 return (char_u *)&(curbuf->b_p_wm);
|
|
8476 }
|
|
8477
|
|
8478 /*
|
|
8479 * Get the value of 'equalprg', either the buffer-local one or the global one.
|
|
8480 */
|
|
8481 char_u *
|
|
8482 get_equalprg()
|
|
8483 {
|
|
8484 if (*curbuf->b_p_ep == NUL)
|
|
8485 return p_ep;
|
|
8486 return curbuf->b_p_ep;
|
|
8487 }
|
|
8488
|
|
8489 #if defined(FEAT_WINDOWS) || defined(PROTO)
|
|
8490 /*
|
|
8491 * Copy options from one window to another.
|
|
8492 * Used when splitting a window.
|
|
8493 */
|
|
8494 void
|
|
8495 win_copy_options(wp_from, wp_to)
|
|
8496 win_T *wp_from;
|
|
8497 win_T *wp_to;
|
|
8498 {
|
|
8499 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
|
|
8500 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
|
|
8501 # ifdef FEAT_RIGHTLEFT
|
|
8502 # ifdef FEAT_FKMAP
|
|
8503 /* Is this right? */
|
|
8504 wp_to->w_farsi = wp_from->w_farsi;
|
|
8505 # endif
|
|
8506 # endif
|
|
8507 }
|
|
8508 #endif
|
|
8509
|
|
8510 /*
|
|
8511 * Copy the options from one winopt_T to another.
|
|
8512 * Doesn't free the old option values in "to", use clear_winopt() for that.
|
|
8513 * The 'scroll' option is not copied, because it depends on the window height.
|
|
8514 * The 'previewwindow' option is reset, there can be only one preview window.
|
|
8515 */
|
|
8516 void
|
|
8517 copy_winopt(from, to)
|
|
8518 winopt_T *from;
|
|
8519 winopt_T *to;
|
|
8520 {
|
|
8521 #ifdef FEAT_ARABIC
|
|
8522 to->wo_arab = from->wo_arab;
|
|
8523 #endif
|
|
8524 to->wo_list = from->wo_list;
|
|
8525 to->wo_nu = from->wo_nu;
|
13
|
8526 #ifdef FEAT_LINEBREAK
|
|
8527 to->wo_nuw = from->wo_nuw;
|
|
8528 #endif
|
7
|
8529 #ifdef FEAT_RIGHTLEFT
|
|
8530 to->wo_rl = from->wo_rl;
|
|
8531 to->wo_rlc = vim_strsave(from->wo_rlc);
|
|
8532 #endif
|
40
|
8533 #ifdef FEAT_STL_OPT
|
|
8534 to->wo_stl = vim_strsave(from->wo_stl);
|
|
8535 #endif
|
7
|
8536 to->wo_wrap = from->wo_wrap;
|
|
8537 #ifdef FEAT_LINEBREAK
|
|
8538 to->wo_lbr = from->wo_lbr;
|
|
8539 #endif
|
|
8540 #ifdef FEAT_SCROLLBIND
|
|
8541 to->wo_scb = from->wo_scb;
|
|
8542 #endif
|
221
|
8543 #ifdef FEAT_SYN_HL
|
|
8544 to->wo_spell = from->wo_spell;
|
|
8545 #endif
|
7
|
8546 #ifdef FEAT_DIFF
|
|
8547 to->wo_diff = from->wo_diff;
|
|
8548 #endif
|
|
8549 #ifdef FEAT_FOLDING
|
|
8550 to->wo_fdc = from->wo_fdc;
|
|
8551 to->wo_fen = from->wo_fen;
|
|
8552 to->wo_fdi = vim_strsave(from->wo_fdi);
|
|
8553 to->wo_fml = from->wo_fml;
|
|
8554 to->wo_fdl = from->wo_fdl;
|
|
8555 to->wo_fdm = vim_strsave(from->wo_fdm);
|
|
8556 to->wo_fdn = from->wo_fdn;
|
|
8557 # ifdef FEAT_EVAL
|
|
8558 to->wo_fde = vim_strsave(from->wo_fde);
|
|
8559 to->wo_fdt = vim_strsave(from->wo_fdt);
|
|
8560 # endif
|
|
8561 to->wo_fmr = vim_strsave(from->wo_fmr);
|
|
8562 #endif
|
|
8563 check_winopt(to); /* don't want NULL pointers */
|
|
8564 }
|
|
8565
|
|
8566 /*
|
|
8567 * Check string options in a window for a NULL value.
|
|
8568 */
|
|
8569 void
|
|
8570 check_win_options(win)
|
|
8571 win_T *win;
|
|
8572 {
|
|
8573 check_winopt(&win->w_onebuf_opt);
|
|
8574 check_winopt(&win->w_allbuf_opt);
|
|
8575 }
|
|
8576
|
|
8577 /*
|
|
8578 * Check for NULL pointers in a winopt_T and replace them with empty_option.
|
|
8579 */
|
|
8580 /*ARGSUSED*/
|
|
8581 void
|
|
8582 check_winopt(wop)
|
|
8583 winopt_T *wop;
|
|
8584 {
|
|
8585 #ifdef FEAT_FOLDING
|
|
8586 check_string_option(&wop->wo_fdi);
|
|
8587 check_string_option(&wop->wo_fdm);
|
|
8588 # ifdef FEAT_EVAL
|
|
8589 check_string_option(&wop->wo_fde);
|
|
8590 check_string_option(&wop->wo_fdt);
|
|
8591 # endif
|
|
8592 check_string_option(&wop->wo_fmr);
|
|
8593 #endif
|
|
8594 #ifdef FEAT_RIGHTLEFT
|
|
8595 check_string_option(&wop->wo_rlc);
|
|
8596 #endif
|
40
|
8597 #ifdef FEAT_STL_OPT
|
|
8598 check_string_option(&wop->wo_stl);
|
|
8599 #endif
|
7
|
8600 }
|
|
8601
|
|
8602 /*
|
|
8603 * Free the allocated memory inside a winopt_T.
|
|
8604 */
|
|
8605 /*ARGSUSED*/
|
|
8606 void
|
|
8607 clear_winopt(wop)
|
|
8608 winopt_T *wop;
|
|
8609 {
|
|
8610 #ifdef FEAT_FOLDING
|
|
8611 clear_string_option(&wop->wo_fdi);
|
|
8612 clear_string_option(&wop->wo_fdm);
|
|
8613 # ifdef FEAT_EVAL
|
|
8614 clear_string_option(&wop->wo_fde);
|
|
8615 clear_string_option(&wop->wo_fdt);
|
|
8616 # endif
|
|
8617 clear_string_option(&wop->wo_fmr);
|
|
8618 #endif
|
|
8619 #ifdef FEAT_RIGHTLEFT
|
|
8620 clear_string_option(&wop->wo_rlc);
|
|
8621 #endif
|
40
|
8622 #ifdef FEAT_STL_OPT
|
|
8623 clear_string_option(&wop->wo_stl);
|
|
8624 #endif
|
7
|
8625 }
|
|
8626
|
|
8627 /*
|
|
8628 * Copy global option values to local options for one buffer.
|
|
8629 * Used when creating a new buffer and sometimes when entering a buffer.
|
|
8630 * flags:
|
|
8631 * BCO_ENTER We will enter the buf buffer.
|
|
8632 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
|
|
8633 * appropriate.
|
|
8634 * BCO_NOHELP Don't copy the values to a help buffer.
|
|
8635 */
|
|
8636 void
|
|
8637 buf_copy_options(buf, flags)
|
|
8638 buf_T *buf;
|
|
8639 int flags;
|
|
8640 {
|
|
8641 int should_copy = TRUE;
|
|
8642 char_u *save_p_isk = NULL; /* init for GCC */
|
|
8643 int dont_do_help;
|
|
8644 int did_isk = FALSE;
|
|
8645
|
|
8646 /*
|
|
8647 * Don't do anything of the buffer is invalid.
|
|
8648 */
|
|
8649 if (buf == NULL || !buf_valid(buf))
|
|
8650 return;
|
|
8651
|
|
8652 /*
|
|
8653 * Skip this when the option defaults have not been set yet. Happens when
|
|
8654 * main() allocates the first buffer.
|
|
8655 */
|
|
8656 if (p_cpo != NULL)
|
|
8657 {
|
|
8658 /*
|
|
8659 * Always copy when entering and 'cpo' contains 'S'.
|
|
8660 * Don't copy when already initialized.
|
|
8661 * Don't copy when 'cpo' contains 's' and not entering.
|
|
8662 * 'S' BCO_ENTER initialized 's' should_copy
|
|
8663 * yes yes X X TRUE
|
|
8664 * yes no yes X FALSE
|
|
8665 * no X yes X FALSE
|
|
8666 * X no no yes FALSE
|
|
8667 * X no no no TRUE
|
|
8668 * no yes no X TRUE
|
|
8669 */
|
|
8670 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
|
|
8671 && (buf->b_p_initialized
|
|
8672 || (!(flags & BCO_ENTER)
|
|
8673 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
|
|
8674 should_copy = FALSE;
|
|
8675
|
|
8676 if (should_copy || (flags & BCO_ALWAYS))
|
|
8677 {
|
|
8678 /* Don't copy the options specific to a help buffer when
|
|
8679 * BCO_NOHELP is given or the options were initialized already
|
|
8680 * (jumping back to a help file with CTRL-T or CTRL-O) */
|
|
8681 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
|
|
8682 || buf->b_p_initialized;
|
|
8683 if (dont_do_help) /* don't free b_p_isk */
|
|
8684 {
|
|
8685 save_p_isk = buf->b_p_isk;
|
|
8686 buf->b_p_isk = NULL;
|
|
8687 }
|
|
8688 /*
|
|
8689 * Always free the allocated strings.
|
|
8690 * If not already initialized, set 'readonly' and copy 'fileformat'.
|
|
8691 */
|
|
8692 if (!buf->b_p_initialized)
|
|
8693 {
|
|
8694 free_buf_options(buf, TRUE);
|
|
8695 buf->b_p_ro = FALSE; /* don't copy readonly */
|
|
8696 buf->b_p_tx = p_tx;
|
|
8697 #ifdef FEAT_MBYTE
|
|
8698 buf->b_p_fenc = vim_strsave(p_fenc);
|
|
8699 #endif
|
|
8700 buf->b_p_ff = vim_strsave(p_ff);
|
|
8701 #if defined(FEAT_QUICKFIX)
|
|
8702 buf->b_p_bh = empty_option;
|
|
8703 buf->b_p_bt = empty_option;
|
|
8704 #endif
|
|
8705 }
|
|
8706 else
|
|
8707 free_buf_options(buf, FALSE);
|
|
8708
|
|
8709 buf->b_p_ai = p_ai;
|
|
8710 buf->b_p_ai_nopaste = p_ai_nopaste;
|
|
8711 buf->b_p_sw = p_sw;
|
|
8712 buf->b_p_tw = p_tw;
|
|
8713 buf->b_p_tw_nopaste = p_tw_nopaste;
|
|
8714 buf->b_p_tw_nobin = p_tw_nobin;
|
|
8715 buf->b_p_wm = p_wm;
|
|
8716 buf->b_p_wm_nopaste = p_wm_nopaste;
|
|
8717 buf->b_p_wm_nobin = p_wm_nobin;
|
|
8718 buf->b_p_bin = p_bin;
|
402
|
8719 #ifdef FEAT_MBYTE
|
|
8720 buf->b_p_bomb = p_bomb;
|
|
8721 #endif
|
7
|
8722 buf->b_p_et = p_et;
|
|
8723 buf->b_p_et_nobin = p_et_nobin;
|
|
8724 buf->b_p_ml = p_ml;
|
|
8725 buf->b_p_ml_nobin = p_ml_nobin;
|
|
8726 buf->b_p_inf = p_inf;
|
|
8727 buf->b_p_swf = p_swf;
|
|
8728 #ifdef FEAT_INS_EXPAND
|
|
8729 buf->b_p_cpt = vim_strsave(p_cpt);
|
|
8730 #endif
|
12
|
8731 #ifdef FEAT_COMPL_FUNC
|
|
8732 buf->b_p_cfu = vim_strsave(p_cfu);
|
|
8733 #endif
|
7
|
8734 buf->b_p_sts = p_sts;
|
|
8735 buf->b_p_sts_nopaste = p_sts_nopaste;
|
|
8736 #ifndef SHORT_FNAME
|
|
8737 buf->b_p_sn = p_sn;
|
|
8738 #endif
|
|
8739 #ifdef FEAT_COMMENTS
|
|
8740 buf->b_p_com = vim_strsave(p_com);
|
|
8741 #endif
|
|
8742 #ifdef FEAT_FOLDING
|
|
8743 buf->b_p_cms = vim_strsave(p_cms);
|
|
8744 #endif
|
|
8745 buf->b_p_fo = vim_strsave(p_fo);
|
41
|
8746 buf->b_p_flp = vim_strsave(p_flp);
|
7
|
8747 buf->b_p_nf = vim_strsave(p_nf);
|
|
8748 buf->b_p_mps = vim_strsave(p_mps);
|
|
8749 #ifdef FEAT_SMARTINDENT
|
|
8750 buf->b_p_si = p_si;
|
|
8751 #endif
|
|
8752 buf->b_p_ci = p_ci;
|
|
8753 #ifdef FEAT_CINDENT
|
|
8754 buf->b_p_cin = p_cin;
|
|
8755 buf->b_p_cink = vim_strsave(p_cink);
|
|
8756 buf->b_p_cino = vim_strsave(p_cino);
|
|
8757 #endif
|
|
8758 #ifdef FEAT_AUTOCMD
|
|
8759 /* Don't copy 'filetype', it must be detected */
|
|
8760 buf->b_p_ft = empty_option;
|
|
8761 #endif
|
|
8762 #ifdef FEAT_OSFILETYPE
|
|
8763 buf->b_p_oft = vim_strsave(p_oft);
|
|
8764 #endif
|
|
8765 buf->b_p_pi = p_pi;
|
|
8766 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
8767 buf->b_p_cinw = vim_strsave(p_cinw);
|
|
8768 #endif
|
|
8769 #ifdef FEAT_LISP
|
|
8770 buf->b_p_lisp = p_lisp;
|
|
8771 #endif
|
|
8772 #ifdef FEAT_SYN_HL
|
|
8773 /* Don't copy 'syntax', it must be set */
|
|
8774 buf->b_p_syn = empty_option;
|
410
|
8775 buf->b_p_smc = p_smc;
|
386
|
8776 buf->b_p_spc = vim_strsave(p_spc);
|
389
|
8777 (void)compile_cap_prog(buf);
|
314
|
8778 buf->b_p_spf = vim_strsave(p_spf);
|
221
|
8779 buf->b_p_spl = vim_strsave(p_spl);
|
7
|
8780 #endif
|
|
8781 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
8782 buf->b_p_inde = vim_strsave(p_inde);
|
|
8783 buf->b_p_indk = vim_strsave(p_indk);
|
|
8784 #endif
|
|
8785 #ifdef FEAT_CRYPT
|
|
8786 buf->b_p_key = vim_strsave(p_key);
|
|
8787 #endif
|
|
8788 #ifdef FEAT_SEARCHPATH
|
|
8789 buf->b_p_sua = vim_strsave(p_sua);
|
|
8790 #endif
|
|
8791 #ifdef FEAT_KEYMAP
|
|
8792 buf->b_p_keymap = vim_strsave(p_keymap);
|
|
8793 buf->b_kmap_state |= KEYMAP_INIT;
|
|
8794 #endif
|
|
8795 /* This isn't really an option, but copying the langmap and IME
|
|
8796 * state from the current buffer is better than resetting it. */
|
|
8797 buf->b_p_iminsert = p_iminsert;
|
|
8798 buf->b_p_imsearch = p_imsearch;
|
|
8799
|
|
8800 /* options that are normally global but also have a local value
|
|
8801 * are not copied, start using the global value */
|
|
8802 buf->b_p_ar = -1;
|
|
8803 #ifdef FEAT_QUICKFIX
|
|
8804 buf->b_p_gp = empty_option;
|
|
8805 buf->b_p_mp = empty_option;
|
|
8806 buf->b_p_efm = empty_option;
|
|
8807 #endif
|
|
8808 buf->b_p_ep = empty_option;
|
|
8809 buf->b_p_kp = empty_option;
|
|
8810 buf->b_p_path = empty_option;
|
|
8811 buf->b_p_tags = empty_option;
|
|
8812 #ifdef FEAT_FIND_ID
|
|
8813 buf->b_p_def = empty_option;
|
|
8814 buf->b_p_inc = empty_option;
|
|
8815 # ifdef FEAT_EVAL
|
|
8816 buf->b_p_inex = vim_strsave(p_inex);
|
|
8817 # endif
|
|
8818 #endif
|
|
8819 #ifdef FEAT_INS_EXPAND
|
|
8820 buf->b_p_dict = empty_option;
|
|
8821 buf->b_p_tsr = empty_option;
|
|
8822 #endif
|
12
|
8823 #ifdef FEAT_TEXTOBJ
|
|
8824 buf->b_p_qe = vim_strsave(p_qe);
|
|
8825 #endif
|
7
|
8826
|
|
8827 /*
|
|
8828 * Don't copy the options set by ex_help(), use the saved values,
|
|
8829 * when going from a help buffer to a non-help buffer.
|
|
8830 * Don't touch these at all when BCO_NOHELP is used and going from
|
|
8831 * or to a help buffer.
|
|
8832 */
|
|
8833 if (dont_do_help)
|
|
8834 buf->b_p_isk = save_p_isk;
|
|
8835 else
|
|
8836 {
|
|
8837 buf->b_p_isk = vim_strsave(p_isk);
|
|
8838 did_isk = TRUE;
|
|
8839 buf->b_p_ts = p_ts;
|
|
8840 buf->b_help = FALSE;
|
|
8841 #ifdef FEAT_QUICKFIX
|
|
8842 if (buf->b_p_bt[0] == 'h')
|
|
8843 clear_string_option(&buf->b_p_bt);
|
|
8844 #endif
|
|
8845 buf->b_p_ma = p_ma;
|
|
8846 }
|
|
8847 }
|
|
8848
|
|
8849 /*
|
|
8850 * When the options should be copied (ignoring BCO_ALWAYS), set the
|
|
8851 * flag that indicates that the options have been initialized.
|
|
8852 */
|
|
8853 if (should_copy)
|
|
8854 buf->b_p_initialized = TRUE;
|
|
8855 }
|
|
8856
|
|
8857 check_buf_options(buf); /* make sure we don't have NULLs */
|
|
8858 if (did_isk)
|
|
8859 (void)buf_init_chartab(buf, FALSE);
|
|
8860 }
|
|
8861
|
|
8862 /*
|
|
8863 * Reset the 'modifiable' option and its default value.
|
|
8864 */
|
|
8865 void
|
|
8866 reset_modifiable()
|
|
8867 {
|
|
8868 int opt_idx;
|
|
8869
|
|
8870 curbuf->b_p_ma = FALSE;
|
|
8871 p_ma = FALSE;
|
|
8872 opt_idx = findoption((char_u *)"ma");
|
|
8873 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
|
|
8874 }
|
|
8875
|
|
8876 /*
|
|
8877 * Set the global value for 'iminsert' to the local value.
|
|
8878 */
|
|
8879 void
|
|
8880 set_iminsert_global()
|
|
8881 {
|
|
8882 p_iminsert = curbuf->b_p_iminsert;
|
|
8883 }
|
|
8884
|
|
8885 /*
|
|
8886 * Set the global value for 'imsearch' to the local value.
|
|
8887 */
|
|
8888 void
|
|
8889 set_imsearch_global()
|
|
8890 {
|
|
8891 p_imsearch = curbuf->b_p_imsearch;
|
|
8892 }
|
|
8893
|
|
8894 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
|
|
8895 static int expand_option_idx = -1;
|
|
8896 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
|
|
8897 static int expand_option_flags = 0;
|
|
8898
|
|
8899 void
|
|
8900 set_context_in_set_cmd(xp, arg, opt_flags)
|
|
8901 expand_T *xp;
|
|
8902 char_u *arg;
|
|
8903 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
|
|
8904 {
|
|
8905 int nextchar;
|
|
8906 long_u flags = 0; /* init for GCC */
|
|
8907 int opt_idx = 0; /* init for GCC */
|
|
8908 char_u *p;
|
|
8909 char_u *s;
|
|
8910 int is_term_option = FALSE;
|
|
8911 int key;
|
|
8912
|
|
8913 expand_option_flags = opt_flags;
|
|
8914
|
|
8915 xp->xp_context = EXPAND_SETTINGS;
|
|
8916 if (*arg == NUL)
|
|
8917 {
|
|
8918 xp->xp_pattern = arg;
|
|
8919 return;
|
|
8920 }
|
|
8921 p = arg + STRLEN(arg) - 1;
|
|
8922 if (*p == ' ' && *(p - 1) != '\\')
|
|
8923 {
|
|
8924 xp->xp_pattern = p + 1;
|
|
8925 return;
|
|
8926 }
|
|
8927 while (p > arg)
|
|
8928 {
|
|
8929 s = p;
|
|
8930 /* count number of backslashes before ' ' or ',' */
|
|
8931 if (*p == ' ' || *p == ',')
|
|
8932 {
|
|
8933 while (s > arg && *(s - 1) == '\\')
|
|
8934 --s;
|
|
8935 }
|
|
8936 /* break at a space with an even number of backslashes */
|
|
8937 if (*p == ' ' && ((p - s) & 1) == 0)
|
|
8938 {
|
|
8939 ++p;
|
|
8940 break;
|
|
8941 }
|
|
8942 --p;
|
|
8943 }
|
|
8944 if (STRNCMP(p, "no", 2) == 0)
|
|
8945 {
|
|
8946 xp->xp_context = EXPAND_BOOL_SETTINGS;
|
|
8947 p += 2;
|
|
8948 }
|
|
8949 if (STRNCMP(p, "inv", 3) == 0)
|
|
8950 {
|
|
8951 xp->xp_context = EXPAND_BOOL_SETTINGS;
|
|
8952 p += 3;
|
|
8953 }
|
|
8954 xp->xp_pattern = arg = p;
|
|
8955 if (*arg == '<')
|
|
8956 {
|
|
8957 while (*p != '>')
|
|
8958 if (*p++ == NUL) /* expand terminal option name */
|
|
8959 return;
|
|
8960 key = get_special_key_code(arg + 1);
|
|
8961 if (key == 0) /* unknown name */
|
|
8962 {
|
|
8963 xp->xp_context = EXPAND_NOTHING;
|
|
8964 return;
|
|
8965 }
|
|
8966 nextchar = *++p;
|
|
8967 is_term_option = TRUE;
|
|
8968 expand_option_name[2] = KEY2TERMCAP0(key);
|
|
8969 expand_option_name[3] = KEY2TERMCAP1(key);
|
|
8970 }
|
|
8971 else
|
|
8972 {
|
|
8973 if (p[0] == 't' && p[1] == '_')
|
|
8974 {
|
|
8975 p += 2;
|
|
8976 if (*p != NUL)
|
|
8977 ++p;
|
|
8978 if (*p == NUL)
|
|
8979 return; /* expand option name */
|
|
8980 nextchar = *++p;
|
|
8981 is_term_option = TRUE;
|
|
8982 expand_option_name[2] = p[-2];
|
|
8983 expand_option_name[3] = p[-1];
|
|
8984 }
|
|
8985 else
|
|
8986 {
|
|
8987 /* Allow * wildcard */
|
|
8988 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
|
|
8989 p++;
|
|
8990 if (*p == NUL)
|
|
8991 return;
|
|
8992 nextchar = *p;
|
|
8993 *p = NUL;
|
|
8994 opt_idx = findoption(arg);
|
|
8995 *p = nextchar;
|
|
8996 if (opt_idx == -1 || options[opt_idx].var == NULL)
|
|
8997 {
|
|
8998 xp->xp_context = EXPAND_NOTHING;
|
|
8999 return;
|
|
9000 }
|
|
9001 flags = options[opt_idx].flags;
|
|
9002 if (flags & P_BOOL)
|
|
9003 {
|
|
9004 xp->xp_context = EXPAND_NOTHING;
|
|
9005 return;
|
|
9006 }
|
|
9007 }
|
|
9008 }
|
|
9009 /* handle "-=" and "+=" */
|
|
9010 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
|
|
9011 {
|
|
9012 ++p;
|
|
9013 nextchar = '=';
|
|
9014 }
|
|
9015 if ((nextchar != '=' && nextchar != ':')
|
|
9016 || xp->xp_context == EXPAND_BOOL_SETTINGS)
|
|
9017 {
|
|
9018 xp->xp_context = EXPAND_UNSUCCESSFUL;
|
|
9019 return;
|
|
9020 }
|
|
9021 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
|
|
9022 {
|
|
9023 xp->xp_context = EXPAND_OLD_SETTING;
|
|
9024 if (is_term_option)
|
|
9025 expand_option_idx = -1;
|
|
9026 else
|
|
9027 expand_option_idx = opt_idx;
|
|
9028 xp->xp_pattern = p + 1;
|
|
9029 return;
|
|
9030 }
|
|
9031 xp->xp_context = EXPAND_NOTHING;
|
|
9032 if (is_term_option || (flags & P_NUM))
|
|
9033 return;
|
|
9034
|
|
9035 xp->xp_pattern = p + 1;
|
|
9036
|
|
9037 if (flags & P_EXPAND)
|
|
9038 {
|
|
9039 p = options[opt_idx].var;
|
|
9040 if (p == (char_u *)&p_bdir
|
|
9041 || p == (char_u *)&p_dir
|
|
9042 || p == (char_u *)&p_path
|
|
9043 || p == (char_u *)&p_rtp
|
|
9044 #ifdef FEAT_SEARCHPATH
|
|
9045 || p == (char_u *)&p_cdpath
|
|
9046 #endif
|
|
9047 #ifdef FEAT_SESSION
|
|
9048 || p == (char_u *)&p_vdir
|
|
9049 #endif
|
|
9050 )
|
|
9051 {
|
|
9052 xp->xp_context = EXPAND_DIRECTORIES;
|
|
9053 if (p == (char_u *)&p_path
|
|
9054 #ifdef FEAT_SEARCHPATH
|
|
9055 || p == (char_u *)&p_cdpath
|
|
9056 #endif
|
|
9057 )
|
|
9058 xp->xp_backslash = XP_BS_THREE;
|
|
9059 else
|
|
9060 xp->xp_backslash = XP_BS_ONE;
|
|
9061 }
|
|
9062 else
|
|
9063 {
|
|
9064 xp->xp_context = EXPAND_FILES;
|
|
9065 /* for 'tags' need three backslashes for a space */
|
|
9066 if (p == (char_u *)&p_tags)
|
|
9067 xp->xp_backslash = XP_BS_THREE;
|
|
9068 else
|
|
9069 xp->xp_backslash = XP_BS_ONE;
|
|
9070 }
|
|
9071 }
|
|
9072
|
|
9073 /* For an option that is a list of file names, find the start of the
|
|
9074 * last file name. */
|
|
9075 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
|
|
9076 {
|
|
9077 /* count number of backslashes before ' ' or ',' */
|
|
9078 if (*p == ' ' || *p == ',')
|
|
9079 {
|
|
9080 s = p;
|
|
9081 while (s > xp->xp_pattern && *(s - 1) == '\\')
|
|
9082 --s;
|
|
9083 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|
|
9084 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
|
|
9085 {
|
|
9086 xp->xp_pattern = p + 1;
|
|
9087 break;
|
|
9088 }
|
|
9089 }
|
374
|
9090
|
|
9091 #ifdef FEAT_SYN_HL
|
|
9092 /* for 'spellsuggest' start at "file:" */
|
|
9093 if (options[opt_idx].var == (char_u *)&p_sps
|
|
9094 && STRNCMP(p, "file:", 5) == 0)
|
|
9095 {
|
|
9096 xp->xp_pattern = p + 5;
|
|
9097 break;
|
|
9098 }
|
|
9099 #endif
|
7
|
9100 }
|
|
9101
|
|
9102 return;
|
|
9103 }
|
|
9104
|
|
9105 int
|
|
9106 ExpandSettings(xp, regmatch, num_file, file)
|
|
9107 expand_T *xp;
|
|
9108 regmatch_T *regmatch;
|
|
9109 int *num_file;
|
|
9110 char_u ***file;
|
|
9111 {
|
|
9112 int num_normal = 0; /* Nr of matching non-term-code settings */
|
|
9113 int num_term = 0; /* Nr of matching terminal code settings */
|
|
9114 int opt_idx;
|
|
9115 int match;
|
|
9116 int count = 0;
|
|
9117 char_u *str;
|
|
9118 int loop;
|
|
9119 int is_term_opt;
|
|
9120 char_u name_buf[MAX_KEY_NAME_LEN];
|
|
9121 static char *(names[]) = {"all", "termcap"};
|
|
9122 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
|
|
9123
|
|
9124 /* do this loop twice:
|
|
9125 * loop == 0: count the number of matching options
|
|
9126 * loop == 1: copy the matching options into allocated memory
|
|
9127 */
|
|
9128 for (loop = 0; loop <= 1; ++loop)
|
|
9129 {
|
|
9130 regmatch->rm_ic = ic;
|
|
9131 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
|
|
9132 {
|
|
9133 for (match = 0; match < sizeof(names) / sizeof(char *); ++match)
|
|
9134 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
|
|
9135 {
|
|
9136 if (loop == 0)
|
|
9137 num_normal++;
|
|
9138 else
|
|
9139 (*file)[count++] = vim_strsave((char_u *)names[match]);
|
|
9140 }
|
|
9141 }
|
|
9142 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
|
|
9143 opt_idx++)
|
|
9144 {
|
|
9145 if (options[opt_idx].var == NULL)
|
|
9146 continue;
|
|
9147 if (xp->xp_context == EXPAND_BOOL_SETTINGS
|
|
9148 && !(options[opt_idx].flags & P_BOOL))
|
|
9149 continue;
|
|
9150 is_term_opt = istermoption(&options[opt_idx]);
|
|
9151 if (is_term_opt && num_normal > 0)
|
|
9152 continue;
|
|
9153 match = FALSE;
|
|
9154 if (vim_regexec(regmatch, str, (colnr_T)0)
|
|
9155 || (options[opt_idx].shortname != NULL
|
|
9156 && vim_regexec(regmatch,
|
|
9157 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
|
|
9158 match = TRUE;
|
|
9159 else if (is_term_opt)
|
|
9160 {
|
|
9161 name_buf[0] = '<';
|
|
9162 name_buf[1] = 't';
|
|
9163 name_buf[2] = '_';
|
|
9164 name_buf[3] = str[2];
|
|
9165 name_buf[4] = str[3];
|
|
9166 name_buf[5] = '>';
|
|
9167 name_buf[6] = NUL;
|
|
9168 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9169 {
|
|
9170 match = TRUE;
|
|
9171 str = name_buf;
|
|
9172 }
|
|
9173 }
|
|
9174 if (match)
|
|
9175 {
|
|
9176 if (loop == 0)
|
|
9177 {
|
|
9178 if (is_term_opt)
|
|
9179 num_term++;
|
|
9180 else
|
|
9181 num_normal++;
|
|
9182 }
|
|
9183 else
|
|
9184 (*file)[count++] = vim_strsave(str);
|
|
9185 }
|
|
9186 }
|
|
9187 /*
|
|
9188 * Check terminal key codes, these are not in the option table
|
|
9189 */
|
|
9190 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
|
|
9191 {
|
|
9192 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
|
|
9193 {
|
|
9194 if (!isprint(str[0]) || !isprint(str[1]))
|
|
9195 continue;
|
|
9196
|
|
9197 name_buf[0] = 't';
|
|
9198 name_buf[1] = '_';
|
|
9199 name_buf[2] = str[0];
|
|
9200 name_buf[3] = str[1];
|
|
9201 name_buf[4] = NUL;
|
|
9202
|
|
9203 match = FALSE;
|
|
9204 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9205 match = TRUE;
|
|
9206 else
|
|
9207 {
|
|
9208 name_buf[0] = '<';
|
|
9209 name_buf[1] = 't';
|
|
9210 name_buf[2] = '_';
|
|
9211 name_buf[3] = str[0];
|
|
9212 name_buf[4] = str[1];
|
|
9213 name_buf[5] = '>';
|
|
9214 name_buf[6] = NUL;
|
|
9215
|
|
9216 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9217 match = TRUE;
|
|
9218 }
|
|
9219 if (match)
|
|
9220 {
|
|
9221 if (loop == 0)
|
|
9222 num_term++;
|
|
9223 else
|
|
9224 (*file)[count++] = vim_strsave(name_buf);
|
|
9225 }
|
|
9226 }
|
|
9227
|
|
9228 /*
|
|
9229 * Check special key names.
|
|
9230 */
|
|
9231 regmatch->rm_ic = TRUE; /* ignore case here */
|
|
9232 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
|
|
9233 {
|
|
9234 name_buf[0] = '<';
|
|
9235 STRCPY(name_buf + 1, str);
|
|
9236 STRCAT(name_buf, ">");
|
|
9237
|
|
9238 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9239 {
|
|
9240 if (loop == 0)
|
|
9241 num_term++;
|
|
9242 else
|
|
9243 (*file)[count++] = vim_strsave(name_buf);
|
|
9244 }
|
|
9245 }
|
|
9246 }
|
|
9247 if (loop == 0)
|
|
9248 {
|
|
9249 if (num_normal > 0)
|
|
9250 *num_file = num_normal;
|
|
9251 else if (num_term > 0)
|
|
9252 *num_file = num_term;
|
|
9253 else
|
|
9254 return OK;
|
|
9255 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
|
|
9256 if (*file == NULL)
|
|
9257 {
|
|
9258 *file = (char_u **)"";
|
|
9259 return FAIL;
|
|
9260 }
|
|
9261 }
|
|
9262 }
|
|
9263 return OK;
|
|
9264 }
|
|
9265
|
|
9266 int
|
|
9267 ExpandOldSetting(num_file, file)
|
|
9268 int *num_file;
|
|
9269 char_u ***file;
|
|
9270 {
|
|
9271 char_u *var = NULL; /* init for GCC */
|
|
9272 char_u *buf;
|
|
9273
|
|
9274 *num_file = 0;
|
|
9275 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
|
|
9276 if (*file == NULL)
|
|
9277 return FAIL;
|
|
9278
|
|
9279 /*
|
|
9280 * For a terminal key code expand_option_idx is < 0.
|
|
9281 */
|
|
9282 if (expand_option_idx < 0)
|
|
9283 {
|
|
9284 var = find_termcode(expand_option_name + 2);
|
|
9285 if (var == NULL)
|
|
9286 expand_option_idx = findoption(expand_option_name);
|
|
9287 }
|
|
9288
|
|
9289 if (expand_option_idx >= 0)
|
|
9290 {
|
|
9291 /* put string of option value in NameBuff */
|
|
9292 option_value2string(&options[expand_option_idx], expand_option_flags);
|
|
9293 var = NameBuff;
|
|
9294 }
|
|
9295 else if (var == NULL)
|
|
9296 var = (char_u *)"";
|
|
9297
|
|
9298 /* A backslash is required before some characters. This is the reverse of
|
|
9299 * what happens in do_set(). */
|
|
9300 buf = vim_strsave_escaped(var, escape_chars);
|
|
9301
|
|
9302 if (buf == NULL)
|
|
9303 {
|
|
9304 vim_free(*file);
|
|
9305 *file = NULL;
|
|
9306 return FAIL;
|
|
9307 }
|
|
9308
|
|
9309 #ifdef BACKSLASH_IN_FILENAME
|
|
9310 /* For MS-Windows et al. we don't double backslashes at the start and
|
|
9311 * before a file name character. */
|
39
|
9312 for (var = buf; *var != NUL; mb_ptr_adv(var))
|
7
|
9313 if (var[0] == '\\' && var[1] == '\\'
|
|
9314 && expand_option_idx >= 0
|
|
9315 && (options[expand_option_idx].flags & P_EXPAND)
|
|
9316 && vim_isfilec(var[2])
|
|
9317 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
|
|
9318 mch_memmove(var, var + 1, STRLEN(var));
|
|
9319 #endif
|
|
9320
|
|
9321 *file[0] = buf;
|
|
9322 *num_file = 1;
|
|
9323 return OK;
|
|
9324 }
|
|
9325 #endif
|
|
9326
|
|
9327 /*
|
|
9328 * Get the value for the numeric or string option *opp in a nice format into
|
|
9329 * NameBuff[]. Must not be called with a hidden option!
|
|
9330 */
|
|
9331 static void
|
|
9332 option_value2string(opp, opt_flags)
|
|
9333 struct vimoption *opp;
|
|
9334 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
|
|
9335 {
|
|
9336 char_u *varp;
|
|
9337
|
|
9338 varp = get_varp_scope(opp, opt_flags);
|
|
9339
|
|
9340 if (opp->flags & P_NUM)
|
|
9341 {
|
|
9342 long wc = 0;
|
|
9343
|
|
9344 if (wc_use_keyname(varp, &wc))
|
|
9345 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
|
|
9346 else if (wc != 0)
|
|
9347 STRCPY(NameBuff, transchar((int)wc));
|
|
9348 else
|
|
9349 sprintf((char *)NameBuff, "%ld", *(long *)varp);
|
|
9350 }
|
|
9351 else /* P_STRING */
|
|
9352 {
|
|
9353 varp = *(char_u **)(varp);
|
|
9354 if (varp == NULL) /* just in case */
|
|
9355 NameBuff[0] = NUL;
|
|
9356 #ifdef FEAT_CRYPT
|
|
9357 /* don't show the actual value of 'key', only that it's set */
|
|
9358 if (opp->var == (char_u *)&p_key && *varp)
|
|
9359 STRCPY(NameBuff, "*****");
|
|
9360 #endif
|
|
9361 else if (opp->flags & P_EXPAND)
|
|
9362 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
|
|
9363 /* Translate 'pastetoggle' into special key names */
|
|
9364 else if ((char_u **)opp->var == &p_pt)
|
|
9365 str2specialbuf(p_pt, NameBuff, MAXPATHL);
|
|
9366 else
|
419
|
9367 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
|
7
|
9368 }
|
|
9369 }
|
|
9370
|
|
9371 /*
|
|
9372 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
|
|
9373 * printed as a keyname.
|
|
9374 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
|
|
9375 */
|
|
9376 static int
|
|
9377 wc_use_keyname(varp, wcp)
|
|
9378 char_u *varp;
|
|
9379 long *wcp;
|
|
9380 {
|
|
9381 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
|
|
9382 {
|
|
9383 *wcp = *(long *)varp;
|
|
9384 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
|
|
9385 return TRUE;
|
|
9386 }
|
|
9387 return FALSE;
|
|
9388 }
|
|
9389
|
|
9390 #ifdef FEAT_LANGMAP
|
|
9391 /*
|
|
9392 * Any character has an equivalent character. This is used for keyboards that
|
|
9393 * have a special language mode that sends characters above 128 (although
|
|
9394 * other characters can be translated too).
|
|
9395 */
|
|
9396
|
|
9397 /*
|
|
9398 * char_u langmap_mapchar[256];
|
|
9399 * Normally maps each of the 128 upper chars to an <128 ascii char; used to
|
|
9400 * "translate" native lang chars in normal mode or some cases of
|
|
9401 * insert mode without having to tediously switch lang mode back&forth.
|
|
9402 */
|
|
9403
|
|
9404 static void
|
|
9405 langmap_init()
|
|
9406 {
|
|
9407 int i;
|
|
9408
|
|
9409 for (i = 0; i < 256; i++) /* we init with a-one-to one map */
|
|
9410 langmap_mapchar[i] = i;
|
|
9411 }
|
|
9412
|
|
9413 /*
|
|
9414 * Called when langmap option is set; the language map can be
|
|
9415 * changed at any time!
|
|
9416 */
|
|
9417 static void
|
|
9418 langmap_set()
|
|
9419 {
|
|
9420 char_u *p;
|
|
9421 char_u *p2;
|
|
9422 int from, to;
|
|
9423
|
|
9424 langmap_init(); /* back to one-to-one map first */
|
|
9425
|
|
9426 for (p = p_langmap; p[0] != NUL; )
|
|
9427 {
|
39
|
9428 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
|
|
9429 mb_ptr_adv(p2))
|
7
|
9430 {
|
|
9431 if (p2[0] == '\\' && p2[1] != NUL)
|
|
9432 ++p2;
|
|
9433 }
|
|
9434 if (p2[0] == ';')
|
|
9435 ++p2; /* abcd;ABCD form, p2 points to A */
|
|
9436 else
|
|
9437 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
|
|
9438 while (p[0])
|
|
9439 {
|
|
9440 if (p[0] == '\\' && p[1] != NUL)
|
|
9441 ++p;
|
|
9442 #ifdef FEAT_MBYTE
|
|
9443 from = (*mb_ptr2char)(p);
|
|
9444 #else
|
|
9445 from = p[0];
|
|
9446 #endif
|
|
9447 if (p2 == NULL)
|
|
9448 {
|
39
|
9449 mb_ptr_adv(p);
|
7
|
9450 if (p[0] == '\\')
|
|
9451 ++p;
|
|
9452 #ifdef FEAT_MBYTE
|
|
9453 to = (*mb_ptr2char)(p);
|
|
9454 #else
|
|
9455 to = p[0];
|
|
9456 #endif
|
|
9457 }
|
|
9458 else
|
|
9459 {
|
|
9460 if (p2[0] == '\\')
|
|
9461 ++p2;
|
|
9462 #ifdef FEAT_MBYTE
|
|
9463 to = (*mb_ptr2char)(p2);
|
|
9464 #else
|
|
9465 to = p2[0];
|
|
9466 #endif
|
|
9467 }
|
|
9468 if (to == NUL)
|
|
9469 {
|
|
9470 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
|
|
9471 transchar(from));
|
|
9472 return;
|
|
9473 }
|
|
9474 langmap_mapchar[from & 255] = to;
|
|
9475
|
|
9476 /* Advance to next pair */
|
39
|
9477 mb_ptr_adv(p);
|
7
|
9478 if (p2 == NULL)
|
|
9479 {
|
|
9480 if (p[0] == ',')
|
|
9481 {
|
|
9482 ++p;
|
|
9483 break;
|
|
9484 }
|
|
9485 }
|
|
9486 else
|
|
9487 {
|
39
|
9488 mb_ptr_adv(p2);
|
7
|
9489 if (*p == ';')
|
|
9490 {
|
|
9491 p = p2;
|
|
9492 if (p[0] != NUL)
|
|
9493 {
|
|
9494 if (p[0] != ',')
|
|
9495 {
|
|
9496 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
|
|
9497 return;
|
|
9498 }
|
|
9499 ++p;
|
|
9500 }
|
|
9501 break;
|
|
9502 }
|
|
9503 }
|
|
9504 }
|
|
9505 }
|
|
9506 }
|
|
9507 #endif
|
|
9508
|
|
9509 /*
|
|
9510 * Return TRUE if format option 'x' is in effect.
|
|
9511 * Take care of no formatting when 'paste' is set.
|
|
9512 */
|
|
9513 int
|
|
9514 has_format_option(x)
|
|
9515 int x;
|
|
9516 {
|
|
9517 if (p_paste)
|
|
9518 return FALSE;
|
|
9519 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
|
|
9520 }
|
|
9521
|
|
9522 /*
|
|
9523 * Return TRUE if "x" is present in 'shortmess' option, or
|
|
9524 * 'shortmess' contains 'a' and "x" is present in SHM_A.
|
|
9525 */
|
|
9526 int
|
|
9527 shortmess(x)
|
|
9528 int x;
|
|
9529 {
|
|
9530 return ( vim_strchr(p_shm, x) != NULL
|
|
9531 || (vim_strchr(p_shm, 'a') != NULL
|
|
9532 && vim_strchr((char_u *)SHM_A, x) != NULL));
|
|
9533 }
|
|
9534
|
|
9535 /*
|
|
9536 * paste_option_changed() - Called after p_paste was set or reset.
|
|
9537 */
|
|
9538 static void
|
|
9539 paste_option_changed()
|
|
9540 {
|
|
9541 static int old_p_paste = FALSE;
|
|
9542 static int save_sm = 0;
|
|
9543 #ifdef FEAT_CMDL_INFO
|
|
9544 static int save_ru = 0;
|
|
9545 #endif
|
|
9546 #ifdef FEAT_RIGHTLEFT
|
|
9547 static int save_ri = 0;
|
|
9548 static int save_hkmap = 0;
|
|
9549 #endif
|
|
9550 buf_T *buf;
|
|
9551
|
|
9552 if (p_paste)
|
|
9553 {
|
|
9554 /*
|
|
9555 * Paste switched from off to on.
|
|
9556 * Save the current values, so they can be restored later.
|
|
9557 */
|
|
9558 if (!old_p_paste)
|
|
9559 {
|
|
9560 /* save options for each buffer */
|
|
9561 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
9562 {
|
|
9563 buf->b_p_tw_nopaste = buf->b_p_tw;
|
|
9564 buf->b_p_wm_nopaste = buf->b_p_wm;
|
|
9565 buf->b_p_sts_nopaste = buf->b_p_sts;
|
|
9566 buf->b_p_ai_nopaste = buf->b_p_ai;
|
|
9567 }
|
|
9568
|
|
9569 /* save global options */
|
|
9570 save_sm = p_sm;
|
|
9571 #ifdef FEAT_CMDL_INFO
|
|
9572 save_ru = p_ru;
|
|
9573 #endif
|
|
9574 #ifdef FEAT_RIGHTLEFT
|
|
9575 save_ri = p_ri;
|
|
9576 save_hkmap = p_hkmap;
|
|
9577 #endif
|
|
9578 /* save global values for local buffer options */
|
|
9579 p_tw_nopaste = p_tw;
|
|
9580 p_wm_nopaste = p_wm;
|
|
9581 p_sts_nopaste = p_sts;
|
|
9582 p_ai_nopaste = p_ai;
|
|
9583 }
|
|
9584
|
|
9585 /*
|
|
9586 * Always set the option values, also when 'paste' is set when it is
|
|
9587 * already on.
|
|
9588 */
|
|
9589 /* set options for each buffer */
|
|
9590 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
9591 {
|
|
9592 buf->b_p_tw = 0; /* textwidth is 0 */
|
|
9593 buf->b_p_wm = 0; /* wrapmargin is 0 */
|
|
9594 buf->b_p_sts = 0; /* softtabstop is 0 */
|
|
9595 buf->b_p_ai = 0; /* no auto-indent */
|
|
9596 }
|
|
9597
|
|
9598 /* set global options */
|
|
9599 p_sm = 0; /* no showmatch */
|
|
9600 #ifdef FEAT_CMDL_INFO
|
|
9601 # ifdef FEAT_WINDOWS
|
|
9602 if (p_ru)
|
|
9603 status_redraw_all(); /* redraw to remove the ruler */
|
|
9604 # endif
|
|
9605 p_ru = 0; /* no ruler */
|
|
9606 #endif
|
|
9607 #ifdef FEAT_RIGHTLEFT
|
|
9608 p_ri = 0; /* no reverse insert */
|
|
9609 p_hkmap = 0; /* no Hebrew keyboard */
|
|
9610 #endif
|
|
9611 /* set global values for local buffer options */
|
|
9612 p_tw = 0;
|
|
9613 p_wm = 0;
|
|
9614 p_sts = 0;
|
|
9615 p_ai = 0;
|
|
9616 }
|
|
9617
|
|
9618 /*
|
|
9619 * Paste switched from on to off: Restore saved values.
|
|
9620 */
|
|
9621 else if (old_p_paste)
|
|
9622 {
|
|
9623 /* restore options for each buffer */
|
|
9624 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
9625 {
|
|
9626 buf->b_p_tw = buf->b_p_tw_nopaste;
|
|
9627 buf->b_p_wm = buf->b_p_wm_nopaste;
|
|
9628 buf->b_p_sts = buf->b_p_sts_nopaste;
|
|
9629 buf->b_p_ai = buf->b_p_ai_nopaste;
|
|
9630 }
|
|
9631
|
|
9632 /* restore global options */
|
|
9633 p_sm = save_sm;
|
|
9634 #ifdef FEAT_CMDL_INFO
|
|
9635 # ifdef FEAT_WINDOWS
|
|
9636 if (p_ru != save_ru)
|
|
9637 status_redraw_all(); /* redraw to draw the ruler */
|
|
9638 # endif
|
|
9639 p_ru = save_ru;
|
|
9640 #endif
|
|
9641 #ifdef FEAT_RIGHTLEFT
|
|
9642 p_ri = save_ri;
|
|
9643 p_hkmap = save_hkmap;
|
|
9644 #endif
|
|
9645 /* set global values for local buffer options */
|
|
9646 p_tw = p_tw_nopaste;
|
|
9647 p_wm = p_wm_nopaste;
|
|
9648 p_sts = p_sts_nopaste;
|
|
9649 p_ai = p_ai_nopaste;
|
|
9650 }
|
|
9651
|
|
9652 old_p_paste = p_paste;
|
|
9653 }
|
|
9654
|
|
9655 /*
|
|
9656 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
|
|
9657 *
|
|
9658 * Reset 'compatible' and set the values for options that didn't get set yet
|
|
9659 * to the Vim defaults.
|
|
9660 * Don't do this if the 'compatible' option has been set or reset before.
|
|
9661 */
|
|
9662 void
|
|
9663 vimrc_found()
|
|
9664 {
|
|
9665 int opt_idx;
|
|
9666
|
|
9667 if (!option_was_set((char_u *)"cp"))
|
|
9668 {
|
|
9669 p_cp = FALSE;
|
|
9670 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
|
|
9671 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
|
|
9672 set_option_default(opt_idx, OPT_FREE, FALSE);
|
|
9673 didset_options();
|
|
9674 }
|
|
9675 }
|
|
9676
|
|
9677 /*
|
|
9678 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
|
|
9679 */
|
|
9680 void
|
|
9681 change_compatible(on)
|
|
9682 int on;
|
|
9683 {
|
|
9684 if (p_cp != on)
|
|
9685 {
|
|
9686 p_cp = on;
|
|
9687 compatible_set();
|
|
9688 }
|
|
9689 options[findoption((char_u *)"cp")].flags |= P_WAS_SET;
|
|
9690 }
|
|
9691
|
|
9692 /*
|
|
9693 * Return TRUE when option "name" has been set.
|
|
9694 */
|
|
9695 int
|
|
9696 option_was_set(name)
|
|
9697 char_u *name;
|
|
9698 {
|
|
9699 int idx;
|
|
9700
|
|
9701 idx = findoption(name);
|
|
9702 if (idx < 0) /* unknown option */
|
|
9703 return FALSE;
|
|
9704 if (options[idx].flags & P_WAS_SET)
|
|
9705 return TRUE;
|
|
9706 return FALSE;
|
|
9707 }
|
|
9708
|
|
9709 /*
|
|
9710 * compatible_set() - Called when 'compatible' has been set or unset.
|
|
9711 *
|
|
9712 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
|
|
9713 * flag) to a Vi compatible value.
|
|
9714 * When 'compatible' is unset: Set all options that have a different default
|
|
9715 * for Vim (without the P_VI_DEF flag) to that default.
|
|
9716 */
|
|
9717 static void
|
|
9718 compatible_set()
|
|
9719 {
|
|
9720 int opt_idx;
|
|
9721
|
|
9722 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
|
|
9723 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
|
|
9724 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
|
|
9725 set_option_default(opt_idx, OPT_FREE, p_cp);
|
|
9726 didset_options();
|
|
9727 }
|
|
9728
|
|
9729 #ifdef FEAT_LINEBREAK
|
|
9730
|
|
9731 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
|
9732 /* Borland C++ screws up loop optimisation here (negri) */
|
133
|
9733 #pragma option -O-l
|
7
|
9734 # endif
|
|
9735
|
|
9736 /*
|
|
9737 * fill_breakat_flags() -- called when 'breakat' changes value.
|
|
9738 */
|
|
9739 static void
|
|
9740 fill_breakat_flags()
|
|
9741 {
|
|
9742 char_u *c;
|
|
9743 int i;
|
|
9744
|
|
9745 for (i = 0; i < 256; i++)
|
|
9746 breakat_flags[i] = FALSE;
|
|
9747
|
|
9748 if (p_breakat != NULL)
|
|
9749 for (c = p_breakat; *c; c++)
|
|
9750 breakat_flags[*c] = TRUE;
|
|
9751 }
|
|
9752
|
|
9753 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
133
|
9754 #pragma option -O.l
|
7
|
9755 # endif
|
|
9756
|
|
9757 #endif
|
|
9758
|
|
9759 /*
|
|
9760 * Check an option that can be a range of string values.
|
|
9761 *
|
|
9762 * Return OK for correct value, FAIL otherwise.
|
|
9763 * Empty is always OK.
|
|
9764 */
|
|
9765 static int
|
|
9766 check_opt_strings(val, values, list)
|
|
9767 char_u *val;
|
|
9768 char **values;
|
|
9769 int list; /* when TRUE: accept a list of values */
|
|
9770 {
|
|
9771 return opt_strings_flags(val, values, NULL, list);
|
|
9772 }
|
|
9773
|
|
9774 /*
|
|
9775 * Handle an option that can be a range of string values.
|
|
9776 * Set a flag in "*flagp" for each string present.
|
|
9777 *
|
|
9778 * Return OK for correct value, FAIL otherwise.
|
|
9779 * Empty is always OK.
|
|
9780 */
|
|
9781 static int
|
|
9782 opt_strings_flags(val, values, flagp, list)
|
|
9783 char_u *val; /* new value */
|
|
9784 char **values; /* array of valid string values */
|
|
9785 unsigned *flagp;
|
|
9786 int list; /* when TRUE: accept a list of values */
|
|
9787 {
|
|
9788 int i;
|
|
9789 int len;
|
|
9790 unsigned new_flags = 0;
|
|
9791
|
|
9792 while (*val)
|
|
9793 {
|
|
9794 for (i = 0; ; ++i)
|
|
9795 {
|
|
9796 if (values[i] == NULL) /* val not found in values[] */
|
|
9797 return FAIL;
|
|
9798
|
|
9799 len = (int)STRLEN(values[i]);
|
|
9800 if (STRNCMP(values[i], val, len) == 0
|
|
9801 && ((list && val[len] == ',') || val[len] == NUL))
|
|
9802 {
|
|
9803 val += len + (val[len] == ',');
|
|
9804 new_flags |= (1 << i);
|
|
9805 break; /* check next item in val list */
|
|
9806 }
|
|
9807 }
|
|
9808 }
|
|
9809 if (flagp != NULL)
|
|
9810 *flagp = new_flags;
|
|
9811
|
|
9812 return OK;
|
|
9813 }
|
|
9814
|
|
9815 /*
|
|
9816 * Read the 'wildmode' option, fill wim_flags[].
|
|
9817 */
|
|
9818 static int
|
|
9819 check_opt_wim()
|
|
9820 {
|
|
9821 char_u new_wim_flags[4];
|
|
9822 char_u *p;
|
|
9823 int i;
|
|
9824 int idx = 0;
|
|
9825
|
|
9826 for (i = 0; i < 4; ++i)
|
|
9827 new_wim_flags[i] = 0;
|
|
9828
|
|
9829 for (p = p_wim; *p; ++p)
|
|
9830 {
|
|
9831 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
|
|
9832 ;
|
|
9833 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
|
|
9834 return FAIL;
|
|
9835 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
|
|
9836 new_wim_flags[idx] |= WIM_LONGEST;
|
|
9837 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
|
|
9838 new_wim_flags[idx] |= WIM_FULL;
|
|
9839 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
|
|
9840 new_wim_flags[idx] |= WIM_LIST;
|
|
9841 else
|
|
9842 return FAIL;
|
|
9843 p += i;
|
|
9844 if (*p == NUL)
|
|
9845 break;
|
|
9846 if (*p == ',')
|
|
9847 {
|
|
9848 if (idx == 3)
|
|
9849 return FAIL;
|
|
9850 ++idx;
|
|
9851 }
|
|
9852 }
|
|
9853
|
|
9854 /* fill remaining entries with last flag */
|
|
9855 while (idx < 3)
|
|
9856 {
|
|
9857 new_wim_flags[idx + 1] = new_wim_flags[idx];
|
|
9858 ++idx;
|
|
9859 }
|
|
9860
|
|
9861 /* only when there are no errors, wim_flags[] is changed */
|
|
9862 for (i = 0; i < 4; ++i)
|
|
9863 wim_flags[i] = new_wim_flags[i];
|
|
9864 return OK;
|
|
9865 }
|
|
9866
|
|
9867 /*
|
|
9868 * Check if backspacing over something is allowed.
|
|
9869 */
|
|
9870 int
|
|
9871 can_bs(what)
|
|
9872 int what; /* BS_INDENT, BS_EOL or BS_START */
|
|
9873 {
|
|
9874 switch (*p_bs)
|
|
9875 {
|
|
9876 case '2': return TRUE;
|
|
9877 case '1': return (what != BS_START);
|
|
9878 case '0': return FALSE;
|
|
9879 }
|
|
9880 return vim_strchr(p_bs, what) != NULL;
|
|
9881 }
|
|
9882
|
|
9883 /*
|
|
9884 * Save the current values of 'fileformat' and 'fileencoding', so that we know
|
|
9885 * the file must be considered changed when the value is different.
|
|
9886 */
|
|
9887 void
|
|
9888 save_file_ff(buf)
|
|
9889 buf_T *buf;
|
|
9890 {
|
|
9891 buf->b_start_ffc = *buf->b_p_ff;
|
|
9892 buf->b_start_eol = buf->b_p_eol;
|
|
9893 #ifdef FEAT_MBYTE
|
|
9894 /* Only use free/alloc when necessary, they take time. */
|
|
9895 if (buf->b_start_fenc == NULL
|
|
9896 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
|
|
9897 {
|
|
9898 vim_free(buf->b_start_fenc);
|
|
9899 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
|
|
9900 }
|
|
9901 #endif
|
|
9902 }
|
|
9903
|
|
9904 /*
|
|
9905 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
|
|
9906 * from when editing started (save_file_ff() called).
|
|
9907 * Also when 'endofline' was changed and 'binary' is set.
|
|
9908 * Don't consider a new, empty buffer to be changed.
|
|
9909 */
|
|
9910 int
|
|
9911 file_ff_differs(buf)
|
|
9912 buf_T *buf;
|
|
9913 {
|
|
9914 if ((buf->b_flags & BF_NEW)
|
|
9915 && buf->b_ml.ml_line_count == 1
|
|
9916 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
|
|
9917 return FALSE;
|
|
9918 if (buf->b_start_ffc != *buf->b_p_ff)
|
|
9919 return TRUE;
|
|
9920 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
|
|
9921 return TRUE;
|
|
9922 #ifdef FEAT_MBYTE
|
|
9923 if (buf->b_start_fenc == NULL)
|
|
9924 return (*buf->b_p_fenc != NUL);
|
|
9925 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
|
|
9926 #else
|
|
9927 return FALSE;
|
|
9928 #endif
|
|
9929 }
|
|
9930
|
|
9931 /*
|
|
9932 * return OK if "p" is a valid fileformat name, FAIL otherwise.
|
|
9933 */
|
|
9934 int
|
|
9935 check_ff_value(p)
|
|
9936 char_u *p;
|
|
9937 {
|
|
9938 return check_opt_strings(p, p_ff_values, FALSE);
|
|
9939 }
|