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