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