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}},
|
477
|
2038 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
|
386
|
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
|
440
|
3272
|
|
3273 #ifdef CURSOR_SHAPE
|
|
3274 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
|
|
3275 #endif
|
|
3276 #ifdef FEAT_MOUSESHAPE
|
|
3277 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
|
|
3278 #endif
|
|
3279 #ifdef FEAT_PRINTER
|
|
3280 (void)parse_printoptions(); /* parse 'printoptions' default value */
|
|
3281 #endif
|
7
|
3282 }
|
|
3283
|
|
3284 /*
|
|
3285 * Initialize the options, part three: After reading the .vimrc
|
|
3286 */
|
|
3287 void
|
|
3288 set_init_3()
|
|
3289 {
|
|
3290 #if defined(UNIX) || defined(OS2) || defined(WIN3264)
|
|
3291 /*
|
|
3292 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
|
|
3293 * This is done after other initializations, where 'shell' might have been
|
|
3294 * set, but only if they have not been set before.
|
|
3295 */
|
|
3296 char_u *p;
|
|
3297 int idx_srr;
|
|
3298 int do_srr;
|
|
3299 #ifdef FEAT_QUICKFIX
|
|
3300 int idx_sp;
|
|
3301 int do_sp;
|
|
3302 #endif
|
|
3303
|
|
3304 idx_srr = findoption((char_u *)"srr");
|
|
3305 do_srr = !(options[idx_srr].flags & P_WAS_SET);
|
|
3306 #ifdef FEAT_QUICKFIX
|
|
3307 idx_sp = findoption((char_u *)"sp");
|
|
3308 do_sp = !(options[idx_sp].flags & P_WAS_SET);
|
|
3309 #endif
|
|
3310
|
|
3311 /*
|
|
3312 * Isolate the name of the shell:
|
|
3313 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
|
|
3314 * - Remove any argument. E.g., "csh -f" -> "csh".
|
|
3315 */
|
|
3316 p = gettail(p_sh);
|
|
3317 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
|
|
3318 if (p != NULL)
|
|
3319 {
|
|
3320 /*
|
|
3321 * Default for p_sp is "| tee", for p_srr is ">".
|
|
3322 * For known shells it is changed here to include stderr.
|
|
3323 */
|
|
3324 if ( fnamecmp(p, "csh") == 0
|
|
3325 || fnamecmp(p, "tcsh") == 0
|
|
3326 # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
|
|
3327 || fnamecmp(p, "csh.exe") == 0
|
|
3328 || fnamecmp(p, "tcsh.exe") == 0
|
|
3329 # endif
|
|
3330 )
|
|
3331 {
|
|
3332 #if defined(FEAT_QUICKFIX)
|
|
3333 if (do_sp)
|
|
3334 {
|
|
3335 # ifdef WIN3264
|
|
3336 p_sp = (char_u *)">&";
|
|
3337 # else
|
|
3338 p_sp = (char_u *)"|& tee";
|
|
3339 # endif
|
|
3340 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
|
|
3341 }
|
|
3342 #endif
|
|
3343 if (do_srr)
|
|
3344 {
|
|
3345 p_srr = (char_u *)">&";
|
|
3346 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
|
|
3347 }
|
|
3348 }
|
|
3349 else
|
|
3350 # ifndef OS2 /* Always use bourne shell style redirection if we reach this */
|
|
3351 if ( fnamecmp(p, "sh") == 0
|
|
3352 || fnamecmp(p, "ksh") == 0
|
|
3353 || fnamecmp(p, "zsh") == 0
|
|
3354 || fnamecmp(p, "bash") == 0
|
|
3355 # ifdef WIN3264
|
|
3356 || fnamecmp(p, "cmd") == 0
|
|
3357 || fnamecmp(p, "sh.exe") == 0
|
|
3358 || fnamecmp(p, "ksh.exe") == 0
|
|
3359 || fnamecmp(p, "zsh.exe") == 0
|
|
3360 || fnamecmp(p, "bash.exe") == 0
|
|
3361 || fnamecmp(p, "cmd.exe") == 0
|
|
3362 # endif
|
|
3363 )
|
|
3364 # endif
|
|
3365 {
|
|
3366 #if defined(FEAT_QUICKFIX)
|
|
3367 if (do_sp)
|
|
3368 {
|
|
3369 # ifdef WIN3264
|
|
3370 p_sp = (char_u *)">%s 2>&1";
|
|
3371 # else
|
|
3372 p_sp = (char_u *)"2>&1| tee";
|
|
3373 # endif
|
|
3374 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
|
|
3375 }
|
|
3376 #endif
|
|
3377 if (do_srr)
|
|
3378 {
|
|
3379 p_srr = (char_u *)">%s 2>&1";
|
|
3380 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
|
|
3381 }
|
|
3382 }
|
|
3383 vim_free(p);
|
|
3384 }
|
|
3385 #endif
|
|
3386
|
|
3387 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
|
|
3388 /*
|
|
3389 * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
|
|
3390 * This is done after other initializations, where 'shell' might have been
|
|
3391 * set, but only if they have not been set before. Default for p_shcf is
|
|
3392 * "/c", for p_shq is "". For "sh" like shells it is changed here to
|
|
3393 * "-c" and "\"", but not for DJGPP, because it starts the shell without
|
|
3394 * command.com. And for Win32 we need to set p_sxq instead.
|
|
3395 */
|
10
|
3396 if (strstr((char *)gettail(p_sh), "sh") != NULL)
|
7
|
3397 {
|
|
3398 int idx3;
|
|
3399
|
|
3400 idx3 = findoption((char_u *)"shcf");
|
|
3401 if (!(options[idx3].flags & P_WAS_SET))
|
|
3402 {
|
|
3403 p_shcf = (char_u *)"-c";
|
|
3404 options[idx3].def_val[VI_DEFAULT] = p_shcf;
|
|
3405 }
|
|
3406
|
|
3407 # ifndef DJGPP
|
|
3408 # ifdef WIN3264
|
|
3409 /* Somehow Win32 requires the quotes around the redirection too */
|
|
3410 idx3 = findoption((char_u *)"sxq");
|
|
3411 if (!(options[idx3].flags & P_WAS_SET))
|
|
3412 {
|
|
3413 p_sxq = (char_u *)"\"";
|
|
3414 options[idx3].def_val[VI_DEFAULT] = p_sxq;
|
|
3415 }
|
|
3416 # else
|
|
3417 idx3 = findoption((char_u *)"shq");
|
|
3418 if (!(options[idx3].flags & P_WAS_SET))
|
|
3419 {
|
|
3420 p_shq = (char_u *)"\"";
|
|
3421 options[idx3].def_val[VI_DEFAULT] = p_shq;
|
|
3422 }
|
|
3423 # endif
|
|
3424 # endif
|
|
3425 }
|
|
3426 #endif
|
|
3427
|
|
3428 #ifdef FEAT_TITLE
|
|
3429 set_title_defaults();
|
|
3430 #endif
|
|
3431 }
|
|
3432
|
|
3433 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
|
|
3434 /*
|
|
3435 * When 'helplang' is still at its default value, set it to "lang".
|
|
3436 * Only the first two characters of "lang" are used.
|
|
3437 */
|
|
3438 void
|
|
3439 set_helplang_default(lang)
|
|
3440 char_u *lang;
|
|
3441 {
|
|
3442 int idx;
|
|
3443
|
|
3444 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
|
|
3445 return;
|
|
3446 idx = findoption((char_u *)"hlg");
|
|
3447 if (!(options[idx].flags & P_WAS_SET))
|
|
3448 {
|
|
3449 if (options[idx].flags & P_ALLOCED)
|
|
3450 free_string_option(p_hlg);
|
|
3451 p_hlg = vim_strsave(lang);
|
|
3452 if (p_hlg == NULL)
|
|
3453 p_hlg = empty_option;
|
|
3454 else
|
18
|
3455 {
|
|
3456 /* zh_CN becomes "cn", zh_TW becomes "tw". */
|
|
3457 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
|
|
3458 {
|
|
3459 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
|
|
3460 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
|
|
3461 }
|
7
|
3462 p_hlg[2] = NUL;
|
18
|
3463 }
|
7
|
3464 options[idx].flags |= P_ALLOCED;
|
|
3465 }
|
|
3466 }
|
|
3467 #endif
|
|
3468
|
|
3469 #ifdef FEAT_GUI
|
|
3470 static char_u *gui_bg_default __ARGS((void));
|
|
3471
|
|
3472 static char_u *
|
|
3473 gui_bg_default()
|
|
3474 {
|
|
3475 if (gui_get_lightness(gui.back_pixel) < 127)
|
|
3476 return (char_u *)"dark";
|
|
3477 return (char_u *)"light";
|
|
3478 }
|
|
3479
|
|
3480 /*
|
|
3481 * Option initializations that can only be done after opening the GUI window.
|
|
3482 */
|
|
3483 void
|
|
3484 init_gui_options()
|
|
3485 {
|
|
3486 /* Set the 'background' option according to the lightness of the
|
|
3487 * background color, unless the user has set it already. */
|
|
3488 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
|
|
3489 {
|
|
3490 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
|
|
3491 highlight_changed();
|
|
3492 }
|
|
3493 }
|
|
3494 #endif
|
|
3495
|
|
3496 #ifdef FEAT_TITLE
|
|
3497 /*
|
|
3498 * 'title' and 'icon' only default to true if they have not been set or reset
|
|
3499 * in .vimrc and we can read the old value.
|
|
3500 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
|
|
3501 * they can be reset. This reduces startup time when using X on a remote
|
|
3502 * machine.
|
|
3503 */
|
|
3504 void
|
|
3505 set_title_defaults()
|
|
3506 {
|
|
3507 int idx1;
|
|
3508 long val;
|
|
3509
|
|
3510 /*
|
|
3511 * If GUI is (going to be) used, we can always set the window title and
|
|
3512 * icon name. Saves a bit of time, because the X11 display server does
|
|
3513 * not need to be contacted.
|
|
3514 */
|
|
3515 idx1 = findoption((char_u *)"title");
|
|
3516 if (!(options[idx1].flags & P_WAS_SET))
|
|
3517 {
|
|
3518 #ifdef FEAT_GUI
|
|
3519 if (gui.starting || gui.in_use)
|
|
3520 val = TRUE;
|
|
3521 else
|
|
3522 #endif
|
|
3523 val = mch_can_restore_title();
|
|
3524 options[idx1].def_val[VI_DEFAULT] = (char_u *)val;
|
|
3525 p_title = val;
|
|
3526 }
|
|
3527 idx1 = findoption((char_u *)"icon");
|
|
3528 if (!(options[idx1].flags & P_WAS_SET))
|
|
3529 {
|
|
3530 #ifdef FEAT_GUI
|
|
3531 if (gui.starting || gui.in_use)
|
|
3532 val = TRUE;
|
|
3533 else
|
|
3534 #endif
|
|
3535 val = mch_can_restore_icon();
|
|
3536 options[idx1].def_val[VI_DEFAULT] = (char_u *)val;
|
|
3537 p_icon = val;
|
|
3538 }
|
|
3539 }
|
|
3540 #endif
|
|
3541
|
|
3542 /*
|
|
3543 * Parse 'arg' for option settings.
|
|
3544 *
|
|
3545 * 'arg' may be IObuff, but only when no errors can be present and option
|
|
3546 * does not need to be expanded with option_expand().
|
|
3547 * "opt_flags":
|
|
3548 * 0 for ":set"
|
|
3549 * OPT_GLOBAL for ":setglobal"
|
|
3550 * OPT_LOCAL for ":setlocal" and a modeline
|
|
3551 * OPT_MODELINE for a modeline
|
|
3552 *
|
|
3553 * returns FAIL if an error is detected, OK otherwise
|
|
3554 */
|
|
3555 int
|
|
3556 do_set(arg, opt_flags)
|
|
3557 char_u *arg; /* option string (may be written to!) */
|
|
3558 int opt_flags;
|
|
3559 {
|
|
3560 int opt_idx;
|
|
3561 char_u *errmsg;
|
|
3562 char_u errbuf[80];
|
|
3563 char_u *startarg;
|
|
3564 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
|
|
3565 int nextchar; /* next non-white char after option name */
|
|
3566 int afterchar; /* character just after option name */
|
|
3567 int len;
|
|
3568 int i;
|
|
3569 long value;
|
|
3570 int key;
|
|
3571 long_u flags; /* flags for current option */
|
|
3572 char_u *varp = NULL; /* pointer to variable for current option */
|
|
3573 int did_show = FALSE; /* already showed one value */
|
|
3574 int adding; /* "opt+=arg" */
|
|
3575 int prepending; /* "opt^=arg" */
|
|
3576 int removing; /* "opt-=arg" */
|
|
3577 int cp_val = 0;
|
|
3578 char_u key_name[2];
|
|
3579
|
|
3580 if (*arg == NUL)
|
|
3581 {
|
|
3582 showoptions(0, opt_flags);
|
168
|
3583 did_show = TRUE;
|
|
3584 goto theend;
|
7
|
3585 }
|
|
3586
|
|
3587 while (*arg != NUL) /* loop to process all options */
|
|
3588 {
|
|
3589 errmsg = NULL;
|
|
3590 startarg = arg; /* remember for error message */
|
|
3591
|
36
|
3592 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
|
|
3593 && !(opt_flags & OPT_MODELINE))
|
7
|
3594 {
|
|
3595 /*
|
|
3596 * ":set all" show all options.
|
|
3597 * ":set all&" set all options to their default value.
|
|
3598 */
|
|
3599 arg += 3;
|
|
3600 if (*arg == '&')
|
|
3601 {
|
|
3602 ++arg;
|
|
3603 /* Only for :set command set global value of local options. */
|
|
3604 set_options_default(OPT_FREE | opt_flags);
|
|
3605 }
|
|
3606 else
|
168
|
3607 {
|
7
|
3608 showoptions(1, opt_flags);
|
168
|
3609 did_show = TRUE;
|
|
3610 }
|
7
|
3611 }
|
36
|
3612 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
|
7
|
3613 {
|
|
3614 showoptions(2, opt_flags);
|
|
3615 show_termcodes();
|
168
|
3616 did_show = TRUE;
|
7
|
3617 arg += 7;
|
|
3618 }
|
|
3619 else
|
|
3620 {
|
|
3621 prefix = 1;
|
|
3622 if (STRNCMP(arg, "no", 2) == 0)
|
|
3623 {
|
|
3624 prefix = 0;
|
|
3625 arg += 2;
|
|
3626 }
|
|
3627 else if (STRNCMP(arg, "inv", 3) == 0)
|
|
3628 {
|
|
3629 prefix = 2;
|
|
3630 arg += 3;
|
|
3631 }
|
|
3632
|
|
3633 /* find end of name */
|
|
3634 key = 0;
|
|
3635 if (*arg == '<')
|
|
3636 {
|
|
3637 nextchar = 0;
|
|
3638 opt_idx = -1;
|
|
3639 /* look out for <t_>;> */
|
|
3640 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
|
|
3641 len = 5;
|
|
3642 else
|
|
3643 {
|
|
3644 len = 1;
|
|
3645 while (arg[len] != NUL && arg[len] != '>')
|
|
3646 ++len;
|
|
3647 }
|
|
3648 if (arg[len] != '>')
|
|
3649 {
|
|
3650 errmsg = e_invarg;
|
|
3651 goto skip;
|
|
3652 }
|
|
3653 arg[len] = NUL; /* put NUL after name */
|
|
3654 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
|
|
3655 opt_idx = findoption(arg + 1);
|
|
3656 arg[len++] = '>'; /* restore '>' */
|
|
3657 if (opt_idx == -1)
|
|
3658 key = find_key_option(arg + 1);
|
|
3659 }
|
|
3660 else
|
|
3661 {
|
|
3662 len = 0;
|
|
3663 /*
|
|
3664 * The two characters after "t_" may not be alphanumeric.
|
|
3665 */
|
|
3666 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
|
|
3667 len = 4;
|
|
3668 else
|
|
3669 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
|
|
3670 ++len;
|
|
3671 nextchar = arg[len];
|
|
3672 arg[len] = NUL; /* put NUL after name */
|
|
3673 opt_idx = findoption(arg);
|
|
3674 arg[len] = nextchar; /* restore nextchar */
|
|
3675 if (opt_idx == -1)
|
|
3676 key = find_key_option(arg);
|
|
3677 }
|
|
3678
|
|
3679 /* remember character after option name */
|
|
3680 afterchar = arg[len];
|
|
3681
|
|
3682 /* skip white space, allow ":set ai ?" */
|
|
3683 while (vim_iswhite(arg[len]))
|
|
3684 ++len;
|
|
3685
|
|
3686 adding = FALSE;
|
|
3687 prepending = FALSE;
|
|
3688 removing = FALSE;
|
|
3689 if (arg[len] != NUL && arg[len + 1] == '=')
|
|
3690 {
|
|
3691 if (arg[len] == '+')
|
|
3692 {
|
|
3693 adding = TRUE; /* "+=" */
|
|
3694 ++len;
|
|
3695 }
|
|
3696 else if (arg[len] == '^')
|
|
3697 {
|
|
3698 prepending = TRUE; /* "^=" */
|
|
3699 ++len;
|
|
3700 }
|
|
3701 else if (arg[len] == '-')
|
|
3702 {
|
|
3703 removing = TRUE; /* "-=" */
|
|
3704 ++len;
|
|
3705 }
|
|
3706 }
|
|
3707 nextchar = arg[len];
|
|
3708
|
|
3709 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
|
|
3710 {
|
|
3711 errmsg = (char_u *)N_("E518: Unknown option");
|
|
3712 goto skip;
|
|
3713 }
|
|
3714
|
|
3715 if (opt_idx >= 0)
|
|
3716 {
|
|
3717 if (options[opt_idx].var == NULL) /* hidden option: skip */
|
|
3718 {
|
|
3719 /* Only give an error message when requesting the value of
|
|
3720 * a hidden option, ignore setting it. */
|
|
3721 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
|
|
3722 && (!(options[opt_idx].flags & P_BOOL)
|
|
3723 || nextchar == '?'))
|
|
3724 errmsg = (char_u *)N_("E519: Option not supported");
|
|
3725 goto skip;
|
|
3726 }
|
|
3727
|
|
3728 flags = options[opt_idx].flags;
|
|
3729 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
|
|
3730 }
|
|
3731 else
|
|
3732 {
|
|
3733 flags = P_STRING;
|
|
3734 if (key < 0)
|
|
3735 {
|
|
3736 key_name[0] = KEY2TERMCAP0(key);
|
|
3737 key_name[1] = KEY2TERMCAP1(key);
|
|
3738 }
|
|
3739 else
|
|
3740 {
|
|
3741 key_name[0] = KS_KEY;
|
|
3742 key_name[1] = (key & 0xff);
|
|
3743 }
|
|
3744 }
|
|
3745
|
|
3746 /* Disallow changing some options from modelines */
|
|
3747 if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE))
|
|
3748 {
|
|
3749 errmsg = (char_u *)_("E520: Not allowed in a modeline");
|
|
3750 goto skip;
|
|
3751 }
|
|
3752
|
23
|
3753 /* Skip all options that are not window-local (used when showing
|
|
3754 * an already loaded buffer in a window). */
|
|
3755 if ((opt_flags & OPT_WINONLY)
|
|
3756 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
|
|
3757 goto skip;
|
|
3758
|
7
|
3759 #ifdef HAVE_SANDBOX
|
|
3760 /* Disallow changing some options in the sandbox */
|
|
3761 if (sandbox > 0 && (flags & P_SECURE))
|
|
3762 {
|
|
3763 errmsg = (char_u *)_(e_sandbox);
|
|
3764 goto skip;
|
|
3765 }
|
|
3766 #endif
|
|
3767
|
|
3768 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
|
|
3769 {
|
|
3770 arg += len;
|
|
3771 cp_val = p_cp;
|
|
3772 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
|
|
3773 {
|
|
3774 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
|
|
3775 {
|
|
3776 cp_val = FALSE;
|
|
3777 arg += 3;
|
|
3778 }
|
|
3779 else /* "opt&vi": set to Vi default */
|
|
3780 {
|
|
3781 cp_val = TRUE;
|
|
3782 arg += 2;
|
|
3783 }
|
|
3784 }
|
|
3785 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
|
|
3786 && arg[1] != NUL && !vim_iswhite(arg[1]))
|
|
3787 {
|
|
3788 errmsg = e_trailing;
|
|
3789 goto skip;
|
|
3790 }
|
|
3791 }
|
|
3792
|
|
3793 /*
|
|
3794 * allow '=' and ':' as MSDOS command.com allows only one
|
|
3795 * '=' character per "set" command line. grrr. (jw)
|
|
3796 */
|
|
3797 if (nextchar == '?'
|
|
3798 || (prefix == 1
|
|
3799 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
|
|
3800 && !(flags & P_BOOL)))
|
|
3801 {
|
|
3802 /*
|
|
3803 * print value
|
|
3804 */
|
|
3805 if (did_show)
|
|
3806 msg_putchar('\n'); /* cursor below last one */
|
|
3807 else
|
|
3808 {
|
|
3809 gotocmdline(TRUE); /* cursor at status line */
|
|
3810 did_show = TRUE; /* remember that we did a line */
|
|
3811 }
|
|
3812 if (opt_idx >= 0)
|
|
3813 {
|
|
3814 showoneopt(&options[opt_idx], opt_flags);
|
|
3815 #ifdef FEAT_EVAL
|
|
3816 if (p_verbose > 0)
|
448
|
3817 last_set_msg(options[opt_idx].scriptID);
|
7
|
3818 #endif
|
|
3819 }
|
|
3820 else
|
|
3821 {
|
|
3822 char_u *p;
|
|
3823
|
|
3824 p = find_termcode(key_name);
|
|
3825 if (p == NULL)
|
|
3826 {
|
|
3827 errmsg = (char_u *)N_("E518: Unknown option");
|
|
3828 goto skip;
|
|
3829 }
|
|
3830 else
|
|
3831 (void)show_one_termcode(key_name, p, TRUE);
|
|
3832 }
|
|
3833 if (nextchar != '?'
|
|
3834 && nextchar != NUL && !vim_iswhite(afterchar))
|
|
3835 errmsg = e_trailing;
|
|
3836 }
|
|
3837 else
|
|
3838 {
|
|
3839 if (flags & P_BOOL) /* boolean */
|
|
3840 {
|
|
3841 if (nextchar == '=' || nextchar == ':')
|
|
3842 {
|
|
3843 errmsg = e_invarg;
|
|
3844 goto skip;
|
|
3845 }
|
|
3846
|
|
3847 /*
|
|
3848 * ":set opt!": invert
|
|
3849 * ":set opt&": reset to default value
|
|
3850 * ":set opt<": reset to global value
|
|
3851 */
|
|
3852 if (nextchar == '!')
|
|
3853 value = *(int *)(varp) ^ 1;
|
|
3854 else if (nextchar == '&')
|
|
3855 value = (int)(long)options[opt_idx].def_val[
|
|
3856 ((flags & P_VI_DEF) || cp_val)
|
|
3857 ? VI_DEFAULT : VIM_DEFAULT];
|
|
3858 else if (nextchar == '<')
|
|
3859 {
|
|
3860 /* For 'autoread' -1 means to use global value. */
|
|
3861 if ((int *)varp == &curbuf->b_p_ar
|
|
3862 && opt_flags == OPT_LOCAL)
|
|
3863 value = -1;
|
|
3864 else
|
|
3865 value = *(int *)get_varp_scope(&(options[opt_idx]),
|
|
3866 OPT_GLOBAL);
|
|
3867 }
|
|
3868 else
|
|
3869 {
|
|
3870 /*
|
|
3871 * ":set invopt": invert
|
|
3872 * ":set opt" or ":set noopt": set or reset
|
|
3873 */
|
|
3874 if (nextchar != NUL && !vim_iswhite(afterchar))
|
|
3875 {
|
|
3876 errmsg = e_trailing;
|
|
3877 goto skip;
|
|
3878 }
|
|
3879 if (prefix == 2) /* inv */
|
|
3880 value = *(int *)(varp) ^ 1;
|
|
3881 else
|
|
3882 value = prefix;
|
|
3883 }
|
|
3884
|
|
3885 errmsg = set_bool_option(opt_idx, varp, (int)value,
|
|
3886 opt_flags);
|
|
3887 }
|
|
3888 else /* numeric or string */
|
|
3889 {
|
|
3890 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
|
|
3891 || prefix != 1)
|
|
3892 {
|
|
3893 errmsg = e_invarg;
|
|
3894 goto skip;
|
|
3895 }
|
|
3896
|
|
3897 if (flags & P_NUM) /* numeric */
|
|
3898 {
|
|
3899 /*
|
|
3900 * Different ways to set a number option:
|
|
3901 * & set to default value
|
|
3902 * < set to global value
|
|
3903 * <xx> accept special key codes for 'wildchar'
|
|
3904 * c accept any non-digit for 'wildchar'
|
|
3905 * [-]0-9 set number
|
|
3906 * other error
|
|
3907 */
|
|
3908 ++arg;
|
|
3909 if (nextchar == '&')
|
|
3910 value = (long)options[opt_idx].def_val[
|
|
3911 ((flags & P_VI_DEF) || cp_val)
|
|
3912 ? VI_DEFAULT : VIM_DEFAULT];
|
|
3913 else if (nextchar == '<')
|
|
3914 value = *(long *)get_varp_scope(&(options[opt_idx]),
|
|
3915 OPT_GLOBAL);
|
|
3916 else if (((long *)varp == &p_wc
|
|
3917 || (long *)varp == &p_wcm)
|
|
3918 && (*arg == '<'
|
|
3919 || *arg == '^'
|
|
3920 || ((!arg[1] || vim_iswhite(arg[1]))
|
|
3921 && !VIM_ISDIGIT(*arg))))
|
|
3922 {
|
|
3923 value = string_to_key(arg);
|
|
3924 if (value == 0 && (long *)varp != &p_wcm)
|
|
3925 {
|
|
3926 errmsg = e_invarg;
|
|
3927 goto skip;
|
|
3928 }
|
|
3929 }
|
|
3930 /* allow negative numbers (for 'undolevels') */
|
|
3931 else if (*arg == '-' || VIM_ISDIGIT(*arg))
|
|
3932 {
|
|
3933 i = 0;
|
|
3934 if (*arg == '-')
|
|
3935 i = 1;
|
|
3936 #ifdef HAVE_STRTOL
|
|
3937 value = strtol((char *)arg, NULL, 0);
|
|
3938 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
|
|
3939 i += 2;
|
|
3940 #else
|
|
3941 value = atol((char *)arg);
|
|
3942 #endif
|
|
3943 while (VIM_ISDIGIT(arg[i]))
|
|
3944 ++i;
|
|
3945 if (arg[i] != NUL && !vim_iswhite(arg[i]))
|
|
3946 {
|
|
3947 errmsg = e_invarg;
|
|
3948 goto skip;
|
|
3949 }
|
|
3950 }
|
|
3951 else
|
|
3952 {
|
|
3953 errmsg = (char_u *)N_("E521: Number required after =");
|
|
3954 goto skip;
|
|
3955 }
|
|
3956
|
|
3957 if (adding)
|
|
3958 value = *(long *)varp + value;
|
|
3959 if (prepending)
|
|
3960 value = *(long *)varp * value;
|
|
3961 if (removing)
|
|
3962 value = *(long *)varp - value;
|
|
3963 errmsg = set_num_option(opt_idx, varp, value,
|
274
|
3964 errbuf, sizeof(errbuf), opt_flags);
|
7
|
3965 }
|
|
3966 else if (opt_idx >= 0) /* string */
|
|
3967 {
|
|
3968 char_u *save_arg = NULL;
|
|
3969 char_u *s = NULL;
|
|
3970 char_u *oldval; /* previous value if *varp */
|
|
3971 char_u *newval;
|
|
3972 char_u *origval;
|
|
3973 unsigned newlen;
|
|
3974 int comma;
|
|
3975 int bs;
|
|
3976 int new_value_alloced; /* new string option
|
|
3977 was allocated */
|
|
3978
|
|
3979 /* When using ":set opt=val" for a global option
|
|
3980 * with a local value the local value will be
|
|
3981 * reset, use the global value here. */
|
|
3982 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
3983 && (int)options[opt_idx].indir >= PV_BOTH)
|
|
3984 varp = options[opt_idx].var;
|
|
3985
|
|
3986 /* The old value is kept until we are sure that the
|
|
3987 * new value is valid. */
|
|
3988 oldval = *(char_u **)varp;
|
|
3989 if (nextchar == '&') /* set to default val */
|
|
3990 {
|
|
3991 newval = options[opt_idx].def_val[
|
|
3992 ((flags & P_VI_DEF) || cp_val)
|
|
3993 ? VI_DEFAULT : VIM_DEFAULT];
|
|
3994 if ((char_u **)varp == &p_bg)
|
|
3995 {
|
|
3996 /* guess the value of 'background' */
|
|
3997 #ifdef FEAT_GUI
|
|
3998 if (gui.in_use)
|
|
3999 newval = gui_bg_default();
|
|
4000 else
|
|
4001 #endif
|
|
4002 if (STRCMP(T_NAME, "linux") == 0)
|
|
4003 newval = (char_u *)"dark";
|
|
4004 }
|
|
4005
|
|
4006 /* expand environment variables and ~ (since the
|
|
4007 * default value was already expanded, only
|
|
4008 * required when an environment variable was set
|
|
4009 * later */
|
|
4010 if (newval == NULL)
|
|
4011 newval = empty_option;
|
|
4012 else
|
|
4013 {
|
|
4014 s = option_expand(opt_idx, newval);
|
|
4015 if (s == NULL)
|
|
4016 s = newval;
|
|
4017 newval = vim_strsave(s);
|
|
4018 }
|
|
4019 new_value_alloced = TRUE;
|
|
4020 }
|
|
4021 else if (nextchar == '<') /* set to global val */
|
|
4022 {
|
|
4023 newval = vim_strsave(*(char_u **)get_varp_scope(
|
|
4024 &(options[opt_idx]), OPT_GLOBAL));
|
|
4025 new_value_alloced = TRUE;
|
|
4026 }
|
|
4027 else
|
|
4028 {
|
|
4029 ++arg; /* jump to after the '=' or ':' */
|
|
4030
|
|
4031 /*
|
|
4032 * Set 'keywordprg' to ":help" if an empty
|
|
4033 * value was passed to :set by the user.
|
|
4034 * Misuse errbuf[] for the resulting string.
|
|
4035 */
|
|
4036 if (varp == (char_u *)&p_kp
|
|
4037 && (*arg == NUL || *arg == ' '))
|
|
4038 {
|
|
4039 STRCPY(errbuf, ":help");
|
|
4040 save_arg = arg;
|
|
4041 arg = errbuf;
|
|
4042 }
|
|
4043 /*
|
|
4044 * Convert 'whichwrap' number to string, for
|
|
4045 * backwards compatibility with Vim 3.0.
|
|
4046 * Misuse errbuf[] for the resulting string.
|
|
4047 */
|
|
4048 else if (varp == (char_u *)&p_ww
|
|
4049 && VIM_ISDIGIT(*arg))
|
|
4050 {
|
|
4051 *errbuf = NUL;
|
|
4052 i = getdigits(&arg);
|
|
4053 if (i & 1)
|
|
4054 STRCAT(errbuf, "b,");
|
|
4055 if (i & 2)
|
|
4056 STRCAT(errbuf, "s,");
|
|
4057 if (i & 4)
|
|
4058 STRCAT(errbuf, "h,l,");
|
|
4059 if (i & 8)
|
|
4060 STRCAT(errbuf, "<,>,");
|
|
4061 if (i & 16)
|
|
4062 STRCAT(errbuf, "[,],");
|
|
4063 if (*errbuf != NUL) /* remove trailing , */
|
|
4064 errbuf[STRLEN(errbuf) - 1] = NUL;
|
|
4065 save_arg = arg;
|
|
4066 arg = errbuf;
|
|
4067 }
|
|
4068 /*
|
|
4069 * Remove '>' before 'dir' and 'bdir', for
|
|
4070 * backwards compatibility with version 3.0
|
|
4071 */
|
|
4072 else if ( *arg == '>'
|
|
4073 && (varp == (char_u *)&p_dir
|
|
4074 || varp == (char_u *)&p_bdir))
|
|
4075 {
|
|
4076 ++arg;
|
|
4077 }
|
|
4078
|
|
4079 /* When setting the local value of a global
|
|
4080 * option, the old value may be the global value. */
|
|
4081 if ((int)options[opt_idx].indir >= PV_BOTH
|
|
4082 && (opt_flags & OPT_LOCAL))
|
|
4083 origval = *(char_u **)get_varp(
|
|
4084 &options[opt_idx]);
|
|
4085 else
|
|
4086 origval = oldval;
|
|
4087
|
|
4088 /*
|
|
4089 * Copy the new string into allocated memory.
|
|
4090 * Can't use set_string_option_direct(), because
|
|
4091 * we need to remove the backslashes.
|
|
4092 */
|
|
4093 /* get a bit too much */
|
|
4094 newlen = (unsigned)STRLEN(arg) + 1;
|
|
4095 if (adding || prepending || removing)
|
|
4096 newlen += (unsigned)STRLEN(origval) + 1;
|
|
4097 newval = alloc(newlen);
|
|
4098 if (newval == NULL) /* out of mem, don't change */
|
|
4099 break;
|
|
4100 s = newval;
|
|
4101
|
|
4102 /*
|
|
4103 * Copy the string, skip over escaped chars.
|
|
4104 * For MS-DOS and WIN32 backslashes before normal
|
|
4105 * file name characters are not removed, and keep
|
|
4106 * backslash at start, for "\\machine\path", but
|
|
4107 * do remove it for "\\\\machine\\path".
|
|
4108 * The reverse is found in ExpandOldSetting().
|
|
4109 */
|
|
4110 while (*arg && !vim_iswhite(*arg))
|
|
4111 {
|
|
4112 if (*arg == '\\' && arg[1] != NUL
|
|
4113 #ifdef BACKSLASH_IN_FILENAME
|
|
4114 && !((flags & P_EXPAND)
|
|
4115 && vim_isfilec(arg[1])
|
|
4116 && (arg[1] != '\\'
|
|
4117 || (s == newval
|
|
4118 && arg[2] != '\\')))
|
|
4119 #endif
|
|
4120 )
|
|
4121 ++arg; /* remove backslash */
|
|
4122 #ifdef FEAT_MBYTE
|
|
4123 if (has_mbyte
|
474
|
4124 && (i = (*mb_ptr2len)(arg)) > 1)
|
7
|
4125 {
|
|
4126 /* copy multibyte char */
|
|
4127 mch_memmove(s, arg, (size_t)i);
|
|
4128 arg += i;
|
|
4129 s += i;
|
|
4130 }
|
|
4131 else
|
|
4132 #endif
|
|
4133 *s++ = *arg++;
|
|
4134 }
|
|
4135 *s = NUL;
|
|
4136
|
|
4137 /*
|
|
4138 * Expand environment variables and ~.
|
|
4139 * Don't do it when adding without inserting a
|
|
4140 * comma.
|
|
4141 */
|
|
4142 if (!(adding || prepending || removing)
|
|
4143 || (flags & P_COMMA))
|
|
4144 {
|
|
4145 s = option_expand(opt_idx, newval);
|
|
4146 if (s != NULL)
|
|
4147 {
|
|
4148 vim_free(newval);
|
|
4149 newlen = (unsigned)STRLEN(s) + 1;
|
|
4150 if (adding || prepending || removing)
|
|
4151 newlen += (unsigned)STRLEN(origval) + 1;
|
|
4152 newval = alloc(newlen);
|
|
4153 if (newval == NULL)
|
|
4154 break;
|
|
4155 STRCPY(newval, s);
|
|
4156 }
|
|
4157 }
|
|
4158
|
|
4159 /* locate newval[] in origval[] when removing it
|
|
4160 * and when adding to avoid duplicates */
|
|
4161 i = 0; /* init for GCC */
|
|
4162 if (removing || (flags & P_NODUP))
|
|
4163 {
|
|
4164 i = (int)STRLEN(newval);
|
|
4165 bs = 0;
|
|
4166 for (s = origval; *s; ++s)
|
|
4167 {
|
|
4168 if ((!(flags & P_COMMA)
|
|
4169 || s == origval
|
|
4170 || (s[-1] == ',' && !(bs & 1)))
|
|
4171 && STRNCMP(s, newval, i) == 0
|
|
4172 && (!(flags & P_COMMA)
|
|
4173 || s[i] == ','
|
|
4174 || s[i] == NUL))
|
|
4175 break;
|
|
4176 /* Count backspaces. Only a comma with an
|
|
4177 * even number of backspaces before it is
|
|
4178 * recognized as a separator */
|
|
4179 if (s > origval && s[-1] == '\\')
|
|
4180 ++bs;
|
|
4181 else
|
|
4182 bs = 0;
|
|
4183 }
|
|
4184
|
|
4185 /* do not add if already there */
|
|
4186 if ((adding || prepending) && *s)
|
|
4187 {
|
|
4188 prepending = FALSE;
|
|
4189 adding = FALSE;
|
|
4190 STRCPY(newval, origval);
|
|
4191 }
|
|
4192 }
|
|
4193
|
|
4194 /* concatenate the two strings; add a ',' if
|
|
4195 * needed */
|
|
4196 if (adding || prepending)
|
|
4197 {
|
|
4198 comma = ((flags & P_COMMA) && *origval != NUL
|
|
4199 && *newval != NUL);
|
|
4200 if (adding)
|
|
4201 {
|
|
4202 i = (int)STRLEN(origval);
|
|
4203 mch_memmove(newval + i + comma, newval,
|
|
4204 STRLEN(newval) + 1);
|
|
4205 mch_memmove(newval, origval, (size_t)i);
|
|
4206 }
|
|
4207 else
|
|
4208 {
|
|
4209 i = (int)STRLEN(newval);
|
|
4210 mch_memmove(newval + i + comma, origval,
|
|
4211 STRLEN(origval) + 1);
|
|
4212 }
|
|
4213 if (comma)
|
|
4214 newval[i] = ',';
|
|
4215 }
|
|
4216
|
|
4217 /* Remove newval[] from origval[]. (Note: "i" has
|
|
4218 * been set above and is used here). */
|
|
4219 if (removing)
|
|
4220 {
|
|
4221 STRCPY(newval, origval);
|
|
4222 if (*s)
|
|
4223 {
|
|
4224 /* may need to remove a comma */
|
|
4225 if (flags & P_COMMA)
|
|
4226 {
|
|
4227 if (s == origval)
|
|
4228 {
|
|
4229 /* include comma after string */
|
|
4230 if (s[i] == ',')
|
|
4231 ++i;
|
|
4232 }
|
|
4233 else
|
|
4234 {
|
|
4235 /* include comma before string */
|
|
4236 --s;
|
|
4237 ++i;
|
|
4238 }
|
|
4239 }
|
|
4240 mch_memmove(newval + (s - origval), s + i,
|
|
4241 STRLEN(s + i) + 1);
|
|
4242 }
|
|
4243 }
|
|
4244
|
|
4245 if (flags & P_FLAGLIST)
|
|
4246 {
|
|
4247 /* Remove flags that appear twice. */
|
|
4248 for (s = newval; *s; ++s)
|
|
4249 if ((!(flags & P_COMMA) || *s != ',')
|
|
4250 && vim_strchr(s + 1, *s) != NULL)
|
|
4251 {
|
|
4252 STRCPY(s, s + 1);
|
|
4253 --s;
|
|
4254 }
|
|
4255 }
|
|
4256
|
|
4257 if (save_arg != NULL) /* number for 'whichwrap' */
|
|
4258 arg = save_arg;
|
|
4259 new_value_alloced = TRUE;
|
|
4260 }
|
|
4261
|
|
4262 /* Set the new value. */
|
|
4263 *(char_u **)(varp) = newval;
|
|
4264
|
|
4265 /* Handle side effects, and set the global value for
|
|
4266 * ":set" on local options. */
|
|
4267 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
|
|
4268 new_value_alloced, oldval, errbuf, opt_flags);
|
|
4269
|
|
4270 /* If error detected, print the error message. */
|
|
4271 if (errmsg != NULL)
|
|
4272 goto skip;
|
|
4273 }
|
|
4274 else /* key code option */
|
|
4275 {
|
|
4276 char_u *p;
|
|
4277
|
|
4278 if (nextchar == '&')
|
|
4279 {
|
|
4280 if (add_termcap_entry(key_name, TRUE) == FAIL)
|
|
4281 errmsg = (char_u *)N_("E522: Not found in termcap");
|
|
4282 }
|
|
4283 else
|
|
4284 {
|
|
4285 ++arg; /* jump to after the '=' or ':' */
|
|
4286 for (p = arg; *p && !vim_iswhite(*p); ++p)
|
|
4287 if (*p == '\\' && p[1] != NUL)
|
|
4288 ++p;
|
|
4289 nextchar = *p;
|
|
4290 *p = NUL;
|
|
4291 add_termcode(key_name, arg, FALSE);
|
|
4292 *p = nextchar;
|
|
4293 }
|
|
4294 if (full_screen)
|
|
4295 ttest(FALSE);
|
|
4296 redraw_all_later(CLEAR);
|
|
4297 }
|
|
4298 }
|
|
4299 if (opt_idx >= 0)
|
|
4300 options[opt_idx].flags |= P_WAS_SET;
|
|
4301 }
|
|
4302
|
|
4303 skip:
|
|
4304 /*
|
|
4305 * Advance to next argument.
|
|
4306 * - skip until a blank found, taking care of backslashes
|
|
4307 * - skip blanks
|
|
4308 * - skip one "=val" argument (for hidden options ":set gfn =xx")
|
|
4309 */
|
|
4310 for (i = 0; i < 2 ; ++i)
|
|
4311 {
|
|
4312 while (*arg != NUL && !vim_iswhite(*arg))
|
|
4313 if (*arg++ == '\\' && *arg != NUL)
|
|
4314 ++arg;
|
|
4315 arg = skipwhite(arg);
|
|
4316 if (*arg != '=')
|
|
4317 break;
|
|
4318 }
|
|
4319 }
|
|
4320
|
|
4321 if (errmsg != NULL)
|
|
4322 {
|
419
|
4323 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
|
7
|
4324 i = STRLEN(IObuff) + 2;
|
|
4325 if (i + (arg - startarg) < IOSIZE)
|
|
4326 {
|
|
4327 /* append the argument with the error */
|
|
4328 STRCAT(IObuff, ": ");
|
|
4329 mch_memmove(IObuff + i, startarg, (arg - startarg));
|
|
4330 IObuff[i + (arg - startarg)] = NUL;
|
|
4331 }
|
|
4332 /* make sure all characters are printable */
|
|
4333 trans_characters(IObuff, IOSIZE);
|
|
4334
|
|
4335 ++no_wait_return; /* wait_return done later */
|
|
4336 emsg(IObuff); /* show error highlighted */
|
|
4337 --no_wait_return;
|
|
4338
|
|
4339 return FAIL;
|
|
4340 }
|
|
4341
|
|
4342 arg = skipwhite(arg);
|
|
4343 }
|
|
4344
|
168
|
4345 theend:
|
|
4346 if (silent_mode && did_show)
|
|
4347 {
|
|
4348 /* After displaying option values in silent mode. */
|
|
4349 silent_mode = FALSE;
|
|
4350 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
|
|
4351 msg_putchar('\n');
|
|
4352 cursor_on(); /* msg_start() switches it off */
|
|
4353 out_flush();
|
|
4354 silent_mode = TRUE;
|
|
4355 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
|
|
4356 }
|
|
4357
|
7
|
4358 return OK;
|
|
4359 }
|
|
4360
|
|
4361 static char_u *
|
|
4362 illegal_char(errbuf, c)
|
|
4363 char_u *errbuf;
|
|
4364 int c;
|
|
4365 {
|
|
4366 if (errbuf == NULL)
|
|
4367 return (char_u *)"";
|
|
4368 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
|
274
|
4369 (char *)transchar(c));
|
7
|
4370 return errbuf;
|
|
4371 }
|
|
4372
|
|
4373 /*
|
|
4374 * Convert a key name or string into a key value.
|
|
4375 * Used for 'wildchar' and 'cedit' options.
|
|
4376 */
|
|
4377 static int
|
|
4378 string_to_key(arg)
|
|
4379 char_u *arg;
|
|
4380 {
|
|
4381 if (*arg == '<')
|
|
4382 return find_key_option(arg + 1);
|
|
4383 if (*arg == '^')
|
|
4384 return Ctrl_chr(arg[1]);
|
|
4385 return *arg;
|
|
4386 }
|
|
4387
|
|
4388 #ifdef FEAT_CMDWIN
|
|
4389 /*
|
|
4390 * Check value of 'cedit' and set cedit_key.
|
|
4391 * Returns NULL if value is OK, error message otherwise.
|
|
4392 */
|
|
4393 static char_u *
|
|
4394 check_cedit()
|
|
4395 {
|
|
4396 int n;
|
|
4397
|
|
4398 if (*p_cedit == NUL)
|
|
4399 cedit_key = -1;
|
|
4400 else
|
|
4401 {
|
|
4402 n = string_to_key(p_cedit);
|
|
4403 if (vim_isprintc(n))
|
|
4404 return e_invarg;
|
|
4405 cedit_key = n;
|
|
4406 }
|
|
4407 return NULL;
|
|
4408 }
|
|
4409 #endif
|
|
4410
|
|
4411 #ifdef FEAT_TITLE
|
|
4412 /*
|
|
4413 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
|
|
4414 * maketitle() to create and display it.
|
|
4415 * When switching the title or icon off, call mch_restore_title() to get
|
|
4416 * the old value back.
|
|
4417 */
|
|
4418 static void
|
|
4419 did_set_title(icon)
|
|
4420 int icon; /* Did set icon instead of title */
|
|
4421 {
|
|
4422 if (starting != NO_SCREEN
|
|
4423 #ifdef FEAT_GUI
|
|
4424 && !gui.starting
|
|
4425 #endif
|
|
4426 )
|
|
4427 {
|
|
4428 maketitle();
|
|
4429 if (icon)
|
|
4430 {
|
|
4431 if (!p_icon)
|
|
4432 mch_restore_title(2);
|
|
4433 }
|
|
4434 else
|
|
4435 {
|
|
4436 if (!p_title)
|
|
4437 mch_restore_title(1);
|
|
4438 }
|
|
4439 }
|
|
4440 }
|
|
4441 #endif
|
|
4442
|
|
4443 /*
|
|
4444 * set_options_bin - called when 'bin' changes value.
|
|
4445 */
|
|
4446 void
|
|
4447 set_options_bin(oldval, newval, opt_flags)
|
|
4448 int oldval;
|
|
4449 int newval;
|
|
4450 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
4451 {
|
|
4452 /*
|
|
4453 * The option values that are changed when 'bin' changes are
|
|
4454 * copied when 'bin is set and restored when 'bin' is reset.
|
|
4455 */
|
|
4456 if (newval)
|
|
4457 {
|
|
4458 if (!oldval) /* switched on */
|
|
4459 {
|
|
4460 if (!(opt_flags & OPT_GLOBAL))
|
|
4461 {
|
|
4462 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
|
|
4463 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
|
|
4464 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
|
|
4465 curbuf->b_p_et_nobin = curbuf->b_p_et;
|
|
4466 }
|
|
4467 if (!(opt_flags & OPT_LOCAL))
|
|
4468 {
|
|
4469 p_tw_nobin = p_tw;
|
|
4470 p_wm_nobin = p_wm;
|
|
4471 p_ml_nobin = p_ml;
|
|
4472 p_et_nobin = p_et;
|
|
4473 }
|
|
4474 }
|
|
4475
|
|
4476 if (!(opt_flags & OPT_GLOBAL))
|
|
4477 {
|
|
4478 curbuf->b_p_tw = 0; /* no automatic line wrap */
|
|
4479 curbuf->b_p_wm = 0; /* no automatic line wrap */
|
|
4480 curbuf->b_p_ml = 0; /* no modelines */
|
|
4481 curbuf->b_p_et = 0; /* no expandtab */
|
|
4482 }
|
|
4483 if (!(opt_flags & OPT_LOCAL))
|
|
4484 {
|
|
4485 p_tw = 0;
|
|
4486 p_wm = 0;
|
|
4487 p_ml = FALSE;
|
|
4488 p_et = FALSE;
|
|
4489 p_bin = TRUE; /* needed when called for the "-b" argument */
|
|
4490 }
|
|
4491 }
|
|
4492 else if (oldval) /* switched off */
|
|
4493 {
|
|
4494 if (!(opt_flags & OPT_GLOBAL))
|
|
4495 {
|
|
4496 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
|
|
4497 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
|
|
4498 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
|
|
4499 curbuf->b_p_et = curbuf->b_p_et_nobin;
|
|
4500 }
|
|
4501 if (!(opt_flags & OPT_LOCAL))
|
|
4502 {
|
|
4503 p_tw = p_tw_nobin;
|
|
4504 p_wm = p_wm_nobin;
|
|
4505 p_ml = p_ml_nobin;
|
|
4506 p_et = p_et_nobin;
|
|
4507 }
|
|
4508 }
|
|
4509 }
|
|
4510
|
|
4511 #ifdef FEAT_VIMINFO
|
|
4512 /*
|
|
4513 * Find the parameter represented by the given character (eg ', :, ", or /),
|
|
4514 * and return its associated value in the 'viminfo' string.
|
|
4515 * Only works for number parameters, not for 'r' or 'n'.
|
23
|
4516 * If the parameter is not specified in the string or there is no following
|
|
4517 * number, return -1.
|
7
|
4518 */
|
|
4519 int
|
|
4520 get_viminfo_parameter(type)
|
|
4521 int type;
|
|
4522 {
|
|
4523 char_u *p;
|
|
4524
|
|
4525 p = find_viminfo_parameter(type);
|
|
4526 if (p != NULL && VIM_ISDIGIT(*p))
|
|
4527 return atoi((char *)p);
|
|
4528 return -1;
|
|
4529 }
|
|
4530
|
|
4531 /*
|
|
4532 * Find the parameter represented by the given character (eg ''', ':', '"', or
|
|
4533 * '/') in the 'viminfo' option and return a pointer to the string after it.
|
|
4534 * Return NULL if the parameter is not specified in the string.
|
|
4535 */
|
|
4536 char_u *
|
|
4537 find_viminfo_parameter(type)
|
|
4538 int type;
|
|
4539 {
|
|
4540 char_u *p;
|
|
4541
|
|
4542 for (p = p_viminfo; *p; ++p)
|
|
4543 {
|
|
4544 if (*p == type)
|
|
4545 return p + 1;
|
|
4546 if (*p == 'n') /* 'n' is always the last one */
|
|
4547 break;
|
|
4548 p = vim_strchr(p, ','); /* skip until next ',' */
|
|
4549 if (p == NULL) /* hit the end without finding parameter */
|
|
4550 break;
|
|
4551 }
|
|
4552 return NULL;
|
|
4553 }
|
|
4554 #endif
|
|
4555
|
|
4556 /*
|
|
4557 * Expand environment variables for some string options.
|
|
4558 * These string options cannot be indirect!
|
|
4559 * If "val" is NULL expand the current value of the option.
|
|
4560 * Return pointer to NameBuff, or NULL when not expanded.
|
|
4561 */
|
|
4562 static char_u *
|
|
4563 option_expand(opt_idx, val)
|
|
4564 int opt_idx;
|
|
4565 char_u *val;
|
|
4566 {
|
|
4567 /* if option doesn't need expansion nothing to do */
|
|
4568 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
|
|
4569 return NULL;
|
|
4570
|
|
4571 /* If val is longer than MAXPATHL no meaningful expansion can be done,
|
|
4572 * expand_env() would truncate the string. */
|
|
4573 if (val != NULL && STRLEN(val) > MAXPATHL)
|
|
4574 return NULL;
|
|
4575
|
|
4576 if (val == NULL)
|
|
4577 val = *(char_u **)options[opt_idx].var;
|
|
4578
|
|
4579 /*
|
|
4580 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
|
|
4581 * Escape spaces when expanding 'tags', they are used to separate file
|
|
4582 * names.
|
374
|
4583 * For 'spellsuggest' expand after "file:".
|
7
|
4584 */
|
|
4585 expand_env_esc(val, NameBuff, MAXPATHL,
|
374
|
4586 (char_u **)options[opt_idx].var == &p_tags,
|
|
4587 #ifdef FEAT_SYN_HL
|
|
4588 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
|
|
4589 #endif
|
|
4590 NULL);
|
7
|
4591 if (STRCMP(NameBuff, val) == 0) /* they are the same */
|
|
4592 return NULL;
|
|
4593
|
|
4594 return NameBuff;
|
|
4595 }
|
|
4596
|
|
4597 /*
|
|
4598 * After setting various option values: recompute variables that depend on
|
|
4599 * option values.
|
|
4600 */
|
|
4601 static void
|
|
4602 didset_options()
|
|
4603 {
|
|
4604 /* initialize the table for 'iskeyword' et.al. */
|
|
4605 (void)init_chartab();
|
|
4606
|
|
4607 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
|
|
4608 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
|
|
4609 #ifdef FEAT_SESSION
|
|
4610 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
|
|
4611 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
|
|
4612 #endif
|
|
4613 #ifdef FEAT_FOLDING
|
|
4614 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
|
|
4615 #endif
|
|
4616 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
|
|
4617 #ifdef FEAT_VIRTUALEDIT
|
|
4618 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
|
|
4619 #endif
|
|
4620 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
|
|
4621 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
|
|
4622 #endif
|
344
|
4623 #ifdef FEAT_SYN_HL
|
374
|
4624 (void)spell_check_sps();
|
389
|
4625 (void)compile_cap_prog(curbuf);
|
344
|
4626 #endif
|
7
|
4627 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
|
|
4628 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
|
|
4629 #endif
|
|
4630 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
4631 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
|
|
4632 #endif
|
|
4633 #ifdef FEAT_CMDWIN
|
|
4634 /* set cedit_key */
|
|
4635 (void)check_cedit();
|
|
4636 #endif
|
|
4637 }
|
|
4638
|
|
4639 /*
|
|
4640 * Check for string options that are NULL (normally only termcap options).
|
|
4641 */
|
|
4642 void
|
|
4643 check_options()
|
|
4644 {
|
|
4645 int opt_idx;
|
|
4646
|
|
4647 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
|
|
4648 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
|
|
4649 check_string_option((char_u **)get_varp(&(options[opt_idx])));
|
|
4650 }
|
|
4651
|
|
4652 /*
|
|
4653 * Check string options in a buffer for NULL value.
|
|
4654 */
|
|
4655 void
|
|
4656 check_buf_options(buf)
|
|
4657 buf_T *buf;
|
|
4658 {
|
|
4659 #if defined(FEAT_QUICKFIX)
|
|
4660 check_string_option(&buf->b_p_bh);
|
|
4661 check_string_option(&buf->b_p_bt);
|
|
4662 #endif
|
|
4663 #ifdef FEAT_MBYTE
|
|
4664 check_string_option(&buf->b_p_fenc);
|
|
4665 #endif
|
|
4666 check_string_option(&buf->b_p_ff);
|
|
4667 #ifdef FEAT_FIND_ID
|
|
4668 check_string_option(&buf->b_p_def);
|
|
4669 check_string_option(&buf->b_p_inc);
|
|
4670 # ifdef FEAT_EVAL
|
|
4671 check_string_option(&buf->b_p_inex);
|
|
4672 # endif
|
|
4673 #endif
|
|
4674 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
4675 check_string_option(&buf->b_p_inde);
|
|
4676 check_string_option(&buf->b_p_indk);
|
|
4677 #endif
|
|
4678 #ifdef FEAT_CRYPT
|
|
4679 check_string_option(&buf->b_p_key);
|
|
4680 #endif
|
|
4681 check_string_option(&buf->b_p_kp);
|
|
4682 check_string_option(&buf->b_p_mps);
|
|
4683 check_string_option(&buf->b_p_fo);
|
41
|
4684 check_string_option(&buf->b_p_flp);
|
7
|
4685 check_string_option(&buf->b_p_isk);
|
|
4686 #ifdef FEAT_COMMENTS
|
|
4687 check_string_option(&buf->b_p_com);
|
|
4688 #endif
|
|
4689 #ifdef FEAT_FOLDING
|
|
4690 check_string_option(&buf->b_p_cms);
|
|
4691 #endif
|
|
4692 check_string_option(&buf->b_p_nf);
|
12
|
4693 #ifdef FEAT_TEXTOBJ
|
|
4694 check_string_option(&buf->b_p_qe);
|
|
4695 #endif
|
7
|
4696 #ifdef FEAT_SYN_HL
|
|
4697 check_string_option(&buf->b_p_syn);
|
386
|
4698 check_string_option(&buf->b_p_spc);
|
314
|
4699 check_string_option(&buf->b_p_spf);
|
221
|
4700 check_string_option(&buf->b_p_spl);
|
7
|
4701 #endif
|
|
4702 #ifdef FEAT_SEARCHPATH
|
|
4703 check_string_option(&buf->b_p_sua);
|
|
4704 #endif
|
|
4705 #ifdef FEAT_CINDENT
|
|
4706 check_string_option(&buf->b_p_cink);
|
|
4707 check_string_option(&buf->b_p_cino);
|
|
4708 #endif
|
|
4709 #ifdef FEAT_AUTOCMD
|
|
4710 check_string_option(&buf->b_p_ft);
|
|
4711 #endif
|
|
4712 #ifdef FEAT_OSFILETYPE
|
|
4713 check_string_option(&buf->b_p_oft);
|
|
4714 #endif
|
|
4715 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
4716 check_string_option(&buf->b_p_cinw);
|
|
4717 #endif
|
|
4718 #ifdef FEAT_INS_EXPAND
|
|
4719 check_string_option(&buf->b_p_cpt);
|
|
4720 #endif
|
12
|
4721 #ifdef FEAT_COMPL_FUNC
|
|
4722 check_string_option(&buf->b_p_cfu);
|
|
4723 #endif
|
7
|
4724 #ifdef FEAT_KEYMAP
|
|
4725 check_string_option(&buf->b_p_keymap);
|
|
4726 #endif
|
|
4727 #ifdef FEAT_QUICKFIX
|
|
4728 check_string_option(&buf->b_p_gp);
|
|
4729 check_string_option(&buf->b_p_mp);
|
|
4730 check_string_option(&buf->b_p_efm);
|
|
4731 #endif
|
|
4732 check_string_option(&buf->b_p_ep);
|
|
4733 check_string_option(&buf->b_p_path);
|
|
4734 check_string_option(&buf->b_p_tags);
|
|
4735 #ifdef FEAT_INS_EXPAND
|
|
4736 check_string_option(&buf->b_p_dict);
|
|
4737 check_string_option(&buf->b_p_tsr);
|
|
4738 #endif
|
|
4739 }
|
|
4740
|
|
4741 /*
|
|
4742 * Free the string allocated for an option.
|
|
4743 * Checks for the string being empty_option. This may happen if we're out of
|
|
4744 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
|
|
4745 * check_options().
|
|
4746 * Does NOT check for P_ALLOCED flag!
|
|
4747 */
|
|
4748 void
|
|
4749 free_string_option(p)
|
|
4750 char_u *p;
|
|
4751 {
|
|
4752 if (p != empty_option)
|
|
4753 vim_free(p);
|
|
4754 }
|
|
4755
|
|
4756 void
|
|
4757 clear_string_option(pp)
|
|
4758 char_u **pp;
|
|
4759 {
|
|
4760 if (*pp != empty_option)
|
|
4761 vim_free(*pp);
|
|
4762 *pp = empty_option;
|
|
4763 }
|
|
4764
|
|
4765 static void
|
|
4766 check_string_option(pp)
|
|
4767 char_u **pp;
|
|
4768 {
|
|
4769 if (*pp == NULL)
|
|
4770 *pp = empty_option;
|
|
4771 }
|
|
4772
|
|
4773 /*
|
|
4774 * Mark a terminal option as allocated, found by a pointer into term_strings[].
|
|
4775 */
|
|
4776 void
|
|
4777 set_term_option_alloced(p)
|
|
4778 char_u **p;
|
|
4779 {
|
|
4780 int opt_idx;
|
|
4781
|
|
4782 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
|
|
4783 if (options[opt_idx].var == (char_u *)p)
|
|
4784 {
|
|
4785 options[opt_idx].flags |= P_ALLOCED;
|
|
4786 return;
|
|
4787 }
|
|
4788 return; /* cannot happen: didn't find it! */
|
|
4789 }
|
|
4790
|
|
4791 /*
|
|
4792 * Set a string option to a new value (without checking the effect).
|
|
4793 * The string is copied into allocated memory.
|
|
4794 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
|
|
4795 */
|
|
4796 void
|
|
4797 set_string_option_direct(name, opt_idx, val, opt_flags)
|
|
4798 char_u *name;
|
|
4799 int opt_idx;
|
|
4800 char_u *val;
|
|
4801 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
|
|
4802 {
|
|
4803 char_u *s;
|
|
4804 char_u **varp;
|
|
4805 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
|
|
4806
|
|
4807 if (opt_idx == -1) /* use name */
|
|
4808 {
|
|
4809 opt_idx = findoption(name);
|
|
4810 if (opt_idx == -1) /* not found (should not happen) */
|
|
4811 return;
|
|
4812 }
|
|
4813
|
|
4814 if (options[opt_idx].var == NULL) /* can't set hidden option */
|
|
4815 return;
|
|
4816
|
|
4817 s = vim_strsave(val);
|
|
4818 if (s != NULL)
|
|
4819 {
|
|
4820 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
|
|
4821 both ? OPT_LOCAL : opt_flags);
|
|
4822 if ((opt_flags & OPT_FREE) && (options[opt_idx].flags & P_ALLOCED))
|
|
4823 free_string_option(*varp);
|
|
4824 *varp = s;
|
|
4825
|
|
4826 /* For buffer/window local option may also set the global value. */
|
|
4827 if (both)
|
|
4828 set_string_option_global(opt_idx, varp);
|
|
4829
|
|
4830 options[opt_idx].flags |= P_ALLOCED;
|
|
4831
|
|
4832 /* When setting both values of a global option with a local value,
|
|
4833 * make the local value empty, so that the global value is used. */
|
|
4834 if ((int)options[opt_idx].indir >= PV_BOTH && both)
|
|
4835 {
|
|
4836 free_string_option(*varp);
|
|
4837 *varp = empty_option;
|
|
4838 }
|
|
4839 }
|
|
4840 }
|
|
4841
|
|
4842 /*
|
|
4843 * Set global value for string option when it's a local option.
|
|
4844 */
|
|
4845 static void
|
|
4846 set_string_option_global(opt_idx, varp)
|
|
4847 int opt_idx; /* option index */
|
|
4848 char_u **varp; /* pointer to option variable */
|
|
4849 {
|
|
4850 char_u **p, *s;
|
|
4851
|
|
4852 /* the global value is always allocated */
|
|
4853 if (options[opt_idx].var == VAR_WIN)
|
|
4854 p = (char_u **)GLOBAL_WO(varp);
|
|
4855 else
|
|
4856 p = (char_u **)options[opt_idx].var;
|
|
4857 if (options[opt_idx].indir != PV_NONE
|
|
4858 && p != varp
|
|
4859 && (s = vim_strsave(*varp)) != NULL)
|
|
4860 {
|
|
4861 free_string_option(*p);
|
|
4862 *p = s;
|
|
4863 }
|
|
4864 }
|
|
4865
|
|
4866 /*
|
|
4867 * Set a string option to a new value, and handle the effects.
|
|
4868 */
|
|
4869 static void
|
|
4870 set_string_option(opt_idx, value, opt_flags)
|
|
4871 int opt_idx;
|
|
4872 char_u *value;
|
|
4873 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
4874 {
|
|
4875 char_u *s;
|
|
4876 char_u **varp;
|
|
4877 char_u *oldval;
|
|
4878
|
|
4879 if (options[opt_idx].var == NULL) /* don't set hidden option */
|
|
4880 return;
|
|
4881
|
|
4882 s = vim_strsave(value);
|
|
4883 if (s != NULL)
|
|
4884 {
|
|
4885 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
|
|
4886 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
4887 ? ((int)options[opt_idx].indir >= PV_BOTH
|
|
4888 ? OPT_GLOBAL : OPT_LOCAL)
|
|
4889 : opt_flags);
|
|
4890 oldval = *varp;
|
|
4891 *varp = s;
|
|
4892 options[opt_idx].flags |= P_WAS_SET;
|
|
4893 (void)did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
|
4894 opt_flags);
|
|
4895 }
|
|
4896 }
|
|
4897
|
|
4898 /*
|
|
4899 * Handle string options that need some action to perform when changed.
|
|
4900 * Returns NULL for success, or an error message for an error.
|
|
4901 */
|
|
4902 static char_u *
|
|
4903 did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
|
|
4904 opt_flags)
|
|
4905 int opt_idx; /* index in options[] table */
|
|
4906 char_u **varp; /* pointer to the option variable */
|
|
4907 int new_value_alloced; /* new value was allocated */
|
|
4908 char_u *oldval; /* previous value of the option */
|
|
4909 char_u *errbuf; /* buffer for errors, or NULL */
|
|
4910 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
4911 {
|
|
4912 char_u *errmsg = NULL;
|
|
4913 char_u *s, *p;
|
|
4914 int did_chartab = FALSE;
|
|
4915 char_u **gvarp;
|
24
|
4916 int free_oldval = (options[opt_idx].flags & P_ALLOCED);
|
7
|
4917
|
|
4918 /* Get the global option to compare with, otherwise we would have to check
|
|
4919 * two values for all local options. */
|
|
4920 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
|
|
4921
|
|
4922 /* Disallow changing some options from secure mode */
|
|
4923 if ((secure
|
|
4924 #ifdef HAVE_SANDBOX
|
|
4925 || sandbox != 0
|
|
4926 #endif
|
|
4927 ) && (options[opt_idx].flags & P_SECURE))
|
|
4928 {
|
|
4929 errmsg = e_secure;
|
|
4930 }
|
|
4931
|
36
|
4932 /* Check for a "normal" file name in some options. Disallow a path
|
|
4933 * separator (slash and/or backslash), wildcards and characters that are
|
|
4934 * often illegal in a file name. */
|
|
4935 else if ((options[opt_idx].flags & P_NFNAME)
|
39
|
4936 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
|
36
|
4937 {
|
|
4938 errmsg = e_invarg;
|
|
4939 }
|
|
4940
|
7
|
4941 /* 'term' */
|
|
4942 else if (varp == &T_NAME)
|
|
4943 {
|
|
4944 if (T_NAME[0] == NUL)
|
|
4945 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
|
|
4946 #ifdef FEAT_GUI
|
|
4947 if (gui.in_use)
|
|
4948 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
|
|
4949 else if (term_is_gui(T_NAME))
|
|
4950 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
|
|
4951 #endif
|
|
4952 else if (set_termname(T_NAME) == FAIL)
|
|
4953 errmsg = (char_u *)N_("E522: Not found in termcap");
|
|
4954 else
|
|
4955 /* Screen colors may have changed. */
|
|
4956 redraw_later_clear();
|
|
4957 }
|
|
4958
|
|
4959 /* 'backupcopy' */
|
|
4960 else if (varp == &p_bkc)
|
|
4961 {
|
|
4962 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
|
|
4963 errmsg = e_invarg;
|
|
4964 if (((bkc_flags & BKC_AUTO) != 0)
|
|
4965 + ((bkc_flags & BKC_YES) != 0)
|
|
4966 + ((bkc_flags & BKC_NO) != 0) != 1)
|
|
4967 {
|
|
4968 /* Must have exactly one of "auto", "yes" and "no". */
|
|
4969 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
|
|
4970 errmsg = e_invarg;
|
|
4971 }
|
|
4972 }
|
|
4973
|
|
4974 /* 'backupext' and 'patchmode' */
|
|
4975 else if (varp == &p_bex || varp == &p_pm)
|
|
4976 {
|
|
4977 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
|
|
4978 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
|
|
4979 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
|
|
4980 }
|
|
4981
|
|
4982 /*
|
|
4983 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
|
|
4984 * If the new option is invalid, use old value. 'lisp' option: refill
|
|
4985 * chartab[] for '-' char
|
|
4986 */
|
|
4987 else if ( varp == &p_isi
|
|
4988 || varp == &(curbuf->b_p_isk)
|
|
4989 || varp == &p_isp
|
|
4990 || varp == &p_isf)
|
|
4991 {
|
|
4992 if (init_chartab() == FAIL)
|
|
4993 {
|
|
4994 did_chartab = TRUE; /* need to restore it below */
|
|
4995 errmsg = e_invarg; /* error in value */
|
|
4996 }
|
|
4997 }
|
|
4998
|
|
4999 /* 'helpfile' */
|
|
5000 else if (varp == &p_hf)
|
|
5001 {
|
|
5002 /* May compute new values for $VIM and $VIMRUNTIME */
|
|
5003 if (didset_vim)
|
|
5004 {
|
|
5005 vim_setenv((char_u *)"VIM", (char_u *)"");
|
|
5006 didset_vim = FALSE;
|
|
5007 }
|
|
5008 if (didset_vimruntime)
|
|
5009 {
|
|
5010 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
|
|
5011 didset_vimruntime = FALSE;
|
|
5012 }
|
|
5013 }
|
|
5014
|
|
5015 #ifdef FEAT_MULTI_LANG
|
|
5016 /* 'helplang' */
|
|
5017 else if (varp == &p_hlg)
|
|
5018 {
|
|
5019 /* Check for "", "ab", "ab,cd", etc. */
|
|
5020 for (s = p_hlg; *s != NUL; s += 3)
|
|
5021 {
|
|
5022 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
|
|
5023 {
|
|
5024 errmsg = e_invarg;
|
|
5025 break;
|
|
5026 }
|
|
5027 if (s[2] == NUL)
|
|
5028 break;
|
|
5029 }
|
|
5030 }
|
|
5031 #endif
|
|
5032
|
|
5033 /* 'highlight' */
|
|
5034 else if (varp == &p_hl)
|
|
5035 {
|
|
5036 if (highlight_changed() == FAIL)
|
|
5037 errmsg = e_invarg; /* invalid flags */
|
|
5038 }
|
|
5039
|
|
5040 /* 'nrformats' */
|
|
5041 else if (gvarp == &p_nf)
|
|
5042 {
|
|
5043 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
|
|
5044 errmsg = e_invarg;
|
|
5045 }
|
|
5046
|
|
5047 #ifdef FEAT_SESSION
|
|
5048 /* 'sessionoptions' */
|
|
5049 else if (varp == &p_ssop)
|
|
5050 {
|
|
5051 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
|
|
5052 errmsg = e_invarg;
|
|
5053 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
|
|
5054 {
|
|
5055 /* Don't allow both "sesdir" and "curdir". */
|
|
5056 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
|
|
5057 errmsg = e_invarg;
|
|
5058 }
|
|
5059 }
|
|
5060 /* 'viewoptions' */
|
|
5061 else if (varp == &p_vop)
|
|
5062 {
|
|
5063 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
|
|
5064 errmsg = e_invarg;
|
|
5065 }
|
|
5066 #endif
|
|
5067
|
|
5068 /* 'scrollopt' */
|
|
5069 #ifdef FEAT_SCROLLBIND
|
|
5070 else if (varp == &p_sbo)
|
|
5071 {
|
|
5072 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
|
|
5073 errmsg = e_invarg;
|
|
5074 }
|
|
5075 #endif
|
|
5076
|
|
5077 /* 'ambiwidth' */
|
|
5078 #ifdef FEAT_MBYTE
|
|
5079 else if (varp == &p_ambw)
|
|
5080 {
|
|
5081 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
|
|
5082 errmsg = e_invarg;
|
|
5083 }
|
|
5084 #endif
|
|
5085
|
|
5086 /* 'background' */
|
|
5087 else if (varp == &p_bg)
|
|
5088 {
|
|
5089 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
|
|
5090 {
|
|
5091 #ifdef FEAT_EVAL
|
|
5092 int dark = (*p_bg == 'd');
|
|
5093 #endif
|
|
5094
|
|
5095 init_highlight(FALSE, FALSE);
|
|
5096
|
|
5097 #ifdef FEAT_EVAL
|
|
5098 if (dark != (*p_bg == 'd')
|
|
5099 && get_var_value((char_u *)"g:colors_name") != NULL)
|
|
5100 {
|
|
5101 /* The color scheme must have set 'background' back to another
|
|
5102 * value, that's not what we want here. Disable the color
|
|
5103 * scheme and set the colors again. */
|
148
|
5104 do_unlet((char_u *)"g:colors_name", TRUE);
|
7
|
5105 free_string_option(p_bg);
|
|
5106 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
|
|
5107 check_string_option(&p_bg);
|
|
5108 init_highlight(FALSE, FALSE);
|
|
5109 }
|
|
5110 #endif
|
|
5111 }
|
|
5112 else
|
|
5113 errmsg = e_invarg;
|
|
5114 }
|
|
5115
|
|
5116 /* 'wildmode' */
|
|
5117 else if (varp == &p_wim)
|
|
5118 {
|
|
5119 if (check_opt_wim() == FAIL)
|
|
5120 errmsg = e_invarg;
|
|
5121 }
|
|
5122
|
40
|
5123 #ifdef FEAT_CMDL_COMPL
|
|
5124 /* 'wildoptions' */
|
|
5125 else if (varp == &p_wop)
|
|
5126 {
|
|
5127 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
|
|
5128 errmsg = e_invarg;
|
|
5129 }
|
|
5130 #endif
|
|
5131
|
7
|
5132 #ifdef FEAT_WAK
|
|
5133 /* 'winaltkeys' */
|
|
5134 else if (varp == &p_wak)
|
|
5135 {
|
|
5136 if (*p_wak == NUL
|
|
5137 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
|
|
5138 errmsg = e_invarg;
|
|
5139 # ifdef FEAT_MENU
|
|
5140 # ifdef FEAT_GUI_MOTIF
|
|
5141 else if (gui.in_use)
|
|
5142 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
|
|
5143 # else
|
|
5144 # ifdef FEAT_GUI_GTK
|
|
5145 else if (gui.in_use)
|
|
5146 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
|
|
5147 # endif
|
|
5148 # endif
|
|
5149 # endif
|
|
5150 }
|
|
5151 #endif
|
|
5152
|
|
5153 #ifdef FEAT_AUTOCMD
|
|
5154 /* 'eventignore' */
|
|
5155 else if (varp == &p_ei)
|
|
5156 {
|
|
5157 if (check_ei() == FAIL)
|
|
5158 errmsg = e_invarg;
|
|
5159 }
|
|
5160 #endif
|
|
5161
|
|
5162 #ifdef FEAT_MBYTE
|
|
5163 /* 'encoding' and 'fileencoding' */
|
|
5164 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
|
|
5165 {
|
|
5166 if (gvarp == &p_fenc)
|
|
5167 {
|
|
5168 if (!curbuf->b_p_ma)
|
|
5169 errmsg = e_modifiable;
|
|
5170 else if (vim_strchr(*varp, ',') != NULL)
|
|
5171 /* No comma allowed in 'fileencoding'; catches confusing it
|
|
5172 * with 'fileencodings'. */
|
|
5173 errmsg = e_invarg;
|
39
|
5174 else
|
|
5175 {
|
7
|
5176 # ifdef FEAT_TITLE
|
|
5177 /* May show a "+" in the title now. */
|
|
5178 need_maketitle = TRUE;
|
|
5179 # endif
|
39
|
5180 /* Add 'fileencoding' to the swap file. */
|
|
5181 ml_setflags(curbuf);
|
|
5182 }
|
7
|
5183 }
|
|
5184 if (errmsg == NULL)
|
|
5185 {
|
|
5186 /* canonize the value, so that STRCMP() can be used on it */
|
|
5187 p = enc_canonize(*varp);
|
|
5188 if (p != NULL)
|
|
5189 {
|
|
5190 vim_free(*varp);
|
|
5191 *varp = p;
|
|
5192 }
|
|
5193 if (varp == &p_enc)
|
|
5194 {
|
|
5195 errmsg = mb_init();
|
|
5196 # ifdef FEAT_TITLE
|
|
5197 need_maketitle = TRUE;
|
|
5198 # endif
|
|
5199 }
|
|
5200 }
|
|
5201
|
|
5202 # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
5203 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
|
|
5204 {
|
|
5205 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
|
|
5206 if (STRCMP(p_tenc, "utf-8") != 0)
|
|
5207 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
|
|
5208 }
|
|
5209 # endif
|
|
5210
|
|
5211 if (errmsg == NULL)
|
|
5212 {
|
|
5213 # ifdef FEAT_KEYMAP
|
|
5214 /* When 'keymap' is used and 'encoding' changes, reload the keymap
|
|
5215 * (with another encoding). */
|
|
5216 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
|
|
5217 (void)keymap_init();
|
|
5218 # endif
|
|
5219
|
|
5220 /* When 'termencoding' is not empty and 'encoding' changes or when
|
|
5221 * 'termencoding' changes, need to setup for keyboard input and
|
|
5222 * display output conversion. */
|
|
5223 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
|
|
5224 {
|
|
5225 convert_setup(&input_conv, p_tenc, p_enc);
|
|
5226 convert_setup(&output_conv, p_enc, p_tenc);
|
|
5227 }
|
170
|
5228
|
|
5229 # if defined(WIN3264) && defined(FEAT_MBYTE)
|
|
5230 /* $HOME may have characters in active code page. */
|
|
5231 if (varp == &p_enc)
|
|
5232 init_homedir();
|
|
5233 # endif
|
7
|
5234 }
|
|
5235 }
|
|
5236 #endif
|
|
5237
|
|
5238 #if defined(FEAT_POSTSCRIPT)
|
|
5239 else if (varp == &p_penc)
|
|
5240 {
|
|
5241 /* Canonize printencoding if VIM standard one */
|
|
5242 p = enc_canonize(p_penc);
|
|
5243 if (p != NULL)
|
|
5244 {
|
|
5245 vim_free(p_penc);
|
|
5246 p_penc = p;
|
|
5247 }
|
|
5248 else
|
|
5249 {
|
|
5250 /* Ensure lower case and '-' for '_' */
|
|
5251 for (s = p_penc; *s != NUL; s++)
|
|
5252 {
|
|
5253 if (*s == '_')
|
|
5254 *s = '-';
|
|
5255 else
|
|
5256 *s = TOLOWER_ASC(*s);
|
|
5257 }
|
|
5258 }
|
|
5259 }
|
|
5260 #endif
|
|
5261
|
11
|
5262 #if defined(FEAT_XIM) && ( defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) )
|
7
|
5263 else if (varp == &p_imak)
|
|
5264 {
|
|
5265 if (gui.in_use && !im_xim_isvalid_imactivate())
|
|
5266 errmsg = e_invarg;
|
|
5267 }
|
|
5268 #endif
|
|
5269
|
|
5270 #ifdef FEAT_KEYMAP
|
|
5271 else if (varp == &curbuf->b_p_keymap)
|
|
5272 {
|
|
5273 /* load or unload key mapping tables */
|
|
5274 errmsg = keymap_init();
|
|
5275
|
|
5276 /* When successfully installed a new keymap switch on using it. */
|
|
5277 if (*curbuf->b_p_keymap != NUL && errmsg == NULL)
|
|
5278 {
|
|
5279 curbuf->b_p_iminsert = B_IMODE_LMAP;
|
|
5280 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
|
|
5281 curbuf->b_p_imsearch = B_IMODE_LMAP;
|
|
5282 set_iminsert_global();
|
|
5283 set_imsearch_global();
|
|
5284 # ifdef FEAT_WINDOWS
|
|
5285 status_redraw_curbuf();
|
|
5286 # endif
|
|
5287 }
|
|
5288 }
|
|
5289 #endif
|
|
5290
|
|
5291 /* 'fileformat' */
|
|
5292 else if (gvarp == &p_ff)
|
|
5293 {
|
|
5294 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
|
|
5295 errmsg = e_modifiable;
|
|
5296 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
|
|
5297 errmsg = e_invarg;
|
|
5298 else
|
|
5299 {
|
|
5300 /* may also change 'textmode' */
|
|
5301 if (get_fileformat(curbuf) == EOL_DOS)
|
|
5302 curbuf->b_p_tx = TRUE;
|
|
5303 else
|
|
5304 curbuf->b_p_tx = FALSE;
|
|
5305 #ifdef FEAT_TITLE
|
|
5306 need_maketitle = TRUE;
|
|
5307 #endif
|
39
|
5308 /* update flag in swap file */
|
|
5309 ml_setflags(curbuf);
|
7
|
5310 }
|
|
5311 }
|
|
5312
|
|
5313 /* 'fileformats' */
|
|
5314 else if (varp == &p_ffs)
|
|
5315 {
|
|
5316 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
|
|
5317 errmsg = e_invarg;
|
|
5318 else
|
|
5319 {
|
|
5320 /* also change 'textauto' */
|
|
5321 if (*p_ffs == NUL)
|
|
5322 p_ta = FALSE;
|
|
5323 else
|
|
5324 p_ta = TRUE;
|
|
5325 }
|
|
5326 }
|
|
5327
|
|
5328 #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST)
|
|
5329 /* 'cryptkey' */
|
|
5330 else if (gvarp == &p_key)
|
|
5331 {
|
|
5332 /* Make sure the ":set" command doesn't show the new value in the
|
|
5333 * history. */
|
|
5334 remove_key_from_history();
|
|
5335 }
|
|
5336 #endif
|
|
5337
|
|
5338 /* 'matchpairs' */
|
|
5339 else if (gvarp == &p_mps)
|
|
5340 {
|
|
5341 /* Check for "x:y,x:y" */
|
|
5342 for (p = *varp; *p != NUL; p += 4)
|
|
5343 {
|
|
5344 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
|
|
5345 {
|
|
5346 errmsg = e_invarg;
|
|
5347 break;
|
|
5348 }
|
|
5349 if (p[3] == NUL)
|
|
5350 break;
|
|
5351 }
|
|
5352 }
|
|
5353
|
|
5354 #ifdef FEAT_COMMENTS
|
|
5355 /* 'comments' */
|
|
5356 else if (gvarp == &p_com)
|
|
5357 {
|
|
5358 for (s = *varp; *s; )
|
|
5359 {
|
|
5360 while (*s && *s != ':')
|
|
5361 {
|
|
5362 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
|
|
5363 && !VIM_ISDIGIT(*s) && *s != '-')
|
|
5364 {
|
|
5365 errmsg = illegal_char(errbuf, *s);
|
|
5366 break;
|
|
5367 }
|
|
5368 ++s;
|
|
5369 }
|
|
5370 if (*s++ == NUL)
|
|
5371 errmsg = (char_u *)N_("E524: Missing colon");
|
|
5372 else if (*s == ',' || *s == NUL)
|
|
5373 errmsg = (char_u *)N_("E525: Zero length string");
|
|
5374 if (errmsg != NULL)
|
|
5375 break;
|
|
5376 while (*s && *s != ',')
|
|
5377 {
|
|
5378 if (*s == '\\' && s[1] != NUL)
|
|
5379 ++s;
|
|
5380 ++s;
|
|
5381 }
|
|
5382 s = skip_to_option_part(s);
|
|
5383 }
|
|
5384 }
|
|
5385 #endif
|
|
5386
|
|
5387 /* 'listchars' */
|
|
5388 else if (varp == &p_lcs)
|
|
5389 {
|
|
5390 errmsg = set_chars_option(varp);
|
|
5391 }
|
|
5392
|
|
5393 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
5394 /* 'fillchars' */
|
|
5395 else if (varp == &p_fcs)
|
|
5396 {
|
|
5397 errmsg = set_chars_option(varp);
|
|
5398 }
|
|
5399 #endif
|
|
5400
|
|
5401 #ifdef FEAT_CMDWIN
|
|
5402 /* 'cedit' */
|
|
5403 else if (varp == &p_cedit)
|
|
5404 {
|
|
5405 errmsg = check_cedit();
|
|
5406 }
|
|
5407 #endif
|
|
5408
|
294
|
5409 /* 'verbosefile' */
|
|
5410 else if (varp == &p_vfile)
|
|
5411 {
|
|
5412 verbose_stop();
|
|
5413 if (*p_vfile != NUL && verbose_open() == FAIL)
|
|
5414 errmsg = e_invarg;
|
|
5415 }
|
|
5416
|
7
|
5417 #ifdef FEAT_VIMINFO
|
|
5418 /* 'viminfo' */
|
|
5419 else if (varp == &p_viminfo)
|
|
5420 {
|
|
5421 for (s = p_viminfo; *s;)
|
|
5422 {
|
|
5423 /* Check it's a valid character */
|
|
5424 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
|
|
5425 {
|
|
5426 errmsg = illegal_char(errbuf, *s);
|
|
5427 break;
|
|
5428 }
|
|
5429 if (*s == 'n') /* name is always last one */
|
|
5430 {
|
|
5431 break;
|
|
5432 }
|
|
5433 else if (*s == 'r') /* skip until next ',' */
|
|
5434 {
|
|
5435 while (*++s && *s != ',')
|
|
5436 ;
|
|
5437 }
|
23
|
5438 else if (*s == '%')
|
|
5439 {
|
|
5440 /* optional number */
|
|
5441 while (vim_isdigit(*++s))
|
|
5442 ;
|
|
5443 }
|
|
5444 else if (*s == '!' || *s == 'h' || *s == 'c')
|
7
|
5445 ++s; /* no extra chars */
|
|
5446 else /* must have a number */
|
|
5447 {
|
|
5448 while (vim_isdigit(*++s))
|
|
5449 ;
|
|
5450
|
|
5451 if (!VIM_ISDIGIT(*(s - 1)))
|
|
5452 {
|
|
5453 if (errbuf != NULL)
|
|
5454 {
|
133
|
5455 sprintf((char *)errbuf,
|
|
5456 _("E526: Missing number after <%s>"),
|
7
|
5457 transchar_byte(*(s - 1)));
|
|
5458 errmsg = errbuf;
|
|
5459 }
|
|
5460 else
|
|
5461 errmsg = (char_u *)"";
|
|
5462 break;
|
|
5463 }
|
|
5464 }
|
|
5465 if (*s == ',')
|
|
5466 ++s;
|
|
5467 else if (*s)
|
|
5468 {
|
|
5469 if (errbuf != NULL)
|
|
5470 errmsg = (char_u *)N_("E527: Missing comma");
|
|
5471 else
|
|
5472 errmsg = (char_u *)"";
|
|
5473 break;
|
|
5474 }
|
|
5475 }
|
|
5476 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
|
|
5477 errmsg = (char_u *)N_("E528: Must specify a ' value");
|
|
5478 }
|
|
5479 #endif /* FEAT_VIMINFO */
|
|
5480
|
|
5481 /* terminal options */
|
|
5482 else if (istermoption(&options[opt_idx]) && full_screen)
|
|
5483 {
|
|
5484 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
|
|
5485 if (varp == &T_CCO)
|
|
5486 {
|
|
5487 t_colors = atoi((char *)T_CCO);
|
|
5488 if (t_colors <= 1)
|
|
5489 {
|
|
5490 if (new_value_alloced)
|
|
5491 vim_free(T_CCO);
|
|
5492 T_CCO = empty_option;
|
|
5493 }
|
|
5494 /* We now have a different color setup, initialize it again. */
|
|
5495 init_highlight(TRUE, FALSE);
|
|
5496 }
|
|
5497 ttest(FALSE);
|
|
5498 if (varp == &T_ME)
|
|
5499 {
|
|
5500 out_str(T_ME);
|
|
5501 redraw_later(CLEAR);
|
|
5502 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
|
|
5503 /* Since t_me has been set, this probably means that the user
|
|
5504 * wants to use this as default colors. Need to reset default
|
|
5505 * background/foreground colors. */
|
|
5506 mch_set_normal_colors();
|
|
5507 #endif
|
|
5508 }
|
|
5509 }
|
|
5510
|
|
5511 #ifdef FEAT_LINEBREAK
|
|
5512 /* 'showbreak' */
|
|
5513 else if (varp == &p_sbr)
|
|
5514 {
|
|
5515 for (s = p_sbr; *s; )
|
|
5516 {
|
|
5517 if (ptr2cells(s) != 1)
|
|
5518 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
|
39
|
5519 mb_ptr_adv(s);
|
7
|
5520 }
|
|
5521 }
|
|
5522 #endif
|
|
5523
|
|
5524 #ifdef FEAT_GUI
|
|
5525 /* 'guifont' */
|
|
5526 else if (varp == &p_guifont)
|
|
5527 {
|
|
5528 if (gui.in_use)
|
|
5529 {
|
|
5530 p = p_guifont;
|
11
|
5531 # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
|
7
|
5532 /*
|
|
5533 * Put up a font dialog and let the user select a new value.
|
|
5534 * If this is cancelled go back to the old value but don't
|
|
5535 * give an error message.
|
|
5536 */
|
|
5537 if (STRCMP(p, "*") == 0)
|
|
5538 {
|
|
5539 p = gui_mch_font_dialog(oldval);
|
|
5540
|
|
5541 if (new_value_alloced)
|
|
5542 free_string_option(p_guifont);
|
|
5543
|
|
5544 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
|
|
5545 new_value_alloced = TRUE;
|
|
5546 }
|
|
5547 # endif
|
|
5548 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
|
|
5549 {
|
|
5550 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
|
|
5551 if (STRCMP(p_guifont, "*") == 0)
|
|
5552 {
|
|
5553 /* Dialog was cancelled: Keep the old value without giving
|
|
5554 * an error message. */
|
|
5555 if (new_value_alloced)
|
|
5556 free_string_option(p_guifont);
|
|
5557 p_guifont = vim_strsave(oldval);
|
|
5558 new_value_alloced = TRUE;
|
|
5559 }
|
|
5560 else
|
|
5561 # endif
|
|
5562 errmsg = (char_u *)N_("E596: Invalid font(s)");
|
|
5563 }
|
|
5564 }
|
|
5565 }
|
|
5566 # ifdef FEAT_XFONTSET
|
|
5567 else if (varp == &p_guifontset)
|
|
5568 {
|
|
5569 if (STRCMP(p_guifontset, "*") == 0)
|
|
5570 errmsg = (char_u *)N_("E597: can't select fontset");
|
|
5571 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
|
|
5572 errmsg = (char_u *)N_("E598: Invalid fontset");
|
|
5573 }
|
|
5574 # endif
|
|
5575 # ifdef FEAT_MBYTE
|
|
5576 else if (varp == &p_guifontwide)
|
|
5577 {
|
|
5578 if (STRCMP(p_guifontwide, "*") == 0)
|
|
5579 errmsg = (char_u *)N_("E533: can't select wide font");
|
|
5580 else if (gui_get_wide_font() == FAIL)
|
|
5581 errmsg = (char_u *)N_("E534: Invalid wide font");
|
|
5582 }
|
|
5583 # endif
|
|
5584 #endif
|
|
5585
|
|
5586 #ifdef CURSOR_SHAPE
|
|
5587 /* 'guicursor' */
|
|
5588 else if (varp == &p_guicursor)
|
|
5589 errmsg = parse_shape_opt(SHAPE_CURSOR);
|
|
5590 #endif
|
|
5591
|
|
5592 #ifdef FEAT_MOUSESHAPE
|
|
5593 /* 'mouseshape' */
|
|
5594 else if (varp == &p_mouseshape)
|
|
5595 {
|
|
5596 errmsg = parse_shape_opt(SHAPE_MOUSE);
|
|
5597 update_mouseshape(-1);
|
|
5598 }
|
|
5599 #endif
|
|
5600
|
|
5601 #ifdef FEAT_PRINTER
|
|
5602 else if (varp == &p_popt)
|
440
|
5603 errmsg = parse_printoptions();
|
16
|
5604 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
|
15
|
5605 else if (varp == &p_pmfn)
|
440
|
5606 errmsg = parse_printmbfont();
|
15
|
5607 # endif
|
7
|
5608 #endif
|
|
5609
|
|
5610 #ifdef FEAT_LANGMAP
|
|
5611 /* 'langmap' */
|
|
5612 else if (varp == &p_langmap)
|
|
5613 langmap_set();
|
|
5614 #endif
|
|
5615
|
|
5616 #ifdef FEAT_LINEBREAK
|
|
5617 /* 'breakat' */
|
|
5618 else if (varp == &p_breakat)
|
|
5619 fill_breakat_flags();
|
|
5620 #endif
|
|
5621
|
|
5622 #ifdef FEAT_TITLE
|
|
5623 /* 'titlestring' and 'iconstring' */
|
|
5624 else if (varp == &p_titlestring || varp == &p_iconstring)
|
|
5625 {
|
|
5626 # ifdef FEAT_STL_OPT
|
|
5627 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
|
|
5628
|
|
5629 /* NULL => statusline syntax */
|
|
5630 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
|
|
5631 stl_syntax |= flagval;
|
|
5632 else
|
|
5633 stl_syntax &= ~flagval;
|
|
5634 # endif
|
|
5635 did_set_title(varp == &p_iconstring);
|
|
5636
|
|
5637 }
|
|
5638 #endif
|
|
5639
|
|
5640 #ifdef FEAT_GUI
|
|
5641 /* 'guioptions' */
|
|
5642 else if (varp == &p_go)
|
|
5643 gui_init_which_components(oldval);
|
|
5644 #endif
|
|
5645
|
|
5646 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
|
|
5647 /* 'ttymouse' */
|
|
5648 else if (varp == &p_ttym)
|
|
5649 {
|
190
|
5650 /* Switch the mouse off before changing the escape sequences used for
|
|
5651 * that. */
|
|
5652 mch_setmouse(FALSE);
|
7
|
5653 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
|
|
5654 errmsg = e_invarg;
|
|
5655 else
|
|
5656 check_mouse_termcode();
|
227
|
5657 if (termcap_active)
|
|
5658 setmouse(); /* may switch it on again */
|
7
|
5659 }
|
|
5660 #endif
|
|
5661
|
|
5662 #ifdef FEAT_VISUAL
|
|
5663 /* 'selection' */
|
|
5664 else if (varp == &p_sel)
|
|
5665 {
|
|
5666 if (*p_sel == NUL
|
|
5667 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
|
|
5668 errmsg = e_invarg;
|
|
5669 }
|
|
5670
|
|
5671 /* 'selectmode' */
|
|
5672 else if (varp == &p_slm)
|
|
5673 {
|
|
5674 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
|
|
5675 errmsg = e_invarg;
|
|
5676 }
|
|
5677 #endif
|
|
5678
|
|
5679 #ifdef FEAT_BROWSE
|
|
5680 /* 'browsedir' */
|
|
5681 else if (varp == &p_bsdir)
|
|
5682 {
|
|
5683 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
|
|
5684 && !mch_isdir(p_bsdir))
|
|
5685 errmsg = e_invarg;
|
|
5686 }
|
|
5687 #endif
|
|
5688
|
|
5689 #ifdef FEAT_VISUAL
|
|
5690 /* 'keymodel' */
|
|
5691 else if (varp == &p_km)
|
|
5692 {
|
|
5693 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
|
|
5694 errmsg = e_invarg;
|
|
5695 else
|
|
5696 {
|
|
5697 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
|
|
5698 km_startsel = (vim_strchr(p_km, 'a') != NULL);
|
|
5699 }
|
|
5700 }
|
|
5701 #endif
|
|
5702
|
|
5703 /* 'mousemodel' */
|
|
5704 else if (varp == &p_mousem)
|
|
5705 {
|
|
5706 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
|
|
5707 errmsg = e_invarg;
|
|
5708 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
|
|
5709 else if (*p_mousem != *oldval)
|
|
5710 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
|
|
5711 * to create or delete the popup menus. */
|
|
5712 gui_motif_update_mousemodel(root_menu);
|
|
5713 #endif
|
|
5714 }
|
|
5715
|
|
5716 /* 'switchbuf' */
|
|
5717 else if (varp == &p_swb)
|
|
5718 {
|
|
5719 if (check_opt_strings(p_swb, p_swb_values, TRUE) != OK)
|
|
5720 errmsg = e_invarg;
|
|
5721 }
|
|
5722
|
|
5723 /* 'debug' */
|
|
5724 else if (varp == &p_debug)
|
|
5725 {
|
|
5726 if (check_opt_strings(p_debug, p_debug_values, FALSE) != OK)
|
|
5727 errmsg = e_invarg;
|
|
5728 }
|
|
5729
|
|
5730 /* 'display' */
|
|
5731 else if (varp == &p_dy)
|
|
5732 {
|
|
5733 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
|
|
5734 errmsg = e_invarg;
|
|
5735 else
|
|
5736 (void)init_chartab();
|
|
5737
|
|
5738 }
|
|
5739
|
|
5740 #ifdef FEAT_VERTSPLIT
|
|
5741 /* 'eadirection' */
|
|
5742 else if (varp == &p_ead)
|
|
5743 {
|
|
5744 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
|
|
5745 errmsg = e_invarg;
|
|
5746 }
|
|
5747 #endif
|
|
5748
|
|
5749 #ifdef FEAT_CLIPBOARD
|
|
5750 /* 'clipboard' */
|
|
5751 else if (varp == &p_cb)
|
|
5752 errmsg = check_clipboard_option();
|
|
5753 #endif
|
|
5754
|
221
|
5755 #ifdef FEAT_SYN_HL
|
323
|
5756 /* When 'spelllang' or 'spellfile' is set and there is a window for this
|
|
5757 * buffer in which 'spell' is set load the wordlists. */
|
|
5758 else if (varp == &(curbuf->b_p_spl) || varp == &(curbuf->b_p_spf))
|
221
|
5759 {
|
258
|
5760 win_T *wp;
|
323
|
5761 int l;
|
|
5762
|
|
5763 if (varp == &(curbuf->b_p_spf))
|
|
5764 {
|
|
5765 l = STRLEN(curbuf->b_p_spf);
|
|
5766 if (l > 0 && (l < 4 || STRCMP(curbuf->b_p_spf + l - 4,
|
|
5767 ".add") != 0))
|
|
5768 errmsg = e_invarg;
|
|
5769 }
|
|
5770
|
|
5771 if (errmsg == NULL)
|
|
5772 {
|
|
5773 FOR_ALL_WINDOWS(wp)
|
|
5774 if (wp->w_buffer == curbuf && wp->w_p_spell)
|
|
5775 {
|
|
5776 errmsg = did_set_spelllang(curbuf);
|
258
|
5777 # ifdef FEAT_WINDOWS
|
323
|
5778 break;
|
258
|
5779 # endif
|
323
|
5780 }
|
|
5781 }
|
221
|
5782 }
|
386
|
5783 /* When 'spellcapcheck' is set compile the regexp program. */
|
|
5784 else if (varp == &(curbuf->b_p_spc))
|
|
5785 {
|
389
|
5786 errmsg = compile_cap_prog(curbuf);
|
386
|
5787 }
|
344
|
5788 /* 'spellsuggest' */
|
|
5789 else if (varp == &p_sps)
|
|
5790 {
|
374
|
5791 if (spell_check_sps() != OK)
|
344
|
5792 errmsg = e_invarg;
|
|
5793 }
|
221
|
5794 #endif
|
|
5795
|
7
|
5796 #ifdef FEAT_AUTOCMD
|
|
5797 # ifdef FEAT_SYN_HL
|
|
5798 /* When 'syntax' is set, load the syntax of that name */
|
|
5799 else if (varp == &(curbuf->b_p_syn))
|
|
5800 {
|
|
5801 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
|
|
5802 curbuf->b_fname, TRUE, curbuf);
|
|
5803 }
|
|
5804 # endif
|
|
5805
|
|
5806 /* When 'filetype' is set, trigger the FileType autocommands of that name */
|
|
5807 else if (varp == &(curbuf->b_p_ft))
|
|
5808 {
|
|
5809 did_filetype = TRUE;
|
|
5810 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
|
|
5811 curbuf->b_fname, TRUE, curbuf);
|
|
5812 }
|
|
5813 #endif
|
|
5814
|
|
5815 #ifdef FEAT_QUICKFIX
|
|
5816 /* When 'bufhidden' is set, check for valid value. */
|
|
5817 else if (gvarp == &p_bh)
|
|
5818 {
|
|
5819 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
|
|
5820 errmsg = e_invarg;
|
|
5821 }
|
|
5822
|
|
5823 /* When 'buftype' is set, check for valid value. */
|
|
5824 else if (gvarp == &p_bt)
|
|
5825 {
|
|
5826 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
|
|
5827 errmsg = e_invarg;
|
|
5828 else
|
|
5829 {
|
|
5830 # ifdef FEAT_WINDOWS
|
|
5831 if (curwin->w_status_height)
|
|
5832 {
|
|
5833 curwin->w_redr_status = TRUE;
|
|
5834 redraw_later(VALID);
|
|
5835 }
|
|
5836 # endif
|
|
5837 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
|
|
5838 }
|
|
5839 }
|
|
5840 #endif
|
|
5841
|
|
5842 #ifdef FEAT_STL_OPT
|
|
5843 /* 'statusline' or 'rulerformat' */
|
40
|
5844 else if (gvarp == &p_stl || varp == &p_ruf)
|
7
|
5845 {
|
|
5846 int wid;
|
|
5847
|
|
5848 if (varp == &p_ruf) /* reset ru_wid first */
|
|
5849 ru_wid = 0;
|
|
5850 s = *varp;
|
|
5851 if (varp == &p_ruf && *s == '%')
|
|
5852 {
|
|
5853 /* set ru_wid if 'ruf' starts with "%99(" */
|
|
5854 if (*++s == '-') /* ignore a '-' */
|
|
5855 s++;
|
|
5856 wid = getdigits(&s);
|
|
5857 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
|
|
5858 ru_wid = wid;
|
|
5859 else
|
|
5860 errmsg = check_stl_option(p_ruf);
|
|
5861 }
|
|
5862 else
|
|
5863 errmsg = check_stl_option(s);
|
40
|
5864 if (varp == &p_ruf && errmsg == NULL)
|
7
|
5865 comp_col();
|
|
5866 }
|
|
5867 #endif
|
|
5868
|
|
5869 #ifdef FEAT_INS_EXPAND
|
|
5870 /* check if it is a valid value for 'complete' -- Acevedo */
|
|
5871 else if (gvarp == &p_cpt)
|
|
5872 {
|
|
5873 for (s = *varp; *s;)
|
|
5874 {
|
|
5875 while(*s == ',' || *s == ' ')
|
|
5876 s++;
|
|
5877 if (!*s)
|
|
5878 break;
|
|
5879 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
|
|
5880 {
|
|
5881 errmsg = illegal_char(errbuf, *s);
|
|
5882 break;
|
|
5883 }
|
|
5884 if (*++s != NUL && *s != ',' && *s != ' ')
|
|
5885 {
|
|
5886 if (s[-1] == 'k' || s[-1] == 's')
|
|
5887 {
|
|
5888 /* skip optional filename after 'k' and 's' */
|
|
5889 while (*s && *s != ',' && *s != ' ')
|
|
5890 {
|
|
5891 if (*s == '\\')
|
|
5892 ++s;
|
|
5893 ++s;
|
|
5894 }
|
|
5895 }
|
|
5896 else
|
|
5897 {
|
|
5898 if (errbuf != NULL)
|
|
5899 {
|
|
5900 sprintf((char *)errbuf,
|
|
5901 _("E535: Illegal character after <%c>"),
|
|
5902 *--s);
|
|
5903 errmsg = errbuf;
|
|
5904 }
|
|
5905 else
|
|
5906 errmsg = (char_u *)"";
|
|
5907 break;
|
|
5908 }
|
|
5909 }
|
|
5910 }
|
|
5911 }
|
|
5912 #endif /* FEAT_INS_EXPAND */
|
|
5913
|
|
5914
|
|
5915 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
|
|
5916 else if (varp == &p_toolbar)
|
|
5917 {
|
|
5918 if (opt_strings_flags(p_toolbar, p_toolbar_values,
|
|
5919 &toolbar_flags, TRUE) != OK)
|
|
5920 errmsg = e_invarg;
|
|
5921 else
|
|
5922 {
|
|
5923 out_flush();
|
|
5924 gui_mch_show_toolbar((toolbar_flags &
|
|
5925 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
|
|
5926 }
|
|
5927 }
|
|
5928 #endif
|
|
5929
|
|
5930 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
|
|
5931 /* 'toolbariconsize': GTK+ 2 only */
|
|
5932 else if (varp == &p_tbis)
|
|
5933 {
|
|
5934 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
|
|
5935 errmsg = e_invarg;
|
|
5936 else
|
|
5937 {
|
|
5938 out_flush();
|
|
5939 gui_mch_show_toolbar((toolbar_flags &
|
|
5940 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
|
|
5941 }
|
|
5942 }
|
|
5943 #endif
|
|
5944
|
|
5945 /* 'pastetoggle': translate key codes like in a mapping */
|
|
5946 else if (varp == &p_pt)
|
|
5947 {
|
|
5948 if (*p_pt)
|
|
5949 {
|
|
5950 (void)replace_termcodes(p_pt, &p, TRUE, TRUE);
|
|
5951 if (p != NULL)
|
|
5952 {
|
|
5953 if (new_value_alloced)
|
|
5954 free_string_option(p_pt);
|
|
5955 p_pt = p;
|
|
5956 new_value_alloced = TRUE;
|
|
5957 }
|
|
5958 }
|
|
5959 }
|
|
5960
|
|
5961 /* 'backspace' */
|
|
5962 else if (varp == &p_bs)
|
|
5963 {
|
|
5964 if (VIM_ISDIGIT(*p_bs))
|
|
5965 {
|
|
5966 if (*p_bs >'2' || p_bs[1] != NUL)
|
|
5967 errmsg = e_invarg;
|
|
5968 }
|
|
5969 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
|
|
5970 errmsg = e_invarg;
|
|
5971 }
|
|
5972
|
|
5973 /* 'casemap' */
|
|
5974 else if (varp == &p_cmp)
|
|
5975 {
|
|
5976 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
|
|
5977 errmsg = e_invarg;
|
|
5978 }
|
|
5979
|
|
5980 #ifdef FEAT_DIFF
|
|
5981 /* 'diffopt' */
|
|
5982 else if (varp == &p_dip)
|
|
5983 {
|
|
5984 if (diffopt_changed() == FAIL)
|
|
5985 errmsg = e_invarg;
|
|
5986 }
|
|
5987 #endif
|
|
5988
|
|
5989 #ifdef FEAT_FOLDING
|
|
5990 /* 'foldmethod' */
|
|
5991 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
|
|
5992 {
|
|
5993 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
|
|
5994 || *curwin->w_p_fdm == NUL)
|
|
5995 errmsg = e_invarg;
|
|
5996 else
|
|
5997 foldUpdateAll(curwin);
|
|
5998 }
|
|
5999 # ifdef FEAT_EVAL
|
|
6000 /* 'foldexpr' */
|
|
6001 else if (varp == &curwin->w_p_fde)
|
|
6002 {
|
|
6003 if (foldmethodIsExpr(curwin))
|
|
6004 foldUpdateAll(curwin);
|
|
6005 }
|
|
6006 # endif
|
|
6007 /* 'foldmarker' */
|
|
6008 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
|
|
6009 {
|
|
6010 p = vim_strchr(*varp, ',');
|
|
6011 if (p == NULL)
|
|
6012 errmsg = (char_u *)N_("E536: comma required");
|
|
6013 else if (p == *varp || p[1] == NUL)
|
|
6014 errmsg = e_invarg;
|
|
6015 else if (foldmethodIsMarker(curwin))
|
|
6016 foldUpdateAll(curwin);
|
|
6017 }
|
|
6018 /* 'commentstring' */
|
|
6019 else if (gvarp == &p_cms)
|
|
6020 {
|
|
6021 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
|
|
6022 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
|
|
6023 }
|
|
6024 /* 'foldopen' */
|
|
6025 else if (varp == &p_fdo)
|
|
6026 {
|
|
6027 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
|
|
6028 errmsg = e_invarg;
|
|
6029 }
|
|
6030 /* 'foldclose' */
|
|
6031 else if (varp == &p_fcl)
|
|
6032 {
|
|
6033 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
|
|
6034 errmsg = e_invarg;
|
|
6035 }
|
|
6036 #endif
|
|
6037
|
|
6038 #ifdef FEAT_VIRTUALEDIT
|
|
6039 /* 'virtualedit' */
|
|
6040 else if (varp == &p_ve)
|
|
6041 {
|
|
6042 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
|
|
6043 errmsg = e_invarg;
|
|
6044 else if (STRCMP(p_ve, oldval) != 0)
|
|
6045 {
|
|
6046 /* Recompute cursor position in case the new 've' setting
|
|
6047 * changes something. */
|
|
6048 validate_virtcol();
|
|
6049 coladvance(curwin->w_virtcol);
|
|
6050 }
|
|
6051 }
|
|
6052 #endif
|
|
6053
|
|
6054 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
|
|
6055 else if (varp == &p_csqf)
|
|
6056 {
|
|
6057 if (p_csqf != NULL)
|
|
6058 {
|
|
6059 p = p_csqf;
|
|
6060 while (*p != NUL)
|
|
6061 {
|
|
6062 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
|
|
6063 || p[1] == NUL
|
|
6064 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
|
|
6065 || (p[2] != NUL && p[2] != ','))
|
|
6066 {
|
|
6067 errmsg = e_invarg;
|
|
6068 break;
|
|
6069 }
|
|
6070 else if (p[2] == NUL)
|
|
6071 break;
|
|
6072 else
|
|
6073 p += 3;
|
|
6074 }
|
|
6075 }
|
|
6076 }
|
|
6077 #endif
|
|
6078
|
|
6079 /* Options that are a list of flags. */
|
|
6080 else
|
|
6081 {
|
|
6082 p = NULL;
|
|
6083 if (varp == &p_ww)
|
|
6084 p = (char_u *)WW_ALL;
|
|
6085 if (varp == &p_shm)
|
|
6086 p = (char_u *)SHM_ALL;
|
|
6087 else if (varp == &(p_cpo))
|
|
6088 p = (char_u *)CPO_ALL;
|
|
6089 else if (varp == &(curbuf->b_p_fo))
|
|
6090 p = (char_u *)FO_ALL;
|
|
6091 else if (varp == &p_mouse)
|
|
6092 {
|
|
6093 #ifdef FEAT_MOUSE
|
|
6094 p = (char_u *)MOUSE_ALL;
|
|
6095 #else
|
|
6096 if (*p_mouse != NUL)
|
|
6097 errmsg = (char_u *)N_("E538: No mouse support");
|
|
6098 #endif
|
|
6099 }
|
|
6100 #if defined(FEAT_GUI)
|
|
6101 else if (varp == &p_go)
|
|
6102 p = (char_u *)GO_ALL;
|
|
6103 #endif
|
|
6104 if (p != NULL)
|
|
6105 {
|
|
6106 for (s = *varp; *s; ++s)
|
|
6107 if (vim_strchr(p, *s) == NULL)
|
|
6108 {
|
|
6109 errmsg = illegal_char(errbuf, *s);
|
|
6110 break;
|
|
6111 }
|
|
6112 }
|
|
6113 }
|
|
6114
|
|
6115 /*
|
|
6116 * If error detected, restore the previous value.
|
|
6117 */
|
|
6118 if (errmsg != NULL)
|
|
6119 {
|
|
6120 if (new_value_alloced)
|
|
6121 free_string_option(*varp);
|
|
6122 *varp = oldval;
|
|
6123 /*
|
|
6124 * When resetting some values, need to act on it.
|
|
6125 */
|
|
6126 if (did_chartab)
|
|
6127 (void)init_chartab();
|
|
6128 if (varp == &p_hl)
|
|
6129 (void)highlight_changed();
|
|
6130 }
|
|
6131 else
|
|
6132 {
|
|
6133 #ifdef FEAT_EVAL
|
|
6134 /* Remember where the option was set. */
|
|
6135 options[opt_idx].scriptID = current_SID;
|
|
6136 #endif
|
|
6137 /*
|
|
6138 * Free string options that are in allocated memory.
|
24
|
6139 * Use "free_oldval", because recursiveness may change the flags under
|
|
6140 * our fingers (esp. init_highlight()).
|
7
|
6141 */
|
24
|
6142 if (free_oldval)
|
7
|
6143 free_string_option(oldval);
|
|
6144 if (new_value_alloced)
|
|
6145 options[opt_idx].flags |= P_ALLOCED;
|
|
6146 else
|
|
6147 options[opt_idx].flags &= ~P_ALLOCED;
|
|
6148
|
|
6149 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
|
6150 && (int)options[opt_idx].indir >= PV_BOTH)
|
|
6151 {
|
|
6152 /* global option with local value set to use global value; free
|
|
6153 * the local value and make it empty */
|
|
6154 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
|
|
6155 free_string_option(*(char_u **)p);
|
|
6156 *(char_u **)p = empty_option;
|
|
6157 }
|
|
6158
|
|
6159 /* May set global value for local option. */
|
|
6160 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
|
|
6161 set_string_option_global(opt_idx, varp);
|
|
6162 }
|
|
6163
|
|
6164 #ifdef FEAT_MOUSE
|
|
6165 if (varp == &p_mouse)
|
|
6166 {
|
|
6167 # ifdef FEAT_MOUSE_TTY
|
|
6168 if (*p_mouse == NUL)
|
|
6169 mch_setmouse(FALSE); /* switch mouse off */
|
|
6170 else
|
|
6171 # endif
|
|
6172 setmouse(); /* in case 'mouse' changed */
|
|
6173 }
|
|
6174 #endif
|
|
6175
|
|
6176 if (curwin->w_curswant != MAXCOL)
|
|
6177 curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */
|
|
6178 check_redraw(options[opt_idx].flags);
|
|
6179
|
|
6180 return errmsg;
|
|
6181 }
|
|
6182
|
|
6183 /*
|
|
6184 * Handle setting 'listchars' or 'fillchars'.
|
|
6185 * Returns error message, NULL if it's OK.
|
|
6186 */
|
|
6187 static char_u *
|
|
6188 set_chars_option(varp)
|
|
6189 char_u **varp;
|
|
6190 {
|
|
6191 int round, i, len, entries;
|
|
6192 char_u *p, *s;
|
|
6193 int c1, c2 = 0;
|
|
6194 struct charstab
|
|
6195 {
|
|
6196 int *cp;
|
|
6197 char *name;
|
|
6198 };
|
|
6199 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6200 static struct charstab filltab[] =
|
|
6201 {
|
|
6202 {&fill_stl, "stl"},
|
|
6203 {&fill_stlnc, "stlnc"},
|
|
6204 {&fill_vert, "vert"},
|
|
6205 {&fill_fold, "fold"},
|
|
6206 {&fill_diff, "diff"},
|
|
6207 };
|
|
6208 #endif
|
|
6209 static struct charstab lcstab[] =
|
|
6210 {
|
|
6211 {&lcs_eol, "eol"},
|
|
6212 {&lcs_ext, "extends"},
|
12
|
6213 {&lcs_nbsp, "nbsp"},
|
7
|
6214 {&lcs_prec, "precedes"},
|
|
6215 {&lcs_tab2, "tab"},
|
|
6216 {&lcs_trail, "trail"},
|
|
6217 };
|
|
6218 struct charstab *tab;
|
|
6219
|
|
6220 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6221 if (varp == &p_lcs)
|
|
6222 #endif
|
|
6223 {
|
|
6224 tab = lcstab;
|
|
6225 entries = sizeof(lcstab) / sizeof(struct charstab);
|
|
6226 }
|
|
6227 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6228 else
|
|
6229 {
|
|
6230 tab = filltab;
|
|
6231 entries = sizeof(filltab) / sizeof(struct charstab);
|
|
6232 }
|
|
6233 #endif
|
|
6234
|
|
6235 /* first round: check for valid value, second round: assign values */
|
|
6236 for (round = 0; round <= 1; ++round)
|
|
6237 {
|
|
6238 if (round)
|
|
6239 {
|
|
6240 /* After checking that the value is valid: set defaults: space for
|
|
6241 * 'fillchars', NUL for 'listchars' */
|
|
6242 for (i = 0; i < entries; ++i)
|
|
6243 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
|
|
6244 if (varp == &p_lcs)
|
|
6245 lcs_tab1 = NUL;
|
|
6246 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
|
|
6247 else
|
|
6248 fill_diff = '-';
|
|
6249 #endif
|
|
6250 }
|
|
6251 p = *varp;
|
|
6252 while (*p)
|
|
6253 {
|
|
6254 for (i = 0; i < entries; ++i)
|
|
6255 {
|
|
6256 len = (int)STRLEN(tab[i].name);
|
|
6257 if (STRNCMP(p, tab[i].name, len) == 0
|
|
6258 && p[len] == ':'
|
|
6259 && p[len + 1] != NUL)
|
|
6260 {
|
|
6261 s = p + len + 1;
|
|
6262 #ifdef FEAT_MBYTE
|
|
6263 c1 = mb_ptr2char_adv(&s);
|
|
6264 #else
|
|
6265 c1 = *s++;
|
|
6266 #endif
|
|
6267 if (tab[i].cp == &lcs_tab2)
|
|
6268 {
|
|
6269 if (*s == NUL)
|
|
6270 continue;
|
|
6271 #ifdef FEAT_MBYTE
|
|
6272 c2 = mb_ptr2char_adv(&s);
|
|
6273 #else
|
|
6274 c2 = *s++;
|
|
6275 #endif
|
|
6276 }
|
|
6277 if (*s == ',' || *s == NUL)
|
|
6278 {
|
|
6279 if (round)
|
|
6280 {
|
|
6281 if (tab[i].cp == &lcs_tab2)
|
|
6282 {
|
|
6283 lcs_tab1 = c1;
|
|
6284 lcs_tab2 = c2;
|
|
6285 }
|
|
6286 else
|
|
6287 *(tab[i].cp) = c1;
|
|
6288
|
|
6289 }
|
|
6290 p = s;
|
|
6291 break;
|
|
6292 }
|
|
6293 }
|
|
6294 }
|
|
6295
|
|
6296 if (i == entries)
|
|
6297 return e_invarg;
|
|
6298 if (*p == ',')
|
|
6299 ++p;
|
|
6300 }
|
|
6301 }
|
|
6302
|
|
6303 return NULL; /* no error */
|
|
6304 }
|
|
6305
|
|
6306 #ifdef FEAT_STL_OPT
|
|
6307 /*
|
|
6308 * Check validity of options with the 'statusline' format.
|
|
6309 * Return error message or NULL.
|
|
6310 */
|
|
6311 char_u *
|
|
6312 check_stl_option(s)
|
|
6313 char_u *s;
|
|
6314 {
|
|
6315 int itemcnt = 0;
|
|
6316 int groupdepth = 0;
|
|
6317 static char_u errbuf[80];
|
|
6318
|
|
6319 while (*s && itemcnt < STL_MAX_ITEM)
|
|
6320 {
|
|
6321 /* Check for valid keys after % sequences */
|
|
6322 while (*s && *s != '%')
|
|
6323 s++;
|
|
6324 if (!*s)
|
|
6325 break;
|
|
6326 s++;
|
|
6327 if (*s != '%' && *s != ')')
|
|
6328 ++itemcnt;
|
|
6329 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
|
|
6330 {
|
|
6331 s++;
|
|
6332 continue;
|
|
6333 }
|
|
6334 if (*s == ')')
|
|
6335 {
|
|
6336 s++;
|
|
6337 if (--groupdepth < 0)
|
|
6338 break;
|
|
6339 continue;
|
|
6340 }
|
|
6341 if (*s == '-')
|
|
6342 s++;
|
|
6343 while (VIM_ISDIGIT(*s))
|
|
6344 s++;
|
|
6345 if (*s == STL_HIGHLIGHT)
|
|
6346 continue;
|
|
6347 if (*s == '.')
|
|
6348 {
|
|
6349 s++;
|
|
6350 while (*s && VIM_ISDIGIT(*s))
|
|
6351 s++;
|
|
6352 }
|
|
6353 if (*s == '(')
|
|
6354 {
|
|
6355 groupdepth++;
|
|
6356 continue;
|
|
6357 }
|
|
6358 if (vim_strchr(STL_ALL, *s) == NULL)
|
|
6359 {
|
|
6360 return illegal_char(errbuf, *s);
|
|
6361 }
|
|
6362 if (*s == '{')
|
|
6363 {
|
|
6364 s++;
|
|
6365 while (*s != '}' && *s)
|
|
6366 s++;
|
|
6367 if (*s != '}')
|
|
6368 return (char_u *)N_("E540: Unclosed expression sequence");
|
|
6369 }
|
|
6370 }
|
|
6371 if (itemcnt >= STL_MAX_ITEM)
|
|
6372 return (char_u *)N_("E541: too many items");
|
|
6373 if (groupdepth != 0)
|
|
6374 return (char_u *)N_("E542: unbalanced groups");
|
|
6375 return NULL;
|
|
6376 }
|
|
6377 #endif
|
|
6378
|
|
6379 #ifdef FEAT_CLIPBOARD
|
|
6380 /*
|
|
6381 * Extract the items in the 'clipboard' option and set global values.
|
|
6382 */
|
|
6383 static char_u *
|
|
6384 check_clipboard_option()
|
|
6385 {
|
|
6386 int new_unnamed = FALSE;
|
|
6387 int new_autoselect = FALSE;
|
|
6388 int new_autoselectml = FALSE;
|
|
6389 regprog_T *new_exclude_prog = NULL;
|
|
6390 char_u *errmsg = NULL;
|
|
6391 char_u *p;
|
|
6392
|
|
6393 for (p = p_cb; *p != NUL; )
|
|
6394 {
|
|
6395 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
|
|
6396 {
|
|
6397 new_unnamed = TRUE;
|
|
6398 p += 7;
|
|
6399 }
|
|
6400 else if (STRNCMP(p, "autoselect", 10) == 0
|
|
6401 && (p[10] == ',' || p[10] == NUL))
|
|
6402 {
|
|
6403 new_autoselect = TRUE;
|
|
6404 p += 10;
|
|
6405 }
|
|
6406 else if (STRNCMP(p, "autoselectml", 12) == 0
|
|
6407 && (p[12] == ',' || p[12] == NUL))
|
|
6408 {
|
|
6409 new_autoselectml = TRUE;
|
|
6410 p += 12;
|
|
6411 }
|
|
6412 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
|
|
6413 {
|
|
6414 p += 8;
|
|
6415 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
|
|
6416 if (new_exclude_prog == NULL)
|
|
6417 errmsg = e_invarg;
|
|
6418 break;
|
|
6419 }
|
|
6420 else
|
|
6421 {
|
|
6422 errmsg = e_invarg;
|
|
6423 break;
|
|
6424 }
|
|
6425 if (*p == ',')
|
|
6426 ++p;
|
|
6427 }
|
|
6428 if (errmsg == NULL)
|
|
6429 {
|
|
6430 clip_unnamed = new_unnamed;
|
|
6431 clip_autoselect = new_autoselect;
|
|
6432 clip_autoselectml = new_autoselectml;
|
|
6433 vim_free(clip_exclude_prog);
|
|
6434 clip_exclude_prog = new_exclude_prog;
|
|
6435 }
|
|
6436 else
|
|
6437 vim_free(new_exclude_prog);
|
|
6438
|
|
6439 return errmsg;
|
|
6440 }
|
|
6441 #endif
|
|
6442
|
386
|
6443 #ifdef FEAT_SYN_HL
|
|
6444 /*
|
|
6445 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
|
|
6446 * Return error message when failed, NULL when OK.
|
|
6447 */
|
|
6448 static char_u *
|
389
|
6449 compile_cap_prog(buf)
|
|
6450 buf_T *buf;
|
386
|
6451 {
|
389
|
6452 regprog_T *rp = buf->b_cap_prog;
|
|
6453
|
|
6454 if (*buf->b_p_spc == NUL)
|
|
6455 {
|
|
6456 buf->b_cap_prog = NULL;
|
386
|
6457 vim_free(rp);
|
|
6458 return NULL;
|
|
6459 }
|
|
6460
|
|
6461 /* Prepend a ^ so that we only match at one column */
|
389
|
6462 vim_snprintf((char *)IObuff, IOSIZE, "^%s", buf->b_p_spc);
|
|
6463 buf->b_cap_prog = vim_regcomp(IObuff, RE_MAGIC);
|
|
6464 if (buf->b_cap_prog == NULL)
|
|
6465 {
|
|
6466 buf->b_cap_prog = rp;
|
386
|
6467 return e_invarg;
|
|
6468 }
|
|
6469
|
|
6470 vim_free(rp);
|
|
6471 return NULL;
|
|
6472 }
|
|
6473 #endif
|
|
6474
|
7
|
6475 /*
|
|
6476 * Set the value of a boolean option, and take care of side effects.
|
|
6477 * Returns NULL for success, or an error message for an error.
|
|
6478 */
|
|
6479 static char_u *
|
|
6480 set_bool_option(opt_idx, varp, value, opt_flags)
|
|
6481 int opt_idx; /* index in options[] table */
|
|
6482 char_u *varp; /* pointer to the option variable */
|
|
6483 int value; /* new value */
|
|
6484 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
6485 {
|
|
6486 int old_value = *(int *)varp;
|
|
6487
|
|
6488 #ifdef FEAT_GUI
|
|
6489 need_mouse_correct = TRUE;
|
|
6490 #endif
|
|
6491
|
|
6492 /* Disallow changing some options from secure mode */
|
|
6493 if ((secure
|
|
6494 #ifdef HAVE_SANDBOX
|
|
6495 || sandbox != 0
|
|
6496 #endif
|
|
6497 ) && (options[opt_idx].flags & P_SECURE))
|
|
6498 return e_secure;
|
|
6499
|
|
6500 *(int *)varp = value; /* set the new value */
|
|
6501 #ifdef FEAT_EVAL
|
|
6502 /* Remember where the option was set. */
|
|
6503 options[opt_idx].scriptID = current_SID;
|
|
6504 #endif
|
|
6505
|
|
6506 /* May set global value for local option. */
|
|
6507 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
6508 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
|
|
6509
|
|
6510 /*
|
|
6511 * Handle side effects of changing a bool option.
|
|
6512 */
|
|
6513
|
|
6514 /* 'compatible' */
|
|
6515 if ((int *)varp == &p_cp)
|
|
6516 {
|
|
6517 compatible_set();
|
|
6518 }
|
|
6519
|
|
6520 /* when 'readonly' is reset globally, also reset readonlymode */
|
|
6521 else if ((int *)varp == &curbuf->b_p_ro)
|
|
6522 {
|
|
6523 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
|
|
6524 readonlymode = FALSE;
|
|
6525 #ifdef FEAT_TITLE
|
|
6526 need_maketitle = TRUE;
|
|
6527 #endif
|
|
6528 }
|
|
6529
|
|
6530 #ifdef FEAT_TITLE
|
|
6531 /* when 'modifiable' is changed, redraw the window title */
|
|
6532 else if ((int *)varp == &curbuf->b_p_ma)
|
|
6533 need_maketitle = TRUE;
|
|
6534 /* when 'endofline' is changed, redraw the window title */
|
|
6535 else if ((int *)varp == &curbuf->b_p_eol)
|
|
6536 need_maketitle = TRUE;
|
|
6537 #endif
|
|
6538
|
|
6539 /* when 'bin' is set also set some other options */
|
|
6540 else if ((int *)varp == &curbuf->b_p_bin)
|
|
6541 {
|
|
6542 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
|
|
6543 #ifdef FEAT_TITLE
|
|
6544 need_maketitle = TRUE;
|
|
6545 #endif
|
|
6546 }
|
|
6547
|
|
6548 #ifdef FEAT_AUTOCMD
|
|
6549 /* when 'buflisted' changes, trigger autocommands */
|
|
6550 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
|
|
6551 {
|
|
6552 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
|
|
6553 NULL, NULL, TRUE, curbuf);
|
|
6554 }
|
|
6555 #endif
|
|
6556
|
|
6557 /* when 'swf' is set, create swapfile, when reset remove swapfile */
|
|
6558 else if ((int *)varp == &curbuf->b_p_swf)
|
|
6559 {
|
|
6560 if (curbuf->b_p_swf && p_uc)
|
|
6561 ml_open_file(curbuf); /* create the swap file */
|
|
6562 else
|
|
6563 mf_close_file(curbuf, TRUE); /* remove the swap file */
|
|
6564 }
|
|
6565
|
|
6566 /* when 'terse' is set change 'shortmess' */
|
|
6567 else if ((int *)varp == &p_terse)
|
|
6568 {
|
|
6569 char_u *p;
|
|
6570
|
|
6571 p = vim_strchr(p_shm, SHM_SEARCH);
|
|
6572
|
|
6573 /* insert 's' in p_shm */
|
|
6574 if (p_terse && p == NULL)
|
|
6575 {
|
|
6576 STRCPY(IObuff, p_shm);
|
|
6577 STRCAT(IObuff, "s");
|
|
6578 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE);
|
|
6579 }
|
|
6580 /* remove 's' from p_shm */
|
|
6581 else if (!p_terse && p != NULL)
|
|
6582 mch_memmove(p, p + 1, STRLEN(p));
|
|
6583 }
|
|
6584
|
|
6585 /* when 'paste' is set or reset also change other options */
|
|
6586 else if ((int *)varp == &p_paste)
|
|
6587 {
|
|
6588 paste_option_changed();
|
|
6589 }
|
|
6590
|
|
6591 /* when 'insertmode' is set from an autocommand need to do work here */
|
|
6592 else if ((int *)varp == &p_im)
|
|
6593 {
|
|
6594 if (p_im)
|
|
6595 {
|
|
6596 if ((State & INSERT) == 0)
|
|
6597 need_start_insertmode = TRUE;
|
|
6598 stop_insert_mode = FALSE;
|
|
6599 }
|
|
6600 else
|
|
6601 {
|
|
6602 need_start_insertmode = FALSE;
|
|
6603 stop_insert_mode = TRUE;
|
|
6604 if (p_smd && restart_edit != 0)
|
|
6605 clear_cmdline = TRUE; /* remove "(insert)" */
|
|
6606 restart_edit = 0;
|
|
6607 }
|
|
6608 }
|
|
6609
|
|
6610 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
|
|
6611 else if ((int *)varp == &p_ic && p_hls)
|
|
6612 {
|
|
6613 redraw_all_later(NOT_VALID);
|
|
6614 }
|
|
6615
|
|
6616 #ifdef FEAT_SEARCH_EXTRA
|
|
6617 /* when 'hlsearch' is set or reset: reset no_hlsearch */
|
|
6618 else if ((int *)varp == &p_hls)
|
|
6619 {
|
|
6620 no_hlsearch = FALSE;
|
|
6621 }
|
|
6622 #endif
|
|
6623
|
|
6624 #ifdef FEAT_SCROLLBIND
|
|
6625 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
|
|
6626 * at the end of normal_cmd() */
|
|
6627 else if ((int *)varp == &curwin->w_p_scb)
|
|
6628 {
|
|
6629 if (curwin->w_p_scb)
|
|
6630 do_check_scrollbind(FALSE);
|
|
6631 }
|
|
6632 #endif
|
|
6633
|
|
6634 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
|
6635 /* There can be only one window with 'previewwindow' set. */
|
|
6636 else if ((int *)varp == &curwin->w_p_pvw)
|
|
6637 {
|
|
6638 if (curwin->w_p_pvw)
|
|
6639 {
|
|
6640 win_T *win;
|
|
6641
|
|
6642 for (win = firstwin; win != NULL; win = win->w_next)
|
|
6643 if (win->w_p_pvw && win != curwin)
|
|
6644 {
|
|
6645 curwin->w_p_pvw = FALSE;
|
|
6646 return (char_u *)N_("E590: A preview window already exists");
|
|
6647 }
|
|
6648 }
|
|
6649 }
|
|
6650 #endif
|
|
6651
|
|
6652 /* when 'textmode' is set or reset also change 'fileformat' */
|
|
6653 else if ((int *)varp == &curbuf->b_p_tx)
|
|
6654 {
|
|
6655 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
|
|
6656 }
|
|
6657
|
|
6658 /* when 'textauto' is set or reset also change 'fileformats' */
|
|
6659 else if ((int *)varp == &p_ta)
|
|
6660 {
|
|
6661 set_string_option_direct((char_u *)"ffs", -1,
|
|
6662 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
|
|
6663 OPT_FREE | opt_flags);
|
|
6664 }
|
|
6665
|
|
6666 /*
|
|
6667 * When 'lisp' option changes include/exclude '-' in
|
|
6668 * keyword characters.
|
|
6669 */
|
|
6670 #ifdef FEAT_LISP
|
|
6671 else if (varp == (char_u *)&(curbuf->b_p_lisp))
|
|
6672 {
|
|
6673 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
|
|
6674 }
|
|
6675 #endif
|
|
6676
|
|
6677 #ifdef FEAT_TITLE
|
|
6678 /* when 'title' changed, may need to change the title; same for 'icon' */
|
|
6679 else if ((int *)varp == &p_title)
|
|
6680 {
|
|
6681 did_set_title(FALSE);
|
|
6682 }
|
|
6683
|
|
6684 else if ((int *)varp == &p_icon)
|
|
6685 {
|
|
6686 did_set_title(TRUE);
|
|
6687 }
|
|
6688 #endif
|
|
6689
|
|
6690 else if ((int *)varp == &curbuf->b_changed)
|
|
6691 {
|
|
6692 if (!value)
|
|
6693 save_file_ff(curbuf); /* Buffer is unchanged */
|
|
6694 #ifdef FEAT_TITLE
|
|
6695 need_maketitle = TRUE;
|
|
6696 #endif
|
|
6697 #ifdef FEAT_AUTOCMD
|
|
6698 modified_was_set = value;
|
|
6699 #endif
|
|
6700 }
|
|
6701
|
|
6702 #ifdef BACKSLASH_IN_FILENAME
|
|
6703 else if ((int *)varp == &p_ssl)
|
|
6704 {
|
|
6705 if (p_ssl)
|
|
6706 {
|
|
6707 psepc = '/';
|
|
6708 psepcN = '\\';
|
|
6709 pseps[0] = '/';
|
|
6710 }
|
|
6711 else
|
|
6712 {
|
|
6713 psepc = '\\';
|
|
6714 psepcN = '/';
|
|
6715 pseps[0] = '\\';
|
|
6716 }
|
|
6717
|
|
6718 /* need to adjust the file name arguments and buffer names. */
|
|
6719 buflist_slash_adjust();
|
|
6720 alist_slash_adjust();
|
|
6721 # ifdef FEAT_EVAL
|
|
6722 scriptnames_slash_adjust();
|
|
6723 # endif
|
|
6724 }
|
|
6725 #endif
|
|
6726
|
|
6727 /* If 'wrap' is set, set w_leftcol to zero. */
|
|
6728 else if ((int *)varp == &curwin->w_p_wrap)
|
|
6729 {
|
|
6730 if (curwin->w_p_wrap)
|
|
6731 curwin->w_leftcol = 0;
|
|
6732 }
|
|
6733
|
|
6734 #ifdef FEAT_WINDOWS
|
|
6735 else if ((int *)varp == &p_ea)
|
|
6736 {
|
|
6737 if (p_ea && !old_value)
|
|
6738 win_equal(curwin, FALSE, 0);
|
|
6739 }
|
|
6740 #endif
|
|
6741
|
|
6742 else if ((int *)varp == &p_wiv)
|
|
6743 {
|
|
6744 /*
|
|
6745 * When 'weirdinvert' changed, set/reset 't_xs'.
|
|
6746 * Then set 'weirdinvert' according to value of 't_xs'.
|
|
6747 */
|
|
6748 if (p_wiv && !old_value)
|
|
6749 T_XS = (char_u *)"y";
|
|
6750 else if (!p_wiv && old_value)
|
|
6751 T_XS = empty_option;
|
|
6752 p_wiv = (*T_XS != NUL);
|
|
6753 }
|
|
6754
|
190
|
6755 #ifdef FEAT_BEVAL
|
7
|
6756 else if ((int *)varp == &p_beval)
|
|
6757 {
|
|
6758 if (p_beval == TRUE)
|
|
6759 gui_mch_enable_beval_area(balloonEval);
|
|
6760 else
|
|
6761 gui_mch_disable_beval_area(balloonEval);
|
|
6762 }
|
|
6763
|
190
|
6764 # if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
|
7
|
6765 else if ((int *)varp == &p_acd)
|
|
6766 {
|
|
6767 if (p_acd && curbuf->b_ffname != NULL
|
|
6768 && vim_chdirfile(curbuf->b_ffname) == OK)
|
|
6769 shorten_fnames(TRUE);
|
|
6770 }
|
190
|
6771 # endif
|
7
|
6772 #endif
|
|
6773
|
|
6774 #ifdef FEAT_DIFF
|
|
6775 /* 'diff' */
|
|
6776 else if ((int *)varp == &curwin->w_p_diff)
|
|
6777 {
|
16
|
6778 /* May add or remove the buffer from the list of diff buffers. */
|
|
6779 diff_buf_adjust(curwin);
|
|
6780 # ifdef FEAT_FOLDING
|
7
|
6781 if (foldmethodIsDiff(curwin))
|
|
6782 foldUpdateAll(curwin);
|
16
|
6783 # endif
|
7
|
6784 }
|
|
6785 #endif
|
|
6786
|
|
6787 #ifdef USE_IM_CONTROL
|
|
6788 /* 'imdisable' */
|
|
6789 else if ((int *)varp == &p_imdisable)
|
|
6790 {
|
|
6791 /* Only de-activate it here, it will be enabled when changing mode. */
|
|
6792 if (p_imdisable)
|
|
6793 im_set_active(FALSE);
|
|
6794 }
|
|
6795 #endif
|
|
6796
|
258
|
6797 #ifdef FEAT_SYN_HL
|
|
6798 /* 'spell' */
|
|
6799 else if ((int *)varp == &curwin->w_p_spell)
|
|
6800 {
|
|
6801 if (curwin->w_p_spell)
|
|
6802 {
|
|
6803 char_u *errmsg = did_set_spelllang(curbuf);
|
320
|
6804
|
258
|
6805 if (errmsg != NULL)
|
|
6806 EMSG(_(errmsg));
|
|
6807 }
|
|
6808 }
|
|
6809 #endif
|
|
6810
|
7
|
6811 #ifdef FEAT_FKMAP
|
|
6812 else if ((int *)varp == &p_altkeymap)
|
|
6813 {
|
|
6814 if (old_value != p_altkeymap)
|
|
6815 {
|
|
6816 if (!p_altkeymap)
|
|
6817 {
|
|
6818 p_hkmap = p_fkmap;
|
|
6819 p_fkmap = 0;
|
|
6820 }
|
|
6821 else
|
|
6822 {
|
|
6823 p_fkmap = p_hkmap;
|
|
6824 p_hkmap = 0;
|
|
6825 }
|
|
6826 (void)init_chartab();
|
|
6827 }
|
|
6828 }
|
|
6829
|
|
6830 /*
|
|
6831 * In case some second language keymapping options have changed, check
|
|
6832 * and correct the setting in a consistent way.
|
|
6833 */
|
|
6834
|
|
6835 /*
|
|
6836 * If hkmap or fkmap are set, reset Arabic keymapping.
|
|
6837 */
|
|
6838 if ((p_hkmap || p_fkmap) && p_altkeymap)
|
|
6839 {
|
|
6840 p_altkeymap = p_fkmap;
|
|
6841 # ifdef FEAT_ARABIC
|
|
6842 curwin->w_p_arab = FALSE;
|
|
6843 # endif
|
|
6844 (void)init_chartab();
|
|
6845 }
|
|
6846
|
|
6847 /*
|
|
6848 * If hkmap set, reset Farsi keymapping.
|
|
6849 */
|
|
6850 if (p_hkmap && p_altkeymap)
|
|
6851 {
|
|
6852 p_altkeymap = 0;
|
|
6853 p_fkmap = 0;
|
|
6854 # ifdef FEAT_ARABIC
|
|
6855 curwin->w_p_arab = FALSE;
|
|
6856 # endif
|
|
6857 (void)init_chartab();
|
|
6858 }
|
|
6859
|
|
6860 /*
|
|
6861 * If fkmap set, reset Hebrew keymapping.
|
|
6862 */
|
|
6863 if (p_fkmap && !p_altkeymap)
|
|
6864 {
|
|
6865 p_altkeymap = 1;
|
|
6866 p_hkmap = 0;
|
|
6867 # ifdef FEAT_ARABIC
|
|
6868 curwin->w_p_arab = FALSE;
|
|
6869 # endif
|
|
6870 (void)init_chartab();
|
|
6871 }
|
|
6872 #endif
|
|
6873
|
|
6874 #ifdef FEAT_ARABIC
|
|
6875 if ((int *)varp == &curwin->w_p_arab)
|
|
6876 {
|
|
6877 if (curwin->w_p_arab)
|
|
6878 {
|
|
6879 /*
|
|
6880 * 'arabic' is set, handle various sub-settings.
|
|
6881 */
|
|
6882 if (!p_tbidi)
|
|
6883 {
|
|
6884 /* set rightleft mode */
|
|
6885 if (!curwin->w_p_rl)
|
|
6886 {
|
|
6887 curwin->w_p_rl = TRUE;
|
|
6888 changed_window_setting();
|
|
6889 }
|
|
6890
|
|
6891 /* Enable Arabic shaping (major part of what Arabic requires) */
|
|
6892 if (!p_arshape)
|
|
6893 {
|
|
6894 p_arshape = TRUE;
|
|
6895 redraw_later_clear();
|
|
6896 }
|
|
6897 }
|
|
6898
|
|
6899 /* Arabic requires a utf-8 encoding, inform the user if its not
|
|
6900 * set. */
|
|
6901 if (STRCMP(p_enc, "utf-8") != 0)
|
16
|
6902 {
|
|
6903 msg_source(hl_attr(HLF_W));
|
7
|
6904 MSG_ATTR(_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"),
|
|
6905 hl_attr(HLF_W));
|
16
|
6906 }
|
7
|
6907
|
|
6908 # ifdef FEAT_MBYTE
|
|
6909 /* set 'delcombine' */
|
|
6910 p_deco = TRUE;
|
|
6911 # endif
|
|
6912
|
|
6913 # ifdef FEAT_KEYMAP
|
|
6914 /* Force-set the necessary keymap for arabic */
|
|
6915 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
|
|
6916 OPT_LOCAL);
|
|
6917 # endif
|
|
6918 # ifdef FEAT_FKMAP
|
|
6919 p_altkeymap = 0;
|
|
6920 p_hkmap = 0;
|
|
6921 p_fkmap = 0;
|
|
6922 (void)init_chartab();
|
|
6923 # endif
|
|
6924 }
|
|
6925 else
|
|
6926 {
|
|
6927 /*
|
|
6928 * 'arabic' is reset, handle various sub-settings.
|
|
6929 */
|
|
6930 if (!p_tbidi)
|
|
6931 {
|
|
6932 /* reset rightleft mode */
|
|
6933 if (curwin->w_p_rl)
|
|
6934 {
|
|
6935 curwin->w_p_rl = FALSE;
|
|
6936 changed_window_setting();
|
|
6937 }
|
|
6938
|
|
6939 /* 'arabicshape' isn't reset, it is a global option and
|
|
6940 * another window may still need it "on". */
|
|
6941 }
|
|
6942
|
|
6943 /* 'delcombine' isn't reset, it is a global option and another
|
|
6944 * window may still want it "on". */
|
|
6945
|
|
6946 # ifdef FEAT_KEYMAP
|
|
6947 /* Revert to the default keymap */
|
|
6948 curbuf->b_p_iminsert = B_IMODE_NONE;
|
|
6949 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
|
|
6950 # endif
|
|
6951 }
|
|
6952 }
|
|
6953 #endif
|
|
6954
|
|
6955 /*
|
|
6956 * End of handling side effects for bool options.
|
|
6957 */
|
|
6958
|
|
6959 options[opt_idx].flags |= P_WAS_SET;
|
|
6960
|
|
6961 comp_col(); /* in case 'ruler' or 'showcmd' changed */
|
|
6962 if (curwin->w_curswant != MAXCOL)
|
|
6963 curwin->w_set_curswant = TRUE; /* in case 'list' changed */
|
|
6964 check_redraw(options[opt_idx].flags);
|
|
6965
|
|
6966 return NULL;
|
|
6967 }
|
|
6968
|
|
6969 /*
|
|
6970 * Set the value of a number option, and take care of side effects.
|
|
6971 * Returns NULL for success, or an error message for an error.
|
|
6972 */
|
|
6973 static char_u *
|
274
|
6974 set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
|
7
|
6975 int opt_idx; /* index in options[] table */
|
|
6976 char_u *varp; /* pointer to the option variable */
|
|
6977 long value; /* new value */
|
|
6978 char_u *errbuf; /* buffer for error messages */
|
274
|
6979 size_t errbuflen; /* length of "errbuf" */
|
7
|
6980 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
|
|
6981 OPT_MODELINE */
|
|
6982 {
|
|
6983 char_u *errmsg = NULL;
|
|
6984 long old_value = *(long *)varp;
|
|
6985 long old_Rows = Rows; /* remember old Rows */
|
|
6986 long old_Columns = Columns; /* remember old Columns */
|
|
6987 long *pp = (long *)varp;
|
|
6988
|
|
6989 #ifdef FEAT_GUI
|
|
6990 need_mouse_correct = TRUE;
|
|
6991 #endif
|
|
6992
|
|
6993 *pp = value;
|
|
6994 #ifdef FEAT_EVAL
|
|
6995 /* Remember where the option was set. */
|
|
6996 options[opt_idx].scriptID = current_SID;
|
|
6997 #endif
|
|
6998
|
|
6999 if (curbuf->b_p_sw <= 0)
|
|
7000 {
|
|
7001 errmsg = e_positive;
|
|
7002 curbuf->b_p_sw = curbuf->b_p_ts;
|
|
7003 }
|
|
7004
|
|
7005 /*
|
|
7006 * Number options that need some action when changed
|
|
7007 */
|
|
7008 #ifdef FEAT_WINDOWS
|
|
7009 if (pp == &p_wh || pp == &p_hh)
|
|
7010 {
|
|
7011 if (p_wh < 1)
|
|
7012 {
|
|
7013 errmsg = e_positive;
|
|
7014 p_wh = 1;
|
|
7015 }
|
|
7016 if (p_wmh > p_wh)
|
|
7017 {
|
|
7018 errmsg = e_winheight;
|
|
7019 p_wh = p_wmh;
|
|
7020 }
|
|
7021 if (p_hh < 0)
|
|
7022 {
|
|
7023 errmsg = e_positive;
|
|
7024 p_hh = 0;
|
|
7025 }
|
|
7026
|
|
7027 /* Change window height NOW */
|
|
7028 if (lastwin != firstwin)
|
|
7029 {
|
|
7030 if (pp == &p_wh && curwin->w_height < p_wh)
|
|
7031 win_setheight((int)p_wh);
|
|
7032 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
|
|
7033 win_setheight((int)p_hh);
|
|
7034 }
|
|
7035 }
|
|
7036
|
|
7037 /* 'winminheight' */
|
|
7038 else if (pp == &p_wmh)
|
|
7039 {
|
|
7040 if (p_wmh < 0)
|
|
7041 {
|
|
7042 errmsg = e_positive;
|
|
7043 p_wmh = 0;
|
|
7044 }
|
|
7045 if (p_wmh > p_wh)
|
|
7046 {
|
|
7047 errmsg = e_winheight;
|
|
7048 p_wmh = p_wh;
|
|
7049 }
|
|
7050 win_setminheight();
|
|
7051 }
|
|
7052
|
|
7053 # ifdef FEAT_VERTSPLIT
|
13
|
7054 else if (pp == &p_wiw)
|
7
|
7055 {
|
|
7056 if (p_wiw < 1)
|
|
7057 {
|
|
7058 errmsg = e_positive;
|
|
7059 p_wiw = 1;
|
|
7060 }
|
|
7061 if (p_wmw > p_wiw)
|
|
7062 {
|
|
7063 errmsg = e_winwidth;
|
|
7064 p_wiw = p_wmw;
|
|
7065 }
|
|
7066
|
|
7067 /* Change window width NOW */
|
|
7068 if (lastwin != firstwin && curwin->w_width < p_wiw)
|
|
7069 win_setwidth((int)p_wiw);
|
|
7070 }
|
|
7071
|
|
7072 /* 'winminwidth' */
|
|
7073 else if (pp == &p_wmw)
|
|
7074 {
|
|
7075 if (p_wmw < 0)
|
|
7076 {
|
|
7077 errmsg = e_positive;
|
|
7078 p_wmw = 0;
|
|
7079 }
|
|
7080 if (p_wmw > p_wiw)
|
|
7081 {
|
|
7082 errmsg = e_winwidth;
|
|
7083 p_wmw = p_wiw;
|
|
7084 }
|
|
7085 win_setminheight();
|
|
7086 }
|
|
7087 # endif
|
|
7088
|
|
7089 #endif
|
|
7090
|
|
7091 #ifdef FEAT_WINDOWS
|
|
7092 /* (re)set last window status line */
|
|
7093 else if (pp == &p_ls)
|
|
7094 {
|
|
7095 last_status(FALSE);
|
|
7096 }
|
|
7097 #endif
|
|
7098
|
|
7099 #ifdef FEAT_GUI
|
|
7100 else if (pp == &p_linespace)
|
|
7101 {
|
444
|
7102 /* Recompute gui.char_height and resize the Vim window to keep the
|
|
7103 * same number of lines. */
|
|
7104 if (gui.in_use && gui_mch_adjust_charheight() == OK)
|
7
|
7105 gui_set_shellsize(FALSE, FALSE);
|
|
7106 }
|
|
7107 #endif
|
|
7108
|
|
7109 #ifdef FEAT_FOLDING
|
|
7110 /* 'foldlevel' */
|
|
7111 else if (pp == &curwin->w_p_fdl)
|
|
7112 {
|
|
7113 if (curwin->w_p_fdl < 0)
|
|
7114 curwin->w_p_fdl = 0;
|
|
7115 newFoldLevel();
|
|
7116 }
|
|
7117
|
|
7118 /* 'foldminlevel' */
|
|
7119 else if (pp == &curwin->w_p_fml)
|
|
7120 {
|
|
7121 foldUpdateAll(curwin);
|
|
7122 }
|
|
7123
|
|
7124 /* 'foldnestmax' */
|
|
7125 else if (pp == &curwin->w_p_fdn)
|
|
7126 {
|
|
7127 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
|
|
7128 foldUpdateAll(curwin);
|
|
7129 }
|
|
7130
|
|
7131 /* 'foldcolumn' */
|
|
7132 else if (pp == &curwin->w_p_fdc)
|
|
7133 {
|
|
7134 if (curwin->w_p_fdc < 0)
|
|
7135 {
|
|
7136 errmsg = e_positive;
|
|
7137 curwin->w_p_fdc = 0;
|
|
7138 }
|
|
7139 else if (curwin->w_p_fdc > 12)
|
|
7140 {
|
|
7141 errmsg = e_invarg;
|
|
7142 curwin->w_p_fdc = 12;
|
|
7143 }
|
|
7144 }
|
|
7145
|
|
7146 /* 'shiftwidth' or 'tabstop' */
|
|
7147 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
|
|
7148 {
|
|
7149 if (foldmethodIsIndent(curwin))
|
|
7150 foldUpdateAll(curwin);
|
|
7151 }
|
|
7152 #endif /* FEAT_FOLDING */
|
|
7153
|
|
7154 else if (pp == &curbuf->b_p_iminsert)
|
|
7155 {
|
|
7156 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
|
|
7157 {
|
|
7158 errmsg = e_invarg;
|
|
7159 curbuf->b_p_iminsert = B_IMODE_NONE;
|
|
7160 }
|
|
7161 p_iminsert = curbuf->b_p_iminsert;
|
|
7162 if (termcap_active) /* don't do this in the alternate screen */
|
|
7163 showmode();
|
|
7164 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
|
|
7165 /* Show/unshow value of 'keymap' in status lines. */
|
|
7166 status_redraw_curbuf();
|
|
7167 #endif
|
|
7168 }
|
|
7169
|
164
|
7170 else if (pp == &p_window)
|
|
7171 {
|
|
7172 if (p_window < 1)
|
|
7173 p_window = 1;
|
|
7174 else if (p_window >= Rows)
|
|
7175 p_window = Rows - 1;
|
|
7176 }
|
|
7177
|
7
|
7178 else if (pp == &curbuf->b_p_imsearch)
|
|
7179 {
|
|
7180 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
|
|
7181 {
|
|
7182 errmsg = e_invarg;
|
|
7183 curbuf->b_p_imsearch = B_IMODE_NONE;
|
|
7184 }
|
|
7185 p_imsearch = curbuf->b_p_imsearch;
|
|
7186 }
|
|
7187
|
|
7188 #ifdef FEAT_TITLE
|
|
7189 /* if 'titlelen' has changed, redraw the title */
|
|
7190 else if (pp == &p_titlelen)
|
|
7191 {
|
|
7192 if (p_titlelen < 0)
|
|
7193 {
|
|
7194 errmsg = e_positive;
|
|
7195 p_titlelen = 85;
|
|
7196 }
|
|
7197 if (starting != NO_SCREEN && old_value != p_titlelen)
|
|
7198 need_maketitle = TRUE;
|
|
7199 }
|
|
7200 #endif
|
|
7201
|
|
7202 /* if p_ch changed value, change the command line height */
|
|
7203 else if (pp == &p_ch)
|
|
7204 {
|
|
7205 if (p_ch < 1)
|
|
7206 {
|
|
7207 errmsg = e_positive;
|
|
7208 p_ch = 1;
|
|
7209 }
|
|
7210
|
|
7211 /* Only compute the new window layout when startup has been
|
|
7212 * completed. Otherwise the frame sizes may be wrong. */
|
|
7213 if (p_ch != old_value && full_screen
|
|
7214 #ifdef FEAT_GUI
|
|
7215 && !gui.starting
|
|
7216 #endif
|
|
7217 )
|
|
7218 command_height(old_value);
|
|
7219 }
|
|
7220
|
|
7221 /* when 'updatecount' changes from zero to non-zero, open swap files */
|
|
7222 else if (pp == &p_uc)
|
|
7223 {
|
|
7224 if (p_uc < 0)
|
|
7225 {
|
|
7226 errmsg = e_positive;
|
|
7227 p_uc = 100;
|
|
7228 }
|
|
7229 if (p_uc && !old_value)
|
|
7230 ml_open_files();
|
|
7231 }
|
16
|
7232 #ifdef MZSCHEME_GUI_THREADS
|
14
|
7233 else if (pp == &p_mzq)
|
|
7234 mzvim_reset_timer();
|
|
7235 #endif
|
7
|
7236
|
|
7237 /* sync undo before 'undolevels' changes */
|
|
7238 else if (pp == &p_ul)
|
|
7239 {
|
|
7240 /* use the old value, otherwise u_sync() may not work properly */
|
|
7241 p_ul = old_value;
|
|
7242 u_sync();
|
|
7243 p_ul = value;
|
|
7244 }
|
|
7245
|
13
|
7246 #ifdef FEAT_LINEBREAK
|
|
7247 /* 'numberwidth' must be positive */
|
|
7248 else if (pp == &curwin->w_p_nuw)
|
|
7249 {
|
|
7250 if (curwin->w_p_nuw < 1)
|
|
7251 {
|
|
7252 errmsg = e_positive;
|
|
7253 curwin->w_p_nuw = 1;
|
|
7254 }
|
|
7255 if (curwin->w_p_nuw > 10)
|
|
7256 {
|
|
7257 errmsg = e_invarg;
|
|
7258 curwin->w_p_nuw = 10;
|
|
7259 }
|
|
7260 curwin->w_nrwidth_line_count = 0;
|
|
7261 }
|
|
7262 #endif
|
|
7263
|
7
|
7264 /*
|
|
7265 * Check the bounds for numeric options here
|
|
7266 */
|
|
7267 if (Rows < min_rows() && full_screen)
|
|
7268 {
|
|
7269 if (errbuf != NULL)
|
|
7270 {
|
274
|
7271 vim_snprintf((char *)errbuf, errbuflen,
|
|
7272 _("E593: Need at least %d lines"), min_rows());
|
7
|
7273 errmsg = errbuf;
|
|
7274 }
|
|
7275 Rows = min_rows();
|
|
7276 }
|
|
7277 if (Columns < MIN_COLUMNS && full_screen)
|
|
7278 {
|
|
7279 if (errbuf != NULL)
|
|
7280 {
|
274
|
7281 vim_snprintf((char *)errbuf, errbuflen,
|
|
7282 _("E594: Need at least %d columns"), MIN_COLUMNS);
|
7
|
7283 errmsg = errbuf;
|
|
7284 }
|
|
7285 Columns = MIN_COLUMNS;
|
|
7286 }
|
|
7287
|
|
7288 #ifdef DJGPP
|
|
7289 /* avoid a crash by checking for a too large value of 'columns' */
|
|
7290 if (old_Columns != Columns && full_screen && term_console)
|
|
7291 mch_check_columns();
|
|
7292 #endif
|
|
7293
|
|
7294 /*
|
|
7295 * If the screen (shell) height has been changed, assume it is the
|
|
7296 * physical screenheight.
|
|
7297 */
|
|
7298 if (old_Rows != Rows || old_Columns != Columns)
|
|
7299 {
|
|
7300 /* Changing the screen size is not allowed while updating the screen. */
|
|
7301 if (updating_screen)
|
|
7302 *pp = old_value;
|
|
7303 else if (full_screen
|
|
7304 #ifdef FEAT_GUI
|
|
7305 && !gui.starting
|
|
7306 #endif
|
|
7307 )
|
|
7308 set_shellsize((int)Columns, (int)Rows, TRUE);
|
|
7309 else
|
|
7310 {
|
|
7311 /* Postpone the resizing; check the size and cmdline position for
|
|
7312 * messages. */
|
|
7313 check_shellsize();
|
|
7314 if (cmdline_row > Rows - p_ch && Rows > p_ch)
|
|
7315 cmdline_row = Rows - p_ch;
|
|
7316 }
|
164
|
7317 if (p_window >= Rows)
|
|
7318 p_window = Rows - 1;
|
7
|
7319 }
|
|
7320
|
|
7321 if (curbuf->b_p_sts < 0)
|
|
7322 {
|
|
7323 errmsg = e_positive;
|
|
7324 curbuf->b_p_sts = 0;
|
|
7325 }
|
|
7326 if (curbuf->b_p_ts <= 0)
|
|
7327 {
|
|
7328 errmsg = e_positive;
|
|
7329 curbuf->b_p_ts = 8;
|
|
7330 }
|
|
7331 if (curbuf->b_p_tw < 0)
|
|
7332 {
|
|
7333 errmsg = e_positive;
|
|
7334 curbuf->b_p_tw = 0;
|
|
7335 }
|
|
7336 if (p_tm < 0)
|
|
7337 {
|
|
7338 errmsg = e_positive;
|
|
7339 p_tm = 0;
|
|
7340 }
|
|
7341 if ((curwin->w_p_scr <= 0
|
|
7342 || (curwin->w_p_scr > curwin->w_height
|
|
7343 && curwin->w_height > 0))
|
|
7344 && full_screen)
|
|
7345 {
|
|
7346 if (pp == &(curwin->w_p_scr))
|
|
7347 {
|
|
7348 if (curwin->w_p_scr != 0)
|
|
7349 errmsg = e_scroll;
|
|
7350 win_comp_scroll(curwin);
|
|
7351 }
|
|
7352 /* If 'scroll' became invalid because of a side effect silently adjust
|
|
7353 * it. */
|
|
7354 else if (curwin->w_p_scr <= 0)
|
|
7355 curwin->w_p_scr = 1;
|
|
7356 else /* curwin->w_p_scr > curwin->w_height */
|
|
7357 curwin->w_p_scr = curwin->w_height;
|
|
7358 }
|
|
7359 if (p_report < 0)
|
|
7360 {
|
|
7361 errmsg = e_positive;
|
|
7362 p_report = 1;
|
|
7363 }
|
|
7364 if ((p_sj < 0 || p_sj >= Rows) && full_screen)
|
|
7365 {
|
|
7366 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
|
|
7367 p_sj = Rows / 2;
|
|
7368 else
|
|
7369 {
|
|
7370 errmsg = e_scroll;
|
|
7371 p_sj = 1;
|
|
7372 }
|
|
7373 }
|
|
7374 if (p_so < 0 && full_screen)
|
|
7375 {
|
|
7376 errmsg = e_scroll;
|
|
7377 p_so = 0;
|
|
7378 }
|
|
7379 if (p_siso < 0 && full_screen)
|
|
7380 {
|
|
7381 errmsg = e_positive;
|
|
7382 p_siso = 0;
|
|
7383 }
|
|
7384 #ifdef FEAT_CMDWIN
|
|
7385 if (p_cwh < 1)
|
|
7386 {
|
|
7387 errmsg = e_positive;
|
|
7388 p_cwh = 1;
|
|
7389 }
|
|
7390 #endif
|
|
7391 if (p_ut < 0)
|
|
7392 {
|
|
7393 errmsg = e_positive;
|
|
7394 p_ut = 2000;
|
|
7395 }
|
|
7396 if (p_ss < 0)
|
|
7397 {
|
|
7398 errmsg = e_positive;
|
|
7399 p_ss = 0;
|
|
7400 }
|
|
7401
|
|
7402 /* May set global value for local option. */
|
|
7403 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
7404 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
|
|
7405
|
|
7406 options[opt_idx].flags |= P_WAS_SET;
|
|
7407
|
|
7408 comp_col(); /* in case 'columns' or 'ls' changed */
|
|
7409 if (curwin->w_curswant != MAXCOL)
|
|
7410 curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */
|
|
7411 check_redraw(options[opt_idx].flags);
|
|
7412
|
|
7413 return errmsg;
|
|
7414 }
|
|
7415
|
|
7416 /*
|
|
7417 * Called after an option changed: check if something needs to be redrawn.
|
|
7418 */
|
|
7419 static void
|
|
7420 check_redraw(flags)
|
|
7421 long_u flags;
|
|
7422 {
|
|
7423 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
|
|
7424 int clear = (flags & P_RCLR) == P_RCLR;
|
|
7425 int all = ((flags & P_RALL) == P_RALL || clear);
|
|
7426
|
|
7427 #ifdef FEAT_WINDOWS
|
|
7428 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
|
|
7429 status_redraw_all();
|
|
7430 #endif
|
|
7431
|
|
7432 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
|
|
7433 changed_window_setting();
|
|
7434 if (flags & P_RBUF)
|
|
7435 redraw_curbuf_later(NOT_VALID);
|
|
7436 if (clear)
|
|
7437 redraw_all_later(CLEAR);
|
|
7438 else if (all)
|
|
7439 redraw_all_later(NOT_VALID);
|
|
7440 }
|
|
7441
|
|
7442 /*
|
|
7443 * Find index for option 'arg'.
|
|
7444 * Return -1 if not found.
|
|
7445 */
|
|
7446 static int
|
|
7447 findoption(arg)
|
|
7448 char_u *arg;
|
|
7449 {
|
|
7450 int opt_idx;
|
|
7451 char *s, *p;
|
|
7452 static short quick_tab[27] = {0, 0}; /* quick access table */
|
|
7453 int is_term_opt;
|
|
7454
|
|
7455 /*
|
|
7456 * For first call: Initialize the quick-access table.
|
|
7457 * It contains the index for the first option that starts with a certain
|
|
7458 * letter. There are 26 letters, plus the first "t_" option.
|
|
7459 */
|
|
7460 if (quick_tab[1] == 0)
|
|
7461 {
|
|
7462 p = options[0].fullname;
|
|
7463 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
|
|
7464 {
|
|
7465 if (s[0] != p[0])
|
|
7466 {
|
|
7467 if (s[0] == 't' && s[1] == '_')
|
|
7468 quick_tab[26] = opt_idx;
|
|
7469 else
|
|
7470 quick_tab[CharOrdLow(s[0])] = opt_idx;
|
|
7471 }
|
|
7472 p = s;
|
|
7473 }
|
|
7474 }
|
|
7475
|
|
7476 /*
|
|
7477 * Check for name starting with an illegal character.
|
|
7478 */
|
|
7479 #ifdef EBCDIC
|
|
7480 if (!islower(arg[0]))
|
|
7481 #else
|
|
7482 if (arg[0] < 'a' || arg[0] > 'z')
|
|
7483 #endif
|
|
7484 return -1;
|
|
7485
|
|
7486 is_term_opt = (arg[0] == 't' && arg[1] == '_');
|
|
7487 if (is_term_opt)
|
|
7488 opt_idx = quick_tab[26];
|
|
7489 else
|
|
7490 opt_idx = quick_tab[CharOrdLow(arg[0])];
|
|
7491 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
|
|
7492 {
|
|
7493 if (STRCMP(arg, s) == 0) /* match full name */
|
|
7494 break;
|
|
7495 }
|
|
7496 if (s == NULL && !is_term_opt)
|
|
7497 {
|
|
7498 opt_idx = quick_tab[CharOrdLow(arg[0])];
|
|
7499 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
|
|
7500 {
|
|
7501 s = options[opt_idx].shortname;
|
|
7502 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
|
|
7503 break;
|
|
7504 s = NULL;
|
|
7505 }
|
|
7506 }
|
|
7507 if (s == NULL)
|
|
7508 opt_idx = -1;
|
|
7509 return opt_idx;
|
|
7510 }
|
|
7511
|
14
|
7512 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
|
7
|
7513 /*
|
|
7514 * Get the value for an option.
|
|
7515 *
|
|
7516 * Returns:
|
|
7517 * Number or Toggle option: 1, *numval gets value.
|
|
7518 * String option: 0, *stringval gets allocated string.
|
|
7519 * Hidden Number or Toggle option: -1.
|
|
7520 * hidden String option: -2.
|
|
7521 * unknown option: -3.
|
|
7522 */
|
|
7523 int
|
|
7524 get_option_value(name, numval, stringval, opt_flags)
|
|
7525 char_u *name;
|
|
7526 long *numval;
|
|
7527 char_u **stringval; /* NULL when only checking existance */
|
|
7528 int opt_flags;
|
|
7529 {
|
|
7530 int opt_idx;
|
|
7531 char_u *varp;
|
|
7532
|
|
7533 opt_idx = findoption(name);
|
|
7534 if (opt_idx < 0) /* unknown option */
|
|
7535 return -3;
|
|
7536
|
|
7537 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
|
|
7538
|
|
7539 if (options[opt_idx].flags & P_STRING)
|
|
7540 {
|
|
7541 if (varp == NULL) /* hidden option */
|
|
7542 return -2;
|
|
7543 if (stringval != NULL)
|
|
7544 {
|
|
7545 #ifdef FEAT_CRYPT
|
|
7546 /* never return the value of the crypt key */
|
|
7547 if ((char_u **)varp == &curbuf->b_p_key)
|
|
7548 *stringval = vim_strsave((char_u *)"*****");
|
|
7549 else
|
|
7550 #endif
|
|
7551 *stringval = vim_strsave(*(char_u **)(varp));
|
|
7552 }
|
|
7553 return 0;
|
|
7554 }
|
|
7555
|
|
7556 if (varp == NULL) /* hidden option */
|
|
7557 return -1;
|
|
7558 if (options[opt_idx].flags & P_NUM)
|
|
7559 *numval = *(long *)varp;
|
|
7560 else
|
|
7561 {
|
|
7562 /* Special case: 'modified' is b_changed, but we also want to consider
|
|
7563 * it set when 'ff' or 'fenc' changed. */
|
|
7564 if ((int *)varp == &curbuf->b_changed)
|
|
7565 *numval = curbufIsChanged();
|
|
7566 else
|
|
7567 *numval = *(int *)varp;
|
|
7568 }
|
|
7569 return 1;
|
|
7570 }
|
|
7571 #endif
|
|
7572
|
|
7573 /*
|
|
7574 * Set the value of option "name".
|
|
7575 * Use "string" for string options, use "number" for other options.
|
|
7576 */
|
|
7577 void
|
|
7578 set_option_value(name, number, string, opt_flags)
|
|
7579 char_u *name;
|
|
7580 long number;
|
|
7581 char_u *string;
|
|
7582 int opt_flags; /* OPT_LOCAL or 0 (both) */
|
|
7583 {
|
|
7584 int opt_idx;
|
|
7585 char_u *varp;
|
|
7586 int flags;
|
|
7587
|
|
7588 opt_idx = findoption(name);
|
|
7589 if (opt_idx == -1)
|
|
7590 EMSG2(_("E355: Unknown option: %s"), name);
|
|
7591 else
|
|
7592 {
|
|
7593 flags = options[opt_idx].flags;
|
|
7594 #ifdef HAVE_SANDBOX
|
|
7595 /* Disallow changing some options in the sandbox */
|
|
7596 if (sandbox > 0 && (flags & P_SECURE))
|
|
7597 EMSG(_(e_sandbox));
|
|
7598 else
|
|
7599 #endif
|
|
7600 if (flags & P_STRING)
|
|
7601 set_string_option(opt_idx, string, opt_flags);
|
|
7602 else
|
|
7603 {
|
|
7604 varp = get_varp(&options[opt_idx]);
|
|
7605 if (varp != NULL) /* hidden option is not changed */
|
|
7606 {
|
|
7607 if (flags & P_NUM)
|
274
|
7608 (void)set_num_option(opt_idx, varp, number,
|
|
7609 NULL, 0, opt_flags);
|
7
|
7610 else
|
|
7611 (void)set_bool_option(opt_idx, varp, (int)number, opt_flags);
|
|
7612 }
|
|
7613 }
|
|
7614 }
|
|
7615 }
|
|
7616
|
|
7617 /*
|
|
7618 * Get the terminal code for a terminal option.
|
|
7619 * Returns NULL when not found.
|
|
7620 */
|
|
7621 char_u *
|
|
7622 get_term_code(tname)
|
|
7623 char_u *tname;
|
|
7624 {
|
|
7625 int opt_idx;
|
|
7626 char_u *varp;
|
|
7627
|
|
7628 if (tname[0] != 't' || tname[1] != '_' ||
|
|
7629 tname[2] == NUL || tname[3] == NUL)
|
|
7630 return NULL;
|
|
7631 if ((opt_idx = findoption(tname)) >= 0)
|
|
7632 {
|
|
7633 varp = get_varp(&(options[opt_idx]));
|
|
7634 if (varp != NULL)
|
|
7635 varp = *(char_u **)(varp);
|
|
7636 return varp;
|
|
7637 }
|
|
7638 return find_termcode(tname + 2);
|
|
7639 }
|
|
7640
|
|
7641 char_u *
|
|
7642 get_highlight_default()
|
|
7643 {
|
|
7644 int i;
|
|
7645
|
|
7646 i = findoption((char_u *)"hl");
|
|
7647 if (i >= 0)
|
|
7648 return options[i].def_val[VI_DEFAULT];
|
|
7649 return (char_u *)NULL;
|
|
7650 }
|
|
7651
|
39
|
7652 #if defined(FEAT_MBYTE) || defined(PROTO)
|
|
7653 char_u *
|
|
7654 get_encoding_default()
|
|
7655 {
|
|
7656 int i;
|
|
7657
|
|
7658 i = findoption((char_u *)"enc");
|
|
7659 if (i >= 0)
|
|
7660 return options[i].def_val[VI_DEFAULT];
|
|
7661 return (char_u *)NULL;
|
|
7662 }
|
|
7663 #endif
|
|
7664
|
7
|
7665 /*
|
|
7666 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
|
|
7667 */
|
|
7668 static int
|
|
7669 find_key_option(arg)
|
|
7670 char_u *arg;
|
|
7671 {
|
|
7672 int key;
|
|
7673 int modifiers;
|
|
7674
|
|
7675 /*
|
|
7676 * Don't use get_special_key_code() for t_xx, we don't want it to call
|
|
7677 * add_termcap_entry().
|
|
7678 */
|
|
7679 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
|
|
7680 key = TERMCAP2KEY(arg[2], arg[3]);
|
|
7681 else
|
|
7682 {
|
|
7683 --arg; /* put arg at the '<' */
|
|
7684 modifiers = 0;
|
|
7685 key = find_special_key(&arg, &modifiers, TRUE);
|
|
7686 if (modifiers) /* can't handle modifiers here */
|
|
7687 key = 0;
|
|
7688 }
|
|
7689 return key;
|
|
7690 }
|
|
7691
|
|
7692 /*
|
|
7693 * if 'all' == 0: show changed options
|
|
7694 * if 'all' == 1: show all normal options
|
|
7695 * if 'all' == 2: show all terminal options
|
|
7696 */
|
|
7697 static void
|
|
7698 showoptions(all, opt_flags)
|
|
7699 int all;
|
|
7700 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
|
|
7701 {
|
|
7702 struct vimoption *p;
|
|
7703 int col;
|
|
7704 int isterm;
|
|
7705 char_u *varp;
|
|
7706 struct vimoption **items;
|
|
7707 int item_count;
|
|
7708 int run;
|
|
7709 int row, rows;
|
|
7710 int cols;
|
|
7711 int i;
|
|
7712 int len;
|
|
7713
|
|
7714 #define INC 20
|
|
7715 #define GAP 3
|
|
7716
|
|
7717 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
|
|
7718 PARAM_COUNT));
|
|
7719 if (items == NULL)
|
|
7720 return;
|
|
7721
|
|
7722 /* Highlight title */
|
|
7723 if (all == 2)
|
|
7724 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
|
|
7725 else if (opt_flags & OPT_GLOBAL)
|
|
7726 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
|
|
7727 else if (opt_flags & OPT_LOCAL)
|
|
7728 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
|
|
7729 else
|
|
7730 MSG_PUTS_TITLE(_("\n--- Options ---"));
|
|
7731
|
|
7732 /*
|
|
7733 * do the loop two times:
|
|
7734 * 1. display the short items
|
|
7735 * 2. display the long items (only strings and numbers)
|
|
7736 */
|
|
7737 for (run = 1; run <= 2 && !got_int; ++run)
|
|
7738 {
|
|
7739 /*
|
|
7740 * collect the items in items[]
|
|
7741 */
|
|
7742 item_count = 0;
|
|
7743 for (p = &options[0]; p->fullname != NULL; p++)
|
|
7744 {
|
|
7745 varp = NULL;
|
|
7746 isterm = istermoption(p);
|
|
7747 if (opt_flags != 0)
|
|
7748 {
|
|
7749 if (p->indir != PV_NONE && !isterm)
|
|
7750 varp = get_varp_scope(p, opt_flags);
|
|
7751 }
|
|
7752 else
|
|
7753 varp = get_varp(p);
|
|
7754 if (varp != NULL
|
|
7755 && ((all == 2 && isterm)
|
|
7756 || (all == 1 && !isterm)
|
|
7757 || (all == 0 && !optval_default(p, varp))))
|
|
7758 {
|
|
7759 if (p->flags & P_BOOL)
|
|
7760 len = 1; /* a toggle option fits always */
|
|
7761 else
|
|
7762 {
|
|
7763 option_value2string(p, opt_flags);
|
|
7764 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
|
|
7765 }
|
|
7766 if ((len <= INC - GAP && run == 1) ||
|
|
7767 (len > INC - GAP && run == 2))
|
|
7768 items[item_count++] = p;
|
|
7769 }
|
|
7770 }
|
|
7771
|
|
7772 /*
|
|
7773 * display the items
|
|
7774 */
|
|
7775 if (run == 1)
|
|
7776 {
|
|
7777 cols = (Columns + GAP - 3) / INC;
|
|
7778 if (cols == 0)
|
|
7779 cols = 1;
|
|
7780 rows = (item_count + cols - 1) / cols;
|
|
7781 }
|
|
7782 else /* run == 2 */
|
|
7783 rows = item_count;
|
|
7784 for (row = 0; row < rows && !got_int; ++row)
|
|
7785 {
|
|
7786 msg_putchar('\n'); /* go to next line */
|
|
7787 if (got_int) /* 'q' typed in more */
|
|
7788 break;
|
|
7789 col = 0;
|
|
7790 for (i = row; i < item_count; i += rows)
|
|
7791 {
|
|
7792 msg_col = col; /* make columns */
|
|
7793 showoneopt(items[i], opt_flags);
|
|
7794 col += INC;
|
|
7795 }
|
|
7796 out_flush();
|
|
7797 ui_breakcheck();
|
|
7798 }
|
|
7799 }
|
|
7800 vim_free(items);
|
|
7801 }
|
|
7802
|
|
7803 /*
|
|
7804 * Return TRUE if option "p" has its default value.
|
|
7805 */
|
|
7806 static int
|
|
7807 optval_default(p, varp)
|
|
7808 struct vimoption *p;
|
|
7809 char_u *varp;
|
|
7810 {
|
|
7811 int dvi;
|
|
7812
|
|
7813 if (varp == NULL)
|
|
7814 return TRUE; /* hidden option is always at default */
|
|
7815 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
|
|
7816 if (p->flags & P_NUM)
|
|
7817 return (*(long *)varp == (long)p->def_val[dvi]);
|
|
7818 if (p->flags & P_BOOL)
|
|
7819 /* the cast to long is required for Manx C */
|
|
7820 return (*(int *)varp == (int)(long)p->def_val[dvi]);
|
|
7821 /* P_STRING */
|
|
7822 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
|
|
7823 }
|
|
7824
|
|
7825 /*
|
|
7826 * showoneopt: show the value of one option
|
|
7827 * must not be called with a hidden option!
|
|
7828 */
|
|
7829 static void
|
|
7830 showoneopt(p, opt_flags)
|
|
7831 struct vimoption *p;
|
|
7832 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
|
|
7833 {
|
168
|
7834 char_u *varp;
|
|
7835 int save_silent = silent_mode;
|
|
7836
|
|
7837 silent_mode = FALSE;
|
|
7838 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
|
7
|
7839
|
|
7840 varp = get_varp_scope(p, opt_flags);
|
|
7841
|
|
7842 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
|
|
7843 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
|
|
7844 ? !curbufIsChanged() : !*(int *)varp))
|
|
7845 MSG_PUTS("no");
|
|
7846 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
|
|
7847 MSG_PUTS("--");
|
|
7848 else
|
|
7849 MSG_PUTS(" ");
|
|
7850 MSG_PUTS(p->fullname);
|
|
7851 if (!(p->flags & P_BOOL))
|
|
7852 {
|
|
7853 msg_putchar('=');
|
|
7854 /* put value string in NameBuff */
|
|
7855 option_value2string(p, opt_flags);
|
|
7856 msg_outtrans(NameBuff);
|
|
7857 }
|
168
|
7858
|
|
7859 silent_mode = save_silent;
|
|
7860 info_message = FALSE;
|
7
|
7861 }
|
|
7862
|
|
7863 /*
|
|
7864 * Write modified options as ":set" commands to a file.
|
|
7865 *
|
|
7866 * There are three values for "opt_flags":
|
|
7867 * OPT_GLOBAL: Write global option values and fresh values of
|
|
7868 * buffer-local options (used for start of a session
|
|
7869 * file).
|
|
7870 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
|
|
7871 * curwin (used for a vimrc file).
|
|
7872 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
|
|
7873 * and local values for window-local options of
|
|
7874 * curwin. Local values are also written when at the
|
|
7875 * default value, because a modeline or autocommand
|
|
7876 * may have set them when doing ":edit file" and the
|
|
7877 * user has set them back at the default or fresh
|
|
7878 * value.
|
|
7879 * When "local_only" is TRUE, don't write fresh
|
|
7880 * values, only local values (for ":mkview").
|
|
7881 * (fresh value = value used for a new buffer or window for a local option).
|
|
7882 *
|
|
7883 * Return FAIL on error, OK otherwise.
|
|
7884 */
|
|
7885 int
|
|
7886 makeset(fd, opt_flags, local_only)
|
|
7887 FILE *fd;
|
|
7888 int opt_flags;
|
|
7889 int local_only;
|
|
7890 {
|
|
7891 struct vimoption *p;
|
|
7892 char_u *varp; /* currently used value */
|
|
7893 char_u *varp_fresh; /* local value */
|
|
7894 char_u *varp_local = NULL; /* fresh value */
|
|
7895 char *cmd;
|
|
7896 int round;
|
|
7897
|
|
7898 /*
|
|
7899 * The options that don't have a default (terminal name, columns, lines)
|
|
7900 * are never written. Terminal options are also not written.
|
|
7901 */
|
|
7902 for (p = &options[0]; !istermoption(p); p++)
|
|
7903 if (!(p->flags & P_NO_MKRC) && !istermoption(p))
|
|
7904 {
|
|
7905 /* skip global option when only doing locals */
|
|
7906 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
|
|
7907 continue;
|
|
7908
|
|
7909 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
|
|
7910 * file, they are always buffer-specific. */
|
|
7911 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
|
|
7912 continue;
|
|
7913
|
|
7914 /* Global values are only written when not at the default value. */
|
|
7915 varp = get_varp_scope(p, opt_flags);
|
|
7916 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
|
|
7917 continue;
|
|
7918
|
|
7919 round = 2;
|
|
7920 if (p->indir != PV_NONE)
|
|
7921 {
|
|
7922 if (p->var == VAR_WIN)
|
|
7923 {
|
|
7924 /* skip window-local option when only doing globals */
|
|
7925 if (!(opt_flags & OPT_LOCAL))
|
|
7926 continue;
|
|
7927 /* When fresh value of window-local option is not at the
|
|
7928 * default, need to write it too. */
|
|
7929 if (!(opt_flags & OPT_GLOBAL) && !local_only)
|
|
7930 {
|
|
7931 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
|
|
7932 if (!optval_default(p, varp_fresh))
|
|
7933 {
|
|
7934 round = 1;
|
|
7935 varp_local = varp;
|
|
7936 varp = varp_fresh;
|
|
7937 }
|
|
7938 }
|
|
7939 }
|
|
7940 }
|
|
7941
|
|
7942 /* Round 1: fresh value for window-local options.
|
|
7943 * Round 2: other values */
|
|
7944 for ( ; round <= 2; varp = varp_local, ++round)
|
|
7945 {
|
|
7946 if (round == 1 || (opt_flags & OPT_GLOBAL))
|
|
7947 cmd = "set";
|
|
7948 else
|
|
7949 cmd = "setlocal";
|
|
7950
|
|
7951 if (p->flags & P_BOOL)
|
|
7952 {
|
|
7953 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
|
|
7954 return FAIL;
|
|
7955 }
|
|
7956 else if (p->flags & P_NUM)
|
|
7957 {
|
|
7958 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
|
|
7959 return FAIL;
|
|
7960 }
|
|
7961 else /* P_STRING */
|
|
7962 {
|
|
7963 /* Don't set 'syntax' and 'filetype' again if the value is
|
|
7964 * already right, avoids reloading the syntax file. */
|
|
7965 if (p->indir == PV_SYN || p->indir == PV_FT)
|
|
7966 {
|
|
7967 if (fprintf(fd, "if &%s != '%s'", p->fullname,
|
|
7968 *(char_u **)(varp)) < 0
|
|
7969 || put_eol(fd) < 0)
|
|
7970 return FAIL;
|
|
7971 }
|
|
7972 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
|
|
7973 (p->flags & P_EXPAND) != 0) == FAIL)
|
|
7974 return FAIL;
|
|
7975 if (p->indir == PV_SYN || p->indir == PV_FT)
|
|
7976 {
|
|
7977 if (put_line(fd, "endif") == FAIL)
|
|
7978 return FAIL;
|
|
7979 }
|
|
7980 }
|
|
7981 }
|
|
7982 }
|
|
7983 return OK;
|
|
7984 }
|
|
7985
|
|
7986 #if defined(FEAT_FOLDING) || defined(PROTO)
|
|
7987 /*
|
|
7988 * Generate set commands for the local fold options only. Used when
|
|
7989 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
|
|
7990 */
|
|
7991 int
|
|
7992 makefoldset(fd)
|
|
7993 FILE *fd;
|
|
7994 {
|
|
7995 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
|
|
7996 # ifdef FEAT_EVAL
|
|
7997 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
|
|
7998 == FAIL
|
|
7999 # endif
|
|
8000 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
|
|
8001 == FAIL
|
|
8002 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
|
|
8003 == FAIL
|
|
8004 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
|
|
8005 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
|
|
8006 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
|
|
8007 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
|
|
8008 )
|
|
8009 return FAIL;
|
|
8010
|
|
8011 return OK;
|
|
8012 }
|
|
8013 #endif
|
|
8014
|
|
8015 static int
|
|
8016 put_setstring(fd, cmd, name, valuep, expand)
|
|
8017 FILE *fd;
|
|
8018 char *cmd;
|
|
8019 char *name;
|
|
8020 char_u **valuep;
|
|
8021 int expand;
|
|
8022 {
|
|
8023 char_u *s;
|
|
8024 char_u buf[MAXPATHL];
|
|
8025
|
|
8026 if (fprintf(fd, "%s %s=", cmd, name) < 0)
|
|
8027 return FAIL;
|
|
8028 if (*valuep != NULL)
|
|
8029 {
|
|
8030 /* Output 'pastetoggle' as key names. For other
|
|
8031 * options some characters have to be escaped with
|
|
8032 * CTRL-V or backslash */
|
|
8033 if (valuep == &p_pt)
|
|
8034 {
|
|
8035 s = *valuep;
|
|
8036 while (*s != NUL)
|
|
8037 if (fputs((char *)str2special(&s, FALSE), fd) < 0)
|
|
8038 return FAIL;
|
|
8039 }
|
|
8040 else if (expand)
|
|
8041 {
|
|
8042 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
|
|
8043 if (put_escstr(fd, buf, 2) == FAIL)
|
|
8044 return FAIL;
|
|
8045 }
|
|
8046 else if (put_escstr(fd, *valuep, 2) == FAIL)
|
|
8047 return FAIL;
|
|
8048 }
|
|
8049 if (put_eol(fd) < 0)
|
|
8050 return FAIL;
|
|
8051 return OK;
|
|
8052 }
|
|
8053
|
|
8054 static int
|
|
8055 put_setnum(fd, cmd, name, valuep)
|
|
8056 FILE *fd;
|
|
8057 char *cmd;
|
|
8058 char *name;
|
|
8059 long *valuep;
|
|
8060 {
|
|
8061 long wc;
|
|
8062
|
|
8063 if (fprintf(fd, "%s %s=", cmd, name) < 0)
|
|
8064 return FAIL;
|
|
8065 if (wc_use_keyname((char_u *)valuep, &wc))
|
|
8066 {
|
|
8067 /* print 'wildchar' and 'wildcharm' as a key name */
|
|
8068 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
|
|
8069 return FAIL;
|
|
8070 }
|
|
8071 else if (fprintf(fd, "%ld", *valuep) < 0)
|
|
8072 return FAIL;
|
|
8073 if (put_eol(fd) < 0)
|
|
8074 return FAIL;
|
|
8075 return OK;
|
|
8076 }
|
|
8077
|
|
8078 static int
|
|
8079 put_setbool(fd, cmd, name, value)
|
|
8080 FILE *fd;
|
|
8081 char *cmd;
|
|
8082 char *name;
|
|
8083 int value;
|
|
8084 {
|
|
8085 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
|
|
8086 || put_eol(fd) < 0)
|
|
8087 return FAIL;
|
|
8088 return OK;
|
|
8089 }
|
|
8090
|
|
8091 /*
|
|
8092 * Clear all the terminal options.
|
|
8093 * If the option has been allocated, free the memory.
|
|
8094 * Terminal options are never hidden or indirect.
|
|
8095 */
|
|
8096 void
|
|
8097 clear_termoptions()
|
|
8098 {
|
|
8099 /*
|
|
8100 * Reset a few things before clearing the old options. This may cause
|
|
8101 * outputting a few things that the terminal doesn't understand, but the
|
|
8102 * screen will be cleared later, so this is OK.
|
|
8103 */
|
|
8104 #ifdef FEAT_MOUSE_TTY
|
|
8105 mch_setmouse(FALSE); /* switch mouse off */
|
|
8106 #endif
|
|
8107 #ifdef FEAT_TITLE
|
|
8108 mch_restore_title(3); /* restore window titles */
|
|
8109 #endif
|
|
8110 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
|
|
8111 /* When starting the GUI close the display opened for the clipboard.
|
|
8112 * After restoring the title, because that will need the display. */
|
|
8113 if (gui.starting)
|
|
8114 clear_xterm_clip();
|
|
8115 #endif
|
|
8116 #ifdef WIN3264
|
|
8117 /*
|
|
8118 * Check if this is allowed now.
|
|
8119 */
|
|
8120 if (can_end_termcap_mode(FALSE) == TRUE)
|
|
8121 #endif
|
|
8122 stoptermcap(); /* stop termcap mode */
|
|
8123
|
359
|
8124 free_termoptions();
|
|
8125 }
|
|
8126
|
|
8127 void
|
|
8128 free_termoptions()
|
|
8129 {
|
|
8130 struct vimoption *p;
|
|
8131
|
7
|
8132 for (p = &options[0]; p->fullname != NULL; p++)
|
|
8133 if (istermoption(p))
|
|
8134 {
|
|
8135 if (p->flags & P_ALLOCED)
|
|
8136 free_string_option(*(char_u **)(p->var));
|
|
8137 if (p->flags & P_DEF_ALLOCED)
|
|
8138 free_string_option(p->def_val[VI_DEFAULT]);
|
|
8139 *(char_u **)(p->var) = empty_option;
|
|
8140 p->def_val[VI_DEFAULT] = empty_option;
|
|
8141 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
|
|
8142 }
|
|
8143 clear_termcodes();
|
|
8144 }
|
|
8145
|
|
8146 /*
|
|
8147 * Set the terminal option defaults to the current value.
|
|
8148 * Used after setting the terminal name.
|
|
8149 */
|
|
8150 void
|
|
8151 set_term_defaults()
|
|
8152 {
|
|
8153 struct vimoption *p;
|
|
8154
|
|
8155 for (p = &options[0]; p->fullname != NULL; p++)
|
|
8156 {
|
|
8157 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
|
|
8158 {
|
|
8159 if (p->flags & P_DEF_ALLOCED)
|
|
8160 {
|
|
8161 free_string_option(p->def_val[VI_DEFAULT]);
|
|
8162 p->flags &= ~P_DEF_ALLOCED;
|
|
8163 }
|
|
8164 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
|
|
8165 if (p->flags & P_ALLOCED)
|
|
8166 {
|
|
8167 p->flags |= P_DEF_ALLOCED;
|
|
8168 p->flags &= ~P_ALLOCED; /* don't free the value now */
|
|
8169 }
|
|
8170 }
|
|
8171 }
|
|
8172 }
|
|
8173
|
|
8174 /*
|
|
8175 * return TRUE if 'p' starts with 't_'
|
|
8176 */
|
|
8177 static int
|
|
8178 istermoption(p)
|
|
8179 struct vimoption *p;
|
|
8180 {
|
|
8181 return (p->fullname[0] == 't' && p->fullname[1] == '_');
|
|
8182 }
|
|
8183
|
|
8184 /*
|
|
8185 * Compute columns for ruler and shown command. 'sc_col' is also used to
|
|
8186 * decide what the maximum length of a message on the status line can be.
|
|
8187 * If there is a status line for the last window, 'sc_col' is independent
|
|
8188 * of 'ru_col'.
|
|
8189 */
|
|
8190
|
|
8191 #define COL_RULER 17 /* columns needed by standard ruler */
|
|
8192
|
|
8193 void
|
|
8194 comp_col()
|
|
8195 {
|
|
8196 #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
|
|
8197 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
|
|
8198
|
|
8199 sc_col = 0;
|
|
8200 ru_col = 0;
|
|
8201 if (p_ru)
|
|
8202 {
|
|
8203 #ifdef FEAT_STL_OPT
|
|
8204 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
|
|
8205 #else
|
|
8206 ru_col = COL_RULER + 1;
|
|
8207 #endif
|
|
8208 /* no last status line, adjust sc_col */
|
|
8209 if (!last_has_status)
|
|
8210 sc_col = ru_col;
|
|
8211 }
|
|
8212 if (p_sc)
|
|
8213 {
|
|
8214 sc_col += SHOWCMD_COLS;
|
|
8215 if (!p_ru || last_has_status) /* no need for separating space */
|
|
8216 ++sc_col;
|
|
8217 }
|
|
8218 sc_col = Columns - sc_col;
|
|
8219 ru_col = Columns - ru_col;
|
|
8220 if (sc_col <= 0) /* screen too narrow, will become a mess */
|
|
8221 sc_col = 1;
|
|
8222 if (ru_col <= 0)
|
|
8223 ru_col = 1;
|
|
8224 #else
|
|
8225 sc_col = Columns;
|
|
8226 ru_col = Columns;
|
|
8227 #endif
|
|
8228 }
|
|
8229
|
|
8230 /*
|
|
8231 * Get pointer to option variable, depending on local or global scope.
|
|
8232 */
|
|
8233 static char_u *
|
|
8234 get_varp_scope(p, opt_flags)
|
|
8235 struct vimoption *p;
|
|
8236 int opt_flags;
|
|
8237 {
|
|
8238 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
|
|
8239 {
|
|
8240 if (p->var == VAR_WIN)
|
|
8241 return (char_u *)GLOBAL_WO(get_varp(p));
|
|
8242 return p->var;
|
|
8243 }
|
|
8244 if ((opt_flags & OPT_LOCAL) && (int)p->indir >= PV_BOTH)
|
|
8245 {
|
|
8246 switch ((int)p->indir)
|
|
8247 {
|
|
8248 #ifdef FEAT_QUICKFIX
|
|
8249 case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp);
|
|
8250 case OPT_BOTH(PV_MP): return (char_u *)&(curbuf->b_p_mp);
|
|
8251 case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm);
|
|
8252 #endif
|
|
8253 case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep);
|
|
8254 case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp);
|
|
8255 case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path);
|
|
8256 case OPT_BOTH(PV_AR): return (char_u *)&(curbuf->b_p_ar);
|
|
8257 case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags);
|
|
8258 #ifdef FEAT_FIND_ID
|
|
8259 case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def);
|
|
8260 case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc);
|
|
8261 #endif
|
|
8262 #ifdef FEAT_INS_EXPAND
|
|
8263 case OPT_BOTH(PV_DICT): return (char_u *)&(curbuf->b_p_dict);
|
|
8264 case OPT_BOTH(PV_TSR): return (char_u *)&(curbuf->b_p_tsr);
|
|
8265 #endif
|
40
|
8266 #ifdef FEAT_STL_OPT
|
|
8267 case OPT_BOTH(PV_STL): return (char_u *)&(curwin->w_p_stl);
|
|
8268 #endif
|
7
|
8269 }
|
|
8270 return NULL; /* "cannot happen" */
|
|
8271 }
|
|
8272 return get_varp(p);
|
|
8273 }
|
|
8274
|
|
8275 /*
|
|
8276 * Get pointer to option variable.
|
|
8277 */
|
|
8278 static char_u *
|
|
8279 get_varp(p)
|
|
8280 struct vimoption *p;
|
|
8281 {
|
|
8282 /* hidden option, always return NULL */
|
|
8283 if (p->var == NULL)
|
|
8284 return NULL;
|
|
8285
|
|
8286 switch ((int)p->indir)
|
|
8287 {
|
|
8288 case PV_NONE: return p->var;
|
|
8289
|
|
8290 /* global option with local value: use local value if it's been set */
|
|
8291 case OPT_BOTH(PV_EP): return *curbuf->b_p_ep != NUL
|
|
8292 ? (char_u *)&curbuf->b_p_ep : p->var;
|
|
8293 case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL
|
|
8294 ? (char_u *)&curbuf->b_p_kp : p->var;
|
|
8295 case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL
|
|
8296 ? (char_u *)&(curbuf->b_p_path) : p->var;
|
|
8297 case OPT_BOTH(PV_AR): return curbuf->b_p_ar >= 0
|
|
8298 ? (char_u *)&(curbuf->b_p_ar) : p->var;
|
|
8299 case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL
|
|
8300 ? (char_u *)&(curbuf->b_p_tags) : p->var;
|
|
8301 #ifdef FEAT_FIND_ID
|
|
8302 case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL
|
|
8303 ? (char_u *)&(curbuf->b_p_def) : p->var;
|
|
8304 case OPT_BOTH(PV_INC): return *curbuf->b_p_inc != NUL
|
|
8305 ? (char_u *)&(curbuf->b_p_inc) : p->var;
|
|
8306 #endif
|
|
8307 #ifdef FEAT_INS_EXPAND
|
|
8308 case OPT_BOTH(PV_DICT): return *curbuf->b_p_dict != NUL
|
|
8309 ? (char_u *)&(curbuf->b_p_dict) : p->var;
|
|
8310 case OPT_BOTH(PV_TSR): return *curbuf->b_p_tsr != NUL
|
|
8311 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
|
|
8312 #endif
|
|
8313 #ifdef FEAT_QUICKFIX
|
|
8314 case OPT_BOTH(PV_GP): return *curbuf->b_p_gp != NUL
|
|
8315 ? (char_u *)&(curbuf->b_p_gp) : p->var;
|
|
8316 case OPT_BOTH(PV_MP): return *curbuf->b_p_mp != NUL
|
|
8317 ? (char_u *)&(curbuf->b_p_mp) : p->var;
|
|
8318 case OPT_BOTH(PV_EFM): return *curbuf->b_p_efm != NUL
|
|
8319 ? (char_u *)&(curbuf->b_p_efm) : p->var;
|
|
8320 #endif
|
40
|
8321 #ifdef FEAT_STL_OPT
|
|
8322 case OPT_BOTH(PV_STL): return *curwin->w_p_stl != NUL
|
|
8323 ? (char_u *)&(curwin->w_p_stl) : p->var;
|
|
8324 #endif
|
7
|
8325
|
|
8326 #ifdef FEAT_ARABIC
|
|
8327 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
|
|
8328 #endif
|
|
8329 case PV_LIST: return (char_u *)&(curwin->w_p_list);
|
221
|
8330 #ifdef FEAT_SYN_HL
|
|
8331 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
|
|
8332 #endif
|
7
|
8333 #ifdef FEAT_DIFF
|
|
8334 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
|
|
8335 #endif
|
|
8336 #ifdef FEAT_FOLDING
|
|
8337 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
|
|
8338 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
|
|
8339 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
|
|
8340 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
|
|
8341 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
|
|
8342 case PV_FML: return (char_u *)&(curwin->w_p_fml);
|
|
8343 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
|
|
8344 # ifdef FEAT_EVAL
|
|
8345 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
|
|
8346 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
|
|
8347 # endif
|
|
8348 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
|
|
8349 #endif
|
|
8350 case PV_NU: return (char_u *)&(curwin->w_p_nu);
|
13
|
8351 #ifdef FEAT_LINEBREAK
|
|
8352 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
|
|
8353 #endif
|
7
|
8354 #if defined(FEAT_WINDOWS)
|
|
8355 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
|
|
8356 #endif
|
|
8357 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
|
8358 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
|
|
8359 #endif
|
|
8360 #ifdef FEAT_RIGHTLEFT
|
|
8361 case PV_RL: return (char_u *)&(curwin->w_p_rl);
|
|
8362 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
|
|
8363 #endif
|
|
8364 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
|
|
8365 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
|
|
8366 #ifdef FEAT_LINEBREAK
|
|
8367 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
|
|
8368 #endif
|
|
8369 #ifdef FEAT_SCROLLBIND
|
|
8370 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
|
|
8371 #endif
|
|
8372
|
|
8373 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
|
|
8374 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
|
|
8375 #ifdef FEAT_MBYTE
|
|
8376 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
|
|
8377 #endif
|
|
8378 #if defined(FEAT_QUICKFIX)
|
|
8379 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
|
|
8380 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
|
|
8381 #endif
|
|
8382 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
|
|
8383 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
|
|
8384 #ifdef FEAT_CINDENT
|
|
8385 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
|
|
8386 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
|
|
8387 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
|
|
8388 #endif
|
|
8389 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
8390 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
|
|
8391 #endif
|
|
8392 #ifdef FEAT_COMMENTS
|
|
8393 case PV_COM: return (char_u *)&(curbuf->b_p_com);
|
|
8394 #endif
|
|
8395 #ifdef FEAT_FOLDING
|
|
8396 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
|
|
8397 #endif
|
|
8398 #ifdef FEAT_INS_EXPAND
|
|
8399 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
|
|
8400 #endif
|
12
|
8401 #ifdef FEAT_COMPL_FUNC
|
|
8402 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
|
|
8403 #endif
|
7
|
8404 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
|
|
8405 case PV_ET: return (char_u *)&(curbuf->b_p_et);
|
|
8406 #ifdef FEAT_MBYTE
|
|
8407 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
|
|
8408 #endif
|
|
8409 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
|
|
8410 #ifdef FEAT_AUTOCMD
|
|
8411 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
|
|
8412 #endif
|
|
8413 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
|
41
|
8414 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
|
7
|
8415 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
|
|
8416 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
|
|
8417 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
|
|
8418 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
|
|
8419 #ifdef FEAT_FIND_ID
|
|
8420 # ifdef FEAT_EVAL
|
|
8421 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
|
|
8422 # endif
|
|
8423 #endif
|
|
8424 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
8425 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
|
|
8426 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
|
|
8427 #endif
|
|
8428 #ifdef FEAT_CRYPT
|
|
8429 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
|
|
8430 #endif
|
|
8431 #ifdef FEAT_LISP
|
|
8432 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
|
|
8433 #endif
|
|
8434 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
|
|
8435 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
|
|
8436 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
|
|
8437 case PV_MOD: return (char_u *)&(curbuf->b_changed);
|
|
8438 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
|
|
8439 #ifdef FEAT_OSFILETYPE
|
|
8440 case PV_OFT: return (char_u *)&(curbuf->b_p_oft);
|
|
8441 #endif
|
|
8442 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
|
12
|
8443 #ifdef FEAT_TEXTOBJ
|
|
8444 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
|
|
8445 #endif
|
7
|
8446 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
|
|
8447 #ifdef FEAT_SMARTINDENT
|
|
8448 case PV_SI: return (char_u *)&(curbuf->b_p_si);
|
|
8449 #endif
|
|
8450 #ifndef SHORT_FNAME
|
|
8451 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
|
|
8452 #endif
|
|
8453 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
|
|
8454 #ifdef FEAT_SEARCHPATH
|
|
8455 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
|
|
8456 #endif
|
|
8457 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
|
|
8458 #ifdef FEAT_SYN_HL
|
410
|
8459 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
|
7
|
8460 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
|
386
|
8461 case PV_SPC: return (char_u *)&(curbuf->b_p_spc);
|
314
|
8462 case PV_SPF: return (char_u *)&(curbuf->b_p_spf);
|
221
|
8463 case PV_SPL: return (char_u *)&(curbuf->b_p_spl);
|
7
|
8464 #endif
|
|
8465 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
|
|
8466 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
|
|
8467 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
|
|
8468 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
|
|
8469 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
|
|
8470 #ifdef FEAT_KEYMAP
|
|
8471 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
|
|
8472 #endif
|
|
8473 default: EMSG(_("E356: get_varp ERROR"));
|
|
8474 }
|
|
8475 /* always return a valid pointer to avoid a crash! */
|
|
8476 return (char_u *)&(curbuf->b_p_wm);
|
|
8477 }
|
|
8478
|
|
8479 /*
|
|
8480 * Get the value of 'equalprg', either the buffer-local one or the global one.
|
|
8481 */
|
|
8482 char_u *
|
|
8483 get_equalprg()
|
|
8484 {
|
|
8485 if (*curbuf->b_p_ep == NUL)
|
|
8486 return p_ep;
|
|
8487 return curbuf->b_p_ep;
|
|
8488 }
|
|
8489
|
|
8490 #if defined(FEAT_WINDOWS) || defined(PROTO)
|
|
8491 /*
|
|
8492 * Copy options from one window to another.
|
|
8493 * Used when splitting a window.
|
|
8494 */
|
|
8495 void
|
|
8496 win_copy_options(wp_from, wp_to)
|
|
8497 win_T *wp_from;
|
|
8498 win_T *wp_to;
|
|
8499 {
|
|
8500 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
|
|
8501 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
|
|
8502 # ifdef FEAT_RIGHTLEFT
|
|
8503 # ifdef FEAT_FKMAP
|
|
8504 /* Is this right? */
|
|
8505 wp_to->w_farsi = wp_from->w_farsi;
|
|
8506 # endif
|
|
8507 # endif
|
|
8508 }
|
|
8509 #endif
|
|
8510
|
|
8511 /*
|
|
8512 * Copy the options from one winopt_T to another.
|
|
8513 * Doesn't free the old option values in "to", use clear_winopt() for that.
|
|
8514 * The 'scroll' option is not copied, because it depends on the window height.
|
|
8515 * The 'previewwindow' option is reset, there can be only one preview window.
|
|
8516 */
|
|
8517 void
|
|
8518 copy_winopt(from, to)
|
|
8519 winopt_T *from;
|
|
8520 winopt_T *to;
|
|
8521 {
|
|
8522 #ifdef FEAT_ARABIC
|
|
8523 to->wo_arab = from->wo_arab;
|
|
8524 #endif
|
|
8525 to->wo_list = from->wo_list;
|
|
8526 to->wo_nu = from->wo_nu;
|
13
|
8527 #ifdef FEAT_LINEBREAK
|
|
8528 to->wo_nuw = from->wo_nuw;
|
|
8529 #endif
|
7
|
8530 #ifdef FEAT_RIGHTLEFT
|
|
8531 to->wo_rl = from->wo_rl;
|
|
8532 to->wo_rlc = vim_strsave(from->wo_rlc);
|
|
8533 #endif
|
40
|
8534 #ifdef FEAT_STL_OPT
|
|
8535 to->wo_stl = vim_strsave(from->wo_stl);
|
|
8536 #endif
|
7
|
8537 to->wo_wrap = from->wo_wrap;
|
|
8538 #ifdef FEAT_LINEBREAK
|
|
8539 to->wo_lbr = from->wo_lbr;
|
|
8540 #endif
|
|
8541 #ifdef FEAT_SCROLLBIND
|
|
8542 to->wo_scb = from->wo_scb;
|
|
8543 #endif
|
221
|
8544 #ifdef FEAT_SYN_HL
|
|
8545 to->wo_spell = from->wo_spell;
|
|
8546 #endif
|
7
|
8547 #ifdef FEAT_DIFF
|
|
8548 to->wo_diff = from->wo_diff;
|
|
8549 #endif
|
|
8550 #ifdef FEAT_FOLDING
|
|
8551 to->wo_fdc = from->wo_fdc;
|
|
8552 to->wo_fen = from->wo_fen;
|
|
8553 to->wo_fdi = vim_strsave(from->wo_fdi);
|
|
8554 to->wo_fml = from->wo_fml;
|
|
8555 to->wo_fdl = from->wo_fdl;
|
|
8556 to->wo_fdm = vim_strsave(from->wo_fdm);
|
|
8557 to->wo_fdn = from->wo_fdn;
|
|
8558 # ifdef FEAT_EVAL
|
|
8559 to->wo_fde = vim_strsave(from->wo_fde);
|
|
8560 to->wo_fdt = vim_strsave(from->wo_fdt);
|
|
8561 # endif
|
|
8562 to->wo_fmr = vim_strsave(from->wo_fmr);
|
|
8563 #endif
|
|
8564 check_winopt(to); /* don't want NULL pointers */
|
|
8565 }
|
|
8566
|
|
8567 /*
|
|
8568 * Check string options in a window for a NULL value.
|
|
8569 */
|
|
8570 void
|
|
8571 check_win_options(win)
|
|
8572 win_T *win;
|
|
8573 {
|
|
8574 check_winopt(&win->w_onebuf_opt);
|
|
8575 check_winopt(&win->w_allbuf_opt);
|
|
8576 }
|
|
8577
|
|
8578 /*
|
|
8579 * Check for NULL pointers in a winopt_T and replace them with empty_option.
|
|
8580 */
|
|
8581 /*ARGSUSED*/
|
|
8582 void
|
|
8583 check_winopt(wop)
|
|
8584 winopt_T *wop;
|
|
8585 {
|
|
8586 #ifdef FEAT_FOLDING
|
|
8587 check_string_option(&wop->wo_fdi);
|
|
8588 check_string_option(&wop->wo_fdm);
|
|
8589 # ifdef FEAT_EVAL
|
|
8590 check_string_option(&wop->wo_fde);
|
|
8591 check_string_option(&wop->wo_fdt);
|
|
8592 # endif
|
|
8593 check_string_option(&wop->wo_fmr);
|
|
8594 #endif
|
|
8595 #ifdef FEAT_RIGHTLEFT
|
|
8596 check_string_option(&wop->wo_rlc);
|
|
8597 #endif
|
40
|
8598 #ifdef FEAT_STL_OPT
|
|
8599 check_string_option(&wop->wo_stl);
|
|
8600 #endif
|
7
|
8601 }
|
|
8602
|
|
8603 /*
|
|
8604 * Free the allocated memory inside a winopt_T.
|
|
8605 */
|
|
8606 /*ARGSUSED*/
|
|
8607 void
|
|
8608 clear_winopt(wop)
|
|
8609 winopt_T *wop;
|
|
8610 {
|
|
8611 #ifdef FEAT_FOLDING
|
|
8612 clear_string_option(&wop->wo_fdi);
|
|
8613 clear_string_option(&wop->wo_fdm);
|
|
8614 # ifdef FEAT_EVAL
|
|
8615 clear_string_option(&wop->wo_fde);
|
|
8616 clear_string_option(&wop->wo_fdt);
|
|
8617 # endif
|
|
8618 clear_string_option(&wop->wo_fmr);
|
|
8619 #endif
|
|
8620 #ifdef FEAT_RIGHTLEFT
|
|
8621 clear_string_option(&wop->wo_rlc);
|
|
8622 #endif
|
40
|
8623 #ifdef FEAT_STL_OPT
|
|
8624 clear_string_option(&wop->wo_stl);
|
|
8625 #endif
|
7
|
8626 }
|
|
8627
|
|
8628 /*
|
|
8629 * Copy global option values to local options for one buffer.
|
|
8630 * Used when creating a new buffer and sometimes when entering a buffer.
|
|
8631 * flags:
|
|
8632 * BCO_ENTER We will enter the buf buffer.
|
|
8633 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
|
|
8634 * appropriate.
|
|
8635 * BCO_NOHELP Don't copy the values to a help buffer.
|
|
8636 */
|
|
8637 void
|
|
8638 buf_copy_options(buf, flags)
|
|
8639 buf_T *buf;
|
|
8640 int flags;
|
|
8641 {
|
|
8642 int should_copy = TRUE;
|
|
8643 char_u *save_p_isk = NULL; /* init for GCC */
|
|
8644 int dont_do_help;
|
|
8645 int did_isk = FALSE;
|
|
8646
|
|
8647 /*
|
|
8648 * Don't do anything of the buffer is invalid.
|
|
8649 */
|
|
8650 if (buf == NULL || !buf_valid(buf))
|
|
8651 return;
|
|
8652
|
|
8653 /*
|
|
8654 * Skip this when the option defaults have not been set yet. Happens when
|
|
8655 * main() allocates the first buffer.
|
|
8656 */
|
|
8657 if (p_cpo != NULL)
|
|
8658 {
|
|
8659 /*
|
|
8660 * Always copy when entering and 'cpo' contains 'S'.
|
|
8661 * Don't copy when already initialized.
|
|
8662 * Don't copy when 'cpo' contains 's' and not entering.
|
|
8663 * 'S' BCO_ENTER initialized 's' should_copy
|
|
8664 * yes yes X X TRUE
|
|
8665 * yes no yes X FALSE
|
|
8666 * no X yes X FALSE
|
|
8667 * X no no yes FALSE
|
|
8668 * X no no no TRUE
|
|
8669 * no yes no X TRUE
|
|
8670 */
|
|
8671 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
|
|
8672 && (buf->b_p_initialized
|
|
8673 || (!(flags & BCO_ENTER)
|
|
8674 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
|
|
8675 should_copy = FALSE;
|
|
8676
|
|
8677 if (should_copy || (flags & BCO_ALWAYS))
|
|
8678 {
|
|
8679 /* Don't copy the options specific to a help buffer when
|
|
8680 * BCO_NOHELP is given or the options were initialized already
|
|
8681 * (jumping back to a help file with CTRL-T or CTRL-O) */
|
|
8682 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
|
|
8683 || buf->b_p_initialized;
|
|
8684 if (dont_do_help) /* don't free b_p_isk */
|
|
8685 {
|
|
8686 save_p_isk = buf->b_p_isk;
|
|
8687 buf->b_p_isk = NULL;
|
|
8688 }
|
|
8689 /*
|
|
8690 * Always free the allocated strings.
|
|
8691 * If not already initialized, set 'readonly' and copy 'fileformat'.
|
|
8692 */
|
|
8693 if (!buf->b_p_initialized)
|
|
8694 {
|
|
8695 free_buf_options(buf, TRUE);
|
|
8696 buf->b_p_ro = FALSE; /* don't copy readonly */
|
|
8697 buf->b_p_tx = p_tx;
|
|
8698 #ifdef FEAT_MBYTE
|
|
8699 buf->b_p_fenc = vim_strsave(p_fenc);
|
|
8700 #endif
|
|
8701 buf->b_p_ff = vim_strsave(p_ff);
|
|
8702 #if defined(FEAT_QUICKFIX)
|
|
8703 buf->b_p_bh = empty_option;
|
|
8704 buf->b_p_bt = empty_option;
|
|
8705 #endif
|
|
8706 }
|
|
8707 else
|
|
8708 free_buf_options(buf, FALSE);
|
|
8709
|
|
8710 buf->b_p_ai = p_ai;
|
|
8711 buf->b_p_ai_nopaste = p_ai_nopaste;
|
|
8712 buf->b_p_sw = p_sw;
|
|
8713 buf->b_p_tw = p_tw;
|
|
8714 buf->b_p_tw_nopaste = p_tw_nopaste;
|
|
8715 buf->b_p_tw_nobin = p_tw_nobin;
|
|
8716 buf->b_p_wm = p_wm;
|
|
8717 buf->b_p_wm_nopaste = p_wm_nopaste;
|
|
8718 buf->b_p_wm_nobin = p_wm_nobin;
|
|
8719 buf->b_p_bin = p_bin;
|
402
|
8720 #ifdef FEAT_MBYTE
|
|
8721 buf->b_p_bomb = p_bomb;
|
|
8722 #endif
|
7
|
8723 buf->b_p_et = p_et;
|
|
8724 buf->b_p_et_nobin = p_et_nobin;
|
|
8725 buf->b_p_ml = p_ml;
|
|
8726 buf->b_p_ml_nobin = p_ml_nobin;
|
|
8727 buf->b_p_inf = p_inf;
|
|
8728 buf->b_p_swf = p_swf;
|
|
8729 #ifdef FEAT_INS_EXPAND
|
|
8730 buf->b_p_cpt = vim_strsave(p_cpt);
|
|
8731 #endif
|
12
|
8732 #ifdef FEAT_COMPL_FUNC
|
|
8733 buf->b_p_cfu = vim_strsave(p_cfu);
|
|
8734 #endif
|
7
|
8735 buf->b_p_sts = p_sts;
|
|
8736 buf->b_p_sts_nopaste = p_sts_nopaste;
|
|
8737 #ifndef SHORT_FNAME
|
|
8738 buf->b_p_sn = p_sn;
|
|
8739 #endif
|
|
8740 #ifdef FEAT_COMMENTS
|
|
8741 buf->b_p_com = vim_strsave(p_com);
|
|
8742 #endif
|
|
8743 #ifdef FEAT_FOLDING
|
|
8744 buf->b_p_cms = vim_strsave(p_cms);
|
|
8745 #endif
|
|
8746 buf->b_p_fo = vim_strsave(p_fo);
|
41
|
8747 buf->b_p_flp = vim_strsave(p_flp);
|
7
|
8748 buf->b_p_nf = vim_strsave(p_nf);
|
|
8749 buf->b_p_mps = vim_strsave(p_mps);
|
|
8750 #ifdef FEAT_SMARTINDENT
|
|
8751 buf->b_p_si = p_si;
|
|
8752 #endif
|
|
8753 buf->b_p_ci = p_ci;
|
|
8754 #ifdef FEAT_CINDENT
|
|
8755 buf->b_p_cin = p_cin;
|
|
8756 buf->b_p_cink = vim_strsave(p_cink);
|
|
8757 buf->b_p_cino = vim_strsave(p_cino);
|
|
8758 #endif
|
|
8759 #ifdef FEAT_AUTOCMD
|
|
8760 /* Don't copy 'filetype', it must be detected */
|
|
8761 buf->b_p_ft = empty_option;
|
|
8762 #endif
|
|
8763 #ifdef FEAT_OSFILETYPE
|
|
8764 buf->b_p_oft = vim_strsave(p_oft);
|
|
8765 #endif
|
|
8766 buf->b_p_pi = p_pi;
|
|
8767 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
|
|
8768 buf->b_p_cinw = vim_strsave(p_cinw);
|
|
8769 #endif
|
|
8770 #ifdef FEAT_LISP
|
|
8771 buf->b_p_lisp = p_lisp;
|
|
8772 #endif
|
|
8773 #ifdef FEAT_SYN_HL
|
|
8774 /* Don't copy 'syntax', it must be set */
|
|
8775 buf->b_p_syn = empty_option;
|
410
|
8776 buf->b_p_smc = p_smc;
|
386
|
8777 buf->b_p_spc = vim_strsave(p_spc);
|
389
|
8778 (void)compile_cap_prog(buf);
|
314
|
8779 buf->b_p_spf = vim_strsave(p_spf);
|
221
|
8780 buf->b_p_spl = vim_strsave(p_spl);
|
7
|
8781 #endif
|
|
8782 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
|
|
8783 buf->b_p_inde = vim_strsave(p_inde);
|
|
8784 buf->b_p_indk = vim_strsave(p_indk);
|
|
8785 #endif
|
|
8786 #ifdef FEAT_CRYPT
|
|
8787 buf->b_p_key = vim_strsave(p_key);
|
|
8788 #endif
|
|
8789 #ifdef FEAT_SEARCHPATH
|
|
8790 buf->b_p_sua = vim_strsave(p_sua);
|
|
8791 #endif
|
|
8792 #ifdef FEAT_KEYMAP
|
|
8793 buf->b_p_keymap = vim_strsave(p_keymap);
|
|
8794 buf->b_kmap_state |= KEYMAP_INIT;
|
|
8795 #endif
|
|
8796 /* This isn't really an option, but copying the langmap and IME
|
|
8797 * state from the current buffer is better than resetting it. */
|
|
8798 buf->b_p_iminsert = p_iminsert;
|
|
8799 buf->b_p_imsearch = p_imsearch;
|
|
8800
|
|
8801 /* options that are normally global but also have a local value
|
|
8802 * are not copied, start using the global value */
|
|
8803 buf->b_p_ar = -1;
|
|
8804 #ifdef FEAT_QUICKFIX
|
|
8805 buf->b_p_gp = empty_option;
|
|
8806 buf->b_p_mp = empty_option;
|
|
8807 buf->b_p_efm = empty_option;
|
|
8808 #endif
|
|
8809 buf->b_p_ep = empty_option;
|
|
8810 buf->b_p_kp = empty_option;
|
|
8811 buf->b_p_path = empty_option;
|
|
8812 buf->b_p_tags = empty_option;
|
|
8813 #ifdef FEAT_FIND_ID
|
|
8814 buf->b_p_def = empty_option;
|
|
8815 buf->b_p_inc = empty_option;
|
|
8816 # ifdef FEAT_EVAL
|
|
8817 buf->b_p_inex = vim_strsave(p_inex);
|
|
8818 # endif
|
|
8819 #endif
|
|
8820 #ifdef FEAT_INS_EXPAND
|
|
8821 buf->b_p_dict = empty_option;
|
|
8822 buf->b_p_tsr = empty_option;
|
|
8823 #endif
|
12
|
8824 #ifdef FEAT_TEXTOBJ
|
|
8825 buf->b_p_qe = vim_strsave(p_qe);
|
|
8826 #endif
|
7
|
8827
|
|
8828 /*
|
|
8829 * Don't copy the options set by ex_help(), use the saved values,
|
|
8830 * when going from a help buffer to a non-help buffer.
|
|
8831 * Don't touch these at all when BCO_NOHELP is used and going from
|
|
8832 * or to a help buffer.
|
|
8833 */
|
|
8834 if (dont_do_help)
|
|
8835 buf->b_p_isk = save_p_isk;
|
|
8836 else
|
|
8837 {
|
|
8838 buf->b_p_isk = vim_strsave(p_isk);
|
|
8839 did_isk = TRUE;
|
|
8840 buf->b_p_ts = p_ts;
|
|
8841 buf->b_help = FALSE;
|
|
8842 #ifdef FEAT_QUICKFIX
|
|
8843 if (buf->b_p_bt[0] == 'h')
|
|
8844 clear_string_option(&buf->b_p_bt);
|
|
8845 #endif
|
|
8846 buf->b_p_ma = p_ma;
|
|
8847 }
|
|
8848 }
|
|
8849
|
|
8850 /*
|
|
8851 * When the options should be copied (ignoring BCO_ALWAYS), set the
|
|
8852 * flag that indicates that the options have been initialized.
|
|
8853 */
|
|
8854 if (should_copy)
|
|
8855 buf->b_p_initialized = TRUE;
|
|
8856 }
|
|
8857
|
|
8858 check_buf_options(buf); /* make sure we don't have NULLs */
|
|
8859 if (did_isk)
|
|
8860 (void)buf_init_chartab(buf, FALSE);
|
|
8861 }
|
|
8862
|
|
8863 /*
|
|
8864 * Reset the 'modifiable' option and its default value.
|
|
8865 */
|
|
8866 void
|
|
8867 reset_modifiable()
|
|
8868 {
|
|
8869 int opt_idx;
|
|
8870
|
|
8871 curbuf->b_p_ma = FALSE;
|
|
8872 p_ma = FALSE;
|
|
8873 opt_idx = findoption((char_u *)"ma");
|
|
8874 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
|
|
8875 }
|
|
8876
|
|
8877 /*
|
|
8878 * Set the global value for 'iminsert' to the local value.
|
|
8879 */
|
|
8880 void
|
|
8881 set_iminsert_global()
|
|
8882 {
|
|
8883 p_iminsert = curbuf->b_p_iminsert;
|
|
8884 }
|
|
8885
|
|
8886 /*
|
|
8887 * Set the global value for 'imsearch' to the local value.
|
|
8888 */
|
|
8889 void
|
|
8890 set_imsearch_global()
|
|
8891 {
|
|
8892 p_imsearch = curbuf->b_p_imsearch;
|
|
8893 }
|
|
8894
|
|
8895 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
|
|
8896 static int expand_option_idx = -1;
|
|
8897 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
|
|
8898 static int expand_option_flags = 0;
|
|
8899
|
|
8900 void
|
|
8901 set_context_in_set_cmd(xp, arg, opt_flags)
|
|
8902 expand_T *xp;
|
|
8903 char_u *arg;
|
|
8904 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
|
|
8905 {
|
|
8906 int nextchar;
|
|
8907 long_u flags = 0; /* init for GCC */
|
|
8908 int opt_idx = 0; /* init for GCC */
|
|
8909 char_u *p;
|
|
8910 char_u *s;
|
|
8911 int is_term_option = FALSE;
|
|
8912 int key;
|
|
8913
|
|
8914 expand_option_flags = opt_flags;
|
|
8915
|
|
8916 xp->xp_context = EXPAND_SETTINGS;
|
|
8917 if (*arg == NUL)
|
|
8918 {
|
|
8919 xp->xp_pattern = arg;
|
|
8920 return;
|
|
8921 }
|
|
8922 p = arg + STRLEN(arg) - 1;
|
|
8923 if (*p == ' ' && *(p - 1) != '\\')
|
|
8924 {
|
|
8925 xp->xp_pattern = p + 1;
|
|
8926 return;
|
|
8927 }
|
|
8928 while (p > arg)
|
|
8929 {
|
|
8930 s = p;
|
|
8931 /* count number of backslashes before ' ' or ',' */
|
|
8932 if (*p == ' ' || *p == ',')
|
|
8933 {
|
|
8934 while (s > arg && *(s - 1) == '\\')
|
|
8935 --s;
|
|
8936 }
|
|
8937 /* break at a space with an even number of backslashes */
|
|
8938 if (*p == ' ' && ((p - s) & 1) == 0)
|
|
8939 {
|
|
8940 ++p;
|
|
8941 break;
|
|
8942 }
|
|
8943 --p;
|
|
8944 }
|
|
8945 if (STRNCMP(p, "no", 2) == 0)
|
|
8946 {
|
|
8947 xp->xp_context = EXPAND_BOOL_SETTINGS;
|
|
8948 p += 2;
|
|
8949 }
|
|
8950 if (STRNCMP(p, "inv", 3) == 0)
|
|
8951 {
|
|
8952 xp->xp_context = EXPAND_BOOL_SETTINGS;
|
|
8953 p += 3;
|
|
8954 }
|
|
8955 xp->xp_pattern = arg = p;
|
|
8956 if (*arg == '<')
|
|
8957 {
|
|
8958 while (*p != '>')
|
|
8959 if (*p++ == NUL) /* expand terminal option name */
|
|
8960 return;
|
|
8961 key = get_special_key_code(arg + 1);
|
|
8962 if (key == 0) /* unknown name */
|
|
8963 {
|
|
8964 xp->xp_context = EXPAND_NOTHING;
|
|
8965 return;
|
|
8966 }
|
|
8967 nextchar = *++p;
|
|
8968 is_term_option = TRUE;
|
|
8969 expand_option_name[2] = KEY2TERMCAP0(key);
|
|
8970 expand_option_name[3] = KEY2TERMCAP1(key);
|
|
8971 }
|
|
8972 else
|
|
8973 {
|
|
8974 if (p[0] == 't' && p[1] == '_')
|
|
8975 {
|
|
8976 p += 2;
|
|
8977 if (*p != NUL)
|
|
8978 ++p;
|
|
8979 if (*p == NUL)
|
|
8980 return; /* expand option name */
|
|
8981 nextchar = *++p;
|
|
8982 is_term_option = TRUE;
|
|
8983 expand_option_name[2] = p[-2];
|
|
8984 expand_option_name[3] = p[-1];
|
|
8985 }
|
|
8986 else
|
|
8987 {
|
|
8988 /* Allow * wildcard */
|
|
8989 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
|
|
8990 p++;
|
|
8991 if (*p == NUL)
|
|
8992 return;
|
|
8993 nextchar = *p;
|
|
8994 *p = NUL;
|
|
8995 opt_idx = findoption(arg);
|
|
8996 *p = nextchar;
|
|
8997 if (opt_idx == -1 || options[opt_idx].var == NULL)
|
|
8998 {
|
|
8999 xp->xp_context = EXPAND_NOTHING;
|
|
9000 return;
|
|
9001 }
|
|
9002 flags = options[opt_idx].flags;
|
|
9003 if (flags & P_BOOL)
|
|
9004 {
|
|
9005 xp->xp_context = EXPAND_NOTHING;
|
|
9006 return;
|
|
9007 }
|
|
9008 }
|
|
9009 }
|
|
9010 /* handle "-=" and "+=" */
|
|
9011 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
|
|
9012 {
|
|
9013 ++p;
|
|
9014 nextchar = '=';
|
|
9015 }
|
|
9016 if ((nextchar != '=' && nextchar != ':')
|
|
9017 || xp->xp_context == EXPAND_BOOL_SETTINGS)
|
|
9018 {
|
|
9019 xp->xp_context = EXPAND_UNSUCCESSFUL;
|
|
9020 return;
|
|
9021 }
|
|
9022 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
|
|
9023 {
|
|
9024 xp->xp_context = EXPAND_OLD_SETTING;
|
|
9025 if (is_term_option)
|
|
9026 expand_option_idx = -1;
|
|
9027 else
|
|
9028 expand_option_idx = opt_idx;
|
|
9029 xp->xp_pattern = p + 1;
|
|
9030 return;
|
|
9031 }
|
|
9032 xp->xp_context = EXPAND_NOTHING;
|
|
9033 if (is_term_option || (flags & P_NUM))
|
|
9034 return;
|
|
9035
|
|
9036 xp->xp_pattern = p + 1;
|
|
9037
|
|
9038 if (flags & P_EXPAND)
|
|
9039 {
|
|
9040 p = options[opt_idx].var;
|
|
9041 if (p == (char_u *)&p_bdir
|
|
9042 || p == (char_u *)&p_dir
|
|
9043 || p == (char_u *)&p_path
|
|
9044 || p == (char_u *)&p_rtp
|
|
9045 #ifdef FEAT_SEARCHPATH
|
|
9046 || p == (char_u *)&p_cdpath
|
|
9047 #endif
|
|
9048 #ifdef FEAT_SESSION
|
|
9049 || p == (char_u *)&p_vdir
|
|
9050 #endif
|
|
9051 )
|
|
9052 {
|
|
9053 xp->xp_context = EXPAND_DIRECTORIES;
|
|
9054 if (p == (char_u *)&p_path
|
|
9055 #ifdef FEAT_SEARCHPATH
|
|
9056 || p == (char_u *)&p_cdpath
|
|
9057 #endif
|
|
9058 )
|
|
9059 xp->xp_backslash = XP_BS_THREE;
|
|
9060 else
|
|
9061 xp->xp_backslash = XP_BS_ONE;
|
|
9062 }
|
|
9063 else
|
|
9064 {
|
|
9065 xp->xp_context = EXPAND_FILES;
|
|
9066 /* for 'tags' need three backslashes for a space */
|
|
9067 if (p == (char_u *)&p_tags)
|
|
9068 xp->xp_backslash = XP_BS_THREE;
|
|
9069 else
|
|
9070 xp->xp_backslash = XP_BS_ONE;
|
|
9071 }
|
|
9072 }
|
|
9073
|
|
9074 /* For an option that is a list of file names, find the start of the
|
|
9075 * last file name. */
|
|
9076 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
|
|
9077 {
|
|
9078 /* count number of backslashes before ' ' or ',' */
|
|
9079 if (*p == ' ' || *p == ',')
|
|
9080 {
|
|
9081 s = p;
|
|
9082 while (s > xp->xp_pattern && *(s - 1) == '\\')
|
|
9083 --s;
|
|
9084 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|
|
9085 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
|
|
9086 {
|
|
9087 xp->xp_pattern = p + 1;
|
|
9088 break;
|
|
9089 }
|
|
9090 }
|
374
|
9091
|
|
9092 #ifdef FEAT_SYN_HL
|
|
9093 /* for 'spellsuggest' start at "file:" */
|
|
9094 if (options[opt_idx].var == (char_u *)&p_sps
|
|
9095 && STRNCMP(p, "file:", 5) == 0)
|
|
9096 {
|
|
9097 xp->xp_pattern = p + 5;
|
|
9098 break;
|
|
9099 }
|
|
9100 #endif
|
7
|
9101 }
|
|
9102
|
|
9103 return;
|
|
9104 }
|
|
9105
|
|
9106 int
|
|
9107 ExpandSettings(xp, regmatch, num_file, file)
|
|
9108 expand_T *xp;
|
|
9109 regmatch_T *regmatch;
|
|
9110 int *num_file;
|
|
9111 char_u ***file;
|
|
9112 {
|
|
9113 int num_normal = 0; /* Nr of matching non-term-code settings */
|
|
9114 int num_term = 0; /* Nr of matching terminal code settings */
|
|
9115 int opt_idx;
|
|
9116 int match;
|
|
9117 int count = 0;
|
|
9118 char_u *str;
|
|
9119 int loop;
|
|
9120 int is_term_opt;
|
|
9121 char_u name_buf[MAX_KEY_NAME_LEN];
|
|
9122 static char *(names[]) = {"all", "termcap"};
|
|
9123 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
|
|
9124
|
|
9125 /* do this loop twice:
|
|
9126 * loop == 0: count the number of matching options
|
|
9127 * loop == 1: copy the matching options into allocated memory
|
|
9128 */
|
|
9129 for (loop = 0; loop <= 1; ++loop)
|
|
9130 {
|
|
9131 regmatch->rm_ic = ic;
|
|
9132 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
|
|
9133 {
|
|
9134 for (match = 0; match < sizeof(names) / sizeof(char *); ++match)
|
|
9135 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
|
|
9136 {
|
|
9137 if (loop == 0)
|
|
9138 num_normal++;
|
|
9139 else
|
|
9140 (*file)[count++] = vim_strsave((char_u *)names[match]);
|
|
9141 }
|
|
9142 }
|
|
9143 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
|
|
9144 opt_idx++)
|
|
9145 {
|
|
9146 if (options[opt_idx].var == NULL)
|
|
9147 continue;
|
|
9148 if (xp->xp_context == EXPAND_BOOL_SETTINGS
|
|
9149 && !(options[opt_idx].flags & P_BOOL))
|
|
9150 continue;
|
|
9151 is_term_opt = istermoption(&options[opt_idx]);
|
|
9152 if (is_term_opt && num_normal > 0)
|
|
9153 continue;
|
|
9154 match = FALSE;
|
|
9155 if (vim_regexec(regmatch, str, (colnr_T)0)
|
|
9156 || (options[opt_idx].shortname != NULL
|
|
9157 && vim_regexec(regmatch,
|
|
9158 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
|
|
9159 match = TRUE;
|
|
9160 else if (is_term_opt)
|
|
9161 {
|
|
9162 name_buf[0] = '<';
|
|
9163 name_buf[1] = 't';
|
|
9164 name_buf[2] = '_';
|
|
9165 name_buf[3] = str[2];
|
|
9166 name_buf[4] = str[3];
|
|
9167 name_buf[5] = '>';
|
|
9168 name_buf[6] = NUL;
|
|
9169 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9170 {
|
|
9171 match = TRUE;
|
|
9172 str = name_buf;
|
|
9173 }
|
|
9174 }
|
|
9175 if (match)
|
|
9176 {
|
|
9177 if (loop == 0)
|
|
9178 {
|
|
9179 if (is_term_opt)
|
|
9180 num_term++;
|
|
9181 else
|
|
9182 num_normal++;
|
|
9183 }
|
|
9184 else
|
|
9185 (*file)[count++] = vim_strsave(str);
|
|
9186 }
|
|
9187 }
|
|
9188 /*
|
|
9189 * Check terminal key codes, these are not in the option table
|
|
9190 */
|
|
9191 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
|
|
9192 {
|
|
9193 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
|
|
9194 {
|
|
9195 if (!isprint(str[0]) || !isprint(str[1]))
|
|
9196 continue;
|
|
9197
|
|
9198 name_buf[0] = 't';
|
|
9199 name_buf[1] = '_';
|
|
9200 name_buf[2] = str[0];
|
|
9201 name_buf[3] = str[1];
|
|
9202 name_buf[4] = NUL;
|
|
9203
|
|
9204 match = FALSE;
|
|
9205 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9206 match = TRUE;
|
|
9207 else
|
|
9208 {
|
|
9209 name_buf[0] = '<';
|
|
9210 name_buf[1] = 't';
|
|
9211 name_buf[2] = '_';
|
|
9212 name_buf[3] = str[0];
|
|
9213 name_buf[4] = str[1];
|
|
9214 name_buf[5] = '>';
|
|
9215 name_buf[6] = NUL;
|
|
9216
|
|
9217 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9218 match = TRUE;
|
|
9219 }
|
|
9220 if (match)
|
|
9221 {
|
|
9222 if (loop == 0)
|
|
9223 num_term++;
|
|
9224 else
|
|
9225 (*file)[count++] = vim_strsave(name_buf);
|
|
9226 }
|
|
9227 }
|
|
9228
|
|
9229 /*
|
|
9230 * Check special key names.
|
|
9231 */
|
|
9232 regmatch->rm_ic = TRUE; /* ignore case here */
|
|
9233 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
|
|
9234 {
|
|
9235 name_buf[0] = '<';
|
|
9236 STRCPY(name_buf + 1, str);
|
|
9237 STRCAT(name_buf, ">");
|
|
9238
|
|
9239 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
|
|
9240 {
|
|
9241 if (loop == 0)
|
|
9242 num_term++;
|
|
9243 else
|
|
9244 (*file)[count++] = vim_strsave(name_buf);
|
|
9245 }
|
|
9246 }
|
|
9247 }
|
|
9248 if (loop == 0)
|
|
9249 {
|
|
9250 if (num_normal > 0)
|
|
9251 *num_file = num_normal;
|
|
9252 else if (num_term > 0)
|
|
9253 *num_file = num_term;
|
|
9254 else
|
|
9255 return OK;
|
|
9256 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
|
|
9257 if (*file == NULL)
|
|
9258 {
|
|
9259 *file = (char_u **)"";
|
|
9260 return FAIL;
|
|
9261 }
|
|
9262 }
|
|
9263 }
|
|
9264 return OK;
|
|
9265 }
|
|
9266
|
|
9267 int
|
|
9268 ExpandOldSetting(num_file, file)
|
|
9269 int *num_file;
|
|
9270 char_u ***file;
|
|
9271 {
|
|
9272 char_u *var = NULL; /* init for GCC */
|
|
9273 char_u *buf;
|
|
9274
|
|
9275 *num_file = 0;
|
|
9276 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
|
|
9277 if (*file == NULL)
|
|
9278 return FAIL;
|
|
9279
|
|
9280 /*
|
|
9281 * For a terminal key code expand_option_idx is < 0.
|
|
9282 */
|
|
9283 if (expand_option_idx < 0)
|
|
9284 {
|
|
9285 var = find_termcode(expand_option_name + 2);
|
|
9286 if (var == NULL)
|
|
9287 expand_option_idx = findoption(expand_option_name);
|
|
9288 }
|
|
9289
|
|
9290 if (expand_option_idx >= 0)
|
|
9291 {
|
|
9292 /* put string of option value in NameBuff */
|
|
9293 option_value2string(&options[expand_option_idx], expand_option_flags);
|
|
9294 var = NameBuff;
|
|
9295 }
|
|
9296 else if (var == NULL)
|
|
9297 var = (char_u *)"";
|
|
9298
|
|
9299 /* A backslash is required before some characters. This is the reverse of
|
|
9300 * what happens in do_set(). */
|
|
9301 buf = vim_strsave_escaped(var, escape_chars);
|
|
9302
|
|
9303 if (buf == NULL)
|
|
9304 {
|
|
9305 vim_free(*file);
|
|
9306 *file = NULL;
|
|
9307 return FAIL;
|
|
9308 }
|
|
9309
|
|
9310 #ifdef BACKSLASH_IN_FILENAME
|
|
9311 /* For MS-Windows et al. we don't double backslashes at the start and
|
|
9312 * before a file name character. */
|
39
|
9313 for (var = buf; *var != NUL; mb_ptr_adv(var))
|
7
|
9314 if (var[0] == '\\' && var[1] == '\\'
|
|
9315 && expand_option_idx >= 0
|
|
9316 && (options[expand_option_idx].flags & P_EXPAND)
|
|
9317 && vim_isfilec(var[2])
|
|
9318 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
|
|
9319 mch_memmove(var, var + 1, STRLEN(var));
|
|
9320 #endif
|
|
9321
|
|
9322 *file[0] = buf;
|
|
9323 *num_file = 1;
|
|
9324 return OK;
|
|
9325 }
|
|
9326 #endif
|
|
9327
|
|
9328 /*
|
|
9329 * Get the value for the numeric or string option *opp in a nice format into
|
|
9330 * NameBuff[]. Must not be called with a hidden option!
|
|
9331 */
|
|
9332 static void
|
|
9333 option_value2string(opp, opt_flags)
|
|
9334 struct vimoption *opp;
|
|
9335 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
|
|
9336 {
|
|
9337 char_u *varp;
|
|
9338
|
|
9339 varp = get_varp_scope(opp, opt_flags);
|
|
9340
|
|
9341 if (opp->flags & P_NUM)
|
|
9342 {
|
|
9343 long wc = 0;
|
|
9344
|
|
9345 if (wc_use_keyname(varp, &wc))
|
|
9346 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
|
|
9347 else if (wc != 0)
|
|
9348 STRCPY(NameBuff, transchar((int)wc));
|
|
9349 else
|
|
9350 sprintf((char *)NameBuff, "%ld", *(long *)varp);
|
|
9351 }
|
|
9352 else /* P_STRING */
|
|
9353 {
|
|
9354 varp = *(char_u **)(varp);
|
|
9355 if (varp == NULL) /* just in case */
|
|
9356 NameBuff[0] = NUL;
|
|
9357 #ifdef FEAT_CRYPT
|
|
9358 /* don't show the actual value of 'key', only that it's set */
|
|
9359 if (opp->var == (char_u *)&p_key && *varp)
|
|
9360 STRCPY(NameBuff, "*****");
|
|
9361 #endif
|
|
9362 else if (opp->flags & P_EXPAND)
|
|
9363 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
|
|
9364 /* Translate 'pastetoggle' into special key names */
|
|
9365 else if ((char_u **)opp->var == &p_pt)
|
|
9366 str2specialbuf(p_pt, NameBuff, MAXPATHL);
|
|
9367 else
|
419
|
9368 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
|
7
|
9369 }
|
|
9370 }
|
|
9371
|
|
9372 /*
|
|
9373 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
|
|
9374 * printed as a keyname.
|
|
9375 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
|
|
9376 */
|
|
9377 static int
|
|
9378 wc_use_keyname(varp, wcp)
|
|
9379 char_u *varp;
|
|
9380 long *wcp;
|
|
9381 {
|
|
9382 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
|
|
9383 {
|
|
9384 *wcp = *(long *)varp;
|
|
9385 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
|
|
9386 return TRUE;
|
|
9387 }
|
|
9388 return FALSE;
|
|
9389 }
|
|
9390
|
|
9391 #ifdef FEAT_LANGMAP
|
|
9392 /*
|
|
9393 * Any character has an equivalent character. This is used for keyboards that
|
|
9394 * have a special language mode that sends characters above 128 (although
|
|
9395 * other characters can be translated too).
|
|
9396 */
|
|
9397
|
|
9398 /*
|
|
9399 * char_u langmap_mapchar[256];
|
|
9400 * Normally maps each of the 128 upper chars to an <128 ascii char; used to
|
|
9401 * "translate" native lang chars in normal mode or some cases of
|
|
9402 * insert mode without having to tediously switch lang mode back&forth.
|
|
9403 */
|
|
9404
|
|
9405 static void
|
|
9406 langmap_init()
|
|
9407 {
|
|
9408 int i;
|
|
9409
|
|
9410 for (i = 0; i < 256; i++) /* we init with a-one-to one map */
|
|
9411 langmap_mapchar[i] = i;
|
|
9412 }
|
|
9413
|
|
9414 /*
|
|
9415 * Called when langmap option is set; the language map can be
|
|
9416 * changed at any time!
|
|
9417 */
|
|
9418 static void
|
|
9419 langmap_set()
|
|
9420 {
|
|
9421 char_u *p;
|
|
9422 char_u *p2;
|
|
9423 int from, to;
|
|
9424
|
|
9425 langmap_init(); /* back to one-to-one map first */
|
|
9426
|
|
9427 for (p = p_langmap; p[0] != NUL; )
|
|
9428 {
|
39
|
9429 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
|
|
9430 mb_ptr_adv(p2))
|
7
|
9431 {
|
|
9432 if (p2[0] == '\\' && p2[1] != NUL)
|
|
9433 ++p2;
|
|
9434 }
|
|
9435 if (p2[0] == ';')
|
|
9436 ++p2; /* abcd;ABCD form, p2 points to A */
|
|
9437 else
|
|
9438 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
|
|
9439 while (p[0])
|
|
9440 {
|
|
9441 if (p[0] == '\\' && p[1] != NUL)
|
|
9442 ++p;
|
|
9443 #ifdef FEAT_MBYTE
|
|
9444 from = (*mb_ptr2char)(p);
|
|
9445 #else
|
|
9446 from = p[0];
|
|
9447 #endif
|
|
9448 if (p2 == NULL)
|
|
9449 {
|
39
|
9450 mb_ptr_adv(p);
|
7
|
9451 if (p[0] == '\\')
|
|
9452 ++p;
|
|
9453 #ifdef FEAT_MBYTE
|
|
9454 to = (*mb_ptr2char)(p);
|
|
9455 #else
|
|
9456 to = p[0];
|
|
9457 #endif
|
|
9458 }
|
|
9459 else
|
|
9460 {
|
|
9461 if (p2[0] == '\\')
|
|
9462 ++p2;
|
|
9463 #ifdef FEAT_MBYTE
|
|
9464 to = (*mb_ptr2char)(p2);
|
|
9465 #else
|
|
9466 to = p2[0];
|
|
9467 #endif
|
|
9468 }
|
|
9469 if (to == NUL)
|
|
9470 {
|
|
9471 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
|
|
9472 transchar(from));
|
|
9473 return;
|
|
9474 }
|
|
9475 langmap_mapchar[from & 255] = to;
|
|
9476
|
|
9477 /* Advance to next pair */
|
39
|
9478 mb_ptr_adv(p);
|
7
|
9479 if (p2 == NULL)
|
|
9480 {
|
|
9481 if (p[0] == ',')
|
|
9482 {
|
|
9483 ++p;
|
|
9484 break;
|
|
9485 }
|
|
9486 }
|
|
9487 else
|
|
9488 {
|
39
|
9489 mb_ptr_adv(p2);
|
7
|
9490 if (*p == ';')
|
|
9491 {
|
|
9492 p = p2;
|
|
9493 if (p[0] != NUL)
|
|
9494 {
|
|
9495 if (p[0] != ',')
|
|
9496 {
|
|
9497 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
|
|
9498 return;
|
|
9499 }
|
|
9500 ++p;
|
|
9501 }
|
|
9502 break;
|
|
9503 }
|
|
9504 }
|
|
9505 }
|
|
9506 }
|
|
9507 }
|
|
9508 #endif
|
|
9509
|
|
9510 /*
|
|
9511 * Return TRUE if format option 'x' is in effect.
|
|
9512 * Take care of no formatting when 'paste' is set.
|
|
9513 */
|
|
9514 int
|
|
9515 has_format_option(x)
|
|
9516 int x;
|
|
9517 {
|
|
9518 if (p_paste)
|
|
9519 return FALSE;
|
|
9520 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
|
|
9521 }
|
|
9522
|
|
9523 /*
|
|
9524 * Return TRUE if "x" is present in 'shortmess' option, or
|
|
9525 * 'shortmess' contains 'a' and "x" is present in SHM_A.
|
|
9526 */
|
|
9527 int
|
|
9528 shortmess(x)
|
|
9529 int x;
|
|
9530 {
|
|
9531 return ( vim_strchr(p_shm, x) != NULL
|
|
9532 || (vim_strchr(p_shm, 'a') != NULL
|
|
9533 && vim_strchr((char_u *)SHM_A, x) != NULL));
|
|
9534 }
|
|
9535
|
|
9536 /*
|
|
9537 * paste_option_changed() - Called after p_paste was set or reset.
|
|
9538 */
|
|
9539 static void
|
|
9540 paste_option_changed()
|
|
9541 {
|
|
9542 static int old_p_paste = FALSE;
|
|
9543 static int save_sm = 0;
|
|
9544 #ifdef FEAT_CMDL_INFO
|
|
9545 static int save_ru = 0;
|
|
9546 #endif
|
|
9547 #ifdef FEAT_RIGHTLEFT
|
|
9548 static int save_ri = 0;
|
|
9549 static int save_hkmap = 0;
|
|
9550 #endif
|
|
9551 buf_T *buf;
|
|
9552
|
|
9553 if (p_paste)
|
|
9554 {
|
|
9555 /*
|
|
9556 * Paste switched from off to on.
|
|
9557 * Save the current values, so they can be restored later.
|
|
9558 */
|
|
9559 if (!old_p_paste)
|
|
9560 {
|
|
9561 /* save options for each buffer */
|
|
9562 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
9563 {
|
|
9564 buf->b_p_tw_nopaste = buf->b_p_tw;
|
|
9565 buf->b_p_wm_nopaste = buf->b_p_wm;
|
|
9566 buf->b_p_sts_nopaste = buf->b_p_sts;
|
|
9567 buf->b_p_ai_nopaste = buf->b_p_ai;
|
|
9568 }
|
|
9569
|
|
9570 /* save global options */
|
|
9571 save_sm = p_sm;
|
|
9572 #ifdef FEAT_CMDL_INFO
|
|
9573 save_ru = p_ru;
|
|
9574 #endif
|
|
9575 #ifdef FEAT_RIGHTLEFT
|
|
9576 save_ri = p_ri;
|
|
9577 save_hkmap = p_hkmap;
|
|
9578 #endif
|
|
9579 /* save global values for local buffer options */
|
|
9580 p_tw_nopaste = p_tw;
|
|
9581 p_wm_nopaste = p_wm;
|
|
9582 p_sts_nopaste = p_sts;
|
|
9583 p_ai_nopaste = p_ai;
|
|
9584 }
|
|
9585
|
|
9586 /*
|
|
9587 * Always set the option values, also when 'paste' is set when it is
|
|
9588 * already on.
|
|
9589 */
|
|
9590 /* set options for each buffer */
|
|
9591 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
9592 {
|
|
9593 buf->b_p_tw = 0; /* textwidth is 0 */
|
|
9594 buf->b_p_wm = 0; /* wrapmargin is 0 */
|
|
9595 buf->b_p_sts = 0; /* softtabstop is 0 */
|
|
9596 buf->b_p_ai = 0; /* no auto-indent */
|
|
9597 }
|
|
9598
|
|
9599 /* set global options */
|
|
9600 p_sm = 0; /* no showmatch */
|
|
9601 #ifdef FEAT_CMDL_INFO
|
|
9602 # ifdef FEAT_WINDOWS
|
|
9603 if (p_ru)
|
|
9604 status_redraw_all(); /* redraw to remove the ruler */
|
|
9605 # endif
|
|
9606 p_ru = 0; /* no ruler */
|
|
9607 #endif
|
|
9608 #ifdef FEAT_RIGHTLEFT
|
|
9609 p_ri = 0; /* no reverse insert */
|
|
9610 p_hkmap = 0; /* no Hebrew keyboard */
|
|
9611 #endif
|
|
9612 /* set global values for local buffer options */
|
|
9613 p_tw = 0;
|
|
9614 p_wm = 0;
|
|
9615 p_sts = 0;
|
|
9616 p_ai = 0;
|
|
9617 }
|
|
9618
|
|
9619 /*
|
|
9620 * Paste switched from on to off: Restore saved values.
|
|
9621 */
|
|
9622 else if (old_p_paste)
|
|
9623 {
|
|
9624 /* restore options for each buffer */
|
|
9625 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
9626 {
|
|
9627 buf->b_p_tw = buf->b_p_tw_nopaste;
|
|
9628 buf->b_p_wm = buf->b_p_wm_nopaste;
|
|
9629 buf->b_p_sts = buf->b_p_sts_nopaste;
|
|
9630 buf->b_p_ai = buf->b_p_ai_nopaste;
|
|
9631 }
|
|
9632
|
|
9633 /* restore global options */
|
|
9634 p_sm = save_sm;
|
|
9635 #ifdef FEAT_CMDL_INFO
|
|
9636 # ifdef FEAT_WINDOWS
|
|
9637 if (p_ru != save_ru)
|
|
9638 status_redraw_all(); /* redraw to draw the ruler */
|
|
9639 # endif
|
|
9640 p_ru = save_ru;
|
|
9641 #endif
|
|
9642 #ifdef FEAT_RIGHTLEFT
|
|
9643 p_ri = save_ri;
|
|
9644 p_hkmap = save_hkmap;
|
|
9645 #endif
|
|
9646 /* set global values for local buffer options */
|
|
9647 p_tw = p_tw_nopaste;
|
|
9648 p_wm = p_wm_nopaste;
|
|
9649 p_sts = p_sts_nopaste;
|
|
9650 p_ai = p_ai_nopaste;
|
|
9651 }
|
|
9652
|
|
9653 old_p_paste = p_paste;
|
|
9654 }
|
|
9655
|
|
9656 /*
|
|
9657 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
|
|
9658 *
|
|
9659 * Reset 'compatible' and set the values for options that didn't get set yet
|
|
9660 * to the Vim defaults.
|
|
9661 * Don't do this if the 'compatible' option has been set or reset before.
|
|
9662 */
|
|
9663 void
|
|
9664 vimrc_found()
|
|
9665 {
|
|
9666 int opt_idx;
|
|
9667
|
|
9668 if (!option_was_set((char_u *)"cp"))
|
|
9669 {
|
|
9670 p_cp = FALSE;
|
|
9671 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
|
|
9672 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
|
|
9673 set_option_default(opt_idx, OPT_FREE, FALSE);
|
|
9674 didset_options();
|
|
9675 }
|
|
9676 }
|
|
9677
|
|
9678 /*
|
|
9679 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
|
|
9680 */
|
|
9681 void
|
|
9682 change_compatible(on)
|
|
9683 int on;
|
|
9684 {
|
|
9685 if (p_cp != on)
|
|
9686 {
|
|
9687 p_cp = on;
|
|
9688 compatible_set();
|
|
9689 }
|
|
9690 options[findoption((char_u *)"cp")].flags |= P_WAS_SET;
|
|
9691 }
|
|
9692
|
|
9693 /*
|
|
9694 * Return TRUE when option "name" has been set.
|
|
9695 */
|
|
9696 int
|
|
9697 option_was_set(name)
|
|
9698 char_u *name;
|
|
9699 {
|
|
9700 int idx;
|
|
9701
|
|
9702 idx = findoption(name);
|
|
9703 if (idx < 0) /* unknown option */
|
|
9704 return FALSE;
|
|
9705 if (options[idx].flags & P_WAS_SET)
|
|
9706 return TRUE;
|
|
9707 return FALSE;
|
|
9708 }
|
|
9709
|
|
9710 /*
|
|
9711 * compatible_set() - Called when 'compatible' has been set or unset.
|
|
9712 *
|
|
9713 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
|
|
9714 * flag) to a Vi compatible value.
|
|
9715 * When 'compatible' is unset: Set all options that have a different default
|
|
9716 * for Vim (without the P_VI_DEF flag) to that default.
|
|
9717 */
|
|
9718 static void
|
|
9719 compatible_set()
|
|
9720 {
|
|
9721 int opt_idx;
|
|
9722
|
|
9723 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
|
|
9724 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
|
|
9725 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
|
|
9726 set_option_default(opt_idx, OPT_FREE, p_cp);
|
|
9727 didset_options();
|
|
9728 }
|
|
9729
|
|
9730 #ifdef FEAT_LINEBREAK
|
|
9731
|
|
9732 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
|
9733 /* Borland C++ screws up loop optimisation here (negri) */
|
133
|
9734 #pragma option -O-l
|
7
|
9735 # endif
|
|
9736
|
|
9737 /*
|
|
9738 * fill_breakat_flags() -- called when 'breakat' changes value.
|
|
9739 */
|
|
9740 static void
|
|
9741 fill_breakat_flags()
|
|
9742 {
|
|
9743 char_u *c;
|
|
9744 int i;
|
|
9745
|
|
9746 for (i = 0; i < 256; i++)
|
|
9747 breakat_flags[i] = FALSE;
|
|
9748
|
|
9749 if (p_breakat != NULL)
|
|
9750 for (c = p_breakat; *c; c++)
|
|
9751 breakat_flags[*c] = TRUE;
|
|
9752 }
|
|
9753
|
|
9754 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
133
|
9755 #pragma option -O.l
|
7
|
9756 # endif
|
|
9757
|
|
9758 #endif
|
|
9759
|
|
9760 /*
|
|
9761 * Check an option that can be a range of string values.
|
|
9762 *
|
|
9763 * Return OK for correct value, FAIL otherwise.
|
|
9764 * Empty is always OK.
|
|
9765 */
|
|
9766 static int
|
|
9767 check_opt_strings(val, values, list)
|
|
9768 char_u *val;
|
|
9769 char **values;
|
|
9770 int list; /* when TRUE: accept a list of values */
|
|
9771 {
|
|
9772 return opt_strings_flags(val, values, NULL, list);
|
|
9773 }
|
|
9774
|
|
9775 /*
|
|
9776 * Handle an option that can be a range of string values.
|
|
9777 * Set a flag in "*flagp" for each string present.
|
|
9778 *
|
|
9779 * Return OK for correct value, FAIL otherwise.
|
|
9780 * Empty is always OK.
|
|
9781 */
|
|
9782 static int
|
|
9783 opt_strings_flags(val, values, flagp, list)
|
|
9784 char_u *val; /* new value */
|
|
9785 char **values; /* array of valid string values */
|
|
9786 unsigned *flagp;
|
|
9787 int list; /* when TRUE: accept a list of values */
|
|
9788 {
|
|
9789 int i;
|
|
9790 int len;
|
|
9791 unsigned new_flags = 0;
|
|
9792
|
|
9793 while (*val)
|
|
9794 {
|
|
9795 for (i = 0; ; ++i)
|
|
9796 {
|
|
9797 if (values[i] == NULL) /* val not found in values[] */
|
|
9798 return FAIL;
|
|
9799
|
|
9800 len = (int)STRLEN(values[i]);
|
|
9801 if (STRNCMP(values[i], val, len) == 0
|
|
9802 && ((list && val[len] == ',') || val[len] == NUL))
|
|
9803 {
|
|
9804 val += len + (val[len] == ',');
|
|
9805 new_flags |= (1 << i);
|
|
9806 break; /* check next item in val list */
|
|
9807 }
|
|
9808 }
|
|
9809 }
|
|
9810 if (flagp != NULL)
|
|
9811 *flagp = new_flags;
|
|
9812
|
|
9813 return OK;
|
|
9814 }
|
|
9815
|
|
9816 /*
|
|
9817 * Read the 'wildmode' option, fill wim_flags[].
|
|
9818 */
|
|
9819 static int
|
|
9820 check_opt_wim()
|
|
9821 {
|
|
9822 char_u new_wim_flags[4];
|
|
9823 char_u *p;
|
|
9824 int i;
|
|
9825 int idx = 0;
|
|
9826
|
|
9827 for (i = 0; i < 4; ++i)
|
|
9828 new_wim_flags[i] = 0;
|
|
9829
|
|
9830 for (p = p_wim; *p; ++p)
|
|
9831 {
|
|
9832 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
|
|
9833 ;
|
|
9834 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
|
|
9835 return FAIL;
|
|
9836 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
|
|
9837 new_wim_flags[idx] |= WIM_LONGEST;
|
|
9838 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
|
|
9839 new_wim_flags[idx] |= WIM_FULL;
|
|
9840 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
|
|
9841 new_wim_flags[idx] |= WIM_LIST;
|
|
9842 else
|
|
9843 return FAIL;
|
|
9844 p += i;
|
|
9845 if (*p == NUL)
|
|
9846 break;
|
|
9847 if (*p == ',')
|
|
9848 {
|
|
9849 if (idx == 3)
|
|
9850 return FAIL;
|
|
9851 ++idx;
|
|
9852 }
|
|
9853 }
|
|
9854
|
|
9855 /* fill remaining entries with last flag */
|
|
9856 while (idx < 3)
|
|
9857 {
|
|
9858 new_wim_flags[idx + 1] = new_wim_flags[idx];
|
|
9859 ++idx;
|
|
9860 }
|
|
9861
|
|
9862 /* only when there are no errors, wim_flags[] is changed */
|
|
9863 for (i = 0; i < 4; ++i)
|
|
9864 wim_flags[i] = new_wim_flags[i];
|
|
9865 return OK;
|
|
9866 }
|
|
9867
|
|
9868 /*
|
|
9869 * Check if backspacing over something is allowed.
|
|
9870 */
|
|
9871 int
|
|
9872 can_bs(what)
|
|
9873 int what; /* BS_INDENT, BS_EOL or BS_START */
|
|
9874 {
|
|
9875 switch (*p_bs)
|
|
9876 {
|
|
9877 case '2': return TRUE;
|
|
9878 case '1': return (what != BS_START);
|
|
9879 case '0': return FALSE;
|
|
9880 }
|
|
9881 return vim_strchr(p_bs, what) != NULL;
|
|
9882 }
|
|
9883
|
|
9884 /*
|
|
9885 * Save the current values of 'fileformat' and 'fileencoding', so that we know
|
|
9886 * the file must be considered changed when the value is different.
|
|
9887 */
|
|
9888 void
|
|
9889 save_file_ff(buf)
|
|
9890 buf_T *buf;
|
|
9891 {
|
|
9892 buf->b_start_ffc = *buf->b_p_ff;
|
|
9893 buf->b_start_eol = buf->b_p_eol;
|
|
9894 #ifdef FEAT_MBYTE
|
|
9895 /* Only use free/alloc when necessary, they take time. */
|
|
9896 if (buf->b_start_fenc == NULL
|
|
9897 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
|
|
9898 {
|
|
9899 vim_free(buf->b_start_fenc);
|
|
9900 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
|
|
9901 }
|
|
9902 #endif
|
|
9903 }
|
|
9904
|
|
9905 /*
|
|
9906 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
|
|
9907 * from when editing started (save_file_ff() called).
|
|
9908 * Also when 'endofline' was changed and 'binary' is set.
|
|
9909 * Don't consider a new, empty buffer to be changed.
|
|
9910 */
|
|
9911 int
|
|
9912 file_ff_differs(buf)
|
|
9913 buf_T *buf;
|
|
9914 {
|
|
9915 if ((buf->b_flags & BF_NEW)
|
|
9916 && buf->b_ml.ml_line_count == 1
|
|
9917 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
|
|
9918 return FALSE;
|
|
9919 if (buf->b_start_ffc != *buf->b_p_ff)
|
|
9920 return TRUE;
|
|
9921 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
|
|
9922 return TRUE;
|
|
9923 #ifdef FEAT_MBYTE
|
|
9924 if (buf->b_start_fenc == NULL)
|
|
9925 return (*buf->b_p_fenc != NUL);
|
|
9926 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
|
|
9927 #else
|
|
9928 return FALSE;
|
|
9929 #endif
|
|
9930 }
|
|
9931
|
|
9932 /*
|
|
9933 * return OK if "p" is a valid fileformat name, FAIL otherwise.
|
|
9934 */
|
|
9935 int
|
|
9936 check_ff_value(p)
|
|
9937 char_u *p;
|
|
9938 {
|
|
9939 return check_opt_strings(p, p_ff_values, FALSE);
|
|
9940 }
|