Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 65 | , PV_CFU |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
| 85 | , PV_FO |
| 86 | , PV_FT |
| 87 | , PV_GP |
| 88 | , PV_IMI |
| 89 | , PV_IMS |
| 90 | , PV_INC |
| 91 | , PV_INDE |
| 92 | , PV_INDK |
| 93 | , PV_INEX |
| 94 | , PV_INF |
| 95 | , PV_ISK |
| 96 | , PV_KEY |
| 97 | , PV_KMAP |
| 98 | , PV_KP |
| 99 | , PV_LBR |
| 100 | , PV_LISP |
| 101 | , PV_LIST |
| 102 | , PV_MA |
| 103 | , PV_ML |
| 104 | , PV_MOD |
| 105 | , PV_MP |
| 106 | , PV_MPS |
| 107 | , PV_NF |
| 108 | , PV_NU |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 109 | , PV_NUW |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 110 | , PV_OFT |
| 111 | , PV_PATH |
| 112 | , PV_PI |
| 113 | , PV_PVW |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 114 | , PV_QE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 115 | , PV_RL |
| 116 | , PV_RLC |
| 117 | , PV_RO |
| 118 | , PV_SCBIND |
| 119 | , PV_SCROLL |
| 120 | , PV_SI |
| 121 | , PV_SN |
| 122 | , PV_STS |
| 123 | , PV_SUA |
| 124 | , PV_SW |
| 125 | , PV_SWF |
| 126 | , PV_SYN |
| 127 | , PV_TAGS |
| 128 | , PV_TS |
| 129 | , PV_TSR |
| 130 | , PV_TW |
| 131 | , PV_TX |
| 132 | , PV_WFH |
| 133 | , PV_WM |
| 134 | , PV_WRAP |
| 135 | } idopt_T; |
| 136 | |
| 137 | /* |
| 138 | * Options local to a window have a value local to a buffer and global to all |
| 139 | * buffers. Indicate this by setting "var" to VAR_WIN. |
| 140 | */ |
| 141 | #define VAR_WIN ((char_u *)-1) |
| 142 | |
| 143 | /* |
| 144 | * These the global values for options which are also local to a buffer. |
| 145 | * Only to be used in option.c! |
| 146 | */ |
| 147 | static int p_ai; |
| 148 | static int p_bin; |
| 149 | #ifdef FEAT_MBYTE |
| 150 | static int p_bomb; |
| 151 | #endif |
| 152 | #if defined(FEAT_QUICKFIX) |
| 153 | static char_u *p_bh; |
| 154 | static char_u *p_bt; |
| 155 | #endif |
| 156 | static int p_bl; |
| 157 | static int p_ci; |
| 158 | #ifdef FEAT_CINDENT |
| 159 | static int p_cin; |
| 160 | static char_u *p_cink; |
| 161 | static char_u *p_cino; |
| 162 | #endif |
| 163 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 164 | static char_u *p_cinw; |
| 165 | #endif |
| 166 | #ifdef FEAT_COMMENTS |
| 167 | static char_u *p_com; |
| 168 | #endif |
| 169 | #ifdef FEAT_FOLDING |
| 170 | static char_u *p_cms; |
| 171 | #endif |
| 172 | #ifdef FEAT_INS_EXPAND |
| 173 | static char_u *p_cpt; |
| 174 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 175 | #ifdef FEAT_COMPL_FUNC |
| 176 | static char_u *p_cfu; |
| 177 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 178 | static int p_eol; |
| 179 | static int p_et; |
| 180 | #ifdef FEAT_MBYTE |
| 181 | static char_u *p_fenc; |
| 182 | #endif |
| 183 | static char_u *p_ff; |
| 184 | static char_u *p_fo; |
| 185 | #ifdef FEAT_AUTOCMD |
| 186 | static char_u *p_ft; |
| 187 | #endif |
| 188 | static long p_iminsert; |
| 189 | static long p_imsearch; |
| 190 | #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) |
| 191 | static char_u *p_inex; |
| 192 | #endif |
| 193 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 194 | static char_u *p_inde; |
| 195 | static char_u *p_indk; |
| 196 | #endif |
| 197 | static int p_inf; |
| 198 | static char_u *p_isk; |
| 199 | #ifdef FEAT_CRYPT |
| 200 | static char_u *p_key; |
| 201 | #endif |
| 202 | #ifdef FEAT_LISP |
| 203 | static int p_lisp; |
| 204 | #endif |
| 205 | static int p_ml; |
| 206 | static int p_ma; |
| 207 | static int p_mod; |
| 208 | static char_u *p_mps; |
| 209 | static char_u *p_nf; |
| 210 | #ifdef FEAT_OSFILETYPE |
| 211 | static char_u *p_oft; |
| 212 | #endif |
| 213 | static int p_pi; |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 214 | #ifdef FEAT_TEXTOBJ |
| 215 | static char_u *p_qe; |
| 216 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 217 | static int p_ro; |
| 218 | #ifdef FEAT_SMARTINDENT |
| 219 | static int p_si; |
| 220 | #endif |
| 221 | #ifndef SHORT_FNAME |
| 222 | static int p_sn; |
| 223 | #endif |
| 224 | static long p_sts; |
| 225 | #if defined(FEAT_SEARCHPATH) |
| 226 | static char_u *p_sua; |
| 227 | #endif |
| 228 | static long p_sw; |
| 229 | static int p_swf; |
| 230 | #ifdef FEAT_SYN_HL |
| 231 | static char_u *p_syn; |
| 232 | #endif |
| 233 | static long p_ts; |
| 234 | static long p_tw; |
| 235 | static int p_tx; |
| 236 | static long p_wm; |
| 237 | #ifdef FEAT_KEYMAP |
| 238 | static char_u *p_keymap; |
| 239 | #endif |
| 240 | |
| 241 | /* Saved values for when 'bin' is set. */ |
| 242 | static int p_et_nobin; |
| 243 | static int p_ml_nobin; |
| 244 | static long p_tw_nobin; |
| 245 | static long p_wm_nobin; |
| 246 | |
| 247 | /* Saved values for when 'paste' is set */ |
| 248 | static long p_tw_nopaste; |
| 249 | static long p_wm_nopaste; |
| 250 | static long p_sts_nopaste; |
| 251 | static int p_ai_nopaste; |
| 252 | |
| 253 | struct vimoption |
| 254 | { |
| 255 | char *fullname; /* full option name */ |
| 256 | char *shortname; /* permissible abbreviation */ |
| 257 | long_u flags; /* see below */ |
| 258 | char_u *var; /* global option: pointer to variable; |
| 259 | * window-local option: VAR_WIN; |
| 260 | * buffer-local option: global value */ |
| 261 | idopt_T indir; /* global option: PV_NONE; |
| 262 | * local option: indirect option index */ |
| 263 | char_u *def_val[2]; /* default values for variable (vi and vim) */ |
| 264 | #ifdef FEAT_EVAL |
| 265 | scid_T scriptID; /* script in which the option was last set */ |
| 266 | #endif |
| 267 | }; |
| 268 | |
| 269 | #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */ |
| 270 | #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */ |
| 271 | |
| 272 | /* |
| 273 | * Flags |
| 274 | */ |
| 275 | #define P_BOOL 0x01 /* the option is boolean */ |
| 276 | #define P_NUM 0x02 /* the option is numeric */ |
| 277 | #define P_STRING 0x04 /* the option is a string */ |
| 278 | #define P_ALLOCED 0x08 /* the string option is in allocated memory, |
| 279 | must use vim_free() when assigning new |
| 280 | value. Not set if default is the same. */ |
| 281 | #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can |
| 282 | never be used for local or hidden options! */ |
| 283 | #define P_NODEFAULT 0x40 /* don't set to default value */ |
| 284 | #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must |
| 285 | use vim_free() when assigning new value */ |
| 286 | #define P_WAS_SET 0x100 /* option has been set/reset */ |
| 287 | #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */ |
| 288 | #define P_VI_DEF 0x400 /* Use Vi default for Vim */ |
| 289 | #define P_VIM 0x800 /* Vim option, reset when 'cp' set */ |
| 290 | |
| 291 | /* when option changed, what to display: */ |
| 292 | #define P_RSTAT 0x1000 /* redraw status lines */ |
| 293 | #define P_RWIN 0x2000 /* redraw current window */ |
| 294 | #define P_RBUF 0x4000 /* redraw current buffer */ |
| 295 | #define P_RALL 0x6000 /* redraw all windows */ |
| 296 | #define P_RCLR 0x7000 /* clear and redraw all */ |
| 297 | |
| 298 | #define P_COMMA 0x8000 /* comma separated list */ |
| 299 | #define P_NODUP 0x10000L/* don't allow duplicate strings */ |
| 300 | #define P_FLAGLIST 0x20000L/* list of single-char flags */ |
| 301 | |
| 302 | #define P_SECURE 0x40000L/* cannot change in modeline or secure mode */ |
| 303 | #define P_GETTEXT 0x80000L/* expand default value with _() */ |
| 304 | #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */ |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 305 | #define P_NFNAME 0x200000L/* only normal file name chars allowed */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 306 | |
| 307 | /* |
| 308 | * options[] is initialized here. |
| 309 | * The order of the options MUST be alphabetic for ":set all" and findoption(). |
| 310 | * All option names MUST start with a lowercase letter (for findoption()). |
| 311 | * Exception: "t_" options are at the end. |
| 312 | * The options with a NULL variable are 'hidden': a set command for them is |
| 313 | * ignored and they are not printed. |
| 314 | */ |
| 315 | static struct vimoption |
| 316 | #ifdef FEAT_GUI_W16 |
| 317 | _far |
| 318 | #endif |
| 319 | options[] = |
| 320 | { |
| 321 | {"aleph", "al", P_NUM|P_VI_DEF, |
| 322 | #ifdef FEAT_RIGHTLEFT |
| 323 | (char_u *)&p_aleph, PV_NONE, |
| 324 | #else |
| 325 | (char_u *)NULL, PV_NONE, |
| 326 | #endif |
| 327 | { |
| 328 | #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32) |
| 329 | (char_u *)128L, |
| 330 | #else |
| 331 | (char_u *)224L, |
| 332 | #endif |
| 333 | (char_u *)0L}}, |
| 334 | {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, |
| 335 | #if defined(FEAT_GUI) && defined(MACOS_X) |
| 336 | (char_u *)&p_antialias, PV_NONE, |
| 337 | {(char_u *)FALSE, (char_u *)FALSE} |
| 338 | #else |
| 339 | (char_u *)NULL, PV_NONE, |
| 340 | {(char_u *)FALSE, (char_u *)FALSE} |
| 341 | #endif |
| 342 | }, |
| 343 | {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM, |
| 344 | #ifdef FEAT_ARABIC |
| 345 | (char_u *)VAR_WIN, PV_ARAB, |
| 346 | #else |
| 347 | (char_u *)NULL, PV_NONE, |
| 348 | #endif |
| 349 | {(char_u *)FALSE, (char_u *)0L}}, |
| 350 | {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, |
| 351 | #ifdef FEAT_ARABIC |
| 352 | (char_u *)&p_arshape, PV_NONE, |
| 353 | #else |
| 354 | (char_u *)NULL, PV_NONE, |
| 355 | #endif |
| 356 | {(char_u *)TRUE, (char_u *)0L}}, |
| 357 | {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM, |
| 358 | #ifdef FEAT_RIGHTLEFT |
| 359 | (char_u *)&p_ari, PV_NONE, |
| 360 | #else |
| 361 | (char_u *)NULL, PV_NONE, |
| 362 | #endif |
| 363 | {(char_u *)FALSE, (char_u *)0L}}, |
| 364 | {"altkeymap", "akm", P_BOOL|P_VI_DEF, |
| 365 | #ifdef FEAT_FKMAP |
| 366 | (char_u *)&p_altkeymap, PV_NONE, |
| 367 | #else |
| 368 | (char_u *)NULL, PV_NONE, |
| 369 | #endif |
| 370 | {(char_u *)FALSE, (char_u *)0L}}, |
| 371 | {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR, |
| 372 | #if defined(FEAT_MBYTE) |
| 373 | (char_u *)&p_ambw, PV_NONE, |
| 374 | {(char_u *)"single", (char_u *)0L} |
| 375 | #else |
| 376 | (char_u *)NULL, PV_NONE, |
| 377 | {(char_u *)0L, (char_u *)0L} |
| 378 | #endif |
| 379 | }, |
| 380 | #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP) |
| 381 | {"autochdir", "acd", P_BOOL|P_VI_DEF, |
| 382 | (char_u *)&p_acd, PV_NONE, |
| 383 | {(char_u *)FALSE, (char_u *)0L}}, |
| 384 | #endif |
| 385 | {"autoindent", "ai", P_BOOL|P_VI_DEF, |
| 386 | (char_u *)&p_ai, PV_AI, |
| 387 | {(char_u *)FALSE, (char_u *)0L}}, |
| 388 | {"autoprint", "ap", P_BOOL|P_VI_DEF, |
| 389 | (char_u *)NULL, PV_NONE, |
| 390 | {(char_u *)FALSE, (char_u *)0L}}, |
| 391 | {"autoread", "ar", P_BOOL|P_VI_DEF, |
| 392 | (char_u *)&p_ar, OPT_BOTH(PV_AR), |
| 393 | {(char_u *)FALSE, (char_u *)0L}}, |
| 394 | {"autowrite", "aw", P_BOOL|P_VI_DEF, |
| 395 | (char_u *)&p_aw, PV_NONE, |
| 396 | {(char_u *)FALSE, (char_u *)0L}}, |
| 397 | {"autowriteall","awa", P_BOOL|P_VI_DEF, |
| 398 | (char_u *)&p_awa, PV_NONE, |
| 399 | {(char_u *)FALSE, (char_u *)0L}}, |
| 400 | {"background", "bg", P_STRING|P_VI_DEF|P_RCLR, |
| 401 | (char_u *)&p_bg, PV_NONE, |
| 402 | { |
| 403 | #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI) |
| 404 | (char_u *)"dark", |
| 405 | #else |
| 406 | (char_u *)"light", |
| 407 | #endif |
| 408 | (char_u *)0L}}, |
| 409 | {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP, |
| 410 | (char_u *)&p_bs, PV_NONE, |
| 411 | {(char_u *)"", (char_u *)0L}}, |
| 412 | {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, |
| 413 | (char_u *)&p_bk, PV_NONE, |
| 414 | {(char_u *)FALSE, (char_u *)0L}}, |
| 415 | {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP, |
| 416 | (char_u *)&p_bkc, PV_NONE, |
| 417 | #ifdef UNIX |
| 418 | {(char_u *)"yes", (char_u *)"auto"} |
| 419 | #else |
| 420 | {(char_u *)"auto", (char_u *)"auto"} |
| 421 | #endif |
| 422 | }, |
| 423 | {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, |
| 424 | (char_u *)&p_bdir, PV_NONE, |
| 425 | {(char_u *)DFLT_BDIR, (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 426 | {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 427 | (char_u *)&p_bex, PV_NONE, |
| 428 | { |
| 429 | #ifdef VMS |
| 430 | (char_u *)"_", |
| 431 | #else |
| 432 | (char_u *)"~", |
| 433 | #endif |
| 434 | (char_u *)0L}}, |
| 435 | {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA, |
| 436 | #ifdef FEAT_WILDIGN |
| 437 | (char_u *)&p_bsk, PV_NONE, |
| 438 | {(char_u *)"", (char_u *)0L} |
| 439 | #else |
| 440 | (char_u *)NULL, PV_NONE, |
| 441 | {(char_u *)0L, (char_u *)0L} |
| 442 | #endif |
| 443 | }, |
| 444 | #ifdef FEAT_BEVAL |
| 445 | {"balloondelay","bdlay",P_NUM|P_VI_DEF, |
| 446 | (char_u *)&p_bdlay, PV_NONE, |
| 447 | {(char_u *)600L, (char_u *)0L}}, |
| 448 | #endif |
| 449 | #if defined(FEAT_BEVAL) && (defined(FEAT_SUN_WORKSHOP) \ |
| 450 | || defined(FEAT_NETBEANS_INTG)) |
| 451 | {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC, |
| 452 | (char_u *)&p_beval, PV_NONE, |
| 453 | {(char_u*)FALSE, (char_u *)0L}}, |
| 454 | #endif |
| 455 | {"beautify", "bf", P_BOOL|P_VI_DEF, |
| 456 | (char_u *)NULL, PV_NONE, |
| 457 | {(char_u *)FALSE, (char_u *)0L}}, |
| 458 | {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, |
| 459 | (char_u *)&p_bin, PV_BIN, |
| 460 | {(char_u *)FALSE, (char_u *)0L}}, |
| 461 | {"bioskey", "biosk",P_BOOL|P_VI_DEF, |
| 462 | #ifdef MSDOS |
| 463 | (char_u *)&p_biosk, PV_NONE, |
| 464 | #else |
| 465 | (char_u *)NULL, PV_NONE, |
| 466 | #endif |
| 467 | {(char_u *)TRUE, (char_u *)0L}}, |
| 468 | {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
| 469 | #ifdef FEAT_MBYTE |
| 470 | (char_u *)&p_bomb, PV_BOMB, |
| 471 | #else |
| 472 | (char_u *)NULL, PV_NONE, |
| 473 | #endif |
| 474 | {(char_u *)FALSE, (char_u *)0L}}, |
| 475 | {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, |
| 476 | #ifdef FEAT_LINEBREAK |
| 477 | (char_u *)&p_breakat, PV_NONE, |
| 478 | {(char_u *)" \t!@*-+;:,./?", (char_u *)0L} |
| 479 | #else |
| 480 | (char_u *)NULL, PV_NONE, |
| 481 | {(char_u *)0L, (char_u *)0L} |
| 482 | #endif |
| 483 | }, |
| 484 | {"browsedir", "bsdir",P_STRING|P_VI_DEF, |
| 485 | #ifdef FEAT_BROWSE |
| 486 | (char_u *)&p_bsdir, PV_NONE, |
| 487 | {(char_u *)"last", (char_u *)0L} |
| 488 | #else |
| 489 | (char_u *)NULL, PV_NONE, |
| 490 | {(char_u *)0L, (char_u *)0L} |
| 491 | #endif |
| 492 | }, |
| 493 | {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, |
| 494 | #if defined(FEAT_QUICKFIX) |
| 495 | (char_u *)&p_bh, PV_BH, |
| 496 | {(char_u *)"", (char_u *)0L} |
| 497 | #else |
| 498 | (char_u *)NULL, PV_NONE, |
| 499 | {(char_u *)0L, (char_u *)0L} |
| 500 | #endif |
| 501 | }, |
| 502 | {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, |
| 503 | (char_u *)&p_bl, PV_BL, |
| 504 | {(char_u *)1L, (char_u *)0L} |
| 505 | }, |
| 506 | {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, |
| 507 | #if defined(FEAT_QUICKFIX) |
| 508 | (char_u *)&p_bt, PV_BT, |
| 509 | {(char_u *)"", (char_u *)0L} |
| 510 | #else |
| 511 | (char_u *)NULL, PV_NONE, |
| 512 | {(char_u *)0L, (char_u *)0L} |
| 513 | #endif |
| 514 | }, |
| 515 | {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 516 | (char_u *)&p_cmp, PV_NONE, |
| 517 | {(char_u *)"internal,keepascii", (char_u *)0L} |
| 518 | }, |
| 519 | {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 520 | #ifdef FEAT_SEARCHPATH |
| 521 | (char_u *)&p_cdpath, PV_NONE, |
| 522 | {(char_u *)",,", (char_u *)0L} |
| 523 | #else |
| 524 | (char_u *)NULL, PV_NONE, |
| 525 | {(char_u *)0L, (char_u *)0L} |
| 526 | #endif |
| 527 | }, |
| 528 | {"cedit", NULL, P_STRING, |
| 529 | #ifdef FEAT_CMDWIN |
| 530 | (char_u *)&p_cedit, PV_NONE, |
| 531 | {(char_u *)"", (char_u *)CTRL_F_STR} |
| 532 | #else |
| 533 | (char_u *)NULL, PV_NONE, |
| 534 | {(char_u *)0L, (char_u *)0L} |
| 535 | #endif |
| 536 | }, |
| 537 | {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE, |
| 538 | #if defined(FEAT_MBYTE) && defined(FEAT_EVAL) |
| 539 | (char_u *)&p_ccv, PV_NONE, |
| 540 | {(char_u *)"", (char_u *)0L} |
| 541 | #else |
| 542 | (char_u *)NULL, PV_NONE, |
| 543 | {(char_u *)0L, (char_u *)0L} |
| 544 | #endif |
| 545 | }, |
| 546 | {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM, |
| 547 | #ifdef FEAT_CINDENT |
| 548 | (char_u *)&p_cin, PV_CIN, |
| 549 | #else |
| 550 | (char_u *)NULL, PV_NONE, |
| 551 | #endif |
| 552 | {(char_u *)FALSE, (char_u *)0L}}, |
| 553 | {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 554 | #ifdef FEAT_CINDENT |
| 555 | (char_u *)&p_cink, PV_CINK, |
| 556 | {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L} |
| 557 | #else |
| 558 | (char_u *)NULL, PV_NONE, |
| 559 | {(char_u *)0L, (char_u *)0L} |
| 560 | #endif |
| 561 | }, |
| 562 | {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 563 | #ifdef FEAT_CINDENT |
| 564 | (char_u *)&p_cino, PV_CINO, |
| 565 | #else |
| 566 | (char_u *)NULL, PV_NONE, |
| 567 | #endif |
| 568 | {(char_u *)"", (char_u *)0L}}, |
| 569 | {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 570 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 571 | (char_u *)&p_cinw, PV_CINW, |
| 572 | {(char_u *)"if,else,while,do,for,switch", |
| 573 | (char_u *)0L} |
| 574 | #else |
| 575 | (char_u *)NULL, PV_NONE, |
| 576 | {(char_u *)0L, (char_u *)0L} |
| 577 | #endif |
| 578 | }, |
| 579 | {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 580 | #ifdef FEAT_CLIPBOARD |
| 581 | (char_u *)&p_cb, PV_NONE, |
| 582 | # ifdef FEAT_XCLIPBOARD |
| 583 | {(char_u *)"autoselect,exclude:cons\\|linux", |
| 584 | (char_u *)0L} |
| 585 | # else |
| 586 | {(char_u *)"", (char_u *)0L} |
| 587 | # endif |
| 588 | #else |
| 589 | (char_u *)NULL, PV_NONE, |
| 590 | {(char_u *)"", (char_u *)0L} |
| 591 | #endif |
| 592 | }, |
| 593 | {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL, |
| 594 | (char_u *)&p_ch, PV_NONE, |
| 595 | {(char_u *)1L, (char_u *)0L}}, |
| 596 | {"cmdwinheight", "cwh", P_NUM|P_VI_DEF, |
| 597 | #ifdef FEAT_CMDWIN |
| 598 | (char_u *)&p_cwh, PV_NONE, |
| 599 | #else |
| 600 | (char_u *)NULL, PV_NONE, |
| 601 | #endif |
| 602 | {(char_u *)7L, (char_u *)0L}}, |
| 603 | {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, |
| 604 | (char_u *)&Columns, PV_NONE, |
| 605 | {(char_u *)80L, (char_u *)0L}}, |
| 606 | {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 607 | #ifdef FEAT_COMMENTS |
| 608 | (char_u *)&p_com, PV_COM, |
| 609 | {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", |
| 610 | (char_u *)0L} |
| 611 | #else |
| 612 | (char_u *)NULL, PV_NONE, |
| 613 | {(char_u *)0L, (char_u *)0L} |
| 614 | #endif |
| 615 | }, |
| 616 | {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF, |
| 617 | #ifdef FEAT_FOLDING |
| 618 | (char_u *)&p_cms, PV_CMS, |
| 619 | {(char_u *)"/*%s*/", (char_u *)0L} |
| 620 | #else |
| 621 | (char_u *)NULL, PV_NONE, |
| 622 | {(char_u *)0L, (char_u *)0L} |
| 623 | #endif |
| 624 | }, |
| 625 | {"compatible", "cp", P_BOOL|P_RALL, |
| 626 | (char_u *)&p_cp, PV_NONE, |
| 627 | {(char_u *)TRUE, (char_u *)FALSE}}, |
| 628 | {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 629 | #ifdef FEAT_INS_EXPAND |
| 630 | (char_u *)&p_cpt, PV_CPT, |
| 631 | {(char_u *)".,w,b,u,t,i", (char_u *)0L} |
| 632 | #else |
| 633 | (char_u *)NULL, PV_NONE, |
| 634 | {(char_u *)0L, (char_u *)0L} |
| 635 | #endif |
| 636 | }, |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 637 | {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, |
| 638 | #ifdef FEAT_COMPL_FUNC |
| 639 | (char_u *)&p_cfu, PV_CFU, |
| 640 | {(char_u *)"", (char_u *)0L} |
| 641 | #else |
| 642 | (char_u *)NULL, PV_NONE, |
| 643 | {(char_u *)0L, (char_u *)0L} |
| 644 | #endif |
| 645 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 646 | {"confirm", "cf", P_BOOL|P_VI_DEF, |
| 647 | #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
| 648 | (char_u *)&p_confirm, PV_NONE, |
| 649 | #else |
| 650 | (char_u *)NULL, PV_NONE, |
| 651 | #endif |
| 652 | {(char_u *)FALSE, (char_u *)0L}}, |
| 653 | {"conskey", "consk",P_BOOL|P_VI_DEF, |
| 654 | #ifdef MSDOS |
| 655 | (char_u *)&p_consk, PV_NONE, |
| 656 | #else |
| 657 | (char_u *)NULL, PV_NONE, |
| 658 | #endif |
| 659 | {(char_u *)FALSE, (char_u *)0L}}, |
| 660 | {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM, |
| 661 | (char_u *)&p_ci, PV_CI, |
| 662 | {(char_u *)FALSE, (char_u *)0L}}, |
| 663 | {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST, |
| 664 | (char_u *)&p_cpo, PV_NONE, |
| 665 | {(char_u *)CPO_ALL, (char_u *)CPO_DEFAULT}}, |
| 666 | {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM, |
| 667 | #ifdef FEAT_CSCOPE |
| 668 | (char_u *)&p_cspc, PV_NONE, |
| 669 | #else |
| 670 | (char_u *)NULL, PV_NONE, |
| 671 | #endif |
| 672 | {(char_u *)0L, (char_u *)0L}}, |
| 673 | {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 674 | #ifdef FEAT_CSCOPE |
| 675 | (char_u *)&p_csprg, PV_NONE, |
| 676 | {(char_u *)"cscope", (char_u *)0L} |
| 677 | #else |
| 678 | (char_u *)NULL, PV_NONE, |
| 679 | {(char_u *)0L, (char_u *)0L} |
| 680 | #endif |
| 681 | }, |
| 682 | {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 683 | #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) |
| 684 | (char_u *)&p_csqf, PV_NONE, |
| 685 | {(char_u *)"", (char_u *)0L} |
| 686 | #else |
| 687 | (char_u *)NULL, PV_NONE, |
| 688 | {(char_u *)0L, (char_u *)0L} |
| 689 | #endif |
| 690 | }, |
| 691 | {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM, |
| 692 | #ifdef FEAT_CSCOPE |
| 693 | (char_u *)&p_cst, PV_NONE, |
| 694 | #else |
| 695 | (char_u *)NULL, PV_NONE, |
| 696 | #endif |
| 697 | {(char_u *)0L, (char_u *)0L}}, |
| 698 | {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM, |
| 699 | #ifdef FEAT_CSCOPE |
| 700 | (char_u *)&p_csto, PV_NONE, |
| 701 | #else |
| 702 | (char_u *)NULL, PV_NONE, |
| 703 | #endif |
| 704 | {(char_u *)0L, (char_u *)0L}}, |
| 705 | {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM, |
| 706 | #ifdef FEAT_CSCOPE |
| 707 | (char_u *)&p_csverbose, PV_NONE, |
| 708 | #else |
| 709 | (char_u *)NULL, PV_NONE, |
| 710 | #endif |
| 711 | {(char_u *)0L, (char_u *)0L}}, |
| 712 | {"debug", NULL, P_STRING|P_VI_DEF, |
| 713 | (char_u *)&p_debug, PV_NONE, |
| 714 | {(char_u *)"", (char_u *)0L}}, |
| 715 | {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF, |
| 716 | #ifdef FEAT_FIND_ID |
| 717 | (char_u *)&p_def, OPT_BOTH(PV_DEF), |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 718 | {(char_u *)"^\\s*#\\s*define", (char_u *)0L} |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 719 | #else |
| 720 | (char_u *)NULL, PV_NONE, |
| 721 | {(char_u *)NULL, (char_u *)0L} |
| 722 | #endif |
| 723 | }, |
| 724 | {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM, |
| 725 | #ifdef FEAT_MBYTE |
| 726 | (char_u *)&p_deco, PV_NONE, |
| 727 | #else |
| 728 | (char_u *)NULL, PV_NONE, |
| 729 | #endif |
| 730 | {(char_u *)FALSE, (char_u *)0L} |
| 731 | }, |
| 732 | {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 733 | #ifdef FEAT_INS_EXPAND |
| 734 | (char_u *)&p_dict, OPT_BOTH(PV_DICT), |
| 735 | #else |
| 736 | (char_u *)NULL, PV_NONE, |
| 737 | #endif |
| 738 | {(char_u *)"", (char_u *)0L}}, |
| 739 | {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB, |
| 740 | #ifdef FEAT_DIFF |
| 741 | (char_u *)VAR_WIN, PV_DIFF, |
| 742 | #else |
| 743 | (char_u *)NULL, PV_NONE, |
| 744 | #endif |
| 745 | {(char_u *)FALSE, (char_u *)0L}}, |
| 746 | {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE, |
| 747 | #if defined(FEAT_DIFF) && defined(FEAT_EVAL) |
| 748 | (char_u *)&p_dex, PV_NONE, |
| 749 | {(char_u *)"", (char_u *)0L} |
| 750 | #else |
| 751 | (char_u *)NULL, PV_NONE, |
| 752 | {(char_u *)0L, (char_u *)0L} |
| 753 | #endif |
| 754 | }, |
| 755 | {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP, |
| 756 | #ifdef FEAT_DIFF |
| 757 | (char_u *)&p_dip, PV_NONE, |
| 758 | {(char_u *)"filler", (char_u *)NULL} |
| 759 | #else |
| 760 | (char_u *)NULL, PV_NONE, |
| 761 | {(char_u *)"", (char_u *)NULL} |
| 762 | #endif |
| 763 | }, |
| 764 | {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM, |
| 765 | #ifdef FEAT_DIGRAPHS |
| 766 | (char_u *)&p_dg, PV_NONE, |
| 767 | #else |
| 768 | (char_u *)NULL, PV_NONE, |
| 769 | #endif |
| 770 | {(char_u *)FALSE, (char_u *)0L}}, |
| 771 | {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, |
| 772 | (char_u *)&p_dir, PV_NONE, |
| 773 | {(char_u *)DFLT_DIR, (char_u *)0L}}, |
| 774 | {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP, |
| 775 | (char_u *)&p_dy, PV_NONE, |
| 776 | {(char_u *)"", (char_u *)0L}}, |
| 777 | {"eadirection", "ead", P_STRING|P_VI_DEF, |
| 778 | #ifdef FEAT_VERTSPLIT |
| 779 | (char_u *)&p_ead, PV_NONE, |
| 780 | {(char_u *)"both", (char_u *)0L} |
| 781 | #else |
| 782 | (char_u *)NULL, PV_NONE, |
| 783 | {(char_u *)NULL, (char_u *)0L} |
| 784 | #endif |
| 785 | }, |
| 786 | {"edcompatible","ed", P_BOOL|P_VI_DEF, |
| 787 | (char_u *)&p_ed, PV_NONE, |
| 788 | {(char_u *)FALSE, (char_u *)0L}}, |
| 789 | {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR, |
| 790 | #ifdef FEAT_MBYTE |
| 791 | (char_u *)&p_enc, PV_NONE, |
| 792 | {(char_u *)ENC_DFLT, (char_u *)0L} |
| 793 | #else |
| 794 | (char_u *)NULL, PV_NONE, |
| 795 | {(char_u *)0L, (char_u *)0L} |
| 796 | #endif |
| 797 | }, |
| 798 | {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
| 799 | (char_u *)&p_eol, PV_EOL, |
| 800 | {(char_u *)TRUE, (char_u *)0L}}, |
| 801 | {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL, |
| 802 | (char_u *)&p_ea, PV_NONE, |
| 803 | {(char_u *)TRUE, (char_u *)0L}}, |
| 804 | {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 805 | (char_u *)&p_ep, OPT_BOTH(PV_EP), |
| 806 | {(char_u *)"", (char_u *)0L}}, |
| 807 | {"errorbells", "eb", P_BOOL|P_VI_DEF, |
| 808 | (char_u *)&p_eb, PV_NONE, |
| 809 | {(char_u *)FALSE, (char_u *)0L}}, |
| 810 | {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 811 | #ifdef FEAT_QUICKFIX |
| 812 | (char_u *)&p_ef, PV_NONE, |
| 813 | {(char_u *)DFLT_ERRORFILE, (char_u *)0L} |
| 814 | #else |
| 815 | (char_u *)NULL, PV_NONE, |
| 816 | {(char_u *)NULL, (char_u *)0L} |
| 817 | #endif |
| 818 | }, |
| 819 | {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 820 | #ifdef FEAT_QUICKFIX |
| 821 | (char_u *)&p_efm, OPT_BOTH(PV_EFM), |
| 822 | {(char_u *)DFLT_EFM, (char_u *)0L}, |
| 823 | #else |
| 824 | (char_u *)NULL, PV_NONE, |
| 825 | {(char_u *)NULL, (char_u *)0L} |
| 826 | #endif |
| 827 | }, |
| 828 | {"esckeys", "ek", P_BOOL|P_VIM, |
| 829 | (char_u *)&p_ek, PV_NONE, |
| 830 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 831 | {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 832 | #ifdef FEAT_AUTOCMD |
| 833 | (char_u *)&p_ei, PV_NONE, |
| 834 | #else |
| 835 | (char_u *)NULL, PV_NONE, |
| 836 | #endif |
| 837 | {(char_u *)"", (char_u *)0L}}, |
| 838 | {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM, |
| 839 | (char_u *)&p_et, PV_ET, |
| 840 | {(char_u *)FALSE, (char_u *)0L}}, |
| 841 | {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE, |
| 842 | (char_u *)&p_exrc, PV_NONE, |
| 843 | {(char_u *)FALSE, (char_u *)0L}}, |
| 844 | {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC, |
| 845 | #ifdef FEAT_MBYTE |
| 846 | (char_u *)&p_fenc, PV_FENC, |
| 847 | {(char_u *)"", (char_u *)0L} |
| 848 | #else |
| 849 | (char_u *)NULL, PV_NONE, |
| 850 | {(char_u *)0L, (char_u *)0L} |
| 851 | #endif |
| 852 | }, |
| 853 | {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA, |
| 854 | #ifdef FEAT_MBYTE |
| 855 | (char_u *)&p_fencs, PV_NONE, |
| 856 | {(char_u *)"ucs-bom", (char_u *)0L} |
| 857 | #else |
| 858 | (char_u *)NULL, PV_NONE, |
| 859 | {(char_u *)0L, (char_u *)0L} |
| 860 | #endif |
| 861 | }, |
| 862 | {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC, |
| 863 | (char_u *)&p_ff, PV_FF, |
| 864 | {(char_u *)DFLT_FF, (char_u *)0L}}, |
| 865 | {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP, |
| 866 | (char_u *)&p_ffs, PV_NONE, |
| 867 | {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 868 | {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 869 | #ifdef FEAT_AUTOCMD |
| 870 | (char_u *)&p_ft, PV_FT, |
| 871 | {(char_u *)"", (char_u *)0L} |
| 872 | #else |
| 873 | (char_u *)NULL, PV_NONE, |
| 874 | {(char_u *)0L, (char_u *)0L} |
| 875 | #endif |
| 876 | }, |
| 877 | {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
| 878 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 879 | (char_u *)&p_fcs, PV_NONE, |
| 880 | {(char_u *)"vert:|,fold:-", (char_u *)0L} |
| 881 | #else |
| 882 | (char_u *)NULL, PV_NONE, |
| 883 | {(char_u *)"", (char_u *)0L} |
| 884 | #endif |
| 885 | }, |
| 886 | {"fkmap", "fk", P_BOOL|P_VI_DEF, |
| 887 | #ifdef FEAT_FKMAP |
| 888 | (char_u *)&p_fkmap, PV_NONE, |
| 889 | #else |
| 890 | (char_u *)NULL, PV_NONE, |
| 891 | #endif |
| 892 | {(char_u *)FALSE, (char_u *)0L}}, |
| 893 | {"flash", "fl", P_BOOL|P_VI_DEF, |
| 894 | (char_u *)NULL, PV_NONE, |
| 895 | {(char_u *)FALSE, (char_u *)0L}}, |
| 896 | #ifdef FEAT_FOLDING |
| 897 | {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN, |
| 898 | (char_u *)&p_fcl, PV_NONE, |
| 899 | {(char_u *)"", (char_u *)0L}}, |
| 900 | {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN, |
| 901 | (char_u *)VAR_WIN, PV_FDC, |
| 902 | {(char_u *)FALSE, (char_u *)0L}}, |
| 903 | {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN, |
| 904 | (char_u *)VAR_WIN, PV_FEN, |
| 905 | {(char_u *)TRUE, (char_u *)0L}}, |
| 906 | {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 907 | # ifdef FEAT_EVAL |
| 908 | (char_u *)VAR_WIN, PV_FDE, |
| 909 | {(char_u *)"0", (char_u *)NULL} |
| 910 | # else |
| 911 | (char_u *)NULL, PV_NONE, |
| 912 | {(char_u *)NULL, (char_u *)0L} |
| 913 | # endif |
| 914 | }, |
| 915 | {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 916 | (char_u *)VAR_WIN, PV_FDI, |
| 917 | {(char_u *)"#", (char_u *)NULL}}, |
| 918 | {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN, |
| 919 | (char_u *)VAR_WIN, PV_FDL, |
| 920 | {(char_u *)0L, (char_u *)0L}}, |
| 921 | {"foldlevelstart","fdls", P_NUM|P_VI_DEF, |
| 922 | (char_u *)&p_fdls, PV_NONE, |
| 923 | {(char_u *)-1L, (char_u *)0L}}, |
| 924 | {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF| |
| 925 | P_RWIN|P_COMMA|P_NODUP, |
| 926 | (char_u *)VAR_WIN, PV_FMR, |
| 927 | {(char_u *)"{{{,}}}", (char_u *)NULL}}, |
| 928 | {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 929 | (char_u *)VAR_WIN, PV_FDM, |
| 930 | {(char_u *)"manual", (char_u *)NULL}}, |
| 931 | {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN, |
| 932 | (char_u *)VAR_WIN, PV_FML, |
| 933 | {(char_u *)1L, (char_u *)0L}}, |
| 934 | {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN, |
| 935 | (char_u *)VAR_WIN, PV_FDN, |
| 936 | {(char_u *)20L, (char_u *)0L}}, |
| 937 | {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 938 | (char_u *)&p_fdo, PV_NONE, |
| 939 | {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", |
| 940 | (char_u *)0L}}, |
| 941 | {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 942 | # ifdef FEAT_EVAL |
| 943 | (char_u *)VAR_WIN, PV_FDT, |
| 944 | {(char_u *)"foldtext()", (char_u *)NULL} |
Bram Moolenaar | 7b0294c | 2004-10-11 10:16:09 +0000 | [diff] [blame] | 945 | # else |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 946 | (char_u *)NULL, PV_NONE, |
| 947 | {(char_u *)NULL, (char_u *)0L} |
Bram Moolenaar | 7b0294c | 2004-10-11 10:16:09 +0000 | [diff] [blame] | 948 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 949 | }, |
| 950 | #endif |
| 951 | {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST, |
| 952 | (char_u *)&p_fo, PV_FO, |
| 953 | {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}}, |
| 954 | {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 955 | (char_u *)&p_fp, PV_NONE, |
| 956 | {(char_u *)"", (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 957 | {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, |
| 958 | #ifdef HAVE_FSYNC |
| 959 | (char_u *)&p_fs, PV_NONE, |
| 960 | {(char_u *)TRUE, (char_u *)0L} |
| 961 | #else |
| 962 | (char_u *)NULL, PV_NONE, |
| 963 | {(char_u *)FALSE, (char_u *)0L} |
| 964 | #endif |
| 965 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 966 | {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM, |
| 967 | (char_u *)&p_gd, PV_NONE, |
| 968 | {(char_u *)FALSE, (char_u *)0L}}, |
| 969 | {"graphic", "gr", P_BOOL|P_VI_DEF, |
| 970 | (char_u *)NULL, PV_NONE, |
| 971 | {(char_u *)FALSE, (char_u *)0L}}, |
| 972 | {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 973 | #ifdef FEAT_QUICKFIX |
| 974 | (char_u *)&p_gefm, PV_NONE, |
| 975 | {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}, |
| 976 | #else |
| 977 | (char_u *)NULL, PV_NONE, |
| 978 | {(char_u *)NULL, (char_u *)0L} |
| 979 | #endif |
| 980 | }, |
| 981 | {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 982 | #ifdef FEAT_QUICKFIX |
| 983 | (char_u *)&p_gp, OPT_BOTH(PV_GP), |
| 984 | { |
| 985 | # ifdef WIN3264 |
| 986 | /* may be changed to "grep -n" in os_win32.c */ |
| 987 | (char_u *)"findstr /n", |
| 988 | # else |
| 989 | # ifdef UNIX |
| 990 | /* Add an extra file name so that grep will always |
| 991 | * insert a file name in the match line. */ |
| 992 | (char_u *)"grep -n $* /dev/null", |
| 993 | # else |
| 994 | # ifdef VMS |
| 995 | (char_u *)"SEARCH/NUMBERS ", |
| 996 | # else |
| 997 | (char_u *)"grep -n ", |
| 998 | #endif |
| 999 | #endif |
| 1000 | # endif |
| 1001 | (char_u *)0L}, |
| 1002 | #else |
| 1003 | (char_u *)NULL, PV_NONE, |
| 1004 | {(char_u *)NULL, (char_u *)0L} |
| 1005 | #endif |
| 1006 | }, |
| 1007 | {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1008 | #ifdef CURSOR_SHAPE |
| 1009 | (char_u *)&p_guicursor, PV_NONE, |
| 1010 | { |
| 1011 | # ifdef FEAT_GUI |
| 1012 | (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", |
| 1013 | # else /* MSDOS or Win32 console */ |
| 1014 | (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block", |
| 1015 | # endif |
| 1016 | (char_u *)0L} |
| 1017 | #else |
| 1018 | (char_u *)NULL, PV_NONE, |
| 1019 | {(char_u *)NULL, (char_u *)0L} |
| 1020 | #endif |
| 1021 | }, |
| 1022 | {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
| 1023 | #ifdef FEAT_GUI |
| 1024 | (char_u *)&p_guifont, PV_NONE, |
| 1025 | {(char_u *)"", (char_u *)0L} |
| 1026 | #else |
| 1027 | (char_u *)NULL, PV_NONE, |
| 1028 | {(char_u *)NULL, (char_u *)0L} |
| 1029 | #endif |
| 1030 | }, |
| 1031 | {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA, |
| 1032 | #if defined(FEAT_GUI) && defined(FEAT_XFONTSET) |
| 1033 | (char_u *)&p_guifontset, PV_NONE, |
| 1034 | {(char_u *)"", (char_u *)0L} |
| 1035 | #else |
| 1036 | (char_u *)NULL, PV_NONE, |
| 1037 | {(char_u *)NULL, (char_u *)0L} |
| 1038 | #endif |
| 1039 | }, |
| 1040 | {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
| 1041 | #if defined(FEAT_GUI) && defined(FEAT_MBYTE) |
| 1042 | (char_u *)&p_guifontwide, PV_NONE, |
| 1043 | {(char_u *)"", (char_u *)0L} |
| 1044 | #else |
| 1045 | (char_u *)NULL, PV_NONE, |
| 1046 | {(char_u *)NULL, (char_u *)0L} |
| 1047 | #endif |
| 1048 | }, |
| 1049 | {"guiheadroom", "ghr", P_NUM|P_VI_DEF, |
Bram Moolenaar | 843ee41 | 2004-06-30 16:16:41 +0000 | [diff] [blame] | 1050 | #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1051 | (char_u *)&p_ghr, PV_NONE, |
| 1052 | #else |
| 1053 | (char_u *)NULL, PV_NONE, |
| 1054 | #endif |
| 1055 | {(char_u *)50L, (char_u *)0L}}, |
| 1056 | {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, |
Bram Moolenaar | 843ee41 | 2004-06-30 16:16:41 +0000 | [diff] [blame] | 1057 | #if defined(FEAT_GUI) || defined(FEAT_GUI_KDE) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1058 | (char_u *)&p_go, PV_NONE, |
| 1059 | # if defined(UNIX) && !defined(MACOS) |
| 1060 | {(char_u *)"agimrLtT", (char_u *)0L} |
| 1061 | # else |
| 1062 | {(char_u *)"gmrLtT", (char_u *)0L} |
| 1063 | # endif |
| 1064 | #else |
| 1065 | (char_u *)NULL, PV_NONE, |
| 1066 | {(char_u *)NULL, (char_u *)0L} |
| 1067 | #endif |
| 1068 | }, |
| 1069 | {"guipty", NULL, P_BOOL|P_VI_DEF, |
| 1070 | #if defined(FEAT_GUI) |
| 1071 | (char_u *)&p_guipty, PV_NONE, |
| 1072 | #else |
| 1073 | (char_u *)NULL, PV_NONE, |
| 1074 | #endif |
| 1075 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1076 | {"hardtabs", "ht", P_NUM|P_VI_DEF, |
| 1077 | (char_u *)NULL, PV_NONE, |
| 1078 | {(char_u *)0L, (char_u *)0L}}, |
| 1079 | {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1080 | (char_u *)&p_hf, PV_NONE, |
| 1081 | {(char_u *)DFLT_HELPFILE, (char_u *)0L}}, |
| 1082 | {"helpheight", "hh", P_NUM|P_VI_DEF, |
| 1083 | #ifdef FEAT_WINDOWS |
| 1084 | (char_u *)&p_hh, PV_NONE, |
| 1085 | #else |
| 1086 | (char_u *)NULL, PV_NONE, |
| 1087 | #endif |
| 1088 | {(char_u *)20L, (char_u *)0L}}, |
| 1089 | {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA, |
| 1090 | #ifdef FEAT_MULTI_LANG |
| 1091 | (char_u *)&p_hlg, PV_NONE, |
| 1092 | {(char_u *)"", (char_u *)0L} |
| 1093 | #else |
| 1094 | (char_u *)NULL, PV_NONE, |
| 1095 | {(char_u *)0L, (char_u *)0L} |
| 1096 | #endif |
| 1097 | }, |
| 1098 | {"hidden", "hid", P_BOOL|P_VI_DEF, |
| 1099 | (char_u *)&p_hid, PV_NONE, |
| 1100 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1101 | {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
| 1102 | (char_u *)&p_hl, PV_NONE, |
| 1103 | {(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", |
| 1104 | (char_u *)0L}}, |
| 1105 | {"history", "hi", P_NUM|P_VIM, |
| 1106 | (char_u *)&p_hi, PV_NONE, |
| 1107 | {(char_u *)0L, (char_u *)20L}}, |
| 1108 | {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM, |
| 1109 | #ifdef FEAT_RIGHTLEFT |
| 1110 | (char_u *)&p_hkmap, PV_NONE, |
| 1111 | #else |
| 1112 | (char_u *)NULL, PV_NONE, |
| 1113 | #endif |
| 1114 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1115 | {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM, |
| 1116 | #ifdef FEAT_RIGHTLEFT |
| 1117 | (char_u *)&p_hkmapp, PV_NONE, |
| 1118 | #else |
| 1119 | (char_u *)NULL, PV_NONE, |
| 1120 | #endif |
| 1121 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1122 | {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL, |
| 1123 | (char_u *)&p_hls, PV_NONE, |
| 1124 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1125 | {"icon", NULL, P_BOOL|P_VI_DEF, |
| 1126 | #ifdef FEAT_TITLE |
| 1127 | (char_u *)&p_icon, PV_NONE, |
| 1128 | #else |
| 1129 | (char_u *)NULL, PV_NONE, |
| 1130 | #endif |
| 1131 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1132 | {"iconstring", NULL, P_STRING|P_VI_DEF, |
| 1133 | #ifdef FEAT_TITLE |
| 1134 | (char_u *)&p_iconstring, PV_NONE, |
| 1135 | #else |
| 1136 | (char_u *)NULL, PV_NONE, |
| 1137 | #endif |
| 1138 | {(char_u *)"", (char_u *)0L}}, |
| 1139 | {"ignorecase", "ic", P_BOOL|P_VI_DEF, |
| 1140 | (char_u *)&p_ic, PV_NONE, |
| 1141 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1142 | {"imactivatekey","imak",P_STRING|P_VI_DEF, |
Bram Moolenaar | 843ee41 | 2004-06-30 16:16:41 +0000 | [diff] [blame] | 1143 | #if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1144 | (char_u *)&p_imak, PV_NONE, |
| 1145 | #else |
| 1146 | (char_u *)NULL, PV_NONE, |
| 1147 | #endif |
| 1148 | {(char_u *)"", (char_u *)0L}}, |
| 1149 | {"imcmdline", "imc", P_BOOL|P_VI_DEF, |
| 1150 | #ifdef USE_IM_CONTROL |
| 1151 | (char_u *)&p_imcmdline, PV_NONE, |
| 1152 | #else |
| 1153 | (char_u *)NULL, PV_NONE, |
| 1154 | #endif |
| 1155 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1156 | {"imdisable", "imd", P_BOOL|P_VI_DEF, |
| 1157 | #ifdef USE_IM_CONTROL |
| 1158 | (char_u *)&p_imdisable, PV_NONE, |
| 1159 | #else |
| 1160 | (char_u *)NULL, PV_NONE, |
| 1161 | #endif |
| 1162 | #ifdef __sgi |
| 1163 | {(char_u *)TRUE, (char_u *)0L} |
| 1164 | #else |
| 1165 | {(char_u *)FALSE, (char_u *)0L} |
| 1166 | #endif |
| 1167 | }, |
| 1168 | {"iminsert", "imi", P_NUM|P_VI_DEF, |
| 1169 | (char_u *)&p_iminsert, PV_IMI, |
| 1170 | #ifdef B_IMODE_IM |
| 1171 | {(char_u *)B_IMODE_IM, (char_u *)0L} |
| 1172 | #else |
| 1173 | {(char_u *)B_IMODE_NONE, (char_u *)0L} |
| 1174 | #endif |
| 1175 | }, |
| 1176 | {"imsearch", "ims", P_NUM|P_VI_DEF, |
| 1177 | (char_u *)&p_imsearch, PV_IMS, |
| 1178 | #ifdef B_IMODE_IM |
| 1179 | {(char_u *)B_IMODE_IM, (char_u *)0L} |
| 1180 | #else |
| 1181 | {(char_u *)B_IMODE_NONE, (char_u *)0L} |
| 1182 | #endif |
| 1183 | }, |
| 1184 | {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1185 | #ifdef FEAT_FIND_ID |
| 1186 | (char_u *)&p_inc, OPT_BOTH(PV_INC), |
| 1187 | {(char_u *)"^\\s*#\\s*include", (char_u *)0L} |
| 1188 | #else |
| 1189 | (char_u *)NULL, PV_NONE, |
| 1190 | {(char_u *)0L, (char_u *)0L} |
| 1191 | #endif |
| 1192 | }, |
| 1193 | {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1194 | #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) |
| 1195 | (char_u *)&p_inex, PV_INEX, |
| 1196 | {(char_u *)"", (char_u *)0L} |
| 1197 | #else |
| 1198 | (char_u *)NULL, PV_NONE, |
| 1199 | {(char_u *)0L, (char_u *)0L} |
| 1200 | #endif |
| 1201 | }, |
| 1202 | {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM, |
| 1203 | (char_u *)&p_is, PV_NONE, |
| 1204 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1205 | {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, |
| 1206 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 1207 | (char_u *)&p_inde, PV_INDE, |
| 1208 | {(char_u *)"", (char_u *)0L} |
| 1209 | #else |
| 1210 | (char_u *)NULL, PV_NONE, |
| 1211 | {(char_u *)0L, (char_u *)0L} |
| 1212 | #endif |
| 1213 | }, |
| 1214 | {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 1215 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 1216 | (char_u *)&p_indk, PV_INDK, |
| 1217 | {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L} |
| 1218 | #else |
| 1219 | (char_u *)NULL, PV_NONE, |
| 1220 | {(char_u *)0L, (char_u *)0L} |
| 1221 | #endif |
| 1222 | }, |
| 1223 | {"infercase", "inf", P_BOOL|P_VI_DEF, |
| 1224 | (char_u *)&p_inf, PV_INF, |
| 1225 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1226 | {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM, |
| 1227 | (char_u *)&p_im, PV_NONE, |
| 1228 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1229 | {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1230 | (char_u *)&p_isf, PV_NONE, |
| 1231 | { |
| 1232 | #ifdef BACKSLASH_IN_FILENAME |
| 1233 | /* Excluded are: & and ^ are special in cmd.exe |
| 1234 | * ( and ) are used in text separating fnames */ |
| 1235 | (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=", |
| 1236 | #else |
| 1237 | # ifdef AMIGA |
| 1238 | (char_u *)"@,48-57,/,.,-,_,+,,,$,:", |
| 1239 | # else |
| 1240 | # ifdef VMS |
| 1241 | (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~", |
| 1242 | # else /* UNIX et al. */ |
| 1243 | # ifdef EBCDIC |
| 1244 | (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=", |
| 1245 | # else |
| 1246 | (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=", |
| 1247 | # endif |
| 1248 | # endif |
| 1249 | # endif |
| 1250 | #endif |
| 1251 | (char_u *)0L}}, |
| 1252 | {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1253 | (char_u *)&p_isi, PV_NONE, |
| 1254 | { |
| 1255 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 1256 | (char_u *)"@,48-57,_,128-167,224-235", |
| 1257 | #else |
| 1258 | # ifdef EBCDIC |
| 1259 | /* TODO: EBCDIC Check this! @ == isalpha()*/ |
| 1260 | (char_u *)"@,240-249,_,66-73,81-89,98-105," |
| 1261 | "112-120,128,140-142,156,158,172," |
| 1262 | "174,186,191,203-207,219-225,235-239," |
| 1263 | "251-254", |
| 1264 | # else |
| 1265 | (char_u *)"@,48-57,_,192-255", |
| 1266 | # endif |
| 1267 | #endif |
| 1268 | (char_u *)0L}}, |
| 1269 | {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP, |
| 1270 | (char_u *)&p_isk, PV_ISK, |
| 1271 | { |
| 1272 | #ifdef EBCDIC |
| 1273 | (char_u *)"@,240-249,_", |
| 1274 | /* TODO: EBCDIC Check this! @ == isalpha()*/ |
| 1275 | (char_u *)"@,240-249,_,66-73,81-89,98-105," |
| 1276 | "112-120,128,140-142,156,158,172," |
| 1277 | "174,186,191,203-207,219-225,235-239," |
| 1278 | "251-254", |
| 1279 | #else |
| 1280 | (char_u *)"@,48-57,_", |
| 1281 | # if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 1282 | (char_u *)"@,48-57,_,128-167,224-235" |
| 1283 | # else |
| 1284 | (char_u *)"@,48-57,_,192-255" |
| 1285 | # endif |
| 1286 | #endif |
| 1287 | }}, |
| 1288 | {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
| 1289 | (char_u *)&p_isp, PV_NONE, |
| 1290 | { |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1291 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \ |
| 1292 | || (defined(MACOS) && !defined(MACOS_X)) \ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1293 | || defined(VMS) |
| 1294 | (char_u *)"@,~-255", |
| 1295 | #else |
| 1296 | # ifdef EBCDIC |
| 1297 | /* all chars above 63 are printable */ |
| 1298 | (char_u *)"63-255", |
| 1299 | # else |
| 1300 | (char_u *)"@,161-255", |
| 1301 | # endif |
| 1302 | #endif |
| 1303 | (char_u *)0L}}, |
| 1304 | {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM, |
| 1305 | (char_u *)&p_js, PV_NONE, |
| 1306 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1307 | {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC, |
| 1308 | #ifdef FEAT_CRYPT |
| 1309 | (char_u *)&p_key, PV_KEY, |
| 1310 | {(char_u *)"", (char_u *)0L} |
| 1311 | #else |
| 1312 | (char_u *)NULL, PV_NONE, |
| 1313 | {(char_u *)0L, (char_u *)0L} |
| 1314 | #endif |
| 1315 | }, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1316 | {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1317 | #ifdef FEAT_KEYMAP |
| 1318 | (char_u *)&p_keymap, PV_KMAP, |
| 1319 | {(char_u *)"", (char_u *)0L} |
| 1320 | #else |
| 1321 | (char_u *)NULL, PV_NONE, |
| 1322 | {(char_u *)"", (char_u *)0L} |
| 1323 | #endif |
| 1324 | }, |
| 1325 | {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1326 | #ifdef FEAT_VISUAL |
| 1327 | (char_u *)&p_km, PV_NONE, |
| 1328 | #else |
| 1329 | (char_u *)NULL, PV_NONE, |
| 1330 | #endif |
| 1331 | {(char_u *)"", (char_u *)0L}}, |
| 1332 | {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1333 | (char_u *)&p_kp, OPT_BOTH(PV_KP), |
| 1334 | { |
| 1335 | #if defined(MSDOS) || defined(MSWIN) |
| 1336 | (char_u *)":help", |
| 1337 | #else |
| 1338 | #ifdef VMS |
| 1339 | (char_u *)"help", |
| 1340 | #else |
| 1341 | # if defined(OS2) |
| 1342 | (char_u *)"view /", |
| 1343 | # else |
| 1344 | # ifdef USEMAN_S |
| 1345 | (char_u *)"man -s", |
| 1346 | # else |
| 1347 | (char_u *)"man", |
| 1348 | # endif |
| 1349 | # endif |
| 1350 | #endif |
| 1351 | #endif |
| 1352 | (char_u *)0L}}, |
| 1353 | {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1354 | #ifdef FEAT_LANGMAP |
| 1355 | (char_u *)&p_langmap, PV_NONE, |
| 1356 | {(char_u *)"", /* unmatched } */ |
| 1357 | #else |
| 1358 | (char_u *)NULL, PV_NONE, |
| 1359 | {(char_u *)NULL, |
| 1360 | #endif |
| 1361 | (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1362 | {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1363 | #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) |
| 1364 | (char_u *)&p_lm, PV_NONE, |
| 1365 | #else |
| 1366 | (char_u *)NULL, PV_NONE, |
| 1367 | #endif |
| 1368 | {(char_u *)"", (char_u *)0L}}, |
| 1369 | {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, |
| 1370 | #ifdef FEAT_WINDOWS |
| 1371 | (char_u *)&p_ls, PV_NONE, |
| 1372 | #else |
| 1373 | (char_u *)NULL, PV_NONE, |
| 1374 | #endif |
| 1375 | {(char_u *)1L, (char_u *)0L}}, |
| 1376 | {"lazyredraw", "lz", P_BOOL|P_VI_DEF, |
| 1377 | (char_u *)&p_lz, PV_NONE, |
| 1378 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1379 | {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN, |
| 1380 | #ifdef FEAT_LINEBREAK |
| 1381 | (char_u *)VAR_WIN, PV_LBR, |
| 1382 | #else |
| 1383 | (char_u *)NULL, PV_NONE, |
| 1384 | #endif |
| 1385 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1386 | {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, |
| 1387 | (char_u *)&Rows, PV_NONE, |
| 1388 | { |
| 1389 | #if defined(MSDOS) || defined(WIN3264) || defined(OS2) |
| 1390 | (char_u *)25L, |
| 1391 | #else |
| 1392 | (char_u *)24L, |
| 1393 | #endif |
| 1394 | (char_u *)0L}}, |
| 1395 | {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR, |
| 1396 | #ifdef FEAT_GUI |
| 1397 | (char_u *)&p_linespace, PV_NONE, |
| 1398 | #else |
| 1399 | (char_u *)NULL, PV_NONE, |
| 1400 | #endif |
| 1401 | #ifdef FEAT_GUI_W32 |
| 1402 | {(char_u *)1L, (char_u *)0L} |
| 1403 | #else |
| 1404 | {(char_u *)0L, (char_u *)0L} |
| 1405 | #endif |
| 1406 | }, |
| 1407 | {"lisp", NULL, P_BOOL|P_VI_DEF, |
| 1408 | #ifdef FEAT_LISP |
| 1409 | (char_u *)&p_lisp, PV_LISP, |
| 1410 | #else |
| 1411 | (char_u *)NULL, PV_NONE, |
| 1412 | #endif |
| 1413 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1414 | {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1415 | #ifdef FEAT_LISP |
| 1416 | (char_u *)&p_lispwords, PV_NONE, |
| 1417 | {(char_u *)LISPWORD_VALUE, (char_u *)0L} |
| 1418 | #else |
| 1419 | (char_u *)NULL, PV_NONE, |
| 1420 | {(char_u *)"", (char_u *)0L} |
| 1421 | #endif |
| 1422 | }, |
| 1423 | {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
| 1424 | (char_u *)VAR_WIN, PV_LIST, |
| 1425 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1426 | {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
| 1427 | (char_u *)&p_lcs, PV_NONE, |
| 1428 | {(char_u *)"eol:$", (char_u *)0L}}, |
| 1429 | {"loadplugins", "lpl", P_BOOL|P_VI_DEF, |
| 1430 | (char_u *)&p_lpl, PV_NONE, |
| 1431 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1432 | {"magic", NULL, P_BOOL|P_VI_DEF, |
| 1433 | (char_u *)&p_magic, PV_NONE, |
| 1434 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1435 | {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1436 | #ifdef FEAT_QUICKFIX |
| 1437 | (char_u *)&p_mef, PV_NONE, |
| 1438 | {(char_u *)"", (char_u *)0L} |
| 1439 | #else |
| 1440 | (char_u *)NULL, PV_NONE, |
| 1441 | {(char_u *)NULL, (char_u *)0L} |
| 1442 | #endif |
| 1443 | }, |
| 1444 | {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1445 | #ifdef FEAT_QUICKFIX |
| 1446 | (char_u *)&p_mp, OPT_BOTH(PV_MP), |
| 1447 | # ifdef VMS |
| 1448 | {(char_u *)"MMS", (char_u *)0L} |
| 1449 | # else |
| 1450 | {(char_u *)"make", (char_u *)0L} |
| 1451 | # endif |
| 1452 | #else |
| 1453 | (char_u *)NULL, PV_NONE, |
| 1454 | {(char_u *)NULL, (char_u *)0L} |
| 1455 | #endif |
| 1456 | }, |
| 1457 | {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 1458 | (char_u *)&p_mps, PV_MPS, |
| 1459 | {(char_u *)"(:),{:},[:]", (char_u *)0L}}, |
| 1460 | {"matchtime", "mat", P_NUM|P_VI_DEF, |
| 1461 | (char_u *)&p_mat, PV_NONE, |
| 1462 | {(char_u *)5L, (char_u *)0L}}, |
| 1463 | {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF, |
| 1464 | #ifdef FEAT_EVAL |
| 1465 | (char_u *)&p_mfd, PV_NONE, |
| 1466 | #else |
| 1467 | (char_u *)NULL, PV_NONE, |
| 1468 | #endif |
| 1469 | {(char_u *)100L, (char_u *)0L}}, |
| 1470 | {"maxmapdepth", "mmd", P_NUM|P_VI_DEF, |
| 1471 | (char_u *)&p_mmd, PV_NONE, |
| 1472 | {(char_u *)1000L, (char_u *)0L}}, |
| 1473 | {"maxmem", "mm", P_NUM|P_VI_DEF, |
| 1474 | (char_u *)&p_mm, PV_NONE, |
| 1475 | {(char_u *)DFLT_MAXMEM, (char_u *)0L}}, |
| 1476 | {"maxmemtot", "mmt", P_NUM|P_VI_DEF, |
| 1477 | (char_u *)&p_mmt, PV_NONE, |
| 1478 | {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}}, |
| 1479 | {"menuitems", "mis", P_NUM|P_VI_DEF, |
| 1480 | #ifdef FEAT_MENU |
| 1481 | (char_u *)&p_mis, PV_NONE, |
| 1482 | #else |
| 1483 | (char_u *)NULL, PV_NONE, |
| 1484 | #endif |
| 1485 | {(char_u *)25L, (char_u *)0L}}, |
| 1486 | {"mesg", NULL, P_BOOL|P_VI_DEF, |
| 1487 | (char_u *)NULL, PV_NONE, |
| 1488 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1489 | {"modeline", "ml", P_BOOL|P_VIM, |
| 1490 | (char_u *)&p_ml, PV_ML, |
| 1491 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 1492 | {"modelines", "mls", P_NUM|P_VI_DEF, |
| 1493 | (char_u *)&p_mls, PV_NONE, |
| 1494 | {(char_u *)5L, (char_u *)0L}}, |
| 1495 | {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB, |
| 1496 | (char_u *)&p_ma, PV_MA, |
| 1497 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1498 | {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
| 1499 | (char_u *)&p_mod, PV_MOD, |
| 1500 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1501 | {"more", NULL, P_BOOL|P_VIM, |
| 1502 | (char_u *)&p_more, PV_NONE, |
| 1503 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 1504 | {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST, |
| 1505 | (char_u *)&p_mouse, PV_NONE, |
| 1506 | { |
| 1507 | #if defined(MSDOS) || defined(WIN3264) |
| 1508 | (char_u *)"a", |
| 1509 | #else |
| 1510 | (char_u *)"", |
| 1511 | #endif |
| 1512 | (char_u *)0L}}, |
| 1513 | {"mousefocus", "mousef", P_BOOL|P_VI_DEF, |
| 1514 | #ifdef FEAT_GUI |
| 1515 | (char_u *)&p_mousef, PV_NONE, |
| 1516 | #else |
| 1517 | (char_u *)NULL, PV_NONE, |
| 1518 | #endif |
| 1519 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1520 | {"mousehide", "mh", P_BOOL|P_VI_DEF, |
| 1521 | #ifdef FEAT_GUI |
| 1522 | (char_u *)&p_mh, PV_NONE, |
| 1523 | #else |
| 1524 | (char_u *)NULL, PV_NONE, |
| 1525 | #endif |
| 1526 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1527 | {"mousemodel", "mousem", P_STRING|P_VI_DEF, |
| 1528 | (char_u *)&p_mousem, PV_NONE, |
| 1529 | { |
| 1530 | #if defined(MSDOS) || defined(MSWIN) |
| 1531 | (char_u *)"popup", |
| 1532 | #else |
| 1533 | # if defined(MACOS) |
| 1534 | (char_u *)"popup_setpos", |
| 1535 | # else |
| 1536 | (char_u *)"extend", |
| 1537 | # endif |
| 1538 | #endif |
| 1539 | (char_u *)0L}}, |
| 1540 | {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1541 | #ifdef FEAT_MOUSESHAPE |
| 1542 | (char_u *)&p_mouseshape, PV_NONE, |
| 1543 | {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L} |
| 1544 | #else |
| 1545 | (char_u *)NULL, PV_NONE, |
| 1546 | {(char_u *)NULL, (char_u *)0L} |
| 1547 | #endif |
| 1548 | }, |
| 1549 | {"mousetime", "mouset", P_NUM|P_VI_DEF, |
| 1550 | (char_u *)&p_mouset, PV_NONE, |
| 1551 | {(char_u *)500L, (char_u *)0L}}, |
Bram Moolenaar | 325b7a2 | 2004-07-05 15:58:32 +0000 | [diff] [blame] | 1552 | {"mzquantum", "mzq", P_NUM, |
| 1553 | #ifdef FEAT_MZSCHEME |
| 1554 | (char_u *)&p_mzq, PV_NONE, |
| 1555 | #else |
| 1556 | (char_u *)NULL, PV_NONE, |
| 1557 | #endif |
| 1558 | {(char_u *)100L, (char_u *)100L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1559 | {"novice", NULL, P_BOOL|P_VI_DEF, |
| 1560 | (char_u *)NULL, PV_NONE, |
| 1561 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1562 | {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 1563 | (char_u *)&p_nf, PV_NF, |
| 1564 | {(char_u *)"octal,hex", (char_u *)0L}}, |
| 1565 | {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, |
| 1566 | (char_u *)VAR_WIN, PV_NU, |
| 1567 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 1568 | {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM, |
| 1569 | #ifdef FEAT_LINEBREAK |
| 1570 | (char_u *)VAR_WIN, PV_NUW, |
| 1571 | #else |
| 1572 | (char_u *)NULL, PV_NONE, |
| 1573 | #endif |
| 1574 | {(char_u *)8L, (char_u *)4L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1575 | {"open", NULL, P_BOOL|P_VI_DEF, |
| 1576 | (char_u *)NULL, PV_NONE, |
| 1577 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1578 | {"optimize", "opt", P_BOOL|P_VI_DEF, |
| 1579 | (char_u *)NULL, PV_NONE, |
| 1580 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1581 | {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1582 | #ifdef FEAT_OSFILETYPE |
| 1583 | (char_u *)&p_oft, PV_OFT, |
| 1584 | {(char_u *)DFLT_OFT, (char_u *)0L} |
| 1585 | #else |
| 1586 | (char_u *)NULL, PV_NONE, |
| 1587 | {(char_u *)0L, (char_u *)0L} |
| 1588 | #endif |
| 1589 | }, |
| 1590 | {"paragraphs", "para", P_STRING|P_VI_DEF, |
| 1591 | (char_u *)&p_para, PV_NONE, |
| 1592 | {(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}}, |
| 1593 | {"paste", NULL, P_BOOL|P_VI_DEF, |
| 1594 | (char_u *)&p_paste, PV_NONE, |
| 1595 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1596 | {"pastetoggle", "pt", P_STRING|P_VI_DEF, |
| 1597 | (char_u *)&p_pt, PV_NONE, |
| 1598 | {(char_u *)"", (char_u *)0L}}, |
| 1599 | {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE, |
| 1600 | #if defined(FEAT_DIFF) && defined(FEAT_EVAL) |
| 1601 | (char_u *)&p_pex, PV_NONE, |
| 1602 | {(char_u *)"", (char_u *)0L} |
| 1603 | #else |
| 1604 | (char_u *)NULL, PV_NONE, |
| 1605 | {(char_u *)0L, (char_u *)0L} |
| 1606 | #endif |
| 1607 | }, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1608 | {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1609 | (char_u *)&p_pm, PV_NONE, |
| 1610 | {(char_u *)"", (char_u *)0L}}, |
| 1611 | {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 1612 | (char_u *)&p_path, OPT_BOTH(PV_PATH), |
| 1613 | { |
| 1614 | #if defined AMIGA || defined MSDOS || defined MSWIN |
| 1615 | (char_u *)".,,", |
| 1616 | #else |
| 1617 | # if defined(__EMX__) |
| 1618 | (char_u *)".,/emx/include,,", |
| 1619 | # else /* Unix, probably */ |
| 1620 | (char_u *)".,/usr/include,,", |
| 1621 | # endif |
| 1622 | #endif |
| 1623 | (char_u *)0L}}, |
| 1624 | {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM, |
| 1625 | (char_u *)&p_pi, PV_PI, |
| 1626 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 1627 | {"previewheight", "pvh", P_NUM|P_VI_DEF, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1628 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 1629 | (char_u *)&p_pvh, PV_NONE, |
| 1630 | #else |
| 1631 | (char_u *)NULL, PV_NONE, |
| 1632 | #endif |
| 1633 | {(char_u *)12L, (char_u *)0L}}, |
| 1634 | {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, |
| 1635 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 1636 | (char_u *)VAR_WIN, PV_PVW, |
| 1637 | #else |
| 1638 | (char_u *)NULL, PV_NONE, |
| 1639 | #endif |
| 1640 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1641 | {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1642 | #ifdef FEAT_PRINTER |
| 1643 | (char_u *)&p_pdev, PV_NONE, |
| 1644 | {(char_u *)"", (char_u *)0L} |
| 1645 | #else |
| 1646 | (char_u *)NULL, PV_NONE, |
| 1647 | {(char_u *)NULL, (char_u *)0L} |
| 1648 | #endif |
| 1649 | }, |
| 1650 | {"printencoding", "penc", P_STRING|P_VI_DEF, |
| 1651 | #ifdef FEAT_POSTSCRIPT |
| 1652 | (char_u *)&p_penc, PV_NONE, |
| 1653 | {(char_u *)"", (char_u *)0L} |
| 1654 | #else |
| 1655 | (char_u *)NULL, PV_NONE, |
| 1656 | {(char_u *)NULL, (char_u *)0L} |
| 1657 | #endif |
| 1658 | }, |
| 1659 | {"printexpr", "pexpr", P_STRING|P_VI_DEF, |
| 1660 | #ifdef FEAT_POSTSCRIPT |
| 1661 | (char_u *)&p_pexpr, PV_NONE, |
| 1662 | {(char_u *)"", (char_u *)0L} |
| 1663 | #else |
| 1664 | (char_u *)NULL, PV_NONE, |
| 1665 | {(char_u *)NULL, (char_u *)0L} |
| 1666 | #endif |
| 1667 | }, |
| 1668 | {"printfont", "pfn", P_STRING|P_VI_DEF, |
| 1669 | #ifdef FEAT_PRINTER |
| 1670 | (char_u *)&p_pfn, PV_NONE, |
| 1671 | { |
| 1672 | # ifdef MSWIN |
| 1673 | (char_u *)"Courier_New:h10", |
| 1674 | # else |
| 1675 | (char_u *)"courier", |
| 1676 | # endif |
| 1677 | (char_u *)0L} |
| 1678 | #else |
| 1679 | (char_u *)NULL, PV_NONE, |
| 1680 | {(char_u *)NULL, (char_u *)0L} |
| 1681 | #endif |
| 1682 | }, |
| 1683 | {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT, |
| 1684 | #ifdef FEAT_PRINTER |
| 1685 | (char_u *)&p_header, PV_NONE, |
| 1686 | {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L} |
| 1687 | #else |
| 1688 | (char_u *)NULL, PV_NONE, |
| 1689 | {(char_u *)NULL, (char_u *)0L} |
| 1690 | #endif |
| 1691 | }, |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 1692 | {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF, |
| 1693 | #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) |
| 1694 | (char_u *)&p_pmcs, PV_NONE, |
| 1695 | {(char_u *)"", (char_u *)0L} |
| 1696 | #else |
| 1697 | (char_u *)NULL, PV_NONE, |
| 1698 | {(char_u *)NULL, (char_u *)0L} |
| 1699 | #endif |
| 1700 | }, |
| 1701 | {"printmbfont", "pmbfn", P_STRING|P_VI_DEF, |
| 1702 | #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) |
| 1703 | (char_u *)&p_pmfn, PV_NONE, |
| 1704 | {(char_u *)"", (char_u *)0L} |
| 1705 | #else |
| 1706 | (char_u *)NULL, PV_NONE, |
| 1707 | {(char_u *)NULL, (char_u *)0L} |
| 1708 | #endif |
| 1709 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1710 | {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1711 | #ifdef FEAT_PRINTER |
| 1712 | (char_u *)&p_popt, PV_NONE, |
| 1713 | {(char_u *)"", (char_u *)0L} |
| 1714 | #else |
| 1715 | (char_u *)NULL, PV_NONE, |
| 1716 | {(char_u *)NULL, (char_u *)0L} |
| 1717 | #endif |
| 1718 | }, |
| 1719 | {"prompt", NULL, P_BOOL|P_VI_DEF, |
| 1720 | (char_u *)NULL, PV_NONE, |
| 1721 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 1722 | {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1723 | #ifdef FEAT_TEXTOBJ |
| 1724 | (char_u *)&p_qe, PV_QE, |
| 1725 | {(char_u *)"\\", (char_u *)0L} |
| 1726 | #else |
| 1727 | (char_u *)NULL, PV_NONE, |
| 1728 | {(char_u *)NULL, (char_u *)0L} |
| 1729 | #endif |
| 1730 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1731 | {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, |
| 1732 | (char_u *)&p_ro, PV_RO, |
| 1733 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1734 | {"redraw", NULL, P_BOOL|P_VI_DEF, |
| 1735 | (char_u *)NULL, PV_NONE, |
| 1736 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1737 | {"remap", NULL, P_BOOL|P_VI_DEF, |
| 1738 | (char_u *)&p_remap, PV_NONE, |
| 1739 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1740 | {"report", NULL, P_NUM|P_VI_DEF, |
| 1741 | (char_u *)&p_report, PV_NONE, |
| 1742 | {(char_u *)2L, (char_u *)0L}}, |
| 1743 | {"restorescreen", "rs", P_BOOL|P_VI_DEF, |
| 1744 | #ifdef WIN3264 |
| 1745 | (char_u *)&p_rs, PV_NONE, |
| 1746 | #else |
| 1747 | (char_u *)NULL, PV_NONE, |
| 1748 | #endif |
| 1749 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1750 | {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM, |
| 1751 | #ifdef FEAT_RIGHTLEFT |
| 1752 | (char_u *)&p_ri, PV_NONE, |
| 1753 | #else |
| 1754 | (char_u *)NULL, PV_NONE, |
| 1755 | #endif |
| 1756 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1757 | {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN, |
| 1758 | #ifdef FEAT_RIGHTLEFT |
| 1759 | (char_u *)VAR_WIN, PV_RL, |
| 1760 | #else |
| 1761 | (char_u *)NULL, PV_NONE, |
| 1762 | #endif |
| 1763 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1764 | {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, |
| 1765 | #ifdef FEAT_RIGHTLEFT |
| 1766 | (char_u *)VAR_WIN, PV_RLC, |
| 1767 | {(char_u *)"search", (char_u *)NULL} |
| 1768 | #else |
| 1769 | (char_u *)NULL, PV_NONE, |
| 1770 | {(char_u *)NULL, (char_u *)0L} |
| 1771 | #endif |
| 1772 | }, |
| 1773 | {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT, |
| 1774 | #ifdef FEAT_CMDL_INFO |
| 1775 | (char_u *)&p_ru, PV_NONE, |
| 1776 | #else |
| 1777 | (char_u *)NULL, PV_NONE, |
| 1778 | #endif |
| 1779 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1780 | {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, |
| 1781 | #ifdef FEAT_STL_OPT |
| 1782 | (char_u *)&p_ruf, PV_NONE, |
| 1783 | #else |
| 1784 | (char_u *)NULL, PV_NONE, |
| 1785 | #endif |
| 1786 | {(char_u *)"", (char_u *)0L}}, |
| 1787 | {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE, |
| 1788 | (char_u *)&p_rtp, PV_NONE, |
| 1789 | {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}}, |
| 1790 | {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF, |
| 1791 | (char_u *)VAR_WIN, PV_SCROLL, |
| 1792 | {(char_u *)12L, (char_u *)0L}}, |
| 1793 | {"scrollbind", "scb", P_BOOL|P_VI_DEF, |
| 1794 | #ifdef FEAT_SCROLLBIND |
| 1795 | (char_u *)VAR_WIN, PV_SCBIND, |
| 1796 | #else |
| 1797 | (char_u *)NULL, PV_NONE, |
| 1798 | #endif |
| 1799 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1800 | {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, |
| 1801 | (char_u *)&p_sj, PV_NONE, |
| 1802 | {(char_u *)1L, (char_u *)0L}}, |
| 1803 | {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, |
| 1804 | (char_u *)&p_so, PV_NONE, |
| 1805 | {(char_u *)0L, (char_u *)0L}}, |
| 1806 | {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1807 | #ifdef FEAT_SCROLLBIND |
| 1808 | (char_u *)&p_sbo, PV_NONE, |
| 1809 | {(char_u *)"ver,jump", (char_u *)0L} |
| 1810 | #else |
| 1811 | (char_u *)NULL, PV_NONE, |
| 1812 | {(char_u *)0L, (char_u *)0L} |
| 1813 | #endif |
| 1814 | }, |
| 1815 | {"sections", "sect", P_STRING|P_VI_DEF, |
| 1816 | (char_u *)&p_sections, PV_NONE, |
| 1817 | {(char_u *)"SHNHH HUnhsh", (char_u *)0L}}, |
| 1818 | {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE, |
| 1819 | (char_u *)&p_secure, PV_NONE, |
| 1820 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1821 | {"selection", "sel", P_STRING|P_VI_DEF, |
| 1822 | #ifdef FEAT_VISUAL |
| 1823 | (char_u *)&p_sel, PV_NONE, |
| 1824 | #else |
| 1825 | (char_u *)NULL, PV_NONE, |
| 1826 | #endif |
| 1827 | {(char_u *)"inclusive", (char_u *)0L}}, |
| 1828 | {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1829 | #ifdef FEAT_VISUAL |
| 1830 | (char_u *)&p_slm, PV_NONE, |
| 1831 | #else |
| 1832 | (char_u *)NULL, PV_NONE, |
| 1833 | #endif |
| 1834 | {(char_u *)"", (char_u *)0L}}, |
| 1835 | {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1836 | #ifdef FEAT_SESSION |
| 1837 | (char_u *)&p_ssop, PV_NONE, |
| 1838 | {(char_u *)"blank,buffers,curdir,folds,help,options,winsize", |
| 1839 | (char_u *)0L} |
| 1840 | #else |
| 1841 | (char_u *)NULL, PV_NONE, |
| 1842 | {(char_u *)0L, (char_u *)0L} |
| 1843 | #endif |
| 1844 | }, |
| 1845 | {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1846 | (char_u *)&p_sh, PV_NONE, |
| 1847 | { |
| 1848 | #ifdef VMS |
| 1849 | (char_u *)"-", |
| 1850 | #else |
| 1851 | # if defined(MSDOS) |
| 1852 | (char_u *)"command", |
| 1853 | # else |
| 1854 | # if defined(WIN16) |
| 1855 | (char_u *)"command.com", |
| 1856 | # else |
| 1857 | # if defined(WIN3264) |
| 1858 | (char_u *)"", /* set in set_init_1() */ |
| 1859 | # else |
| 1860 | # if defined(OS2) |
| 1861 | (char_u *)"cmd.exe", |
| 1862 | # else |
| 1863 | # if defined(ARCHIE) |
| 1864 | (char_u *)"gos", |
| 1865 | # else |
| 1866 | (char_u *)"sh", |
| 1867 | # endif |
| 1868 | # endif |
| 1869 | # endif |
| 1870 | # endif |
| 1871 | # endif |
| 1872 | #endif /* VMS */ |
| 1873 | (char_u *)0L}}, |
| 1874 | {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE, |
| 1875 | (char_u *)&p_shcf, PV_NONE, |
| 1876 | { |
| 1877 | #if defined(MSDOS) || defined(MSWIN) |
| 1878 | (char_u *)"/c", |
| 1879 | #else |
| 1880 | # if defined(OS2) |
| 1881 | (char_u *)"/c", |
| 1882 | # else |
| 1883 | (char_u *)"-c", |
| 1884 | # endif |
| 1885 | #endif |
| 1886 | (char_u *)0L}}, |
| 1887 | {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE, |
| 1888 | #ifdef FEAT_QUICKFIX |
| 1889 | (char_u *)&p_sp, PV_NONE, |
| 1890 | { |
| 1891 | #if defined(UNIX) || defined(OS2) |
| 1892 | # ifdef ARCHIE |
| 1893 | (char_u *)"2>", |
| 1894 | # else |
| 1895 | (char_u *)"| tee", |
| 1896 | # endif |
| 1897 | #else |
| 1898 | (char_u *)">", |
| 1899 | #endif |
| 1900 | (char_u *)0L} |
| 1901 | #else |
| 1902 | (char_u *)NULL, PV_NONE, |
| 1903 | {(char_u *)0L, (char_u *)0L} |
| 1904 | #endif |
| 1905 | }, |
| 1906 | {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE, |
| 1907 | (char_u *)&p_shq, PV_NONE, |
| 1908 | {(char_u *)"", (char_u *)0L}}, |
| 1909 | {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE, |
| 1910 | (char_u *)&p_srr, PV_NONE, |
| 1911 | {(char_u *)">", (char_u *)0L}}, |
| 1912 | {"shellslash", "ssl", P_BOOL|P_VI_DEF, |
| 1913 | #ifdef BACKSLASH_IN_FILENAME |
| 1914 | (char_u *)&p_ssl, PV_NONE, |
| 1915 | #else |
| 1916 | (char_u *)NULL, PV_NONE, |
| 1917 | #endif |
| 1918 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1919 | {"shelltype", "st", P_NUM|P_VI_DEF, |
| 1920 | #ifdef AMIGA |
| 1921 | (char_u *)&p_st, PV_NONE, |
| 1922 | #else |
| 1923 | (char_u *)NULL, PV_NONE, |
| 1924 | #endif |
| 1925 | {(char_u *)0L, (char_u *)0L}}, |
| 1926 | {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE, |
| 1927 | (char_u *)&p_sxq, PV_NONE, |
| 1928 | { |
| 1929 | #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__) |
| 1930 | (char_u *)"\"", |
| 1931 | #else |
| 1932 | (char_u *)"", |
| 1933 | #endif |
| 1934 | (char_u *)0L}}, |
| 1935 | {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM, |
| 1936 | (char_u *)&p_sr, PV_NONE, |
| 1937 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1938 | {"shiftwidth", "sw", P_NUM|P_VI_DEF, |
| 1939 | (char_u *)&p_sw, PV_SW, |
| 1940 | {(char_u *)8L, (char_u *)0L}}, |
| 1941 | {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST, |
| 1942 | (char_u *)&p_shm, PV_NONE, |
| 1943 | {(char_u *)"", (char_u *)"filnxtToO"}}, |
| 1944 | {"shortname", "sn", P_BOOL|P_VI_DEF, |
| 1945 | #ifdef SHORT_FNAME |
| 1946 | (char_u *)NULL, PV_NONE, |
| 1947 | #else |
| 1948 | (char_u *)&p_sn, PV_SN, |
| 1949 | #endif |
| 1950 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1951 | {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL, |
| 1952 | #ifdef FEAT_LINEBREAK |
| 1953 | (char_u *)&p_sbr, PV_NONE, |
| 1954 | #else |
| 1955 | (char_u *)NULL, PV_NONE, |
| 1956 | #endif |
| 1957 | {(char_u *)"", (char_u *)0L}}, |
| 1958 | {"showcmd", "sc", P_BOOL|P_VIM, |
| 1959 | #ifdef FEAT_CMDL_INFO |
| 1960 | (char_u *)&p_sc, PV_NONE, |
| 1961 | #else |
| 1962 | (char_u *)NULL, PV_NONE, |
| 1963 | #endif |
| 1964 | {(char_u *)FALSE, |
| 1965 | #ifdef UNIX |
| 1966 | (char_u *)FALSE |
| 1967 | #else |
| 1968 | (char_u *)TRUE |
| 1969 | #endif |
| 1970 | }}, |
| 1971 | {"showfulltag", "sft", P_BOOL|P_VI_DEF, |
| 1972 | (char_u *)&p_sft, PV_NONE, |
| 1973 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1974 | {"showmatch", "sm", P_BOOL|P_VI_DEF, |
| 1975 | (char_u *)&p_sm, PV_NONE, |
| 1976 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1977 | {"showmode", "smd", P_BOOL|P_VIM, |
| 1978 | (char_u *)&p_smd, PV_NONE, |
| 1979 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 1980 | {"sidescroll", "ss", P_NUM|P_VI_DEF, |
| 1981 | (char_u *)&p_ss, PV_NONE, |
| 1982 | {(char_u *)0L, (char_u *)0L}}, |
| 1983 | {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, |
| 1984 | (char_u *)&p_siso, PV_NONE, |
| 1985 | {(char_u *)0L, (char_u *)0L}}, |
| 1986 | {"slowopen", "slow", P_BOOL|P_VI_DEF, |
| 1987 | (char_u *)NULL, PV_NONE, |
| 1988 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1989 | {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM, |
| 1990 | (char_u *)&p_scs, PV_NONE, |
| 1991 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1992 | {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM, |
| 1993 | #ifdef FEAT_SMARTINDENT |
| 1994 | (char_u *)&p_si, PV_SI, |
| 1995 | #else |
| 1996 | (char_u *)NULL, PV_NONE, |
| 1997 | #endif |
| 1998 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1999 | {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM, |
| 2000 | (char_u *)&p_sta, PV_NONE, |
| 2001 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2002 | {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM, |
| 2003 | (char_u *)&p_sts, PV_STS, |
| 2004 | {(char_u *)0L, (char_u *)0L}}, |
| 2005 | {"sourceany", NULL, P_BOOL|P_VI_DEF, |
| 2006 | (char_u *)NULL, PV_NONE, |
| 2007 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2008 | {"splitbelow", "sb", P_BOOL|P_VI_DEF, |
| 2009 | #ifdef FEAT_WINDOWS |
| 2010 | (char_u *)&p_sb, PV_NONE, |
| 2011 | #else |
| 2012 | (char_u *)NULL, PV_NONE, |
| 2013 | #endif |
| 2014 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2015 | {"splitright", "spr", P_BOOL|P_VI_DEF, |
| 2016 | #ifdef FEAT_VERTSPLIT |
| 2017 | (char_u *)&p_spr, PV_NONE, |
| 2018 | #else |
| 2019 | (char_u *)NULL, PV_NONE, |
| 2020 | #endif |
| 2021 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2022 | {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM, |
| 2023 | (char_u *)&p_sol, PV_NONE, |
| 2024 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2025 | {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, |
| 2026 | #ifdef FEAT_STL_OPT |
| 2027 | (char_u *)&p_stl, PV_NONE, |
| 2028 | #else |
| 2029 | (char_u *)NULL, PV_NONE, |
| 2030 | #endif |
| 2031 | {(char_u *)"", (char_u *)0L}}, |
| 2032 | {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2033 | (char_u *)&p_su, PV_NONE, |
| 2034 | {(char_u *)".bak,~,.o,.h,.info,.swp,.obj", |
| 2035 | (char_u *)0L}}, |
| 2036 | {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP, |
| 2037 | #if defined(FEAT_SEARCHPATH) |
| 2038 | (char_u *)&p_sua, PV_SUA, |
| 2039 | {(char_u *)"", (char_u *)0L} |
| 2040 | #else |
| 2041 | (char_u *)NULL, PV_NONE, |
| 2042 | {(char_u *)0L, (char_u *)0L} |
| 2043 | #endif |
| 2044 | }, |
| 2045 | {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT, |
| 2046 | (char_u *)&p_swf, PV_SWF, |
| 2047 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2048 | {"swapsync", "sws", P_STRING|P_VI_DEF, |
| 2049 | (char_u *)&p_sws, PV_NONE, |
| 2050 | {(char_u *)"fsync", (char_u *)0L}}, |
| 2051 | {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2052 | (char_u *)&p_swb, PV_NONE, |
| 2053 | {(char_u *)"", (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2054 | {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2055 | #ifdef FEAT_SYN_HL |
| 2056 | (char_u *)&p_syn, PV_SYN, |
| 2057 | {(char_u *)"", (char_u *)0L} |
| 2058 | #else |
| 2059 | (char_u *)NULL, PV_NONE, |
| 2060 | {(char_u *)0L, (char_u *)0L} |
| 2061 | #endif |
| 2062 | }, |
| 2063 | {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF, |
| 2064 | (char_u *)&p_ts, PV_TS, |
| 2065 | {(char_u *)8L, (char_u *)0L}}, |
| 2066 | {"tagbsearch", "tbs", P_BOOL|P_VI_DEF, |
| 2067 | (char_u *)&p_tbs, PV_NONE, |
| 2068 | #ifdef VMS /* binary searching doesn't appear to work on VMS */ |
| 2069 | {(char_u *)0L, (char_u *)0L} |
| 2070 | #else |
| 2071 | {(char_u *)TRUE, (char_u *)0L} |
| 2072 | #endif |
| 2073 | }, |
| 2074 | {"taglength", "tl", P_NUM|P_VI_DEF, |
| 2075 | (char_u *)&p_tl, PV_NONE, |
| 2076 | {(char_u *)0L, (char_u *)0L}}, |
| 2077 | {"tagrelative", "tr", P_BOOL|P_VIM, |
| 2078 | (char_u *)&p_tr, PV_NONE, |
| 2079 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 2080 | {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 2081 | (char_u *)&p_tags, OPT_BOTH(PV_TAGS), |
| 2082 | { |
| 2083 | #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME) |
| 2084 | (char_u *)"./tags,./TAGS,tags,TAGS", |
| 2085 | #else |
| 2086 | (char_u *)"./tags,tags", |
| 2087 | #endif |
| 2088 | (char_u *)0L}}, |
| 2089 | {"tagstack", "tgst", P_BOOL|P_VI_DEF, |
| 2090 | (char_u *)&p_tgst, PV_NONE, |
| 2091 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2092 | {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, |
| 2093 | (char_u *)&T_NAME, PV_NONE, |
| 2094 | {(char_u *)"", (char_u *)0L}}, |
| 2095 | {"termbidi", "tbidi", P_BOOL|P_VI_DEF, |
| 2096 | #ifdef FEAT_ARABIC |
| 2097 | (char_u *)&p_tbidi, PV_NONE, |
| 2098 | #else |
| 2099 | (char_u *)NULL, PV_NONE, |
| 2100 | #endif |
| 2101 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2102 | {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR, |
| 2103 | #ifdef FEAT_MBYTE |
| 2104 | (char_u *)&p_tenc, PV_NONE, |
| 2105 | {(char_u *)"", (char_u *)0L} |
| 2106 | #else |
| 2107 | (char_u *)NULL, PV_NONE, |
| 2108 | {(char_u *)0L, (char_u *)0L} |
| 2109 | #endif |
| 2110 | }, |
| 2111 | {"terse", NULL, P_BOOL|P_VI_DEF, |
| 2112 | (char_u *)&p_terse, PV_NONE, |
| 2113 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2114 | {"textauto", "ta", P_BOOL|P_VIM, |
| 2115 | (char_u *)&p_ta, PV_NONE, |
| 2116 | {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}}, |
| 2117 | {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC, |
| 2118 | (char_u *)&p_tx, PV_TX, |
| 2119 | { |
| 2120 | #ifdef USE_CRNL |
| 2121 | (char_u *)TRUE, |
| 2122 | #else |
| 2123 | (char_u *)FALSE, |
| 2124 | #endif |
| 2125 | (char_u *)0L}}, |
| 2126 | {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM, |
| 2127 | (char_u *)&p_tw, PV_TW, |
| 2128 | {(char_u *)0L, (char_u *)0L}}, |
| 2129 | {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 2130 | #ifdef FEAT_INS_EXPAND |
| 2131 | (char_u *)&p_tsr, OPT_BOTH(PV_TSR), |
| 2132 | #else |
| 2133 | (char_u *)NULL, PV_NONE, |
| 2134 | #endif |
| 2135 | {(char_u *)"", (char_u *)0L}}, |
| 2136 | {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM, |
| 2137 | (char_u *)&p_to, PV_NONE, |
| 2138 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2139 | {"timeout", "to", P_BOOL|P_VI_DEF, |
| 2140 | (char_u *)&p_timeout, PV_NONE, |
| 2141 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2142 | {"timeoutlen", "tm", P_NUM|P_VI_DEF, |
| 2143 | (char_u *)&p_tm, PV_NONE, |
| 2144 | {(char_u *)1000L, (char_u *)0L}}, |
| 2145 | {"title", NULL, P_BOOL|P_VI_DEF, |
| 2146 | #ifdef FEAT_TITLE |
| 2147 | (char_u *)&p_title, PV_NONE, |
| 2148 | #else |
| 2149 | (char_u *)NULL, PV_NONE, |
| 2150 | #endif |
| 2151 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2152 | {"titlelen", NULL, P_NUM|P_VI_DEF, |
| 2153 | #ifdef FEAT_TITLE |
| 2154 | (char_u *)&p_titlelen, PV_NONE, |
| 2155 | #else |
| 2156 | (char_u *)NULL, PV_NONE, |
| 2157 | #endif |
| 2158 | {(char_u *)85L, (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2159 | {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2160 | #ifdef FEAT_TITLE |
| 2161 | (char_u *)&p_titleold, PV_NONE, |
| 2162 | {(char_u *)N_("Thanks for flying Vim"), |
| 2163 | (char_u *)0L} |
| 2164 | #else |
| 2165 | (char_u *)NULL, PV_NONE, |
| 2166 | {(char_u *)0L, (char_u *)0L} |
| 2167 | #endif |
| 2168 | }, |
| 2169 | {"titlestring", NULL, P_STRING|P_VI_DEF, |
| 2170 | #ifdef FEAT_TITLE |
| 2171 | (char_u *)&p_titlestring, PV_NONE, |
| 2172 | #else |
| 2173 | (char_u *)NULL, PV_NONE, |
| 2174 | #endif |
| 2175 | {(char_u *)"", (char_u *)0L}}, |
| 2176 | #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
| 2177 | {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP, |
| 2178 | (char_u *)&p_toolbar, PV_NONE, |
| 2179 | {(char_u *)"icons,tooltips", (char_u *)0L}}, |
| 2180 | #endif |
| 2181 | #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 2182 | {"toolbariconsize", "tbis", P_STRING|P_VI_DEF, |
| 2183 | (char_u *)&p_tbis, PV_NONE, |
| 2184 | {(char_u *)"small", (char_u *)0L}}, |
| 2185 | #endif |
| 2186 | {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM, |
| 2187 | (char_u *)&p_ttimeout, PV_NONE, |
| 2188 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2189 | {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF, |
| 2190 | (char_u *)&p_ttm, PV_NONE, |
| 2191 | {(char_u *)-1L, (char_u *)0L}}, |
| 2192 | {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF, |
| 2193 | (char_u *)&p_tbi, PV_NONE, |
| 2194 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2195 | {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF, |
| 2196 | (char_u *)&p_tf, PV_NONE, |
| 2197 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2198 | {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, |
| 2199 | #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) |
| 2200 | (char_u *)&p_ttym, PV_NONE, |
| 2201 | #else |
| 2202 | (char_u *)NULL, PV_NONE, |
| 2203 | #endif |
| 2204 | {(char_u *)"", (char_u *)0L}}, |
| 2205 | {"ttyscroll", "tsl", P_NUM|P_VI_DEF, |
| 2206 | (char_u *)&p_ttyscroll, PV_NONE, |
| 2207 | {(char_u *)999L, (char_u *)0L}}, |
| 2208 | {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, |
| 2209 | (char_u *)&T_NAME, PV_NONE, |
| 2210 | {(char_u *)"", (char_u *)0L}}, |
| 2211 | {"undolevels", "ul", P_NUM|P_VI_DEF, |
| 2212 | (char_u *)&p_ul, PV_NONE, |
| 2213 | { |
| 2214 | #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS) |
| 2215 | (char_u *)1000L, |
| 2216 | #else |
| 2217 | (char_u *)100L, |
| 2218 | #endif |
| 2219 | (char_u *)0L}}, |
| 2220 | {"updatecount", "uc", P_NUM|P_VI_DEF, |
| 2221 | (char_u *)&p_uc, PV_NONE, |
| 2222 | {(char_u *)200L, (char_u *)0L}}, |
| 2223 | {"updatetime", "ut", P_NUM|P_VI_DEF, |
| 2224 | (char_u *)&p_ut, PV_NONE, |
| 2225 | {(char_u *)4000L, (char_u *)0L}}, |
| 2226 | {"verbose", "vbs", P_NUM|P_VI_DEF, |
| 2227 | (char_u *)&p_verbose, PV_NONE, |
| 2228 | {(char_u *)0L, (char_u *)0L}}, |
| 2229 | {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 2230 | #ifdef FEAT_SESSION |
| 2231 | (char_u *)&p_vdir, PV_NONE, |
| 2232 | {(char_u *)DFLT_VDIR, (char_u *)0L} |
| 2233 | #else |
| 2234 | (char_u *)NULL, PV_NONE, |
| 2235 | {(char_u *)0L, (char_u *)0L} |
| 2236 | #endif |
| 2237 | }, |
| 2238 | {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2239 | #ifdef FEAT_SESSION |
| 2240 | (char_u *)&p_vop, PV_NONE, |
| 2241 | {(char_u *)"folds,options,cursor", (char_u *)0L} |
| 2242 | #else |
| 2243 | (char_u *)NULL, PV_NONE, |
| 2244 | {(char_u *)0L, (char_u *)0L} |
| 2245 | #endif |
| 2246 | }, |
| 2247 | {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE, |
| 2248 | #ifdef FEAT_VIMINFO |
| 2249 | (char_u *)&p_viminfo, PV_NONE, |
| 2250 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 2251 | {(char_u *)"", (char_u *)"'20,<50,s10,h,rA:,rB:"} |
| 2252 | #else |
| 2253 | # ifdef AMIGA |
| 2254 | {(char_u *)"", |
| 2255 | (char_u *)"'20,<50,s10,h,rdf0:,rdf1:,rdf2:"} |
| 2256 | # else |
| 2257 | {(char_u *)"", (char_u *)"'20,<50,s10,h"} |
| 2258 | # endif |
| 2259 | #endif |
| 2260 | #else |
| 2261 | (char_u *)NULL, PV_NONE, |
| 2262 | {(char_u *)0L, (char_u *)0L} |
| 2263 | #endif |
| 2264 | }, |
| 2265 | {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM, |
| 2266 | #ifdef FEAT_VIRTUALEDIT |
| 2267 | (char_u *)&p_ve, PV_NONE, |
| 2268 | {(char_u *)"", (char_u *)""} |
| 2269 | #else |
| 2270 | (char_u *)NULL, PV_NONE, |
| 2271 | {(char_u *)0L, (char_u *)0L} |
| 2272 | #endif |
| 2273 | }, |
| 2274 | {"visualbell", "vb", P_BOOL|P_VI_DEF, |
| 2275 | (char_u *)&p_vb, PV_NONE, |
| 2276 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2277 | {"w300", NULL, P_NUM|P_VI_DEF, |
| 2278 | (char_u *)NULL, PV_NONE, |
| 2279 | {(char_u *)0L, (char_u *)0L}}, |
| 2280 | {"w1200", NULL, P_NUM|P_VI_DEF, |
| 2281 | (char_u *)NULL, PV_NONE, |
| 2282 | {(char_u *)0L, (char_u *)0L}}, |
| 2283 | {"w9600", NULL, P_NUM|P_VI_DEF, |
| 2284 | (char_u *)NULL, PV_NONE, |
| 2285 | {(char_u *)0L, (char_u *)0L}}, |
| 2286 | {"warn", NULL, P_BOOL|P_VI_DEF, |
| 2287 | (char_u *)&p_warn, PV_NONE, |
| 2288 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2289 | {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR, |
| 2290 | (char_u *)&p_wiv, PV_NONE, |
| 2291 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2292 | {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST, |
| 2293 | (char_u *)&p_ww, PV_NONE, |
| 2294 | {(char_u *)"", (char_u *)"b,s"}}, |
| 2295 | {"wildchar", "wc", P_NUM|P_VIM, |
| 2296 | (char_u *)&p_wc, PV_NONE, |
| 2297 | {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}}, |
| 2298 | {"wildcharm", "wcm", P_NUM|P_VI_DEF, |
| 2299 | (char_u *)&p_wcm, PV_NONE, |
| 2300 | {(char_u *)0L, (char_u *)0L}}, |
| 2301 | {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2302 | #ifdef FEAT_WILDIGN |
| 2303 | (char_u *)&p_wig, PV_NONE, |
| 2304 | #else |
| 2305 | (char_u *)NULL, PV_NONE, |
| 2306 | #endif |
| 2307 | {(char_u *)"", (char_u *)0L}}, |
| 2308 | {"wildmenu", "wmnu", P_BOOL|P_VI_DEF, |
| 2309 | #ifdef FEAT_WILDMENU |
| 2310 | (char_u *)&p_wmnu, PV_NONE, |
| 2311 | #else |
| 2312 | (char_u *)NULL, PV_NONE, |
| 2313 | #endif |
| 2314 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2315 | {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2316 | (char_u *)&p_wim, PV_NONE, |
| 2317 | {(char_u *)"full", (char_u *)0L}}, |
| 2318 | {"winaltkeys", "wak", P_STRING|P_VI_DEF, |
| 2319 | #ifdef FEAT_WAK |
| 2320 | (char_u *)&p_wak, PV_NONE, |
| 2321 | {(char_u *)"menu", (char_u *)0L} |
| 2322 | #else |
| 2323 | (char_u *)NULL, PV_NONE, |
| 2324 | {(char_u *)NULL, (char_u *)0L} |
| 2325 | #endif |
| 2326 | }, |
| 2327 | {"window", "wi", P_NUM|P_VI_DEF, |
| 2328 | (char_u *)NULL, PV_NONE, |
| 2329 | {(char_u *)0L, (char_u *)0L}}, |
| 2330 | {"winheight", "wh", P_NUM|P_VI_DEF, |
| 2331 | #ifdef FEAT_WINDOWS |
| 2332 | (char_u *)&p_wh, PV_NONE, |
| 2333 | #else |
| 2334 | (char_u *)NULL, PV_NONE, |
| 2335 | #endif |
| 2336 | {(char_u *)1L, (char_u *)0L}}, |
| 2337 | {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, |
| 2338 | #if defined(FEAT_WINDOWS) |
| 2339 | (char_u *)VAR_WIN, PV_WFH, |
| 2340 | #else |
| 2341 | (char_u *)NULL, PV_NONE, |
| 2342 | #endif |
| 2343 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2344 | {"winminheight", "wmh", P_NUM|P_VI_DEF, |
| 2345 | #ifdef FEAT_WINDOWS |
| 2346 | (char_u *)&p_wmh, PV_NONE, |
| 2347 | #else |
| 2348 | (char_u *)NULL, PV_NONE, |
| 2349 | #endif |
| 2350 | {(char_u *)1L, (char_u *)0L}}, |
| 2351 | {"winminwidth", "wmw", P_NUM|P_VI_DEF, |
| 2352 | #ifdef FEAT_VERTSPLIT |
| 2353 | (char_u *)&p_wmw, PV_NONE, |
| 2354 | #else |
| 2355 | (char_u *)NULL, PV_NONE, |
| 2356 | #endif |
| 2357 | {(char_u *)1L, (char_u *)0L}}, |
| 2358 | {"winwidth", "wiw", P_NUM|P_VI_DEF, |
| 2359 | #ifdef FEAT_VERTSPLIT |
| 2360 | (char_u *)&p_wiw, PV_NONE, |
| 2361 | #else |
| 2362 | (char_u *)NULL, PV_NONE, |
| 2363 | #endif |
| 2364 | {(char_u *)20L, (char_u *)0L}}, |
| 2365 | {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
| 2366 | (char_u *)VAR_WIN, PV_WRAP, |
| 2367 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2368 | {"wrapmargin", "wm", P_NUM|P_VI_DEF, |
| 2369 | (char_u *)&p_wm, PV_WM, |
| 2370 | {(char_u *)0L, (char_u *)0L}}, |
| 2371 | {"wrapscan", "ws", P_BOOL|P_VI_DEF, |
| 2372 | (char_u *)&p_ws, PV_NONE, |
| 2373 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2374 | {"write", NULL, P_BOOL|P_VI_DEF, |
| 2375 | (char_u *)&p_write, PV_NONE, |
| 2376 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2377 | {"writeany", "wa", P_BOOL|P_VI_DEF, |
| 2378 | (char_u *)&p_wa, PV_NONE, |
| 2379 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2380 | {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM, |
| 2381 | (char_u *)&p_wb, PV_NONE, |
| 2382 | { |
| 2383 | #ifdef FEAT_WRITEBACKUP |
| 2384 | (char_u *)TRUE, |
| 2385 | #else |
| 2386 | (char_u *)FALSE, |
| 2387 | #endif |
| 2388 | (char_u *)0L}}, |
| 2389 | {"writedelay", "wd", P_NUM|P_VI_DEF, |
| 2390 | (char_u *)&p_wd, PV_NONE, |
| 2391 | {(char_u *)0L, (char_u *)0L}}, |
| 2392 | |
| 2393 | /* terminal output codes */ |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2394 | #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2395 | (char_u *)&vvv, PV_NONE, \ |
| 2396 | {(char_u *)"", (char_u *)0L}}, |
| 2397 | |
| 2398 | p_term("t_AB", T_CAB) |
| 2399 | p_term("t_AF", T_CAF) |
| 2400 | p_term("t_AL", T_CAL) |
| 2401 | p_term("t_al", T_AL) |
| 2402 | p_term("t_bc", T_BC) |
| 2403 | p_term("t_cd", T_CD) |
| 2404 | p_term("t_ce", T_CE) |
| 2405 | p_term("t_cl", T_CL) |
| 2406 | p_term("t_cm", T_CM) |
| 2407 | p_term("t_Co", T_CCO) |
| 2408 | p_term("t_CS", T_CCS) |
| 2409 | p_term("t_cs", T_CS) |
| 2410 | #ifdef FEAT_VERTSPLIT |
| 2411 | p_term("t_CV", T_CSV) |
| 2412 | #endif |
| 2413 | p_term("t_ut", T_UT) |
| 2414 | p_term("t_da", T_DA) |
| 2415 | p_term("t_db", T_DB) |
| 2416 | p_term("t_DL", T_CDL) |
| 2417 | p_term("t_dl", T_DL) |
| 2418 | p_term("t_fs", T_FS) |
| 2419 | p_term("t_IE", T_CIE) |
| 2420 | p_term("t_IS", T_CIS) |
| 2421 | p_term("t_ke", T_KE) |
| 2422 | p_term("t_ks", T_KS) |
| 2423 | p_term("t_le", T_LE) |
| 2424 | p_term("t_mb", T_MB) |
| 2425 | p_term("t_md", T_MD) |
| 2426 | p_term("t_me", T_ME) |
| 2427 | p_term("t_mr", T_MR) |
| 2428 | p_term("t_ms", T_MS) |
| 2429 | p_term("t_nd", T_ND) |
| 2430 | p_term("t_op", T_OP) |
| 2431 | p_term("t_RI", T_CRI) |
| 2432 | p_term("t_RV", T_CRV) |
| 2433 | p_term("t_Sb", T_CSB) |
| 2434 | p_term("t_Sf", T_CSF) |
| 2435 | p_term("t_se", T_SE) |
| 2436 | p_term("t_so", T_SO) |
| 2437 | p_term("t_sr", T_SR) |
| 2438 | p_term("t_ts", T_TS) |
| 2439 | p_term("t_te", T_TE) |
| 2440 | p_term("t_ti", T_TI) |
| 2441 | p_term("t_ue", T_UE) |
| 2442 | p_term("t_us", T_US) |
| 2443 | p_term("t_vb", T_VB) |
| 2444 | p_term("t_ve", T_VE) |
| 2445 | p_term("t_vi", T_VI) |
| 2446 | p_term("t_vs", T_VS) |
| 2447 | p_term("t_WP", T_CWP) |
| 2448 | p_term("t_WS", T_CWS) |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2449 | p_term("t_SI", T_CSI) |
| 2450 | p_term("t_EI", T_CEI) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2451 | p_term("t_xs", T_XS) |
| 2452 | p_term("t_ZH", T_CZH) |
| 2453 | p_term("t_ZR", T_CZR) |
| 2454 | |
| 2455 | /* terminal key codes are not in here */ |
| 2456 | |
| 2457 | {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL}} /* end marker */ |
| 2458 | }; |
| 2459 | |
| 2460 | #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption)) |
| 2461 | |
| 2462 | #ifdef FEAT_MBYTE |
| 2463 | static char *(p_ambw_values[]) = {"single", "double", NULL}; |
| 2464 | #endif |
| 2465 | static char *(p_bg_values[]) = {"light", "dark", NULL}; |
| 2466 | static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL}; |
| 2467 | static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL}; |
| 2468 | #ifdef FEAT_WAK |
| 2469 | static char *(p_wak_values[]) = {"yes", "menu", "no", NULL}; |
| 2470 | #endif |
| 2471 | static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL}; |
| 2472 | #ifdef FEAT_VISUAL |
| 2473 | static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL}; |
| 2474 | static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL}; |
| 2475 | #endif |
| 2476 | #ifdef FEAT_VISUAL |
| 2477 | static char *(p_km_values[]) = {"startsel", "stopsel", NULL}; |
| 2478 | #endif |
| 2479 | #ifdef FEAT_BROWSE |
| 2480 | static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL}; |
| 2481 | #endif |
| 2482 | #ifdef FEAT_SCROLLBIND |
| 2483 | static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; |
| 2484 | #endif |
| 2485 | static char *(p_swb_values[]) = {"useopen", "split", NULL}; |
| 2486 | static char *(p_debug_values[]) = {"msg", NULL}; |
| 2487 | #ifdef FEAT_VERTSPLIT |
| 2488 | static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; |
| 2489 | #endif |
| 2490 | #if defined(FEAT_QUICKFIX) |
Bram Moolenaar | 21cf823 | 2004-07-16 20:18:37 +0000 | [diff] [blame] | 2491 | # ifdef FEAT_AUTOCMD |
| 2492 | static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL}; |
| 2493 | # else |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2494 | static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL}; |
Bram Moolenaar | 21cf823 | 2004-07-16 20:18:37 +0000 | [diff] [blame] | 2495 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2496 | static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; |
| 2497 | #endif |
| 2498 | static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; |
| 2499 | #ifdef FEAT_FOLDING |
| 2500 | static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", |
| 2501 | #ifdef FEAT_DIFF |
| 2502 | "diff", |
| 2503 | #endif |
| 2504 | NULL}; |
| 2505 | static char *(p_fcl_values[]) = {"all", NULL}; |
| 2506 | #endif |
| 2507 | |
| 2508 | static void set_option_default __ARGS((int, int opt_flags, int compatible)); |
| 2509 | static void set_options_default __ARGS((int opt_flags)); |
| 2510 | static char_u *illegal_char __ARGS((char_u *, int)); |
| 2511 | static int string_to_key __ARGS((char_u *arg)); |
| 2512 | #ifdef FEAT_CMDWIN |
| 2513 | static char_u *check_cedit __ARGS((void)); |
| 2514 | #endif |
| 2515 | #ifdef FEAT_TITLE |
| 2516 | static void did_set_title __ARGS((int icon)); |
| 2517 | #endif |
| 2518 | static char_u *option_expand __ARGS((int opt_idx, char_u *val)); |
| 2519 | static void didset_options __ARGS((void)); |
| 2520 | static void check_string_option __ARGS((char_u **pp)); |
| 2521 | static void set_string_option_global __ARGS((int opt_idx, char_u **varp)); |
| 2522 | static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags)); |
| 2523 | 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)); |
| 2524 | static char_u *set_chars_option __ARGS((char_u **varp)); |
| 2525 | #ifdef FEAT_CLIPBOARD |
| 2526 | static char_u *check_clipboard_option __ARGS((void)); |
| 2527 | #endif |
| 2528 | static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags)); |
| 2529 | static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, int opt_flags)); |
| 2530 | static void check_redraw __ARGS((long_u flags)); |
| 2531 | static int findoption __ARGS((char_u *)); |
| 2532 | static int find_key_option __ARGS((char_u *)); |
| 2533 | static void showoptions __ARGS((int all, int opt_flags)); |
| 2534 | static int optval_default __ARGS((struct vimoption *, char_u *varp)); |
| 2535 | static void showoneopt __ARGS((struct vimoption *, int opt_flags)); |
| 2536 | static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand)); |
| 2537 | static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep)); |
| 2538 | static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value)); |
| 2539 | static int istermoption __ARGS((struct vimoption *)); |
| 2540 | static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags)); |
| 2541 | static char_u *get_varp __ARGS((struct vimoption *)); |
| 2542 | static void option_value2string __ARGS((struct vimoption *, int opt_flags)); |
| 2543 | static int wc_use_keyname __ARGS((char_u *varp, long *wcp)); |
| 2544 | #ifdef FEAT_LANGMAP |
| 2545 | static void langmap_init __ARGS((void)); |
| 2546 | static void langmap_set __ARGS((void)); |
| 2547 | #endif |
| 2548 | static void paste_option_changed __ARGS((void)); |
| 2549 | static void compatible_set __ARGS((void)); |
| 2550 | #ifdef FEAT_LINEBREAK |
| 2551 | static void fill_breakat_flags __ARGS((void)); |
| 2552 | #endif |
| 2553 | static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list)); |
| 2554 | static int check_opt_strings __ARGS((char_u *val, char **values, int)); |
| 2555 | static int check_opt_wim __ARGS((void)); |
| 2556 | |
| 2557 | /* |
| 2558 | * Initialize the options, first part. |
| 2559 | * |
| 2560 | * Called only once from main(), just after creating the first buffer. |
| 2561 | */ |
| 2562 | void |
| 2563 | set_init_1() |
| 2564 | { |
| 2565 | char_u *p; |
| 2566 | int opt_idx; |
| 2567 | long n; |
| 2568 | |
| 2569 | #ifdef FEAT_LANGMAP |
| 2570 | langmap_init(); |
| 2571 | #endif |
| 2572 | |
| 2573 | /* Be Vi compatible by default */ |
| 2574 | p_cp = TRUE; |
| 2575 | |
| 2576 | /* |
| 2577 | * Find default value for 'shell' option. |
| 2578 | */ |
| 2579 | if ((p = mch_getenv((char_u *)"SHELL")) != NULL |
| 2580 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 2581 | # ifdef __EMX__ |
| 2582 | || (p = mch_getenv((char_u *)"EMXSHELL")) != NULL |
| 2583 | # endif |
| 2584 | || (p = mch_getenv((char_u *)"COMSPEC")) != NULL |
| 2585 | # ifdef WIN3264 |
| 2586 | || (p = default_shell()) != NULL |
| 2587 | # endif |
| 2588 | #endif |
| 2589 | ) |
| 2590 | set_string_default("sh", p); |
| 2591 | |
| 2592 | #ifdef FEAT_WILDIGN |
| 2593 | /* |
| 2594 | * Set the default for 'backupskip' to include environment variables for |
| 2595 | * temp files. |
| 2596 | */ |
| 2597 | { |
| 2598 | # ifdef UNIX |
| 2599 | static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; |
| 2600 | # else |
| 2601 | static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; |
| 2602 | # endif |
| 2603 | int len; |
| 2604 | garray_T ga; |
| 2605 | |
| 2606 | ga_init2(&ga, 1, 100); |
| 2607 | for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) |
| 2608 | { |
| 2609 | # ifdef UNIX |
| 2610 | if (*names[n] == NUL) |
| 2611 | p = (char_u *)"/tmp"; |
| 2612 | else |
| 2613 | # endif |
| 2614 | p = mch_getenv((char_u *)names[n]); |
| 2615 | if (p != NULL && *p != NUL) |
| 2616 | { |
| 2617 | /* First time count the NUL, otherwise count the ','. */ |
| 2618 | len = STRLEN(p) + 3; |
| 2619 | if (ga_grow(&ga, len) == OK) |
| 2620 | { |
| 2621 | if (ga.ga_len > 0) |
| 2622 | STRCAT(ga.ga_data, ","); |
| 2623 | STRCAT(ga.ga_data, p); |
| 2624 | add_pathsep(ga.ga_data); |
| 2625 | STRCAT(ga.ga_data, "*"); |
| 2626 | ga.ga_room -= len; |
| 2627 | ga.ga_len += len; |
| 2628 | } |
| 2629 | } |
| 2630 | } |
| 2631 | if (ga.ga_data != NULL) |
| 2632 | { |
| 2633 | set_string_default("bsk", ga.ga_data); |
| 2634 | vim_free(ga.ga_data); |
| 2635 | } |
| 2636 | } |
| 2637 | #endif |
| 2638 | |
| 2639 | /* |
| 2640 | * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory |
| 2641 | */ |
| 2642 | opt_idx = findoption((char_u *)"maxmemtot"); |
| 2643 | #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
| 2644 | if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
| 2645 | #endif |
| 2646 | { |
| 2647 | #ifdef HAVE_AVAIL_MEM |
| 2648 | /* Use amount of memory available at this moment. */ |
| 2649 | n = (mch_avail_mem(FALSE) >> 11); |
| 2650 | #else |
| 2651 | # ifdef HAVE_TOTAL_MEM |
| 2652 | /* Use amount of memory available to Vim. */ |
| 2653 | n = (mch_total_mem(FALSE) >> 11); |
| 2654 | # else |
| 2655 | n = (0x7fffffff >> 11); |
| 2656 | # endif |
| 2657 | #endif |
| 2658 | options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
| 2659 | opt_idx = findoption((char_u *)"maxmem"); |
| 2660 | #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
| 2661 | if ((long)options[opt_idx].def_val[VI_DEFAULT] > n |
| 2662 | || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
| 2663 | #endif |
| 2664 | options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
| 2665 | } |
| 2666 | |
| 2667 | #ifdef FEAT_GUI_W32 |
| 2668 | /* force 'shortname' for Win32s */ |
| 2669 | if (gui_is_win32s()) |
| 2670 | options[findoption((char_u *)"shortname")].def_val[VI_DEFAULT] = |
| 2671 | (char_u *)TRUE; |
| 2672 | #endif |
| 2673 | |
| 2674 | #ifdef FEAT_SEARCHPATH |
| 2675 | { |
| 2676 | char_u *cdpath; |
| 2677 | char_u *buf; |
| 2678 | int i; |
| 2679 | int j; |
| 2680 | |
| 2681 | /* Initialize the 'cdpath' option's default value. */ |
| 2682 | cdpath = mch_getenv((char_u *)"CDPATH"); |
| 2683 | if (cdpath != NULL) |
| 2684 | { |
| 2685 | buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2)); |
| 2686 | if (buf != NULL) |
| 2687 | { |
| 2688 | buf[0] = ','; /* start with ",", current dir first */ |
| 2689 | j = 1; |
| 2690 | for (i = 0; cdpath[i] != NUL; ++i) |
| 2691 | { |
| 2692 | if (vim_ispathlistsep(cdpath[i])) |
| 2693 | buf[j++] = ','; |
| 2694 | else |
| 2695 | { |
| 2696 | if (cdpath[i] == ' ' || cdpath[i] == ',') |
| 2697 | buf[j++] = '\\'; |
| 2698 | buf[j++] = cdpath[i]; |
| 2699 | } |
| 2700 | } |
| 2701 | buf[j] = NUL; |
| 2702 | opt_idx = findoption((char_u *)"cdpath"); |
| 2703 | options[opt_idx].def_val[VI_DEFAULT] = buf; |
| 2704 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 2705 | } |
| 2706 | } |
| 2707 | } |
| 2708 | #endif |
| 2709 | |
| 2710 | #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
| 2711 | /* Set print encoding on platforms that don't default to latin1 */ |
| 2712 | set_string_default("penc", |
| 2713 | # if defined(MSWIN) || defined(OS2) |
| 2714 | (char_u *)"cp1252" |
| 2715 | # else |
| 2716 | # ifdef VMS |
| 2717 | (char_u *)"dec-mcs" |
| 2718 | # else |
| 2719 | # ifdef EBCDIC |
| 2720 | (char_u *)"ebcdic-uk" |
| 2721 | # else |
| 2722 | # ifdef MAC |
| 2723 | (char_u *)"mac-roman" |
| 2724 | # else /* HPUX */ |
| 2725 | (char_u *)"hp-roman8" |
| 2726 | # endif |
| 2727 | # endif |
| 2728 | # endif |
| 2729 | # endif |
| 2730 | ); |
| 2731 | #endif |
| 2732 | |
| 2733 | #ifdef FEAT_POSTSCRIPT |
| 2734 | /* 'printexpr' must be allocated to be able to evaluate it. */ |
| 2735 | set_string_default("pexpr", |
Bram Moolenaar | ed20346 | 2004-06-16 11:19:22 +0000 | [diff] [blame] | 2736 | # if defined(MSWIN) || defined(MSDOS) || defined(OS2) |
| 2737 | (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2738 | # else |
| 2739 | # ifdef VMS |
| 2740 | (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" |
| 2741 | |
| 2742 | # else |
| 2743 | (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" |
| 2744 | # endif |
| 2745 | # endif |
| 2746 | ); |
| 2747 | #endif |
| 2748 | |
| 2749 | /* |
| 2750 | * Set all the options (except the terminal options) to their default |
| 2751 | * value. Also set the global value for local options. |
| 2752 | */ |
| 2753 | set_options_default(0); |
| 2754 | |
| 2755 | #ifdef FEAT_GUI |
| 2756 | if (found_reverse_arg) |
| 2757 | set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); |
| 2758 | #endif |
| 2759 | |
| 2760 | curbuf->b_p_initialized = TRUE; |
| 2761 | curbuf->b_p_ar = -1; /* no local 'autoread' value */ |
| 2762 | check_buf_options(curbuf); |
| 2763 | check_win_options(curwin); |
| 2764 | check_options(); |
| 2765 | |
| 2766 | /* Must be before option_expand(), because that one needs vim_isIDc() */ |
| 2767 | didset_options(); |
| 2768 | |
| 2769 | #ifdef FEAT_LINEBREAK |
| 2770 | /* |
| 2771 | * initialize the table for 'breakat'. |
| 2772 | */ |
| 2773 | fill_breakat_flags(); |
| 2774 | #endif |
| 2775 | |
| 2776 | /* |
| 2777 | * Expand environment variables and things like "~" for the defaults. |
| 2778 | * If option_expand() returns non-NULL the variable is expanded. This can |
| 2779 | * only happen for non-indirect options. |
| 2780 | * Also set the default to the expanded value, so ":set" does not list |
| 2781 | * them. |
| 2782 | * Don't set the P_ALLOCED flag, because we don't want to free the |
| 2783 | * default. |
| 2784 | */ |
| 2785 | for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
| 2786 | { |
| 2787 | if ((options[opt_idx].flags & P_GETTEXT) |
| 2788 | && options[opt_idx].var != NULL) |
| 2789 | p = (char_u *)_(*(char **)options[opt_idx].var); |
| 2790 | else |
| 2791 | p = option_expand(opt_idx, NULL); |
| 2792 | if (p != NULL && (p = vim_strsave(p)) != NULL) |
| 2793 | { |
| 2794 | *(char_u **)options[opt_idx].var = p; |
| 2795 | /* VIMEXP |
| 2796 | * Defaults for all expanded options are currently the same for Vi |
| 2797 | * and Vim. When this changes, add some code here! Also need to |
| 2798 | * split P_DEF_ALLOCED in two. |
| 2799 | */ |
| 2800 | if (options[opt_idx].flags & P_DEF_ALLOCED) |
| 2801 | vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
| 2802 | options[opt_idx].def_val[VI_DEFAULT] = p; |
| 2803 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 2804 | } |
| 2805 | } |
| 2806 | |
| 2807 | /* Initialize the highlight_attr[] table. */ |
| 2808 | highlight_changed(); |
| 2809 | |
| 2810 | save_file_ff(curbuf); /* Buffer is unchanged */ |
| 2811 | |
| 2812 | /* Parse default for 'wildmode' */ |
| 2813 | check_opt_wim(); |
| 2814 | |
| 2815 | #if defined(FEAT_ARABIC) |
| 2816 | /* Detect use of mlterm. |
| 2817 | * Mlterm is a terminal emulator akin to xterm that has some special |
| 2818 | * abilities (bidi namely). |
| 2819 | * NOTE: mlterm's author is being asked to 'set' a variable |
| 2820 | * instead of an environment variable due to inheritance. |
| 2821 | */ |
| 2822 | if (mch_getenv((char_u *)"MLTERM") != NULL) |
| 2823 | set_option_value((char_u *)"tbidi", 1L, NULL, 0); |
| 2824 | #endif |
| 2825 | |
| 2826 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 2827 | /* Parse default for 'fillchars'. */ |
| 2828 | (void)set_chars_option(&p_fcs); |
| 2829 | #endif |
| 2830 | |
| 2831 | #ifdef FEAT_CLIPBOARD |
| 2832 | /* Parse default for 'clipboard' */ |
| 2833 | (void)check_clipboard_option(); |
| 2834 | #endif |
| 2835 | |
| 2836 | #ifdef FEAT_MBYTE |
| 2837 | # if defined(WIN3264) && defined(FEAT_GETTEXT) |
| 2838 | /* |
| 2839 | * If $LANG isn't set, try to get a good value for it. This makes the |
| 2840 | * right language be used automatically. Don't do this for English. |
| 2841 | */ |
| 2842 | if (mch_getenv((char_u *)"LANG") == NULL) |
| 2843 | { |
| 2844 | char buf[20]; |
| 2845 | |
| 2846 | /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. |
| 2847 | * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use |
| 2848 | * only the first two. */ |
| 2849 | n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
| 2850 | (LPTSTR)buf, 20); |
| 2851 | if (n >= 2 && STRNICMP(buf, "en", 2) != 0) |
| 2852 | { |
| 2853 | /* There are a few exceptions (probably more) */ |
| 2854 | if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
| 2855 | STRCPY(buf, "zh_TW"); |
| 2856 | else if (STRNICMP(buf, "chs", 3) == 0 |
| 2857 | || STRNICMP(buf, "zhc", 3) == 0) |
| 2858 | STRCPY(buf, "zh_CN"); |
| 2859 | else if (STRNICMP(buf, "jp", 2) == 0) |
| 2860 | STRCPY(buf, "ja"); |
| 2861 | else |
| 2862 | buf[2] = NUL; /* truncate to two-letter code */ |
| 2863 | vim_setenv("LANG", buf); |
| 2864 | } |
| 2865 | } |
| 2866 | # endif |
| 2867 | |
| 2868 | /* enc_locale() will try to find the encoding of the current locale. */ |
| 2869 | p = enc_locale(); |
| 2870 | if (p != NULL) |
| 2871 | { |
| 2872 | char_u *save_enc; |
| 2873 | |
| 2874 | /* Try setting 'encoding' and check if the value is valid. |
| 2875 | * If not, go back to the default "latin1". */ |
| 2876 | save_enc = p_enc; |
| 2877 | p_enc = p; |
| 2878 | if (mb_init() == NULL) |
| 2879 | { |
| 2880 | opt_idx = findoption((char_u *)"encoding"); |
| 2881 | options[opt_idx].def_val[VI_DEFAULT] = p_enc; |
| 2882 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 2883 | |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 2884 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \ |
| 2885 | || defined(VMS) |
| 2886 | if (STRCMP(p_enc, "latin1") == 0 |
| 2887 | # ifdef FEAT_MBYTE |
| 2888 | || enc_utf8 |
| 2889 | # endif |
| 2890 | ) |
| 2891 | { |
| 2892 | /* Adjust the default for 'isprint' to match latin1. */ |
| 2893 | set_string_option_direct((char_u *)"isp", -1, |
| 2894 | (char_u *)"@,161-255", OPT_FREE); |
| 2895 | (void)init_chartab(); |
| 2896 | } |
| 2897 | #endif |
| 2898 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2899 | # if defined(WIN3264) && !defined(FEAT_GUI) |
| 2900 | /* Win32 console: When GetACP() returns a different value from |
| 2901 | * GetConsoleCP() set 'termencoding'. */ |
| 2902 | if (GetACP() != GetConsoleCP()) |
| 2903 | { |
| 2904 | char buf[50]; |
| 2905 | |
| 2906 | sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
| 2907 | p_tenc = vim_strsave((char_u *)buf); |
| 2908 | if (p_tenc != NULL) |
| 2909 | { |
| 2910 | opt_idx = findoption((char_u *)"termencoding"); |
| 2911 | options[opt_idx].def_val[VI_DEFAULT] = p_tenc; |
| 2912 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 2913 | convert_setup(&input_conv, p_tenc, p_enc); |
| 2914 | convert_setup(&output_conv, p_enc, p_tenc); |
| 2915 | } |
| 2916 | else |
| 2917 | p_tenc = empty_option; |
| 2918 | } |
| 2919 | # endif |
| 2920 | } |
| 2921 | else |
| 2922 | { |
| 2923 | vim_free(p_enc); |
| 2924 | p_enc = save_enc; |
| 2925 | } |
| 2926 | } |
| 2927 | #endif |
| 2928 | |
| 2929 | #ifdef FEAT_MULTI_LANG |
| 2930 | /* Set the default for 'helplang'. */ |
| 2931 | set_helplang_default(get_mess_lang()); |
| 2932 | #endif |
| 2933 | } |
| 2934 | |
| 2935 | /* |
| 2936 | * Set an option to its default value. |
| 2937 | * This does not take care of side effects! |
| 2938 | */ |
| 2939 | static void |
| 2940 | set_option_default(opt_idx, opt_flags, compatible) |
| 2941 | int opt_idx; |
| 2942 | int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
| 2943 | int compatible; /* use Vi default value */ |
| 2944 | { |
| 2945 | char_u *varp; /* pointer to variable for current option */ |
| 2946 | int dvi; /* index in def_val[] */ |
| 2947 | long_u flags; |
| 2948 | int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
| 2949 | |
| 2950 | varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); |
| 2951 | flags = options[opt_idx].flags; |
| 2952 | if (varp != NULL) /* nothing to do for hidden option */ |
| 2953 | { |
| 2954 | dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
| 2955 | if (flags & P_STRING) |
| 2956 | { |
| 2957 | /* Use set_string_option_direct() for local options to handle |
| 2958 | * freeing and allocating the value. */ |
| 2959 | if (options[opt_idx].indir != PV_NONE) |
| 2960 | set_string_option_direct(NULL, opt_idx, |
| 2961 | options[opt_idx].def_val[dvi], opt_flags); |
| 2962 | else |
| 2963 | { |
| 2964 | if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) |
| 2965 | free_string_option(*(char_u **)(varp)); |
| 2966 | *(char_u **)varp = options[opt_idx].def_val[dvi]; |
| 2967 | options[opt_idx].flags &= ~P_ALLOCED; |
| 2968 | } |
| 2969 | } |
| 2970 | else if (flags & P_NUM) |
| 2971 | { |
| 2972 | if (varp == (char_u *)PV_SCROLL) |
| 2973 | win_comp_scroll(curwin); |
| 2974 | else |
| 2975 | { |
| 2976 | *(long *)varp = (long)options[opt_idx].def_val[dvi]; |
| 2977 | /* May also set global value for local option. */ |
| 2978 | if (both) |
| 2979 | *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
| 2980 | *(long *)varp; |
| 2981 | } |
| 2982 | } |
| 2983 | else /* P_BOOL */ |
| 2984 | { |
| 2985 | /* the cast to long is required for Manx C */ |
| 2986 | *(int *)varp = (int)(long)options[opt_idx].def_val[dvi]; |
| 2987 | /* May also set global value for local option. */ |
| 2988 | if (both) |
| 2989 | *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
| 2990 | *(int *)varp; |
| 2991 | } |
| 2992 | } |
| 2993 | |
| 2994 | #ifdef FEAT_EVAL |
| 2995 | /* Remember where the option was set. */ |
| 2996 | options[opt_idx].scriptID = current_SID; |
| 2997 | #endif |
| 2998 | } |
| 2999 | |
| 3000 | /* |
| 3001 | * Set all options (except terminal options) to their default value. |
| 3002 | */ |
| 3003 | static void |
| 3004 | set_options_default(opt_flags) |
| 3005 | int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
| 3006 | { |
| 3007 | int i; |
| 3008 | #ifdef FEAT_WINDOWS |
| 3009 | win_T *wp; |
| 3010 | #endif |
| 3011 | |
| 3012 | for (i = 0; !istermoption(&options[i]); i++) |
| 3013 | if (!(options[i].flags & P_NODEFAULT)) |
| 3014 | set_option_default(i, opt_flags, p_cp); |
| 3015 | |
| 3016 | #ifdef FEAT_WINDOWS |
| 3017 | /* The 'scroll' option must be computed for all windows. */ |
| 3018 | for (wp = firstwin; wp != NULL; wp = wp->w_next) |
| 3019 | win_comp_scroll(wp); |
| 3020 | #else |
| 3021 | win_comp_scroll(curwin); |
| 3022 | #endif |
| 3023 | } |
| 3024 | |
| 3025 | /* |
| 3026 | * Set the Vi-default value of a string option. |
| 3027 | * Used for 'sh', 'backupskip' and 'term'. |
| 3028 | */ |
| 3029 | void |
| 3030 | set_string_default(name, val) |
| 3031 | char *name; |
| 3032 | char_u *val; |
| 3033 | { |
| 3034 | char_u *p; |
| 3035 | int opt_idx; |
| 3036 | |
| 3037 | p = vim_strsave(val); |
| 3038 | if (p != NULL) /* we don't want a NULL */ |
| 3039 | { |
| 3040 | opt_idx = findoption((char_u *)name); |
| 3041 | if (options[opt_idx].flags & P_DEF_ALLOCED) |
| 3042 | vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
| 3043 | options[opt_idx].def_val[VI_DEFAULT] = p; |
| 3044 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 3045 | } |
| 3046 | } |
| 3047 | |
| 3048 | /* |
| 3049 | * Set the Vi-default value of a number option. |
| 3050 | * Used for 'lines' and 'columns'. |
| 3051 | */ |
| 3052 | void |
| 3053 | set_number_default(name, val) |
| 3054 | char *name; |
| 3055 | long val; |
| 3056 | { |
| 3057 | options[findoption((char_u *)name)].def_val[VI_DEFAULT] = (char_u *)val; |
| 3058 | } |
| 3059 | |
| 3060 | /* |
| 3061 | * Initialize the options, part two: After getting Rows and Columns and |
| 3062 | * setting 'term'. |
| 3063 | */ |
| 3064 | void |
| 3065 | set_init_2() |
| 3066 | { |
| 3067 | /* |
| 3068 | * 'scroll' defaults to half the window height. Note that this default is |
| 3069 | * wrong when the window height changes. |
| 3070 | */ |
| 3071 | options[findoption((char_u *)"scroll")].def_val[VI_DEFAULT] |
| 3072 | = (char_u *)((long_u)Rows >> 1); |
| 3073 | comp_col(); |
| 3074 | |
| 3075 | #if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)) |
| 3076 | { |
| 3077 | int idx4; |
| 3078 | |
| 3079 | /* |
| 3080 | * If 'background' wasn't set by the user, try guessing the value, |
| 3081 | * depending on the terminal name. Only need to check for terminals |
| 3082 | * with a dark background, that can handle color. Only "linux" |
| 3083 | * console at the moment. |
| 3084 | */ |
| 3085 | idx4 = findoption((char_u *)"bg"); |
| 3086 | if (!(options[idx4].flags & P_WAS_SET) && STRCMP(T_NAME, "linux") == 0) |
| 3087 | { |
| 3088 | set_string_option_direct(NULL, idx4, (char_u *)"dark", OPT_FREE); |
| 3089 | /* don't mark it as set, when starting the GUI it may be changed |
| 3090 | * again */ |
| 3091 | options[idx4].flags &= ~P_WAS_SET; |
| 3092 | } |
| 3093 | } |
| 3094 | #endif |
| 3095 | } |
| 3096 | |
| 3097 | /* |
| 3098 | * Initialize the options, part three: After reading the .vimrc |
| 3099 | */ |
| 3100 | void |
| 3101 | set_init_3() |
| 3102 | { |
| 3103 | #if defined(UNIX) || defined(OS2) || defined(WIN3264) |
| 3104 | /* |
| 3105 | * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. |
| 3106 | * This is done after other initializations, where 'shell' might have been |
| 3107 | * set, but only if they have not been set before. |
| 3108 | */ |
| 3109 | char_u *p; |
| 3110 | int idx_srr; |
| 3111 | int do_srr; |
| 3112 | #ifdef FEAT_QUICKFIX |
| 3113 | int idx_sp; |
| 3114 | int do_sp; |
| 3115 | #endif |
| 3116 | |
| 3117 | idx_srr = findoption((char_u *)"srr"); |
| 3118 | do_srr = !(options[idx_srr].flags & P_WAS_SET); |
| 3119 | #ifdef FEAT_QUICKFIX |
| 3120 | idx_sp = findoption((char_u *)"sp"); |
| 3121 | do_sp = !(options[idx_sp].flags & P_WAS_SET); |
| 3122 | #endif |
| 3123 | |
| 3124 | /* |
| 3125 | * Isolate the name of the shell: |
| 3126 | * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f". |
| 3127 | * - Remove any argument. E.g., "csh -f" -> "csh". |
| 3128 | */ |
| 3129 | p = gettail(p_sh); |
| 3130 | p = vim_strnsave(p, (int)(skiptowhite(p) - p)); |
| 3131 | if (p != NULL) |
| 3132 | { |
| 3133 | /* |
| 3134 | * Default for p_sp is "| tee", for p_srr is ">". |
| 3135 | * For known shells it is changed here to include stderr. |
| 3136 | */ |
| 3137 | if ( fnamecmp(p, "csh") == 0 |
| 3138 | || fnamecmp(p, "tcsh") == 0 |
| 3139 | # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */ |
| 3140 | || fnamecmp(p, "csh.exe") == 0 |
| 3141 | || fnamecmp(p, "tcsh.exe") == 0 |
| 3142 | # endif |
| 3143 | ) |
| 3144 | { |
| 3145 | #if defined(FEAT_QUICKFIX) |
| 3146 | if (do_sp) |
| 3147 | { |
| 3148 | # ifdef WIN3264 |
| 3149 | p_sp = (char_u *)">&"; |
| 3150 | # else |
| 3151 | p_sp = (char_u *)"|& tee"; |
| 3152 | # endif |
| 3153 | options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
| 3154 | } |
| 3155 | #endif |
| 3156 | if (do_srr) |
| 3157 | { |
| 3158 | p_srr = (char_u *)">&"; |
| 3159 | options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
| 3160 | } |
| 3161 | } |
| 3162 | else |
| 3163 | # ifndef OS2 /* Always use bourne shell style redirection if we reach this */ |
| 3164 | if ( fnamecmp(p, "sh") == 0 |
| 3165 | || fnamecmp(p, "ksh") == 0 |
| 3166 | || fnamecmp(p, "zsh") == 0 |
| 3167 | || fnamecmp(p, "bash") == 0 |
| 3168 | # ifdef WIN3264 |
| 3169 | || fnamecmp(p, "cmd") == 0 |
| 3170 | || fnamecmp(p, "sh.exe") == 0 |
| 3171 | || fnamecmp(p, "ksh.exe") == 0 |
| 3172 | || fnamecmp(p, "zsh.exe") == 0 |
| 3173 | || fnamecmp(p, "bash.exe") == 0 |
| 3174 | || fnamecmp(p, "cmd.exe") == 0 |
| 3175 | # endif |
| 3176 | ) |
| 3177 | # endif |
| 3178 | { |
| 3179 | #if defined(FEAT_QUICKFIX) |
| 3180 | if (do_sp) |
| 3181 | { |
| 3182 | # ifdef WIN3264 |
| 3183 | p_sp = (char_u *)">%s 2>&1"; |
| 3184 | # else |
| 3185 | p_sp = (char_u *)"2>&1| tee"; |
| 3186 | # endif |
| 3187 | options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
| 3188 | } |
| 3189 | #endif |
| 3190 | if (do_srr) |
| 3191 | { |
| 3192 | p_srr = (char_u *)">%s 2>&1"; |
| 3193 | options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
| 3194 | } |
| 3195 | } |
| 3196 | vim_free(p); |
| 3197 | } |
| 3198 | #endif |
| 3199 | |
| 3200 | #if defined(MSDOS) || defined(WIN3264) || defined(OS2) |
| 3201 | /* |
| 3202 | * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option. |
| 3203 | * This is done after other initializations, where 'shell' might have been |
| 3204 | * set, but only if they have not been set before. Default for p_shcf is |
| 3205 | * "/c", for p_shq is "". For "sh" like shells it is changed here to |
| 3206 | * "-c" and "\"", but not for DJGPP, because it starts the shell without |
| 3207 | * command.com. And for Win32 we need to set p_sxq instead. |
| 3208 | */ |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 3209 | if (strstr((char *)gettail(p_sh), "sh") != NULL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3210 | { |
| 3211 | int idx3; |
| 3212 | |
| 3213 | idx3 = findoption((char_u *)"shcf"); |
| 3214 | if (!(options[idx3].flags & P_WAS_SET)) |
| 3215 | { |
| 3216 | p_shcf = (char_u *)"-c"; |
| 3217 | options[idx3].def_val[VI_DEFAULT] = p_shcf; |
| 3218 | } |
| 3219 | |
| 3220 | # ifndef DJGPP |
| 3221 | # ifdef WIN3264 |
| 3222 | /* Somehow Win32 requires the quotes around the redirection too */ |
| 3223 | idx3 = findoption((char_u *)"sxq"); |
| 3224 | if (!(options[idx3].flags & P_WAS_SET)) |
| 3225 | { |
| 3226 | p_sxq = (char_u *)"\""; |
| 3227 | options[idx3].def_val[VI_DEFAULT] = p_sxq; |
| 3228 | } |
| 3229 | # else |
| 3230 | idx3 = findoption((char_u *)"shq"); |
| 3231 | if (!(options[idx3].flags & P_WAS_SET)) |
| 3232 | { |
| 3233 | p_shq = (char_u *)"\""; |
| 3234 | options[idx3].def_val[VI_DEFAULT] = p_shq; |
| 3235 | } |
| 3236 | # endif |
| 3237 | # endif |
| 3238 | } |
| 3239 | #endif |
| 3240 | |
| 3241 | #ifdef FEAT_TITLE |
| 3242 | set_title_defaults(); |
| 3243 | #endif |
| 3244 | } |
| 3245 | |
| 3246 | #if defined(FEAT_MULTI_LANG) || defined(PROTO) |
| 3247 | /* |
| 3248 | * When 'helplang' is still at its default value, set it to "lang". |
| 3249 | * Only the first two characters of "lang" are used. |
| 3250 | */ |
| 3251 | void |
| 3252 | set_helplang_default(lang) |
| 3253 | char_u *lang; |
| 3254 | { |
| 3255 | int idx; |
| 3256 | |
| 3257 | if (lang == NULL || STRLEN(lang) < 2) /* safety check */ |
| 3258 | return; |
| 3259 | idx = findoption((char_u *)"hlg"); |
| 3260 | if (!(options[idx].flags & P_WAS_SET)) |
| 3261 | { |
| 3262 | if (options[idx].flags & P_ALLOCED) |
| 3263 | free_string_option(p_hlg); |
| 3264 | p_hlg = vim_strsave(lang); |
| 3265 | if (p_hlg == NULL) |
| 3266 | p_hlg = empty_option; |
| 3267 | else |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 3268 | { |
| 3269 | /* zh_CN becomes "cn", zh_TW becomes "tw". */ |
| 3270 | if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
| 3271 | { |
| 3272 | p_hlg[0] = TOLOWER_ASC(p_hlg[3]); |
| 3273 | p_hlg[1] = TOLOWER_ASC(p_hlg[4]); |
| 3274 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3275 | p_hlg[2] = NUL; |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 3276 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3277 | options[idx].flags |= P_ALLOCED; |
| 3278 | } |
| 3279 | } |
| 3280 | #endif |
| 3281 | |
| 3282 | #ifdef FEAT_GUI |
| 3283 | static char_u *gui_bg_default __ARGS((void)); |
| 3284 | |
| 3285 | static char_u * |
| 3286 | gui_bg_default() |
| 3287 | { |
| 3288 | if (gui_get_lightness(gui.back_pixel) < 127) |
| 3289 | return (char_u *)"dark"; |
| 3290 | return (char_u *)"light"; |
| 3291 | } |
| 3292 | |
| 3293 | /* |
| 3294 | * Option initializations that can only be done after opening the GUI window. |
| 3295 | */ |
| 3296 | void |
| 3297 | init_gui_options() |
| 3298 | { |
| 3299 | /* Set the 'background' option according to the lightness of the |
| 3300 | * background color, unless the user has set it already. */ |
| 3301 | if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) |
| 3302 | { |
| 3303 | set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); |
| 3304 | highlight_changed(); |
| 3305 | } |
| 3306 | } |
| 3307 | #endif |
| 3308 | |
| 3309 | #ifdef FEAT_TITLE |
| 3310 | /* |
| 3311 | * 'title' and 'icon' only default to true if they have not been set or reset |
| 3312 | * in .vimrc and we can read the old value. |
| 3313 | * When 'title' and 'icon' have been reset in .vimrc, we won't even check if |
| 3314 | * they can be reset. This reduces startup time when using X on a remote |
| 3315 | * machine. |
| 3316 | */ |
| 3317 | void |
| 3318 | set_title_defaults() |
| 3319 | { |
| 3320 | int idx1; |
| 3321 | long val; |
| 3322 | |
| 3323 | /* |
| 3324 | * If GUI is (going to be) used, we can always set the window title and |
| 3325 | * icon name. Saves a bit of time, because the X11 display server does |
| 3326 | * not need to be contacted. |
| 3327 | */ |
| 3328 | idx1 = findoption((char_u *)"title"); |
| 3329 | if (!(options[idx1].flags & P_WAS_SET)) |
| 3330 | { |
| 3331 | #ifdef FEAT_GUI |
| 3332 | if (gui.starting || gui.in_use) |
| 3333 | val = TRUE; |
| 3334 | else |
| 3335 | #endif |
| 3336 | val = mch_can_restore_title(); |
| 3337 | options[idx1].def_val[VI_DEFAULT] = (char_u *)val; |
| 3338 | p_title = val; |
| 3339 | } |
| 3340 | idx1 = findoption((char_u *)"icon"); |
| 3341 | if (!(options[idx1].flags & P_WAS_SET)) |
| 3342 | { |
| 3343 | #ifdef FEAT_GUI |
| 3344 | if (gui.starting || gui.in_use) |
| 3345 | val = TRUE; |
| 3346 | else |
| 3347 | #endif |
| 3348 | val = mch_can_restore_icon(); |
| 3349 | options[idx1].def_val[VI_DEFAULT] = (char_u *)val; |
| 3350 | p_icon = val; |
| 3351 | } |
| 3352 | } |
| 3353 | #endif |
| 3354 | |
| 3355 | /* |
| 3356 | * Parse 'arg' for option settings. |
| 3357 | * |
| 3358 | * 'arg' may be IObuff, but only when no errors can be present and option |
| 3359 | * does not need to be expanded with option_expand(). |
| 3360 | * "opt_flags": |
| 3361 | * 0 for ":set" |
| 3362 | * OPT_GLOBAL for ":setglobal" |
| 3363 | * OPT_LOCAL for ":setlocal" and a modeline |
| 3364 | * OPT_MODELINE for a modeline |
| 3365 | * |
| 3366 | * returns FAIL if an error is detected, OK otherwise |
| 3367 | */ |
| 3368 | int |
| 3369 | do_set(arg, opt_flags) |
| 3370 | char_u *arg; /* option string (may be written to!) */ |
| 3371 | int opt_flags; |
| 3372 | { |
| 3373 | int opt_idx; |
| 3374 | char_u *errmsg; |
| 3375 | char_u errbuf[80]; |
| 3376 | char_u *startarg; |
| 3377 | int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ |
| 3378 | int nextchar; /* next non-white char after option name */ |
| 3379 | int afterchar; /* character just after option name */ |
| 3380 | int len; |
| 3381 | int i; |
| 3382 | long value; |
| 3383 | int key; |
| 3384 | long_u flags; /* flags for current option */ |
| 3385 | char_u *varp = NULL; /* pointer to variable for current option */ |
| 3386 | int did_show = FALSE; /* already showed one value */ |
| 3387 | int adding; /* "opt+=arg" */ |
| 3388 | int prepending; /* "opt^=arg" */ |
| 3389 | int removing; /* "opt-=arg" */ |
| 3390 | int cp_val = 0; |
| 3391 | char_u key_name[2]; |
| 3392 | |
| 3393 | if (*arg == NUL) |
| 3394 | { |
| 3395 | showoptions(0, opt_flags); |
| 3396 | return OK; |
| 3397 | } |
| 3398 | |
| 3399 | while (*arg != NUL) /* loop to process all options */ |
| 3400 | { |
| 3401 | errmsg = NULL; |
| 3402 | startarg = arg; /* remember for error message */ |
| 3403 | |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 3404 | if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
| 3405 | && !(opt_flags & OPT_MODELINE)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3406 | { |
| 3407 | /* |
| 3408 | * ":set all" show all options. |
| 3409 | * ":set all&" set all options to their default value. |
| 3410 | */ |
| 3411 | arg += 3; |
| 3412 | if (*arg == '&') |
| 3413 | { |
| 3414 | ++arg; |
| 3415 | /* Only for :set command set global value of local options. */ |
| 3416 | set_options_default(OPT_FREE | opt_flags); |
| 3417 | } |
| 3418 | else |
| 3419 | showoptions(1, opt_flags); |
| 3420 | } |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 3421 | else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3422 | { |
| 3423 | showoptions(2, opt_flags); |
| 3424 | show_termcodes(); |
| 3425 | arg += 7; |
| 3426 | } |
| 3427 | else |
| 3428 | { |
| 3429 | prefix = 1; |
| 3430 | if (STRNCMP(arg, "no", 2) == 0) |
| 3431 | { |
| 3432 | prefix = 0; |
| 3433 | arg += 2; |
| 3434 | } |
| 3435 | else if (STRNCMP(arg, "inv", 3) == 0) |
| 3436 | { |
| 3437 | prefix = 2; |
| 3438 | arg += 3; |
| 3439 | } |
| 3440 | |
| 3441 | /* find end of name */ |
| 3442 | key = 0; |
| 3443 | if (*arg == '<') |
| 3444 | { |
| 3445 | nextchar = 0; |
| 3446 | opt_idx = -1; |
| 3447 | /* look out for <t_>;> */ |
| 3448 | if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
| 3449 | len = 5; |
| 3450 | else |
| 3451 | { |
| 3452 | len = 1; |
| 3453 | while (arg[len] != NUL && arg[len] != '>') |
| 3454 | ++len; |
| 3455 | } |
| 3456 | if (arg[len] != '>') |
| 3457 | { |
| 3458 | errmsg = e_invarg; |
| 3459 | goto skip; |
| 3460 | } |
| 3461 | arg[len] = NUL; /* put NUL after name */ |
| 3462 | if (arg[1] == 't' && arg[2] == '_') /* could be term code */ |
| 3463 | opt_idx = findoption(arg + 1); |
| 3464 | arg[len++] = '>'; /* restore '>' */ |
| 3465 | if (opt_idx == -1) |
| 3466 | key = find_key_option(arg + 1); |
| 3467 | } |
| 3468 | else |
| 3469 | { |
| 3470 | len = 0; |
| 3471 | /* |
| 3472 | * The two characters after "t_" may not be alphanumeric. |
| 3473 | */ |
| 3474 | if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
| 3475 | len = 4; |
| 3476 | else |
| 3477 | while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') |
| 3478 | ++len; |
| 3479 | nextchar = arg[len]; |
| 3480 | arg[len] = NUL; /* put NUL after name */ |
| 3481 | opt_idx = findoption(arg); |
| 3482 | arg[len] = nextchar; /* restore nextchar */ |
| 3483 | if (opt_idx == -1) |
| 3484 | key = find_key_option(arg); |
| 3485 | } |
| 3486 | |
| 3487 | /* remember character after option name */ |
| 3488 | afterchar = arg[len]; |
| 3489 | |
| 3490 | /* skip white space, allow ":set ai ?" */ |
| 3491 | while (vim_iswhite(arg[len])) |
| 3492 | ++len; |
| 3493 | |
| 3494 | adding = FALSE; |
| 3495 | prepending = FALSE; |
| 3496 | removing = FALSE; |
| 3497 | if (arg[len] != NUL && arg[len + 1] == '=') |
| 3498 | { |
| 3499 | if (arg[len] == '+') |
| 3500 | { |
| 3501 | adding = TRUE; /* "+=" */ |
| 3502 | ++len; |
| 3503 | } |
| 3504 | else if (arg[len] == '^') |
| 3505 | { |
| 3506 | prepending = TRUE; /* "^=" */ |
| 3507 | ++len; |
| 3508 | } |
| 3509 | else if (arg[len] == '-') |
| 3510 | { |
| 3511 | removing = TRUE; /* "-=" */ |
| 3512 | ++len; |
| 3513 | } |
| 3514 | } |
| 3515 | nextchar = arg[len]; |
| 3516 | |
| 3517 | if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ |
| 3518 | { |
| 3519 | errmsg = (char_u *)N_("E518: Unknown option"); |
| 3520 | goto skip; |
| 3521 | } |
| 3522 | |
| 3523 | if (opt_idx >= 0) |
| 3524 | { |
| 3525 | if (options[opt_idx].var == NULL) /* hidden option: skip */ |
| 3526 | { |
| 3527 | /* Only give an error message when requesting the value of |
| 3528 | * a hidden option, ignore setting it. */ |
| 3529 | if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
| 3530 | && (!(options[opt_idx].flags & P_BOOL) |
| 3531 | || nextchar == '?')) |
| 3532 | errmsg = (char_u *)N_("E519: Option not supported"); |
| 3533 | goto skip; |
| 3534 | } |
| 3535 | |
| 3536 | flags = options[opt_idx].flags; |
| 3537 | varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
| 3538 | } |
| 3539 | else |
| 3540 | { |
| 3541 | flags = P_STRING; |
| 3542 | if (key < 0) |
| 3543 | { |
| 3544 | key_name[0] = KEY2TERMCAP0(key); |
| 3545 | key_name[1] = KEY2TERMCAP1(key); |
| 3546 | } |
| 3547 | else |
| 3548 | { |
| 3549 | key_name[0] = KS_KEY; |
| 3550 | key_name[1] = (key & 0xff); |
| 3551 | } |
| 3552 | } |
| 3553 | |
| 3554 | /* Disallow changing some options from modelines */ |
| 3555 | if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE)) |
| 3556 | { |
| 3557 | errmsg = (char_u *)_("E520: Not allowed in a modeline"); |
| 3558 | goto skip; |
| 3559 | } |
| 3560 | |
Bram Moolenaar | 15d0a8c | 2004-09-06 17:44:46 +0000 | [diff] [blame] | 3561 | /* Skip all options that are not window-local (used when showing |
| 3562 | * an already loaded buffer in a window). */ |
| 3563 | if ((opt_flags & OPT_WINONLY) |
| 3564 | && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) |
| 3565 | goto skip; |
| 3566 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3567 | #ifdef HAVE_SANDBOX |
| 3568 | /* Disallow changing some options in the sandbox */ |
| 3569 | if (sandbox > 0 && (flags & P_SECURE)) |
| 3570 | { |
| 3571 | errmsg = (char_u *)_(e_sandbox); |
| 3572 | goto skip; |
| 3573 | } |
| 3574 | #endif |
| 3575 | |
| 3576 | if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) |
| 3577 | { |
| 3578 | arg += len; |
| 3579 | cp_val = p_cp; |
| 3580 | if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') |
| 3581 | { |
| 3582 | if (arg[3] == 'm') /* "opt&vim": set to Vim default */ |
| 3583 | { |
| 3584 | cp_val = FALSE; |
| 3585 | arg += 3; |
| 3586 | } |
| 3587 | else /* "opt&vi": set to Vi default */ |
| 3588 | { |
| 3589 | cp_val = TRUE; |
| 3590 | arg += 2; |
| 3591 | } |
| 3592 | } |
| 3593 | if (vim_strchr((char_u *)"?!&<", nextchar) != NULL |
| 3594 | && arg[1] != NUL && !vim_iswhite(arg[1])) |
| 3595 | { |
| 3596 | errmsg = e_trailing; |
| 3597 | goto skip; |
| 3598 | } |
| 3599 | } |
| 3600 | |
| 3601 | /* |
| 3602 | * allow '=' and ':' as MSDOS command.com allows only one |
| 3603 | * '=' character per "set" command line. grrr. (jw) |
| 3604 | */ |
| 3605 | if (nextchar == '?' |
| 3606 | || (prefix == 1 |
| 3607 | && vim_strchr((char_u *)"=:&<", nextchar) == NULL |
| 3608 | && !(flags & P_BOOL))) |
| 3609 | { |
| 3610 | /* |
| 3611 | * print value |
| 3612 | */ |
| 3613 | if (did_show) |
| 3614 | msg_putchar('\n'); /* cursor below last one */ |
| 3615 | else |
| 3616 | { |
| 3617 | gotocmdline(TRUE); /* cursor at status line */ |
| 3618 | did_show = TRUE; /* remember that we did a line */ |
| 3619 | } |
| 3620 | if (opt_idx >= 0) |
| 3621 | { |
| 3622 | showoneopt(&options[opt_idx], opt_flags); |
| 3623 | #ifdef FEAT_EVAL |
| 3624 | if (p_verbose > 0) |
| 3625 | { |
| 3626 | if (options[opt_idx].scriptID != 0) |
| 3627 | { |
| 3628 | MSG_PUTS(_("\n\tLast set from ")); |
| 3629 | MSG_PUTS(get_scriptname(options[opt_idx].scriptID)); |
| 3630 | } |
| 3631 | } |
| 3632 | #endif |
| 3633 | } |
| 3634 | else |
| 3635 | { |
| 3636 | char_u *p; |
| 3637 | |
| 3638 | p = find_termcode(key_name); |
| 3639 | if (p == NULL) |
| 3640 | { |
| 3641 | errmsg = (char_u *)N_("E518: Unknown option"); |
| 3642 | goto skip; |
| 3643 | } |
| 3644 | else |
| 3645 | (void)show_one_termcode(key_name, p, TRUE); |
| 3646 | } |
| 3647 | if (nextchar != '?' |
| 3648 | && nextchar != NUL && !vim_iswhite(afterchar)) |
| 3649 | errmsg = e_trailing; |
| 3650 | } |
| 3651 | else |
| 3652 | { |
| 3653 | if (flags & P_BOOL) /* boolean */ |
| 3654 | { |
| 3655 | if (nextchar == '=' || nextchar == ':') |
| 3656 | { |
| 3657 | errmsg = e_invarg; |
| 3658 | goto skip; |
| 3659 | } |
| 3660 | |
| 3661 | /* |
| 3662 | * ":set opt!": invert |
| 3663 | * ":set opt&": reset to default value |
| 3664 | * ":set opt<": reset to global value |
| 3665 | */ |
| 3666 | if (nextchar == '!') |
| 3667 | value = *(int *)(varp) ^ 1; |
| 3668 | else if (nextchar == '&') |
| 3669 | value = (int)(long)options[opt_idx].def_val[ |
| 3670 | ((flags & P_VI_DEF) || cp_val) |
| 3671 | ? VI_DEFAULT : VIM_DEFAULT]; |
| 3672 | else if (nextchar == '<') |
| 3673 | { |
| 3674 | /* For 'autoread' -1 means to use global value. */ |
| 3675 | if ((int *)varp == &curbuf->b_p_ar |
| 3676 | && opt_flags == OPT_LOCAL) |
| 3677 | value = -1; |
| 3678 | else |
| 3679 | value = *(int *)get_varp_scope(&(options[opt_idx]), |
| 3680 | OPT_GLOBAL); |
| 3681 | } |
| 3682 | else |
| 3683 | { |
| 3684 | /* |
| 3685 | * ":set invopt": invert |
| 3686 | * ":set opt" or ":set noopt": set or reset |
| 3687 | */ |
| 3688 | if (nextchar != NUL && !vim_iswhite(afterchar)) |
| 3689 | { |
| 3690 | errmsg = e_trailing; |
| 3691 | goto skip; |
| 3692 | } |
| 3693 | if (prefix == 2) /* inv */ |
| 3694 | value = *(int *)(varp) ^ 1; |
| 3695 | else |
| 3696 | value = prefix; |
| 3697 | } |
| 3698 | |
| 3699 | errmsg = set_bool_option(opt_idx, varp, (int)value, |
| 3700 | opt_flags); |
| 3701 | } |
| 3702 | else /* numeric or string */ |
| 3703 | { |
| 3704 | if (vim_strchr((char_u *)"=:&<", nextchar) == NULL |
| 3705 | || prefix != 1) |
| 3706 | { |
| 3707 | errmsg = e_invarg; |
| 3708 | goto skip; |
| 3709 | } |
| 3710 | |
| 3711 | if (flags & P_NUM) /* numeric */ |
| 3712 | { |
| 3713 | /* |
| 3714 | * Different ways to set a number option: |
| 3715 | * & set to default value |
| 3716 | * < set to global value |
| 3717 | * <xx> accept special key codes for 'wildchar' |
| 3718 | * c accept any non-digit for 'wildchar' |
| 3719 | * [-]0-9 set number |
| 3720 | * other error |
| 3721 | */ |
| 3722 | ++arg; |
| 3723 | if (nextchar == '&') |
| 3724 | value = (long)options[opt_idx].def_val[ |
| 3725 | ((flags & P_VI_DEF) || cp_val) |
| 3726 | ? VI_DEFAULT : VIM_DEFAULT]; |
| 3727 | else if (nextchar == '<') |
| 3728 | value = *(long *)get_varp_scope(&(options[opt_idx]), |
| 3729 | OPT_GLOBAL); |
| 3730 | else if (((long *)varp == &p_wc |
| 3731 | || (long *)varp == &p_wcm) |
| 3732 | && (*arg == '<' |
| 3733 | || *arg == '^' |
| 3734 | || ((!arg[1] || vim_iswhite(arg[1])) |
| 3735 | && !VIM_ISDIGIT(*arg)))) |
| 3736 | { |
| 3737 | value = string_to_key(arg); |
| 3738 | if (value == 0 && (long *)varp != &p_wcm) |
| 3739 | { |
| 3740 | errmsg = e_invarg; |
| 3741 | goto skip; |
| 3742 | } |
| 3743 | } |
| 3744 | /* allow negative numbers (for 'undolevels') */ |
| 3745 | else if (*arg == '-' || VIM_ISDIGIT(*arg)) |
| 3746 | { |
| 3747 | i = 0; |
| 3748 | if (*arg == '-') |
| 3749 | i = 1; |
| 3750 | #ifdef HAVE_STRTOL |
| 3751 | value = strtol((char *)arg, NULL, 0); |
| 3752 | if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x') |
| 3753 | i += 2; |
| 3754 | #else |
| 3755 | value = atol((char *)arg); |
| 3756 | #endif |
| 3757 | while (VIM_ISDIGIT(arg[i])) |
| 3758 | ++i; |
| 3759 | if (arg[i] != NUL && !vim_iswhite(arg[i])) |
| 3760 | { |
| 3761 | errmsg = e_invarg; |
| 3762 | goto skip; |
| 3763 | } |
| 3764 | } |
| 3765 | else |
| 3766 | { |
| 3767 | errmsg = (char_u *)N_("E521: Number required after ="); |
| 3768 | goto skip; |
| 3769 | } |
| 3770 | |
| 3771 | if (adding) |
| 3772 | value = *(long *)varp + value; |
| 3773 | if (prepending) |
| 3774 | value = *(long *)varp * value; |
| 3775 | if (removing) |
| 3776 | value = *(long *)varp - value; |
| 3777 | errmsg = set_num_option(opt_idx, varp, value, |
| 3778 | errbuf, opt_flags); |
| 3779 | } |
| 3780 | else if (opt_idx >= 0) /* string */ |
| 3781 | { |
| 3782 | char_u *save_arg = NULL; |
| 3783 | char_u *s = NULL; |
| 3784 | char_u *oldval; /* previous value if *varp */ |
| 3785 | char_u *newval; |
| 3786 | char_u *origval; |
| 3787 | unsigned newlen; |
| 3788 | int comma; |
| 3789 | int bs; |
| 3790 | int new_value_alloced; /* new string option |
| 3791 | was allocated */ |
| 3792 | |
| 3793 | /* When using ":set opt=val" for a global option |
| 3794 | * with a local value the local value will be |
| 3795 | * reset, use the global value here. */ |
| 3796 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
| 3797 | && (int)options[opt_idx].indir >= PV_BOTH) |
| 3798 | varp = options[opt_idx].var; |
| 3799 | |
| 3800 | /* The old value is kept until we are sure that the |
| 3801 | * new value is valid. */ |
| 3802 | oldval = *(char_u **)varp; |
| 3803 | if (nextchar == '&') /* set to default val */ |
| 3804 | { |
| 3805 | newval = options[opt_idx].def_val[ |
| 3806 | ((flags & P_VI_DEF) || cp_val) |
| 3807 | ? VI_DEFAULT : VIM_DEFAULT]; |
| 3808 | if ((char_u **)varp == &p_bg) |
| 3809 | { |
| 3810 | /* guess the value of 'background' */ |
| 3811 | #ifdef FEAT_GUI |
| 3812 | if (gui.in_use) |
| 3813 | newval = gui_bg_default(); |
| 3814 | else |
| 3815 | #endif |
| 3816 | if (STRCMP(T_NAME, "linux") == 0) |
| 3817 | newval = (char_u *)"dark"; |
| 3818 | } |
| 3819 | |
| 3820 | /* expand environment variables and ~ (since the |
| 3821 | * default value was already expanded, only |
| 3822 | * required when an environment variable was set |
| 3823 | * later */ |
| 3824 | if (newval == NULL) |
| 3825 | newval = empty_option; |
| 3826 | else |
| 3827 | { |
| 3828 | s = option_expand(opt_idx, newval); |
| 3829 | if (s == NULL) |
| 3830 | s = newval; |
| 3831 | newval = vim_strsave(s); |
| 3832 | } |
| 3833 | new_value_alloced = TRUE; |
| 3834 | } |
| 3835 | else if (nextchar == '<') /* set to global val */ |
| 3836 | { |
| 3837 | newval = vim_strsave(*(char_u **)get_varp_scope( |
| 3838 | &(options[opt_idx]), OPT_GLOBAL)); |
| 3839 | new_value_alloced = TRUE; |
| 3840 | } |
| 3841 | else |
| 3842 | { |
| 3843 | ++arg; /* jump to after the '=' or ':' */ |
| 3844 | |
| 3845 | /* |
| 3846 | * Set 'keywordprg' to ":help" if an empty |
| 3847 | * value was passed to :set by the user. |
| 3848 | * Misuse errbuf[] for the resulting string. |
| 3849 | */ |
| 3850 | if (varp == (char_u *)&p_kp |
| 3851 | && (*arg == NUL || *arg == ' ')) |
| 3852 | { |
| 3853 | STRCPY(errbuf, ":help"); |
| 3854 | save_arg = arg; |
| 3855 | arg = errbuf; |
| 3856 | } |
| 3857 | /* |
| 3858 | * Convert 'whichwrap' number to string, for |
| 3859 | * backwards compatibility with Vim 3.0. |
| 3860 | * Misuse errbuf[] for the resulting string. |
| 3861 | */ |
| 3862 | else if (varp == (char_u *)&p_ww |
| 3863 | && VIM_ISDIGIT(*arg)) |
| 3864 | { |
| 3865 | *errbuf = NUL; |
| 3866 | i = getdigits(&arg); |
| 3867 | if (i & 1) |
| 3868 | STRCAT(errbuf, "b,"); |
| 3869 | if (i & 2) |
| 3870 | STRCAT(errbuf, "s,"); |
| 3871 | if (i & 4) |
| 3872 | STRCAT(errbuf, "h,l,"); |
| 3873 | if (i & 8) |
| 3874 | STRCAT(errbuf, "<,>,"); |
| 3875 | if (i & 16) |
| 3876 | STRCAT(errbuf, "[,],"); |
| 3877 | if (*errbuf != NUL) /* remove trailing , */ |
| 3878 | errbuf[STRLEN(errbuf) - 1] = NUL; |
| 3879 | save_arg = arg; |
| 3880 | arg = errbuf; |
| 3881 | } |
| 3882 | /* |
| 3883 | * Remove '>' before 'dir' and 'bdir', for |
| 3884 | * backwards compatibility with version 3.0 |
| 3885 | */ |
| 3886 | else if ( *arg == '>' |
| 3887 | && (varp == (char_u *)&p_dir |
| 3888 | || varp == (char_u *)&p_bdir)) |
| 3889 | { |
| 3890 | ++arg; |
| 3891 | } |
| 3892 | |
| 3893 | /* When setting the local value of a global |
| 3894 | * option, the old value may be the global value. */ |
| 3895 | if ((int)options[opt_idx].indir >= PV_BOTH |
| 3896 | && (opt_flags & OPT_LOCAL)) |
| 3897 | origval = *(char_u **)get_varp( |
| 3898 | &options[opt_idx]); |
| 3899 | else |
| 3900 | origval = oldval; |
| 3901 | |
| 3902 | /* |
| 3903 | * Copy the new string into allocated memory. |
| 3904 | * Can't use set_string_option_direct(), because |
| 3905 | * we need to remove the backslashes. |
| 3906 | */ |
| 3907 | /* get a bit too much */ |
| 3908 | newlen = (unsigned)STRLEN(arg) + 1; |
| 3909 | if (adding || prepending || removing) |
| 3910 | newlen += (unsigned)STRLEN(origval) + 1; |
| 3911 | newval = alloc(newlen); |
| 3912 | if (newval == NULL) /* out of mem, don't change */ |
| 3913 | break; |
| 3914 | s = newval; |
| 3915 | |
| 3916 | /* |
| 3917 | * Copy the string, skip over escaped chars. |
| 3918 | * For MS-DOS and WIN32 backslashes before normal |
| 3919 | * file name characters are not removed, and keep |
| 3920 | * backslash at start, for "\\machine\path", but |
| 3921 | * do remove it for "\\\\machine\\path". |
| 3922 | * The reverse is found in ExpandOldSetting(). |
| 3923 | */ |
| 3924 | while (*arg && !vim_iswhite(*arg)) |
| 3925 | { |
| 3926 | if (*arg == '\\' && arg[1] != NUL |
| 3927 | #ifdef BACKSLASH_IN_FILENAME |
| 3928 | && !((flags & P_EXPAND) |
| 3929 | && vim_isfilec(arg[1]) |
| 3930 | && (arg[1] != '\\' |
| 3931 | || (s == newval |
| 3932 | && arg[2] != '\\'))) |
| 3933 | #endif |
| 3934 | ) |
| 3935 | ++arg; /* remove backslash */ |
| 3936 | #ifdef FEAT_MBYTE |
| 3937 | if (has_mbyte |
| 3938 | && (i = (*mb_ptr2len_check)(arg)) > 1) |
| 3939 | { |
| 3940 | /* copy multibyte char */ |
| 3941 | mch_memmove(s, arg, (size_t)i); |
| 3942 | arg += i; |
| 3943 | s += i; |
| 3944 | } |
| 3945 | else |
| 3946 | #endif |
| 3947 | *s++ = *arg++; |
| 3948 | } |
| 3949 | *s = NUL; |
| 3950 | |
| 3951 | /* |
| 3952 | * Expand environment variables and ~. |
| 3953 | * Don't do it when adding without inserting a |
| 3954 | * comma. |
| 3955 | */ |
| 3956 | if (!(adding || prepending || removing) |
| 3957 | || (flags & P_COMMA)) |
| 3958 | { |
| 3959 | s = option_expand(opt_idx, newval); |
| 3960 | if (s != NULL) |
| 3961 | { |
| 3962 | vim_free(newval); |
| 3963 | newlen = (unsigned)STRLEN(s) + 1; |
| 3964 | if (adding || prepending || removing) |
| 3965 | newlen += (unsigned)STRLEN(origval) + 1; |
| 3966 | newval = alloc(newlen); |
| 3967 | if (newval == NULL) |
| 3968 | break; |
| 3969 | STRCPY(newval, s); |
| 3970 | } |
| 3971 | } |
| 3972 | |
| 3973 | /* locate newval[] in origval[] when removing it |
| 3974 | * and when adding to avoid duplicates */ |
| 3975 | i = 0; /* init for GCC */ |
| 3976 | if (removing || (flags & P_NODUP)) |
| 3977 | { |
| 3978 | i = (int)STRLEN(newval); |
| 3979 | bs = 0; |
| 3980 | for (s = origval; *s; ++s) |
| 3981 | { |
| 3982 | if ((!(flags & P_COMMA) |
| 3983 | || s == origval |
| 3984 | || (s[-1] == ',' && !(bs & 1))) |
| 3985 | && STRNCMP(s, newval, i) == 0 |
| 3986 | && (!(flags & P_COMMA) |
| 3987 | || s[i] == ',' |
| 3988 | || s[i] == NUL)) |
| 3989 | break; |
| 3990 | /* Count backspaces. Only a comma with an |
| 3991 | * even number of backspaces before it is |
| 3992 | * recognized as a separator */ |
| 3993 | if (s > origval && s[-1] == '\\') |
| 3994 | ++bs; |
| 3995 | else |
| 3996 | bs = 0; |
| 3997 | } |
| 3998 | |
| 3999 | /* do not add if already there */ |
| 4000 | if ((adding || prepending) && *s) |
| 4001 | { |
| 4002 | prepending = FALSE; |
| 4003 | adding = FALSE; |
| 4004 | STRCPY(newval, origval); |
| 4005 | } |
| 4006 | } |
| 4007 | |
| 4008 | /* concatenate the two strings; add a ',' if |
| 4009 | * needed */ |
| 4010 | if (adding || prepending) |
| 4011 | { |
| 4012 | comma = ((flags & P_COMMA) && *origval != NUL |
| 4013 | && *newval != NUL); |
| 4014 | if (adding) |
| 4015 | { |
| 4016 | i = (int)STRLEN(origval); |
| 4017 | mch_memmove(newval + i + comma, newval, |
| 4018 | STRLEN(newval) + 1); |
| 4019 | mch_memmove(newval, origval, (size_t)i); |
| 4020 | } |
| 4021 | else |
| 4022 | { |
| 4023 | i = (int)STRLEN(newval); |
| 4024 | mch_memmove(newval + i + comma, origval, |
| 4025 | STRLEN(origval) + 1); |
| 4026 | } |
| 4027 | if (comma) |
| 4028 | newval[i] = ','; |
| 4029 | } |
| 4030 | |
| 4031 | /* Remove newval[] from origval[]. (Note: "i" has |
| 4032 | * been set above and is used here). */ |
| 4033 | if (removing) |
| 4034 | { |
| 4035 | STRCPY(newval, origval); |
| 4036 | if (*s) |
| 4037 | { |
| 4038 | /* may need to remove a comma */ |
| 4039 | if (flags & P_COMMA) |
| 4040 | { |
| 4041 | if (s == origval) |
| 4042 | { |
| 4043 | /* include comma after string */ |
| 4044 | if (s[i] == ',') |
| 4045 | ++i; |
| 4046 | } |
| 4047 | else |
| 4048 | { |
| 4049 | /* include comma before string */ |
| 4050 | --s; |
| 4051 | ++i; |
| 4052 | } |
| 4053 | } |
| 4054 | mch_memmove(newval + (s - origval), s + i, |
| 4055 | STRLEN(s + i) + 1); |
| 4056 | } |
| 4057 | } |
| 4058 | |
| 4059 | if (flags & P_FLAGLIST) |
| 4060 | { |
| 4061 | /* Remove flags that appear twice. */ |
| 4062 | for (s = newval; *s; ++s) |
| 4063 | if ((!(flags & P_COMMA) || *s != ',') |
| 4064 | && vim_strchr(s + 1, *s) != NULL) |
| 4065 | { |
| 4066 | STRCPY(s, s + 1); |
| 4067 | --s; |
| 4068 | } |
| 4069 | } |
| 4070 | |
| 4071 | if (save_arg != NULL) /* number for 'whichwrap' */ |
| 4072 | arg = save_arg; |
| 4073 | new_value_alloced = TRUE; |
| 4074 | } |
| 4075 | |
| 4076 | /* Set the new value. */ |
| 4077 | *(char_u **)(varp) = newval; |
| 4078 | |
| 4079 | /* Handle side effects, and set the global value for |
| 4080 | * ":set" on local options. */ |
| 4081 | errmsg = did_set_string_option(opt_idx, (char_u **)varp, |
| 4082 | new_value_alloced, oldval, errbuf, opt_flags); |
| 4083 | |
| 4084 | /* If error detected, print the error message. */ |
| 4085 | if (errmsg != NULL) |
| 4086 | goto skip; |
| 4087 | } |
| 4088 | else /* key code option */ |
| 4089 | { |
| 4090 | char_u *p; |
| 4091 | |
| 4092 | if (nextchar == '&') |
| 4093 | { |
| 4094 | if (add_termcap_entry(key_name, TRUE) == FAIL) |
| 4095 | errmsg = (char_u *)N_("E522: Not found in termcap"); |
| 4096 | } |
| 4097 | else |
| 4098 | { |
| 4099 | ++arg; /* jump to after the '=' or ':' */ |
| 4100 | for (p = arg; *p && !vim_iswhite(*p); ++p) |
| 4101 | if (*p == '\\' && p[1] != NUL) |
| 4102 | ++p; |
| 4103 | nextchar = *p; |
| 4104 | *p = NUL; |
| 4105 | add_termcode(key_name, arg, FALSE); |
| 4106 | *p = nextchar; |
| 4107 | } |
| 4108 | if (full_screen) |
| 4109 | ttest(FALSE); |
| 4110 | redraw_all_later(CLEAR); |
| 4111 | } |
| 4112 | } |
| 4113 | if (opt_idx >= 0) |
| 4114 | options[opt_idx].flags |= P_WAS_SET; |
| 4115 | } |
| 4116 | |
| 4117 | skip: |
| 4118 | /* |
| 4119 | * Advance to next argument. |
| 4120 | * - skip until a blank found, taking care of backslashes |
| 4121 | * - skip blanks |
| 4122 | * - skip one "=val" argument (for hidden options ":set gfn =xx") |
| 4123 | */ |
| 4124 | for (i = 0; i < 2 ; ++i) |
| 4125 | { |
| 4126 | while (*arg != NUL && !vim_iswhite(*arg)) |
| 4127 | if (*arg++ == '\\' && *arg != NUL) |
| 4128 | ++arg; |
| 4129 | arg = skipwhite(arg); |
| 4130 | if (*arg != '=') |
| 4131 | break; |
| 4132 | } |
| 4133 | } |
| 4134 | |
| 4135 | if (errmsg != NULL) |
| 4136 | { |
| 4137 | STRNCPY(IObuff, _(errmsg), IOSIZE - 1); |
| 4138 | IObuff[IOSIZE - 1] = NUL; |
| 4139 | i = STRLEN(IObuff) + 2; |
| 4140 | if (i + (arg - startarg) < IOSIZE) |
| 4141 | { |
| 4142 | /* append the argument with the error */ |
| 4143 | STRCAT(IObuff, ": "); |
| 4144 | mch_memmove(IObuff + i, startarg, (arg - startarg)); |
| 4145 | IObuff[i + (arg - startarg)] = NUL; |
| 4146 | } |
| 4147 | /* make sure all characters are printable */ |
| 4148 | trans_characters(IObuff, IOSIZE); |
| 4149 | |
| 4150 | ++no_wait_return; /* wait_return done later */ |
| 4151 | emsg(IObuff); /* show error highlighted */ |
| 4152 | --no_wait_return; |
| 4153 | |
| 4154 | return FAIL; |
| 4155 | } |
| 4156 | |
| 4157 | arg = skipwhite(arg); |
| 4158 | } |
| 4159 | |
| 4160 | return OK; |
| 4161 | } |
| 4162 | |
| 4163 | static char_u * |
| 4164 | illegal_char(errbuf, c) |
| 4165 | char_u *errbuf; |
| 4166 | int c; |
| 4167 | { |
| 4168 | if (errbuf == NULL) |
| 4169 | return (char_u *)""; |
| 4170 | sprintf((char *)errbuf, _("E539: Illegal character <%s>"), |
| 4171 | (char *)transchar(c)); |
| 4172 | return errbuf; |
| 4173 | } |
| 4174 | |
| 4175 | /* |
| 4176 | * Convert a key name or string into a key value. |
| 4177 | * Used for 'wildchar' and 'cedit' options. |
| 4178 | */ |
| 4179 | static int |
| 4180 | string_to_key(arg) |
| 4181 | char_u *arg; |
| 4182 | { |
| 4183 | if (*arg == '<') |
| 4184 | return find_key_option(arg + 1); |
| 4185 | if (*arg == '^') |
| 4186 | return Ctrl_chr(arg[1]); |
| 4187 | return *arg; |
| 4188 | } |
| 4189 | |
| 4190 | #ifdef FEAT_CMDWIN |
| 4191 | /* |
| 4192 | * Check value of 'cedit' and set cedit_key. |
| 4193 | * Returns NULL if value is OK, error message otherwise. |
| 4194 | */ |
| 4195 | static char_u * |
| 4196 | check_cedit() |
| 4197 | { |
| 4198 | int n; |
| 4199 | |
| 4200 | if (*p_cedit == NUL) |
| 4201 | cedit_key = -1; |
| 4202 | else |
| 4203 | { |
| 4204 | n = string_to_key(p_cedit); |
| 4205 | if (vim_isprintc(n)) |
| 4206 | return e_invarg; |
| 4207 | cedit_key = n; |
| 4208 | } |
| 4209 | return NULL; |
| 4210 | } |
| 4211 | #endif |
| 4212 | |
| 4213 | #ifdef FEAT_TITLE |
| 4214 | /* |
| 4215 | * When changing 'title', 'titlestring', 'icon' or 'iconstring', call |
| 4216 | * maketitle() to create and display it. |
| 4217 | * When switching the title or icon off, call mch_restore_title() to get |
| 4218 | * the old value back. |
| 4219 | */ |
| 4220 | static void |
| 4221 | did_set_title(icon) |
| 4222 | int icon; /* Did set icon instead of title */ |
| 4223 | { |
| 4224 | if (starting != NO_SCREEN |
| 4225 | #ifdef FEAT_GUI |
| 4226 | && !gui.starting |
| 4227 | #endif |
| 4228 | ) |
| 4229 | { |
| 4230 | maketitle(); |
| 4231 | if (icon) |
| 4232 | { |
| 4233 | if (!p_icon) |
| 4234 | mch_restore_title(2); |
| 4235 | } |
| 4236 | else |
| 4237 | { |
| 4238 | if (!p_title) |
| 4239 | mch_restore_title(1); |
| 4240 | } |
| 4241 | } |
| 4242 | } |
| 4243 | #endif |
| 4244 | |
| 4245 | /* |
| 4246 | * set_options_bin - called when 'bin' changes value. |
| 4247 | */ |
| 4248 | void |
| 4249 | set_options_bin(oldval, newval, opt_flags) |
| 4250 | int oldval; |
| 4251 | int newval; |
| 4252 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 4253 | { |
| 4254 | /* |
| 4255 | * The option values that are changed when 'bin' changes are |
| 4256 | * copied when 'bin is set and restored when 'bin' is reset. |
| 4257 | */ |
| 4258 | if (newval) |
| 4259 | { |
| 4260 | if (!oldval) /* switched on */ |
| 4261 | { |
| 4262 | if (!(opt_flags & OPT_GLOBAL)) |
| 4263 | { |
| 4264 | curbuf->b_p_tw_nobin = curbuf->b_p_tw; |
| 4265 | curbuf->b_p_wm_nobin = curbuf->b_p_wm; |
| 4266 | curbuf->b_p_ml_nobin = curbuf->b_p_ml; |
| 4267 | curbuf->b_p_et_nobin = curbuf->b_p_et; |
| 4268 | } |
| 4269 | if (!(opt_flags & OPT_LOCAL)) |
| 4270 | { |
| 4271 | p_tw_nobin = p_tw; |
| 4272 | p_wm_nobin = p_wm; |
| 4273 | p_ml_nobin = p_ml; |
| 4274 | p_et_nobin = p_et; |
| 4275 | } |
| 4276 | } |
| 4277 | |
| 4278 | if (!(opt_flags & OPT_GLOBAL)) |
| 4279 | { |
| 4280 | curbuf->b_p_tw = 0; /* no automatic line wrap */ |
| 4281 | curbuf->b_p_wm = 0; /* no automatic line wrap */ |
| 4282 | curbuf->b_p_ml = 0; /* no modelines */ |
| 4283 | curbuf->b_p_et = 0; /* no expandtab */ |
| 4284 | } |
| 4285 | if (!(opt_flags & OPT_LOCAL)) |
| 4286 | { |
| 4287 | p_tw = 0; |
| 4288 | p_wm = 0; |
| 4289 | p_ml = FALSE; |
| 4290 | p_et = FALSE; |
| 4291 | p_bin = TRUE; /* needed when called for the "-b" argument */ |
| 4292 | } |
| 4293 | } |
| 4294 | else if (oldval) /* switched off */ |
| 4295 | { |
| 4296 | if (!(opt_flags & OPT_GLOBAL)) |
| 4297 | { |
| 4298 | curbuf->b_p_tw = curbuf->b_p_tw_nobin; |
| 4299 | curbuf->b_p_wm = curbuf->b_p_wm_nobin; |
| 4300 | curbuf->b_p_ml = curbuf->b_p_ml_nobin; |
| 4301 | curbuf->b_p_et = curbuf->b_p_et_nobin; |
| 4302 | } |
| 4303 | if (!(opt_flags & OPT_LOCAL)) |
| 4304 | { |
| 4305 | p_tw = p_tw_nobin; |
| 4306 | p_wm = p_wm_nobin; |
| 4307 | p_ml = p_ml_nobin; |
| 4308 | p_et = p_et_nobin; |
| 4309 | } |
| 4310 | } |
| 4311 | } |
| 4312 | |
| 4313 | #ifdef FEAT_VIMINFO |
| 4314 | /* |
| 4315 | * Find the parameter represented by the given character (eg ', :, ", or /), |
| 4316 | * and return its associated value in the 'viminfo' string. |
| 4317 | * Only works for number parameters, not for 'r' or 'n'. |
Bram Moolenaar | 15d0a8c | 2004-09-06 17:44:46 +0000 | [diff] [blame] | 4318 | * If the parameter is not specified in the string or there is no following |
| 4319 | * number, return -1. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4320 | */ |
| 4321 | int |
| 4322 | get_viminfo_parameter(type) |
| 4323 | int type; |
| 4324 | { |
| 4325 | char_u *p; |
| 4326 | |
| 4327 | p = find_viminfo_parameter(type); |
| 4328 | if (p != NULL && VIM_ISDIGIT(*p)) |
| 4329 | return atoi((char *)p); |
| 4330 | return -1; |
| 4331 | } |
| 4332 | |
| 4333 | /* |
| 4334 | * Find the parameter represented by the given character (eg ''', ':', '"', or |
| 4335 | * '/') in the 'viminfo' option and return a pointer to the string after it. |
| 4336 | * Return NULL if the parameter is not specified in the string. |
| 4337 | */ |
| 4338 | char_u * |
| 4339 | find_viminfo_parameter(type) |
| 4340 | int type; |
| 4341 | { |
| 4342 | char_u *p; |
| 4343 | |
| 4344 | for (p = p_viminfo; *p; ++p) |
| 4345 | { |
| 4346 | if (*p == type) |
| 4347 | return p + 1; |
| 4348 | if (*p == 'n') /* 'n' is always the last one */ |
| 4349 | break; |
| 4350 | p = vim_strchr(p, ','); /* skip until next ',' */ |
| 4351 | if (p == NULL) /* hit the end without finding parameter */ |
| 4352 | break; |
| 4353 | } |
| 4354 | return NULL; |
| 4355 | } |
| 4356 | #endif |
| 4357 | |
| 4358 | /* |
| 4359 | * Expand environment variables for some string options. |
| 4360 | * These string options cannot be indirect! |
| 4361 | * If "val" is NULL expand the current value of the option. |
| 4362 | * Return pointer to NameBuff, or NULL when not expanded. |
| 4363 | */ |
| 4364 | static char_u * |
| 4365 | option_expand(opt_idx, val) |
| 4366 | int opt_idx; |
| 4367 | char_u *val; |
| 4368 | { |
| 4369 | /* if option doesn't need expansion nothing to do */ |
| 4370 | if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
| 4371 | return NULL; |
| 4372 | |
| 4373 | /* If val is longer than MAXPATHL no meaningful expansion can be done, |
| 4374 | * expand_env() would truncate the string. */ |
| 4375 | if (val != NULL && STRLEN(val) > MAXPATHL) |
| 4376 | return NULL; |
| 4377 | |
| 4378 | if (val == NULL) |
| 4379 | val = *(char_u **)options[opt_idx].var; |
| 4380 | |
| 4381 | /* |
| 4382 | * Expanding this with NameBuff, expand_env() must not be passed IObuff. |
| 4383 | * Escape spaces when expanding 'tags', they are used to separate file |
| 4384 | * names. |
| 4385 | */ |
| 4386 | expand_env_esc(val, NameBuff, MAXPATHL, |
| 4387 | (char_u **)options[opt_idx].var == &p_tags); |
| 4388 | if (STRCMP(NameBuff, val) == 0) /* they are the same */ |
| 4389 | return NULL; |
| 4390 | |
| 4391 | return NameBuff; |
| 4392 | } |
| 4393 | |
| 4394 | /* |
| 4395 | * After setting various option values: recompute variables that depend on |
| 4396 | * option values. |
| 4397 | */ |
| 4398 | static void |
| 4399 | didset_options() |
| 4400 | { |
| 4401 | /* initialize the table for 'iskeyword' et.al. */ |
| 4402 | (void)init_chartab(); |
| 4403 | |
| 4404 | (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); |
| 4405 | (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE); |
| 4406 | #ifdef FEAT_SESSION |
| 4407 | (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE); |
| 4408 | (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE); |
| 4409 | #endif |
| 4410 | #ifdef FEAT_FOLDING |
| 4411 | (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); |
| 4412 | #endif |
| 4413 | (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); |
| 4414 | #ifdef FEAT_VIRTUALEDIT |
| 4415 | (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); |
| 4416 | #endif |
| 4417 | #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) |
| 4418 | (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); |
| 4419 | #endif |
| 4420 | #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
| 4421 | (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); |
| 4422 | #endif |
| 4423 | #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 4424 | (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE); |
| 4425 | #endif |
| 4426 | #ifdef FEAT_CMDWIN |
| 4427 | /* set cedit_key */ |
| 4428 | (void)check_cedit(); |
| 4429 | #endif |
| 4430 | } |
| 4431 | |
| 4432 | /* |
| 4433 | * Check for string options that are NULL (normally only termcap options). |
| 4434 | */ |
| 4435 | void |
| 4436 | check_options() |
| 4437 | { |
| 4438 | int opt_idx; |
| 4439 | |
| 4440 | for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) |
| 4441 | if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) |
| 4442 | check_string_option((char_u **)get_varp(&(options[opt_idx]))); |
| 4443 | } |
| 4444 | |
| 4445 | /* |
| 4446 | * Check string options in a buffer for NULL value. |
| 4447 | */ |
| 4448 | void |
| 4449 | check_buf_options(buf) |
| 4450 | buf_T *buf; |
| 4451 | { |
| 4452 | #if defined(FEAT_QUICKFIX) |
| 4453 | check_string_option(&buf->b_p_bh); |
| 4454 | check_string_option(&buf->b_p_bt); |
| 4455 | #endif |
| 4456 | #ifdef FEAT_MBYTE |
| 4457 | check_string_option(&buf->b_p_fenc); |
| 4458 | #endif |
| 4459 | check_string_option(&buf->b_p_ff); |
| 4460 | #ifdef FEAT_FIND_ID |
| 4461 | check_string_option(&buf->b_p_def); |
| 4462 | check_string_option(&buf->b_p_inc); |
| 4463 | # ifdef FEAT_EVAL |
| 4464 | check_string_option(&buf->b_p_inex); |
| 4465 | # endif |
| 4466 | #endif |
| 4467 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 4468 | check_string_option(&buf->b_p_inde); |
| 4469 | check_string_option(&buf->b_p_indk); |
| 4470 | #endif |
| 4471 | #ifdef FEAT_CRYPT |
| 4472 | check_string_option(&buf->b_p_key); |
| 4473 | #endif |
| 4474 | check_string_option(&buf->b_p_kp); |
| 4475 | check_string_option(&buf->b_p_mps); |
| 4476 | check_string_option(&buf->b_p_fo); |
| 4477 | check_string_option(&buf->b_p_isk); |
| 4478 | #ifdef FEAT_COMMENTS |
| 4479 | check_string_option(&buf->b_p_com); |
| 4480 | #endif |
| 4481 | #ifdef FEAT_FOLDING |
| 4482 | check_string_option(&buf->b_p_cms); |
| 4483 | #endif |
| 4484 | check_string_option(&buf->b_p_nf); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 4485 | #ifdef FEAT_TEXTOBJ |
| 4486 | check_string_option(&buf->b_p_qe); |
| 4487 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4488 | #ifdef FEAT_SYN_HL |
| 4489 | check_string_option(&buf->b_p_syn); |
| 4490 | #endif |
| 4491 | #ifdef FEAT_SEARCHPATH |
| 4492 | check_string_option(&buf->b_p_sua); |
| 4493 | #endif |
| 4494 | #ifdef FEAT_CINDENT |
| 4495 | check_string_option(&buf->b_p_cink); |
| 4496 | check_string_option(&buf->b_p_cino); |
| 4497 | #endif |
| 4498 | #ifdef FEAT_AUTOCMD |
| 4499 | check_string_option(&buf->b_p_ft); |
| 4500 | #endif |
| 4501 | #ifdef FEAT_OSFILETYPE |
| 4502 | check_string_option(&buf->b_p_oft); |
| 4503 | #endif |
| 4504 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 4505 | check_string_option(&buf->b_p_cinw); |
| 4506 | #endif |
| 4507 | #ifdef FEAT_INS_EXPAND |
| 4508 | check_string_option(&buf->b_p_cpt); |
| 4509 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 4510 | #ifdef FEAT_COMPL_FUNC |
| 4511 | check_string_option(&buf->b_p_cfu); |
| 4512 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4513 | #ifdef FEAT_KEYMAP |
| 4514 | check_string_option(&buf->b_p_keymap); |
| 4515 | #endif |
| 4516 | #ifdef FEAT_QUICKFIX |
| 4517 | check_string_option(&buf->b_p_gp); |
| 4518 | check_string_option(&buf->b_p_mp); |
| 4519 | check_string_option(&buf->b_p_efm); |
| 4520 | #endif |
| 4521 | check_string_option(&buf->b_p_ep); |
| 4522 | check_string_option(&buf->b_p_path); |
| 4523 | check_string_option(&buf->b_p_tags); |
| 4524 | #ifdef FEAT_INS_EXPAND |
| 4525 | check_string_option(&buf->b_p_dict); |
| 4526 | check_string_option(&buf->b_p_tsr); |
| 4527 | #endif |
| 4528 | } |
| 4529 | |
| 4530 | /* |
| 4531 | * Free the string allocated for an option. |
| 4532 | * Checks for the string being empty_option. This may happen if we're out of |
| 4533 | * memory, vim_strsave() returned NULL, which was replaced by empty_option by |
| 4534 | * check_options(). |
| 4535 | * Does NOT check for P_ALLOCED flag! |
| 4536 | */ |
| 4537 | void |
| 4538 | free_string_option(p) |
| 4539 | char_u *p; |
| 4540 | { |
| 4541 | if (p != empty_option) |
| 4542 | vim_free(p); |
| 4543 | } |
| 4544 | |
| 4545 | void |
| 4546 | clear_string_option(pp) |
| 4547 | char_u **pp; |
| 4548 | { |
| 4549 | if (*pp != empty_option) |
| 4550 | vim_free(*pp); |
| 4551 | *pp = empty_option; |
| 4552 | } |
| 4553 | |
| 4554 | static void |
| 4555 | check_string_option(pp) |
| 4556 | char_u **pp; |
| 4557 | { |
| 4558 | if (*pp == NULL) |
| 4559 | *pp = empty_option; |
| 4560 | } |
| 4561 | |
| 4562 | /* |
| 4563 | * Mark a terminal option as allocated, found by a pointer into term_strings[]. |
| 4564 | */ |
| 4565 | void |
| 4566 | set_term_option_alloced(p) |
| 4567 | char_u **p; |
| 4568 | { |
| 4569 | int opt_idx; |
| 4570 | |
| 4571 | for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) |
| 4572 | if (options[opt_idx].var == (char_u *)p) |
| 4573 | { |
| 4574 | options[opt_idx].flags |= P_ALLOCED; |
| 4575 | return; |
| 4576 | } |
| 4577 | return; /* cannot happen: didn't find it! */ |
| 4578 | } |
| 4579 | |
| 4580 | /* |
| 4581 | * Set a string option to a new value (without checking the effect). |
| 4582 | * The string is copied into allocated memory. |
| 4583 | * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. |
| 4584 | */ |
| 4585 | void |
| 4586 | set_string_option_direct(name, opt_idx, val, opt_flags) |
| 4587 | char_u *name; |
| 4588 | int opt_idx; |
| 4589 | char_u *val; |
| 4590 | int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
| 4591 | { |
| 4592 | char_u *s; |
| 4593 | char_u **varp; |
| 4594 | int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
| 4595 | |
| 4596 | if (opt_idx == -1) /* use name */ |
| 4597 | { |
| 4598 | opt_idx = findoption(name); |
| 4599 | if (opt_idx == -1) /* not found (should not happen) */ |
| 4600 | return; |
| 4601 | } |
| 4602 | |
| 4603 | if (options[opt_idx].var == NULL) /* can't set hidden option */ |
| 4604 | return; |
| 4605 | |
| 4606 | s = vim_strsave(val); |
| 4607 | if (s != NULL) |
| 4608 | { |
| 4609 | varp = (char_u **)get_varp_scope(&(options[opt_idx]), |
| 4610 | both ? OPT_LOCAL : opt_flags); |
| 4611 | if ((opt_flags & OPT_FREE) && (options[opt_idx].flags & P_ALLOCED)) |
| 4612 | free_string_option(*varp); |
| 4613 | *varp = s; |
| 4614 | |
| 4615 | /* For buffer/window local option may also set the global value. */ |
| 4616 | if (both) |
| 4617 | set_string_option_global(opt_idx, varp); |
| 4618 | |
| 4619 | options[opt_idx].flags |= P_ALLOCED; |
| 4620 | |
| 4621 | /* When setting both values of a global option with a local value, |
| 4622 | * make the local value empty, so that the global value is used. */ |
| 4623 | if ((int)options[opt_idx].indir >= PV_BOTH && both) |
| 4624 | { |
| 4625 | free_string_option(*varp); |
| 4626 | *varp = empty_option; |
| 4627 | } |
| 4628 | } |
| 4629 | } |
| 4630 | |
| 4631 | /* |
| 4632 | * Set global value for string option when it's a local option. |
| 4633 | */ |
| 4634 | static void |
| 4635 | set_string_option_global(opt_idx, varp) |
| 4636 | int opt_idx; /* option index */ |
| 4637 | char_u **varp; /* pointer to option variable */ |
| 4638 | { |
| 4639 | char_u **p, *s; |
| 4640 | |
| 4641 | /* the global value is always allocated */ |
| 4642 | if (options[opt_idx].var == VAR_WIN) |
| 4643 | p = (char_u **)GLOBAL_WO(varp); |
| 4644 | else |
| 4645 | p = (char_u **)options[opt_idx].var; |
| 4646 | if (options[opt_idx].indir != PV_NONE |
| 4647 | && p != varp |
| 4648 | && (s = vim_strsave(*varp)) != NULL) |
| 4649 | { |
| 4650 | free_string_option(*p); |
| 4651 | *p = s; |
| 4652 | } |
| 4653 | } |
| 4654 | |
| 4655 | /* |
| 4656 | * Set a string option to a new value, and handle the effects. |
| 4657 | */ |
| 4658 | static void |
| 4659 | set_string_option(opt_idx, value, opt_flags) |
| 4660 | int opt_idx; |
| 4661 | char_u *value; |
| 4662 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 4663 | { |
| 4664 | char_u *s; |
| 4665 | char_u **varp; |
| 4666 | char_u *oldval; |
| 4667 | |
| 4668 | if (options[opt_idx].var == NULL) /* don't set hidden option */ |
| 4669 | return; |
| 4670 | |
| 4671 | s = vim_strsave(value); |
| 4672 | if (s != NULL) |
| 4673 | { |
| 4674 | varp = (char_u **)get_varp_scope(&(options[opt_idx]), |
| 4675 | (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
| 4676 | ? ((int)options[opt_idx].indir >= PV_BOTH |
| 4677 | ? OPT_GLOBAL : OPT_LOCAL) |
| 4678 | : opt_flags); |
| 4679 | oldval = *varp; |
| 4680 | *varp = s; |
| 4681 | options[opt_idx].flags |= P_WAS_SET; |
| 4682 | (void)did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, |
| 4683 | opt_flags); |
| 4684 | } |
| 4685 | } |
| 4686 | |
| 4687 | /* |
| 4688 | * Handle string options that need some action to perform when changed. |
| 4689 | * Returns NULL for success, or an error message for an error. |
| 4690 | */ |
| 4691 | static char_u * |
| 4692 | did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, |
| 4693 | opt_flags) |
| 4694 | int opt_idx; /* index in options[] table */ |
| 4695 | char_u **varp; /* pointer to the option variable */ |
| 4696 | int new_value_alloced; /* new value was allocated */ |
| 4697 | char_u *oldval; /* previous value of the option */ |
| 4698 | char_u *errbuf; /* buffer for errors, or NULL */ |
| 4699 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 4700 | { |
| 4701 | char_u *errmsg = NULL; |
| 4702 | char_u *s, *p; |
| 4703 | int did_chartab = FALSE; |
| 4704 | char_u **gvarp; |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 4705 | int free_oldval = (options[opt_idx].flags & P_ALLOCED); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4706 | |
| 4707 | /* Get the global option to compare with, otherwise we would have to check |
| 4708 | * two values for all local options. */ |
| 4709 | gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); |
| 4710 | |
| 4711 | /* Disallow changing some options from secure mode */ |
| 4712 | if ((secure |
| 4713 | #ifdef HAVE_SANDBOX |
| 4714 | || sandbox != 0 |
| 4715 | #endif |
| 4716 | ) && (options[opt_idx].flags & P_SECURE)) |
| 4717 | { |
| 4718 | errmsg = e_secure; |
| 4719 | } |
| 4720 | |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 4721 | /* Check for a "normal" file name in some options. Disallow a path |
| 4722 | * separator (slash and/or backslash), wildcards and characters that are |
| 4723 | * often illegal in a file name. */ |
| 4724 | else if ((options[opt_idx].flags & P_NFNAME) |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 4725 | && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 4726 | { |
| 4727 | errmsg = e_invarg; |
| 4728 | } |
| 4729 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4730 | /* 'term' */ |
| 4731 | else if (varp == &T_NAME) |
| 4732 | { |
| 4733 | if (T_NAME[0] == NUL) |
| 4734 | errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); |
| 4735 | #ifdef FEAT_GUI |
| 4736 | if (gui.in_use) |
| 4737 | errmsg = (char_u *)N_("E530: Cannot change term in GUI"); |
| 4738 | else if (term_is_gui(T_NAME)) |
| 4739 | errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI"); |
| 4740 | #endif |
| 4741 | else if (set_termname(T_NAME) == FAIL) |
| 4742 | errmsg = (char_u *)N_("E522: Not found in termcap"); |
| 4743 | else |
| 4744 | /* Screen colors may have changed. */ |
| 4745 | redraw_later_clear(); |
| 4746 | } |
| 4747 | |
| 4748 | /* 'backupcopy' */ |
| 4749 | else if (varp == &p_bkc) |
| 4750 | { |
| 4751 | if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK) |
| 4752 | errmsg = e_invarg; |
| 4753 | if (((bkc_flags & BKC_AUTO) != 0) |
| 4754 | + ((bkc_flags & BKC_YES) != 0) |
| 4755 | + ((bkc_flags & BKC_NO) != 0) != 1) |
| 4756 | { |
| 4757 | /* Must have exactly one of "auto", "yes" and "no". */ |
| 4758 | (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE); |
| 4759 | errmsg = e_invarg; |
| 4760 | } |
| 4761 | } |
| 4762 | |
| 4763 | /* 'backupext' and 'patchmode' */ |
| 4764 | else if (varp == &p_bex || varp == &p_pm) |
| 4765 | { |
| 4766 | if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, |
| 4767 | *p_pm == '.' ? p_pm + 1 : p_pm) == 0) |
| 4768 | errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal"); |
| 4769 | } |
| 4770 | |
| 4771 | /* |
| 4772 | * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[] |
| 4773 | * If the new option is invalid, use old value. 'lisp' option: refill |
| 4774 | * chartab[] for '-' char |
| 4775 | */ |
| 4776 | else if ( varp == &p_isi |
| 4777 | || varp == &(curbuf->b_p_isk) |
| 4778 | || varp == &p_isp |
| 4779 | || varp == &p_isf) |
| 4780 | { |
| 4781 | if (init_chartab() == FAIL) |
| 4782 | { |
| 4783 | did_chartab = TRUE; /* need to restore it below */ |
| 4784 | errmsg = e_invarg; /* error in value */ |
| 4785 | } |
| 4786 | } |
| 4787 | |
| 4788 | /* 'helpfile' */ |
| 4789 | else if (varp == &p_hf) |
| 4790 | { |
| 4791 | /* May compute new values for $VIM and $VIMRUNTIME */ |
| 4792 | if (didset_vim) |
| 4793 | { |
| 4794 | vim_setenv((char_u *)"VIM", (char_u *)""); |
| 4795 | didset_vim = FALSE; |
| 4796 | } |
| 4797 | if (didset_vimruntime) |
| 4798 | { |
| 4799 | vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); |
| 4800 | didset_vimruntime = FALSE; |
| 4801 | } |
| 4802 | } |
| 4803 | |
| 4804 | #ifdef FEAT_MULTI_LANG |
| 4805 | /* 'helplang' */ |
| 4806 | else if (varp == &p_hlg) |
| 4807 | { |
| 4808 | /* Check for "", "ab", "ab,cd", etc. */ |
| 4809 | for (s = p_hlg; *s != NUL; s += 3) |
| 4810 | { |
| 4811 | if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) |
| 4812 | { |
| 4813 | errmsg = e_invarg; |
| 4814 | break; |
| 4815 | } |
| 4816 | if (s[2] == NUL) |
| 4817 | break; |
| 4818 | } |
| 4819 | } |
| 4820 | #endif |
| 4821 | |
| 4822 | /* 'highlight' */ |
| 4823 | else if (varp == &p_hl) |
| 4824 | { |
| 4825 | if (highlight_changed() == FAIL) |
| 4826 | errmsg = e_invarg; /* invalid flags */ |
| 4827 | } |
| 4828 | |
| 4829 | /* 'nrformats' */ |
| 4830 | else if (gvarp == &p_nf) |
| 4831 | { |
| 4832 | if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) |
| 4833 | errmsg = e_invarg; |
| 4834 | } |
| 4835 | |
| 4836 | #ifdef FEAT_SESSION |
| 4837 | /* 'sessionoptions' */ |
| 4838 | else if (varp == &p_ssop) |
| 4839 | { |
| 4840 | if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) |
| 4841 | errmsg = e_invarg; |
| 4842 | if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) |
| 4843 | { |
| 4844 | /* Don't allow both "sesdir" and "curdir". */ |
| 4845 | (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); |
| 4846 | errmsg = e_invarg; |
| 4847 | } |
| 4848 | } |
| 4849 | /* 'viewoptions' */ |
| 4850 | else if (varp == &p_vop) |
| 4851 | { |
| 4852 | if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) |
| 4853 | errmsg = e_invarg; |
| 4854 | } |
| 4855 | #endif |
| 4856 | |
| 4857 | /* 'scrollopt' */ |
| 4858 | #ifdef FEAT_SCROLLBIND |
| 4859 | else if (varp == &p_sbo) |
| 4860 | { |
| 4861 | if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) |
| 4862 | errmsg = e_invarg; |
| 4863 | } |
| 4864 | #endif |
| 4865 | |
| 4866 | /* 'ambiwidth' */ |
| 4867 | #ifdef FEAT_MBYTE |
| 4868 | else if (varp == &p_ambw) |
| 4869 | { |
| 4870 | if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) |
| 4871 | errmsg = e_invarg; |
| 4872 | } |
| 4873 | #endif |
| 4874 | |
| 4875 | /* 'background' */ |
| 4876 | else if (varp == &p_bg) |
| 4877 | { |
| 4878 | if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) |
| 4879 | { |
| 4880 | #ifdef FEAT_EVAL |
| 4881 | int dark = (*p_bg == 'd'); |
| 4882 | #endif |
| 4883 | |
| 4884 | init_highlight(FALSE, FALSE); |
| 4885 | |
| 4886 | #ifdef FEAT_EVAL |
| 4887 | if (dark != (*p_bg == 'd') |
| 4888 | && get_var_value((char_u *)"g:colors_name") != NULL) |
| 4889 | { |
| 4890 | /* The color scheme must have set 'background' back to another |
| 4891 | * value, that's not what we want here. Disable the color |
| 4892 | * scheme and set the colors again. */ |
| 4893 | do_unlet((char_u *)"g:colors_name"); |
| 4894 | free_string_option(p_bg); |
| 4895 | p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); |
| 4896 | check_string_option(&p_bg); |
| 4897 | init_highlight(FALSE, FALSE); |
| 4898 | } |
| 4899 | #endif |
| 4900 | } |
| 4901 | else |
| 4902 | errmsg = e_invarg; |
| 4903 | } |
| 4904 | |
| 4905 | /* 'wildmode' */ |
| 4906 | else if (varp == &p_wim) |
| 4907 | { |
| 4908 | if (check_opt_wim() == FAIL) |
| 4909 | errmsg = e_invarg; |
| 4910 | } |
| 4911 | |
| 4912 | #ifdef FEAT_WAK |
| 4913 | /* 'winaltkeys' */ |
| 4914 | else if (varp == &p_wak) |
| 4915 | { |
| 4916 | if (*p_wak == NUL |
| 4917 | || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) |
| 4918 | errmsg = e_invarg; |
| 4919 | # ifdef FEAT_MENU |
| 4920 | # ifdef FEAT_GUI_MOTIF |
| 4921 | else if (gui.in_use) |
| 4922 | gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); |
| 4923 | # else |
| 4924 | # ifdef FEAT_GUI_GTK |
| 4925 | else if (gui.in_use) |
| 4926 | gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); |
| 4927 | # endif |
| 4928 | # endif |
| 4929 | # endif |
| 4930 | } |
| 4931 | #endif |
| 4932 | |
| 4933 | #ifdef FEAT_AUTOCMD |
| 4934 | /* 'eventignore' */ |
| 4935 | else if (varp == &p_ei) |
| 4936 | { |
| 4937 | if (check_ei() == FAIL) |
| 4938 | errmsg = e_invarg; |
| 4939 | } |
| 4940 | #endif |
| 4941 | |
| 4942 | #ifdef FEAT_MBYTE |
| 4943 | /* 'encoding' and 'fileencoding' */ |
| 4944 | else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc) |
| 4945 | { |
| 4946 | if (gvarp == &p_fenc) |
| 4947 | { |
| 4948 | if (!curbuf->b_p_ma) |
| 4949 | errmsg = e_modifiable; |
| 4950 | else if (vim_strchr(*varp, ',') != NULL) |
| 4951 | /* No comma allowed in 'fileencoding'; catches confusing it |
| 4952 | * with 'fileencodings'. */ |
| 4953 | errmsg = e_invarg; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4954 | else |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 4955 | { |
| 4956 | # ifdef FEAT_TITLE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4957 | /* May show a "+" in the title now. */ |
| 4958 | need_maketitle = TRUE; |
| 4959 | # endif |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 4960 | /* Add 'fileencoding' to the swap file. */ |
| 4961 | ml_setflags(curbuf); |
| 4962 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4963 | } |
| 4964 | if (errmsg == NULL) |
| 4965 | { |
| 4966 | /* canonize the value, so that STRCMP() can be used on it */ |
| 4967 | p = enc_canonize(*varp); |
| 4968 | if (p != NULL) |
| 4969 | { |
| 4970 | vim_free(*varp); |
| 4971 | *varp = p; |
| 4972 | } |
| 4973 | if (varp == &p_enc) |
| 4974 | { |
| 4975 | errmsg = mb_init(); |
| 4976 | # ifdef FEAT_TITLE |
| 4977 | need_maketitle = TRUE; |
| 4978 | # endif |
| 4979 | } |
| 4980 | } |
| 4981 | |
| 4982 | # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 4983 | if (errmsg == NULL && varp == &p_tenc && gui.in_use) |
| 4984 | { |
| 4985 | /* GTK+ 2 uses only a single encoding, and that is UTF-8. */ |
| 4986 | if (STRCMP(p_tenc, "utf-8") != 0) |
| 4987 | errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI"); |
| 4988 | } |
| 4989 | # endif |
| 4990 | |
| 4991 | if (errmsg == NULL) |
| 4992 | { |
| 4993 | # ifdef FEAT_KEYMAP |
| 4994 | /* When 'keymap' is used and 'encoding' changes, reload the keymap |
| 4995 | * (with another encoding). */ |
| 4996 | if (varp == &p_enc && *curbuf->b_p_keymap != NUL) |
| 4997 | (void)keymap_init(); |
| 4998 | # endif |
| 4999 | |
| 5000 | /* When 'termencoding' is not empty and 'encoding' changes or when |
| 5001 | * 'termencoding' changes, need to setup for keyboard input and |
| 5002 | * display output conversion. */ |
| 5003 | if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) |
| 5004 | { |
| 5005 | convert_setup(&input_conv, p_tenc, p_enc); |
| 5006 | convert_setup(&output_conv, p_enc, p_tenc); |
| 5007 | } |
| 5008 | } |
| 5009 | } |
| 5010 | #endif |
| 5011 | |
| 5012 | #if defined(FEAT_POSTSCRIPT) |
| 5013 | else if (varp == &p_penc) |
| 5014 | { |
| 5015 | /* Canonize printencoding if VIM standard one */ |
| 5016 | p = enc_canonize(p_penc); |
| 5017 | if (p != NULL) |
| 5018 | { |
| 5019 | vim_free(p_penc); |
| 5020 | p_penc = p; |
| 5021 | } |
| 5022 | else |
| 5023 | { |
| 5024 | /* Ensure lower case and '-' for '_' */ |
| 5025 | for (s = p_penc; *s != NUL; s++) |
| 5026 | { |
| 5027 | if (*s == '_') |
| 5028 | *s = '-'; |
| 5029 | else |
| 5030 | *s = TOLOWER_ASC(*s); |
| 5031 | } |
| 5032 | } |
| 5033 | } |
| 5034 | #endif |
| 5035 | |
Bram Moolenaar | 843ee41 | 2004-06-30 16:16:41 +0000 | [diff] [blame] | 5036 | #if defined(FEAT_XIM) && ( defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) ) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5037 | else if (varp == &p_imak) |
| 5038 | { |
| 5039 | if (gui.in_use && !im_xim_isvalid_imactivate()) |
| 5040 | errmsg = e_invarg; |
| 5041 | } |
| 5042 | #endif |
| 5043 | |
| 5044 | #ifdef FEAT_KEYMAP |
| 5045 | else if (varp == &curbuf->b_p_keymap) |
| 5046 | { |
| 5047 | /* load or unload key mapping tables */ |
| 5048 | errmsg = keymap_init(); |
| 5049 | |
| 5050 | /* When successfully installed a new keymap switch on using it. */ |
| 5051 | if (*curbuf->b_p_keymap != NUL && errmsg == NULL) |
| 5052 | { |
| 5053 | curbuf->b_p_iminsert = B_IMODE_LMAP; |
| 5054 | if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) |
| 5055 | curbuf->b_p_imsearch = B_IMODE_LMAP; |
| 5056 | set_iminsert_global(); |
| 5057 | set_imsearch_global(); |
| 5058 | # ifdef FEAT_WINDOWS |
| 5059 | status_redraw_curbuf(); |
| 5060 | # endif |
| 5061 | } |
| 5062 | } |
| 5063 | #endif |
| 5064 | |
| 5065 | /* 'fileformat' */ |
| 5066 | else if (gvarp == &p_ff) |
| 5067 | { |
| 5068 | if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) |
| 5069 | errmsg = e_modifiable; |
| 5070 | else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) |
| 5071 | errmsg = e_invarg; |
| 5072 | else |
| 5073 | { |
| 5074 | /* may also change 'textmode' */ |
| 5075 | if (get_fileformat(curbuf) == EOL_DOS) |
| 5076 | curbuf->b_p_tx = TRUE; |
| 5077 | else |
| 5078 | curbuf->b_p_tx = FALSE; |
| 5079 | #ifdef FEAT_TITLE |
| 5080 | need_maketitle = TRUE; |
| 5081 | #endif |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 5082 | /* update flag in swap file */ |
| 5083 | ml_setflags(curbuf); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5084 | } |
| 5085 | } |
| 5086 | |
| 5087 | /* 'fileformats' */ |
| 5088 | else if (varp == &p_ffs) |
| 5089 | { |
| 5090 | if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) |
| 5091 | errmsg = e_invarg; |
| 5092 | else |
| 5093 | { |
| 5094 | /* also change 'textauto' */ |
| 5095 | if (*p_ffs == NUL) |
| 5096 | p_ta = FALSE; |
| 5097 | else |
| 5098 | p_ta = TRUE; |
| 5099 | } |
| 5100 | } |
| 5101 | |
| 5102 | #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST) |
| 5103 | /* 'cryptkey' */ |
| 5104 | else if (gvarp == &p_key) |
| 5105 | { |
| 5106 | /* Make sure the ":set" command doesn't show the new value in the |
| 5107 | * history. */ |
| 5108 | remove_key_from_history(); |
| 5109 | } |
| 5110 | #endif |
| 5111 | |
| 5112 | /* 'matchpairs' */ |
| 5113 | else if (gvarp == &p_mps) |
| 5114 | { |
| 5115 | /* Check for "x:y,x:y" */ |
| 5116 | for (p = *varp; *p != NUL; p += 4) |
| 5117 | { |
| 5118 | if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) |
| 5119 | { |
| 5120 | errmsg = e_invarg; |
| 5121 | break; |
| 5122 | } |
| 5123 | if (p[3] == NUL) |
| 5124 | break; |
| 5125 | } |
| 5126 | } |
| 5127 | |
| 5128 | #ifdef FEAT_COMMENTS |
| 5129 | /* 'comments' */ |
| 5130 | else if (gvarp == &p_com) |
| 5131 | { |
| 5132 | for (s = *varp; *s; ) |
| 5133 | { |
| 5134 | while (*s && *s != ':') |
| 5135 | { |
| 5136 | if (vim_strchr((char_u *)COM_ALL, *s) == NULL |
| 5137 | && !VIM_ISDIGIT(*s) && *s != '-') |
| 5138 | { |
| 5139 | errmsg = illegal_char(errbuf, *s); |
| 5140 | break; |
| 5141 | } |
| 5142 | ++s; |
| 5143 | } |
| 5144 | if (*s++ == NUL) |
| 5145 | errmsg = (char_u *)N_("E524: Missing colon"); |
| 5146 | else if (*s == ',' || *s == NUL) |
| 5147 | errmsg = (char_u *)N_("E525: Zero length string"); |
| 5148 | if (errmsg != NULL) |
| 5149 | break; |
| 5150 | while (*s && *s != ',') |
| 5151 | { |
| 5152 | if (*s == '\\' && s[1] != NUL) |
| 5153 | ++s; |
| 5154 | ++s; |
| 5155 | } |
| 5156 | s = skip_to_option_part(s); |
| 5157 | } |
| 5158 | } |
| 5159 | #endif |
| 5160 | |
| 5161 | /* 'listchars' */ |
| 5162 | else if (varp == &p_lcs) |
| 5163 | { |
| 5164 | errmsg = set_chars_option(varp); |
| 5165 | } |
| 5166 | |
| 5167 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 5168 | /* 'fillchars' */ |
| 5169 | else if (varp == &p_fcs) |
| 5170 | { |
| 5171 | errmsg = set_chars_option(varp); |
| 5172 | } |
| 5173 | #endif |
| 5174 | |
| 5175 | #ifdef FEAT_CMDWIN |
| 5176 | /* 'cedit' */ |
| 5177 | else if (varp == &p_cedit) |
| 5178 | { |
| 5179 | errmsg = check_cedit(); |
| 5180 | } |
| 5181 | #endif |
| 5182 | |
| 5183 | #ifdef FEAT_VIMINFO |
| 5184 | /* 'viminfo' */ |
| 5185 | else if (varp == &p_viminfo) |
| 5186 | { |
| 5187 | for (s = p_viminfo; *s;) |
| 5188 | { |
| 5189 | /* Check it's a valid character */ |
| 5190 | if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) |
| 5191 | { |
| 5192 | errmsg = illegal_char(errbuf, *s); |
| 5193 | break; |
| 5194 | } |
| 5195 | if (*s == 'n') /* name is always last one */ |
| 5196 | { |
| 5197 | break; |
| 5198 | } |
| 5199 | else if (*s == 'r') /* skip until next ',' */ |
| 5200 | { |
| 5201 | while (*++s && *s != ',') |
| 5202 | ; |
| 5203 | } |
Bram Moolenaar | 15d0a8c | 2004-09-06 17:44:46 +0000 | [diff] [blame] | 5204 | else if (*s == '%') |
| 5205 | { |
| 5206 | /* optional number */ |
| 5207 | while (vim_isdigit(*++s)) |
| 5208 | ; |
| 5209 | } |
| 5210 | else if (*s == '!' || *s == 'h' || *s == 'c') |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5211 | ++s; /* no extra chars */ |
| 5212 | else /* must have a number */ |
| 5213 | { |
| 5214 | while (vim_isdigit(*++s)) |
| 5215 | ; |
| 5216 | |
| 5217 | if (!VIM_ISDIGIT(*(s - 1))) |
| 5218 | { |
| 5219 | if (errbuf != NULL) |
| 5220 | { |
| 5221 | sprintf((char *)errbuf, _("E526: Missing number after <%s>"), |
| 5222 | transchar_byte(*(s - 1))); |
| 5223 | errmsg = errbuf; |
| 5224 | } |
| 5225 | else |
| 5226 | errmsg = (char_u *)""; |
| 5227 | break; |
| 5228 | } |
| 5229 | } |
| 5230 | if (*s == ',') |
| 5231 | ++s; |
| 5232 | else if (*s) |
| 5233 | { |
| 5234 | if (errbuf != NULL) |
| 5235 | errmsg = (char_u *)N_("E527: Missing comma"); |
| 5236 | else |
| 5237 | errmsg = (char_u *)""; |
| 5238 | break; |
| 5239 | } |
| 5240 | } |
| 5241 | if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) |
| 5242 | errmsg = (char_u *)N_("E528: Must specify a ' value"); |
| 5243 | } |
| 5244 | #endif /* FEAT_VIMINFO */ |
| 5245 | |
| 5246 | /* terminal options */ |
| 5247 | else if (istermoption(&options[opt_idx]) && full_screen) |
| 5248 | { |
| 5249 | /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ |
| 5250 | if (varp == &T_CCO) |
| 5251 | { |
| 5252 | t_colors = atoi((char *)T_CCO); |
| 5253 | if (t_colors <= 1) |
| 5254 | { |
| 5255 | if (new_value_alloced) |
| 5256 | vim_free(T_CCO); |
| 5257 | T_CCO = empty_option; |
| 5258 | } |
| 5259 | /* We now have a different color setup, initialize it again. */ |
| 5260 | init_highlight(TRUE, FALSE); |
| 5261 | } |
| 5262 | ttest(FALSE); |
| 5263 | if (varp == &T_ME) |
| 5264 | { |
| 5265 | out_str(T_ME); |
| 5266 | redraw_later(CLEAR); |
| 5267 | #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32)) |
| 5268 | /* Since t_me has been set, this probably means that the user |
| 5269 | * wants to use this as default colors. Need to reset default |
| 5270 | * background/foreground colors. */ |
| 5271 | mch_set_normal_colors(); |
| 5272 | #endif |
| 5273 | } |
| 5274 | } |
| 5275 | |
| 5276 | #ifdef FEAT_LINEBREAK |
| 5277 | /* 'showbreak' */ |
| 5278 | else if (varp == &p_sbr) |
| 5279 | { |
| 5280 | for (s = p_sbr; *s; ) |
| 5281 | { |
| 5282 | if (ptr2cells(s) != 1) |
| 5283 | errmsg = (char_u *)N_("E595: contains unprintable or wide character"); |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 5284 | mb_ptr_adv(s); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5285 | } |
| 5286 | } |
| 5287 | #endif |
| 5288 | |
| 5289 | #ifdef FEAT_GUI |
| 5290 | /* 'guifont' */ |
| 5291 | else if (varp == &p_guifont) |
| 5292 | { |
| 5293 | if (gui.in_use) |
| 5294 | { |
| 5295 | p = p_guifont; |
Bram Moolenaar | 843ee41 | 2004-06-30 16:16:41 +0000 | [diff] [blame] | 5296 | # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5297 | /* |
| 5298 | * Put up a font dialog and let the user select a new value. |
| 5299 | * If this is cancelled go back to the old value but don't |
| 5300 | * give an error message. |
| 5301 | */ |
| 5302 | if (STRCMP(p, "*") == 0) |
| 5303 | { |
| 5304 | p = gui_mch_font_dialog(oldval); |
| 5305 | |
| 5306 | if (new_value_alloced) |
| 5307 | free_string_option(p_guifont); |
| 5308 | |
| 5309 | p_guifont = (p != NULL) ? p : vim_strsave(oldval); |
| 5310 | new_value_alloced = TRUE; |
| 5311 | } |
| 5312 | # endif |
| 5313 | if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) |
| 5314 | { |
| 5315 | # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) |
| 5316 | if (STRCMP(p_guifont, "*") == 0) |
| 5317 | { |
| 5318 | /* Dialog was cancelled: Keep the old value without giving |
| 5319 | * an error message. */ |
| 5320 | if (new_value_alloced) |
| 5321 | free_string_option(p_guifont); |
| 5322 | p_guifont = vim_strsave(oldval); |
| 5323 | new_value_alloced = TRUE; |
| 5324 | } |
| 5325 | else |
| 5326 | # endif |
| 5327 | errmsg = (char_u *)N_("E596: Invalid font(s)"); |
| 5328 | } |
| 5329 | } |
| 5330 | } |
| 5331 | # ifdef FEAT_XFONTSET |
| 5332 | else if (varp == &p_guifontset) |
| 5333 | { |
| 5334 | if (STRCMP(p_guifontset, "*") == 0) |
| 5335 | errmsg = (char_u *)N_("E597: can't select fontset"); |
| 5336 | else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) |
| 5337 | errmsg = (char_u *)N_("E598: Invalid fontset"); |
| 5338 | } |
| 5339 | # endif |
| 5340 | # ifdef FEAT_MBYTE |
| 5341 | else if (varp == &p_guifontwide) |
| 5342 | { |
| 5343 | if (STRCMP(p_guifontwide, "*") == 0) |
| 5344 | errmsg = (char_u *)N_("E533: can't select wide font"); |
| 5345 | else if (gui_get_wide_font() == FAIL) |
| 5346 | errmsg = (char_u *)N_("E534: Invalid wide font"); |
| 5347 | } |
| 5348 | # endif |
| 5349 | #endif |
| 5350 | |
| 5351 | #ifdef CURSOR_SHAPE |
| 5352 | /* 'guicursor' */ |
| 5353 | else if (varp == &p_guicursor) |
| 5354 | errmsg = parse_shape_opt(SHAPE_CURSOR); |
| 5355 | #endif |
| 5356 | |
| 5357 | #ifdef FEAT_MOUSESHAPE |
| 5358 | /* 'mouseshape' */ |
| 5359 | else if (varp == &p_mouseshape) |
| 5360 | { |
| 5361 | errmsg = parse_shape_opt(SHAPE_MOUSE); |
| 5362 | update_mouseshape(-1); |
| 5363 | } |
| 5364 | #endif |
| 5365 | |
| 5366 | #ifdef FEAT_PRINTER |
| 5367 | else if (varp == &p_popt) |
Bram Moolenaar | 269ec65 | 2004-07-29 08:43:53 +0000 | [diff] [blame] | 5368 | errmsg = parse_list_options(p_popt, printer_opts, |
| 5369 | OPT_PRINT_NUM_OPTIONS); |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 5370 | |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 5371 | # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT) |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 5372 | else if (varp == &p_pmfn) |
Bram Moolenaar | 269ec65 | 2004-07-29 08:43:53 +0000 | [diff] [blame] | 5373 | errmsg = parse_list_options(p_pmfn, mbfont_opts, |
| 5374 | OPT_MBFONT_NUM_OPTIONS); |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 5375 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5376 | #endif |
| 5377 | |
| 5378 | #ifdef FEAT_LANGMAP |
| 5379 | /* 'langmap' */ |
| 5380 | else if (varp == &p_langmap) |
| 5381 | langmap_set(); |
| 5382 | #endif |
| 5383 | |
| 5384 | #ifdef FEAT_LINEBREAK |
| 5385 | /* 'breakat' */ |
| 5386 | else if (varp == &p_breakat) |
| 5387 | fill_breakat_flags(); |
| 5388 | #endif |
| 5389 | |
| 5390 | #ifdef FEAT_TITLE |
| 5391 | /* 'titlestring' and 'iconstring' */ |
| 5392 | else if (varp == &p_titlestring || varp == &p_iconstring) |
| 5393 | { |
| 5394 | # ifdef FEAT_STL_OPT |
| 5395 | int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; |
| 5396 | |
| 5397 | /* NULL => statusline syntax */ |
| 5398 | if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) |
| 5399 | stl_syntax |= flagval; |
| 5400 | else |
| 5401 | stl_syntax &= ~flagval; |
| 5402 | # endif |
| 5403 | did_set_title(varp == &p_iconstring); |
| 5404 | |
| 5405 | } |
| 5406 | #endif |
| 5407 | |
| 5408 | #ifdef FEAT_GUI |
| 5409 | /* 'guioptions' */ |
| 5410 | else if (varp == &p_go) |
| 5411 | gui_init_which_components(oldval); |
| 5412 | #endif |
| 5413 | |
| 5414 | #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) |
| 5415 | /* 'ttymouse' */ |
| 5416 | else if (varp == &p_ttym) |
| 5417 | { |
| 5418 | if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) |
| 5419 | errmsg = e_invarg; |
| 5420 | else |
| 5421 | check_mouse_termcode(); |
| 5422 | } |
| 5423 | #endif |
| 5424 | |
| 5425 | #ifdef FEAT_VISUAL |
| 5426 | /* 'selection' */ |
| 5427 | else if (varp == &p_sel) |
| 5428 | { |
| 5429 | if (*p_sel == NUL |
| 5430 | || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) |
| 5431 | errmsg = e_invarg; |
| 5432 | } |
| 5433 | |
| 5434 | /* 'selectmode' */ |
| 5435 | else if (varp == &p_slm) |
| 5436 | { |
| 5437 | if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) |
| 5438 | errmsg = e_invarg; |
| 5439 | } |
| 5440 | #endif |
| 5441 | |
| 5442 | #ifdef FEAT_BROWSE |
| 5443 | /* 'browsedir' */ |
| 5444 | else if (varp == &p_bsdir) |
| 5445 | { |
| 5446 | if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK |
| 5447 | && !mch_isdir(p_bsdir)) |
| 5448 | errmsg = e_invarg; |
| 5449 | } |
| 5450 | #endif |
| 5451 | |
| 5452 | #ifdef FEAT_VISUAL |
| 5453 | /* 'keymodel' */ |
| 5454 | else if (varp == &p_km) |
| 5455 | { |
| 5456 | if (check_opt_strings(p_km, p_km_values, TRUE) != OK) |
| 5457 | errmsg = e_invarg; |
| 5458 | else |
| 5459 | { |
| 5460 | km_stopsel = (vim_strchr(p_km, 'o') != NULL); |
| 5461 | km_startsel = (vim_strchr(p_km, 'a') != NULL); |
| 5462 | } |
| 5463 | } |
| 5464 | #endif |
| 5465 | |
| 5466 | /* 'mousemodel' */ |
| 5467 | else if (varp == &p_mousem) |
| 5468 | { |
| 5469 | if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) |
| 5470 | errmsg = e_invarg; |
| 5471 | #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) |
| 5472 | else if (*p_mousem != *oldval) |
| 5473 | /* Changed from "extend" to "popup" or "popup_setpos" or vv: need |
| 5474 | * to create or delete the popup menus. */ |
| 5475 | gui_motif_update_mousemodel(root_menu); |
| 5476 | #endif |
| 5477 | } |
| 5478 | |
| 5479 | /* 'switchbuf' */ |
| 5480 | else if (varp == &p_swb) |
| 5481 | { |
| 5482 | if (check_opt_strings(p_swb, p_swb_values, TRUE) != OK) |
| 5483 | errmsg = e_invarg; |
| 5484 | } |
| 5485 | |
| 5486 | /* 'debug' */ |
| 5487 | else if (varp == &p_debug) |
| 5488 | { |
| 5489 | if (check_opt_strings(p_debug, p_debug_values, FALSE) != OK) |
| 5490 | errmsg = e_invarg; |
| 5491 | } |
| 5492 | |
| 5493 | /* 'display' */ |
| 5494 | else if (varp == &p_dy) |
| 5495 | { |
| 5496 | if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) |
| 5497 | errmsg = e_invarg; |
| 5498 | else |
| 5499 | (void)init_chartab(); |
| 5500 | |
| 5501 | } |
| 5502 | |
| 5503 | #ifdef FEAT_VERTSPLIT |
| 5504 | /* 'eadirection' */ |
| 5505 | else if (varp == &p_ead) |
| 5506 | { |
| 5507 | if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) |
| 5508 | errmsg = e_invarg; |
| 5509 | } |
| 5510 | #endif |
| 5511 | |
| 5512 | #ifdef FEAT_CLIPBOARD |
| 5513 | /* 'clipboard' */ |
| 5514 | else if (varp == &p_cb) |
| 5515 | errmsg = check_clipboard_option(); |
| 5516 | #endif |
| 5517 | |
| 5518 | #ifdef FEAT_AUTOCMD |
| 5519 | # ifdef FEAT_SYN_HL |
| 5520 | /* When 'syntax' is set, load the syntax of that name */ |
| 5521 | else if (varp == &(curbuf->b_p_syn)) |
| 5522 | { |
| 5523 | apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, |
| 5524 | curbuf->b_fname, TRUE, curbuf); |
| 5525 | } |
| 5526 | # endif |
| 5527 | |
| 5528 | /* When 'filetype' is set, trigger the FileType autocommands of that name */ |
| 5529 | else if (varp == &(curbuf->b_p_ft)) |
| 5530 | { |
| 5531 | did_filetype = TRUE; |
| 5532 | apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, |
| 5533 | curbuf->b_fname, TRUE, curbuf); |
| 5534 | } |
| 5535 | #endif |
| 5536 | |
| 5537 | #ifdef FEAT_QUICKFIX |
| 5538 | /* When 'bufhidden' is set, check for valid value. */ |
| 5539 | else if (gvarp == &p_bh) |
| 5540 | { |
| 5541 | if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) |
| 5542 | errmsg = e_invarg; |
| 5543 | } |
| 5544 | |
| 5545 | /* When 'buftype' is set, check for valid value. */ |
| 5546 | else if (gvarp == &p_bt) |
| 5547 | { |
| 5548 | if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) |
| 5549 | errmsg = e_invarg; |
| 5550 | else |
| 5551 | { |
| 5552 | # ifdef FEAT_WINDOWS |
| 5553 | if (curwin->w_status_height) |
| 5554 | { |
| 5555 | curwin->w_redr_status = TRUE; |
| 5556 | redraw_later(VALID); |
| 5557 | } |
| 5558 | # endif |
| 5559 | curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); |
| 5560 | } |
| 5561 | } |
| 5562 | #endif |
| 5563 | |
| 5564 | #ifdef FEAT_STL_OPT |
| 5565 | /* 'statusline' or 'rulerformat' */ |
| 5566 | else if (varp == &p_stl || varp == &p_ruf) |
| 5567 | { |
| 5568 | int wid; |
| 5569 | |
| 5570 | if (varp == &p_ruf) /* reset ru_wid first */ |
| 5571 | ru_wid = 0; |
| 5572 | s = *varp; |
| 5573 | if (varp == &p_ruf && *s == '%') |
| 5574 | { |
| 5575 | /* set ru_wid if 'ruf' starts with "%99(" */ |
| 5576 | if (*++s == '-') /* ignore a '-' */ |
| 5577 | s++; |
| 5578 | wid = getdigits(&s); |
| 5579 | if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) |
| 5580 | ru_wid = wid; |
| 5581 | else |
| 5582 | errmsg = check_stl_option(p_ruf); |
| 5583 | } |
| 5584 | else |
| 5585 | errmsg = check_stl_option(s); |
| 5586 | if (varp == &(p_ruf) && errmsg == NULL) |
| 5587 | comp_col(); |
| 5588 | } |
| 5589 | #endif |
| 5590 | |
| 5591 | #ifdef FEAT_INS_EXPAND |
| 5592 | /* check if it is a valid value for 'complete' -- Acevedo */ |
| 5593 | else if (gvarp == &p_cpt) |
| 5594 | { |
| 5595 | for (s = *varp; *s;) |
| 5596 | { |
| 5597 | while(*s == ',' || *s == ' ') |
| 5598 | s++; |
| 5599 | if (!*s) |
| 5600 | break; |
| 5601 | if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) |
| 5602 | { |
| 5603 | errmsg = illegal_char(errbuf, *s); |
| 5604 | break; |
| 5605 | } |
| 5606 | if (*++s != NUL && *s != ',' && *s != ' ') |
| 5607 | { |
| 5608 | if (s[-1] == 'k' || s[-1] == 's') |
| 5609 | { |
| 5610 | /* skip optional filename after 'k' and 's' */ |
| 5611 | while (*s && *s != ',' && *s != ' ') |
| 5612 | { |
| 5613 | if (*s == '\\') |
| 5614 | ++s; |
| 5615 | ++s; |
| 5616 | } |
| 5617 | } |
| 5618 | else |
| 5619 | { |
| 5620 | if (errbuf != NULL) |
| 5621 | { |
| 5622 | sprintf((char *)errbuf, |
| 5623 | _("E535: Illegal character after <%c>"), |
| 5624 | *--s); |
| 5625 | errmsg = errbuf; |
| 5626 | } |
| 5627 | else |
| 5628 | errmsg = (char_u *)""; |
| 5629 | break; |
| 5630 | } |
| 5631 | } |
| 5632 | } |
| 5633 | } |
| 5634 | #endif /* FEAT_INS_EXPAND */ |
| 5635 | |
| 5636 | |
| 5637 | #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
| 5638 | else if (varp == &p_toolbar) |
| 5639 | { |
| 5640 | if (opt_strings_flags(p_toolbar, p_toolbar_values, |
| 5641 | &toolbar_flags, TRUE) != OK) |
| 5642 | errmsg = e_invarg; |
| 5643 | else |
| 5644 | { |
| 5645 | out_flush(); |
| 5646 | gui_mch_show_toolbar((toolbar_flags & |
| 5647 | (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); |
| 5648 | } |
| 5649 | } |
| 5650 | #endif |
| 5651 | |
| 5652 | #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 5653 | /* 'toolbariconsize': GTK+ 2 only */ |
| 5654 | else if (varp == &p_tbis) |
| 5655 | { |
| 5656 | if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) |
| 5657 | errmsg = e_invarg; |
| 5658 | else |
| 5659 | { |
| 5660 | out_flush(); |
| 5661 | gui_mch_show_toolbar((toolbar_flags & |
| 5662 | (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); |
| 5663 | } |
| 5664 | } |
| 5665 | #endif |
| 5666 | |
| 5667 | /* 'pastetoggle': translate key codes like in a mapping */ |
| 5668 | else if (varp == &p_pt) |
| 5669 | { |
| 5670 | if (*p_pt) |
| 5671 | { |
| 5672 | (void)replace_termcodes(p_pt, &p, TRUE, TRUE); |
| 5673 | if (p != NULL) |
| 5674 | { |
| 5675 | if (new_value_alloced) |
| 5676 | free_string_option(p_pt); |
| 5677 | p_pt = p; |
| 5678 | new_value_alloced = TRUE; |
| 5679 | } |
| 5680 | } |
| 5681 | } |
| 5682 | |
| 5683 | /* 'backspace' */ |
| 5684 | else if (varp == &p_bs) |
| 5685 | { |
| 5686 | if (VIM_ISDIGIT(*p_bs)) |
| 5687 | { |
| 5688 | if (*p_bs >'2' || p_bs[1] != NUL) |
| 5689 | errmsg = e_invarg; |
| 5690 | } |
| 5691 | else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) |
| 5692 | errmsg = e_invarg; |
| 5693 | } |
| 5694 | |
| 5695 | /* 'casemap' */ |
| 5696 | else if (varp == &p_cmp) |
| 5697 | { |
| 5698 | if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) |
| 5699 | errmsg = e_invarg; |
| 5700 | } |
| 5701 | |
| 5702 | #ifdef FEAT_DIFF |
| 5703 | /* 'diffopt' */ |
| 5704 | else if (varp == &p_dip) |
| 5705 | { |
| 5706 | if (diffopt_changed() == FAIL) |
| 5707 | errmsg = e_invarg; |
| 5708 | } |
| 5709 | #endif |
| 5710 | |
| 5711 | #ifdef FEAT_FOLDING |
| 5712 | /* 'foldmethod' */ |
| 5713 | else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) |
| 5714 | { |
| 5715 | if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK |
| 5716 | || *curwin->w_p_fdm == NUL) |
| 5717 | errmsg = e_invarg; |
| 5718 | else |
| 5719 | foldUpdateAll(curwin); |
| 5720 | } |
| 5721 | # ifdef FEAT_EVAL |
| 5722 | /* 'foldexpr' */ |
| 5723 | else if (varp == &curwin->w_p_fde) |
| 5724 | { |
| 5725 | if (foldmethodIsExpr(curwin)) |
| 5726 | foldUpdateAll(curwin); |
| 5727 | } |
| 5728 | # endif |
| 5729 | /* 'foldmarker' */ |
| 5730 | else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) |
| 5731 | { |
| 5732 | p = vim_strchr(*varp, ','); |
| 5733 | if (p == NULL) |
| 5734 | errmsg = (char_u *)N_("E536: comma required"); |
| 5735 | else if (p == *varp || p[1] == NUL) |
| 5736 | errmsg = e_invarg; |
| 5737 | else if (foldmethodIsMarker(curwin)) |
| 5738 | foldUpdateAll(curwin); |
| 5739 | } |
| 5740 | /* 'commentstring' */ |
| 5741 | else if (gvarp == &p_cms) |
| 5742 | { |
| 5743 | if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) |
| 5744 | errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s"); |
| 5745 | } |
| 5746 | /* 'foldopen' */ |
| 5747 | else if (varp == &p_fdo) |
| 5748 | { |
| 5749 | if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) |
| 5750 | errmsg = e_invarg; |
| 5751 | } |
| 5752 | /* 'foldclose' */ |
| 5753 | else if (varp == &p_fcl) |
| 5754 | { |
| 5755 | if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) |
| 5756 | errmsg = e_invarg; |
| 5757 | } |
| 5758 | #endif |
| 5759 | |
| 5760 | #ifdef FEAT_VIRTUALEDIT |
| 5761 | /* 'virtualedit' */ |
| 5762 | else if (varp == &p_ve) |
| 5763 | { |
| 5764 | if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK) |
| 5765 | errmsg = e_invarg; |
| 5766 | else if (STRCMP(p_ve, oldval) != 0) |
| 5767 | { |
| 5768 | /* Recompute cursor position in case the new 've' setting |
| 5769 | * changes something. */ |
| 5770 | validate_virtcol(); |
| 5771 | coladvance(curwin->w_virtcol); |
| 5772 | } |
| 5773 | } |
| 5774 | #endif |
| 5775 | |
| 5776 | #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) |
| 5777 | else if (varp == &p_csqf) |
| 5778 | { |
| 5779 | if (p_csqf != NULL) |
| 5780 | { |
| 5781 | p = p_csqf; |
| 5782 | while (*p != NUL) |
| 5783 | { |
| 5784 | if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL |
| 5785 | || p[1] == NUL |
| 5786 | || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL |
| 5787 | || (p[2] != NUL && p[2] != ',')) |
| 5788 | { |
| 5789 | errmsg = e_invarg; |
| 5790 | break; |
| 5791 | } |
| 5792 | else if (p[2] == NUL) |
| 5793 | break; |
| 5794 | else |
| 5795 | p += 3; |
| 5796 | } |
| 5797 | } |
| 5798 | } |
| 5799 | #endif |
| 5800 | |
| 5801 | /* Options that are a list of flags. */ |
| 5802 | else |
| 5803 | { |
| 5804 | p = NULL; |
| 5805 | if (varp == &p_ww) |
| 5806 | p = (char_u *)WW_ALL; |
| 5807 | if (varp == &p_shm) |
| 5808 | p = (char_u *)SHM_ALL; |
| 5809 | else if (varp == &(p_cpo)) |
| 5810 | p = (char_u *)CPO_ALL; |
| 5811 | else if (varp == &(curbuf->b_p_fo)) |
| 5812 | p = (char_u *)FO_ALL; |
| 5813 | else if (varp == &p_mouse) |
| 5814 | { |
| 5815 | #ifdef FEAT_MOUSE |
| 5816 | p = (char_u *)MOUSE_ALL; |
| 5817 | #else |
| 5818 | if (*p_mouse != NUL) |
| 5819 | errmsg = (char_u *)N_("E538: No mouse support"); |
| 5820 | #endif |
| 5821 | } |
| 5822 | #if defined(FEAT_GUI) |
| 5823 | else if (varp == &p_go) |
| 5824 | p = (char_u *)GO_ALL; |
| 5825 | #endif |
| 5826 | if (p != NULL) |
| 5827 | { |
| 5828 | for (s = *varp; *s; ++s) |
| 5829 | if (vim_strchr(p, *s) == NULL) |
| 5830 | { |
| 5831 | errmsg = illegal_char(errbuf, *s); |
| 5832 | break; |
| 5833 | } |
| 5834 | } |
| 5835 | } |
| 5836 | |
| 5837 | /* |
| 5838 | * If error detected, restore the previous value. |
| 5839 | */ |
| 5840 | if (errmsg != NULL) |
| 5841 | { |
| 5842 | if (new_value_alloced) |
| 5843 | free_string_option(*varp); |
| 5844 | *varp = oldval; |
| 5845 | /* |
| 5846 | * When resetting some values, need to act on it. |
| 5847 | */ |
| 5848 | if (did_chartab) |
| 5849 | (void)init_chartab(); |
| 5850 | if (varp == &p_hl) |
| 5851 | (void)highlight_changed(); |
| 5852 | } |
| 5853 | else |
| 5854 | { |
| 5855 | #ifdef FEAT_EVAL |
| 5856 | /* Remember where the option was set. */ |
| 5857 | options[opt_idx].scriptID = current_SID; |
| 5858 | #endif |
| 5859 | /* |
| 5860 | * Free string options that are in allocated memory. |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 5861 | * Use "free_oldval", because recursiveness may change the flags under |
| 5862 | * our fingers (esp. init_highlight()). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5863 | */ |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 5864 | if (free_oldval) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5865 | free_string_option(oldval); |
| 5866 | if (new_value_alloced) |
| 5867 | options[opt_idx].flags |= P_ALLOCED; |
| 5868 | else |
| 5869 | options[opt_idx].flags &= ~P_ALLOCED; |
| 5870 | |
| 5871 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
| 5872 | && (int)options[opt_idx].indir >= PV_BOTH) |
| 5873 | { |
| 5874 | /* global option with local value set to use global value; free |
| 5875 | * the local value and make it empty */ |
| 5876 | p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); |
| 5877 | free_string_option(*(char_u **)p); |
| 5878 | *(char_u **)p = empty_option; |
| 5879 | } |
| 5880 | |
| 5881 | /* May set global value for local option. */ |
| 5882 | else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) |
| 5883 | set_string_option_global(opt_idx, varp); |
| 5884 | } |
| 5885 | |
| 5886 | #ifdef FEAT_MOUSE |
| 5887 | if (varp == &p_mouse) |
| 5888 | { |
| 5889 | # ifdef FEAT_MOUSE_TTY |
| 5890 | if (*p_mouse == NUL) |
| 5891 | mch_setmouse(FALSE); /* switch mouse off */ |
| 5892 | else |
| 5893 | # endif |
| 5894 | setmouse(); /* in case 'mouse' changed */ |
| 5895 | } |
| 5896 | #endif |
| 5897 | |
| 5898 | if (curwin->w_curswant != MAXCOL) |
| 5899 | curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */ |
| 5900 | check_redraw(options[opt_idx].flags); |
| 5901 | |
| 5902 | return errmsg; |
| 5903 | } |
| 5904 | |
| 5905 | /* |
| 5906 | * Handle setting 'listchars' or 'fillchars'. |
| 5907 | * Returns error message, NULL if it's OK. |
| 5908 | */ |
| 5909 | static char_u * |
| 5910 | set_chars_option(varp) |
| 5911 | char_u **varp; |
| 5912 | { |
| 5913 | int round, i, len, entries; |
| 5914 | char_u *p, *s; |
| 5915 | int c1, c2 = 0; |
| 5916 | struct charstab |
| 5917 | { |
| 5918 | int *cp; |
| 5919 | char *name; |
| 5920 | }; |
| 5921 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 5922 | static struct charstab filltab[] = |
| 5923 | { |
| 5924 | {&fill_stl, "stl"}, |
| 5925 | {&fill_stlnc, "stlnc"}, |
| 5926 | {&fill_vert, "vert"}, |
| 5927 | {&fill_fold, "fold"}, |
| 5928 | {&fill_diff, "diff"}, |
| 5929 | }; |
| 5930 | #endif |
| 5931 | static struct charstab lcstab[] = |
| 5932 | { |
| 5933 | {&lcs_eol, "eol"}, |
| 5934 | {&lcs_ext, "extends"}, |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 5935 | {&lcs_nbsp, "nbsp"}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5936 | {&lcs_prec, "precedes"}, |
| 5937 | {&lcs_tab2, "tab"}, |
| 5938 | {&lcs_trail, "trail"}, |
| 5939 | }; |
| 5940 | struct charstab *tab; |
| 5941 | |
| 5942 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 5943 | if (varp == &p_lcs) |
| 5944 | #endif |
| 5945 | { |
| 5946 | tab = lcstab; |
| 5947 | entries = sizeof(lcstab) / sizeof(struct charstab); |
| 5948 | } |
| 5949 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 5950 | else |
| 5951 | { |
| 5952 | tab = filltab; |
| 5953 | entries = sizeof(filltab) / sizeof(struct charstab); |
| 5954 | } |
| 5955 | #endif |
| 5956 | |
| 5957 | /* first round: check for valid value, second round: assign values */ |
| 5958 | for (round = 0; round <= 1; ++round) |
| 5959 | { |
| 5960 | if (round) |
| 5961 | { |
| 5962 | /* After checking that the value is valid: set defaults: space for |
| 5963 | * 'fillchars', NUL for 'listchars' */ |
| 5964 | for (i = 0; i < entries; ++i) |
| 5965 | *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); |
| 5966 | if (varp == &p_lcs) |
| 5967 | lcs_tab1 = NUL; |
| 5968 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 5969 | else |
| 5970 | fill_diff = '-'; |
| 5971 | #endif |
| 5972 | } |
| 5973 | p = *varp; |
| 5974 | while (*p) |
| 5975 | { |
| 5976 | for (i = 0; i < entries; ++i) |
| 5977 | { |
| 5978 | len = (int)STRLEN(tab[i].name); |
| 5979 | if (STRNCMP(p, tab[i].name, len) == 0 |
| 5980 | && p[len] == ':' |
| 5981 | && p[len + 1] != NUL) |
| 5982 | { |
| 5983 | s = p + len + 1; |
| 5984 | #ifdef FEAT_MBYTE |
| 5985 | c1 = mb_ptr2char_adv(&s); |
| 5986 | #else |
| 5987 | c1 = *s++; |
| 5988 | #endif |
| 5989 | if (tab[i].cp == &lcs_tab2) |
| 5990 | { |
| 5991 | if (*s == NUL) |
| 5992 | continue; |
| 5993 | #ifdef FEAT_MBYTE |
| 5994 | c2 = mb_ptr2char_adv(&s); |
| 5995 | #else |
| 5996 | c2 = *s++; |
| 5997 | #endif |
| 5998 | } |
| 5999 | if (*s == ',' || *s == NUL) |
| 6000 | { |
| 6001 | if (round) |
| 6002 | { |
| 6003 | if (tab[i].cp == &lcs_tab2) |
| 6004 | { |
| 6005 | lcs_tab1 = c1; |
| 6006 | lcs_tab2 = c2; |
| 6007 | } |
| 6008 | else |
| 6009 | *(tab[i].cp) = c1; |
| 6010 | |
| 6011 | } |
| 6012 | p = s; |
| 6013 | break; |
| 6014 | } |
| 6015 | } |
| 6016 | } |
| 6017 | |
| 6018 | if (i == entries) |
| 6019 | return e_invarg; |
| 6020 | if (*p == ',') |
| 6021 | ++p; |
| 6022 | } |
| 6023 | } |
| 6024 | |
| 6025 | return NULL; /* no error */ |
| 6026 | } |
| 6027 | |
| 6028 | #ifdef FEAT_STL_OPT |
| 6029 | /* |
| 6030 | * Check validity of options with the 'statusline' format. |
| 6031 | * Return error message or NULL. |
| 6032 | */ |
| 6033 | char_u * |
| 6034 | check_stl_option(s) |
| 6035 | char_u *s; |
| 6036 | { |
| 6037 | int itemcnt = 0; |
| 6038 | int groupdepth = 0; |
| 6039 | static char_u errbuf[80]; |
| 6040 | |
| 6041 | while (*s && itemcnt < STL_MAX_ITEM) |
| 6042 | { |
| 6043 | /* Check for valid keys after % sequences */ |
| 6044 | while (*s && *s != '%') |
| 6045 | s++; |
| 6046 | if (!*s) |
| 6047 | break; |
| 6048 | s++; |
| 6049 | if (*s != '%' && *s != ')') |
| 6050 | ++itemcnt; |
| 6051 | if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK) |
| 6052 | { |
| 6053 | s++; |
| 6054 | continue; |
| 6055 | } |
| 6056 | if (*s == ')') |
| 6057 | { |
| 6058 | s++; |
| 6059 | if (--groupdepth < 0) |
| 6060 | break; |
| 6061 | continue; |
| 6062 | } |
| 6063 | if (*s == '-') |
| 6064 | s++; |
| 6065 | while (VIM_ISDIGIT(*s)) |
| 6066 | s++; |
| 6067 | if (*s == STL_HIGHLIGHT) |
| 6068 | continue; |
| 6069 | if (*s == '.') |
| 6070 | { |
| 6071 | s++; |
| 6072 | while (*s && VIM_ISDIGIT(*s)) |
| 6073 | s++; |
| 6074 | } |
| 6075 | if (*s == '(') |
| 6076 | { |
| 6077 | groupdepth++; |
| 6078 | continue; |
| 6079 | } |
| 6080 | if (vim_strchr(STL_ALL, *s) == NULL) |
| 6081 | { |
| 6082 | return illegal_char(errbuf, *s); |
| 6083 | } |
| 6084 | if (*s == '{') |
| 6085 | { |
| 6086 | s++; |
| 6087 | while (*s != '}' && *s) |
| 6088 | s++; |
| 6089 | if (*s != '}') |
| 6090 | return (char_u *)N_("E540: Unclosed expression sequence"); |
| 6091 | } |
| 6092 | } |
| 6093 | if (itemcnt >= STL_MAX_ITEM) |
| 6094 | return (char_u *)N_("E541: too many items"); |
| 6095 | if (groupdepth != 0) |
| 6096 | return (char_u *)N_("E542: unbalanced groups"); |
| 6097 | return NULL; |
| 6098 | } |
| 6099 | #endif |
| 6100 | |
| 6101 | #ifdef FEAT_CLIPBOARD |
| 6102 | /* |
| 6103 | * Extract the items in the 'clipboard' option and set global values. |
| 6104 | */ |
| 6105 | static char_u * |
| 6106 | check_clipboard_option() |
| 6107 | { |
| 6108 | int new_unnamed = FALSE; |
| 6109 | int new_autoselect = FALSE; |
| 6110 | int new_autoselectml = FALSE; |
| 6111 | regprog_T *new_exclude_prog = NULL; |
| 6112 | char_u *errmsg = NULL; |
| 6113 | char_u *p; |
| 6114 | |
| 6115 | for (p = p_cb; *p != NUL; ) |
| 6116 | { |
| 6117 | if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) |
| 6118 | { |
| 6119 | new_unnamed = TRUE; |
| 6120 | p += 7; |
| 6121 | } |
| 6122 | else if (STRNCMP(p, "autoselect", 10) == 0 |
| 6123 | && (p[10] == ',' || p[10] == NUL)) |
| 6124 | { |
| 6125 | new_autoselect = TRUE; |
| 6126 | p += 10; |
| 6127 | } |
| 6128 | else if (STRNCMP(p, "autoselectml", 12) == 0 |
| 6129 | && (p[12] == ',' || p[12] == NUL)) |
| 6130 | { |
| 6131 | new_autoselectml = TRUE; |
| 6132 | p += 12; |
| 6133 | } |
| 6134 | else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) |
| 6135 | { |
| 6136 | p += 8; |
| 6137 | new_exclude_prog = vim_regcomp(p, RE_MAGIC); |
| 6138 | if (new_exclude_prog == NULL) |
| 6139 | errmsg = e_invarg; |
| 6140 | break; |
| 6141 | } |
| 6142 | else |
| 6143 | { |
| 6144 | errmsg = e_invarg; |
| 6145 | break; |
| 6146 | } |
| 6147 | if (*p == ',') |
| 6148 | ++p; |
| 6149 | } |
| 6150 | if (errmsg == NULL) |
| 6151 | { |
| 6152 | clip_unnamed = new_unnamed; |
| 6153 | clip_autoselect = new_autoselect; |
| 6154 | clip_autoselectml = new_autoselectml; |
| 6155 | vim_free(clip_exclude_prog); |
| 6156 | clip_exclude_prog = new_exclude_prog; |
| 6157 | } |
| 6158 | else |
| 6159 | vim_free(new_exclude_prog); |
| 6160 | |
| 6161 | return errmsg; |
| 6162 | } |
| 6163 | #endif |
| 6164 | |
| 6165 | /* |
| 6166 | * Set the value of a boolean option, and take care of side effects. |
| 6167 | * Returns NULL for success, or an error message for an error. |
| 6168 | */ |
| 6169 | static char_u * |
| 6170 | set_bool_option(opt_idx, varp, value, opt_flags) |
| 6171 | int opt_idx; /* index in options[] table */ |
| 6172 | char_u *varp; /* pointer to the option variable */ |
| 6173 | int value; /* new value */ |
| 6174 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 6175 | { |
| 6176 | int old_value = *(int *)varp; |
| 6177 | |
| 6178 | #ifdef FEAT_GUI |
| 6179 | need_mouse_correct = TRUE; |
| 6180 | #endif |
| 6181 | |
| 6182 | /* Disallow changing some options from secure mode */ |
| 6183 | if ((secure |
| 6184 | #ifdef HAVE_SANDBOX |
| 6185 | || sandbox != 0 |
| 6186 | #endif |
| 6187 | ) && (options[opt_idx].flags & P_SECURE)) |
| 6188 | return e_secure; |
| 6189 | |
| 6190 | *(int *)varp = value; /* set the new value */ |
| 6191 | #ifdef FEAT_EVAL |
| 6192 | /* Remember where the option was set. */ |
| 6193 | options[opt_idx].scriptID = current_SID; |
| 6194 | #endif |
| 6195 | |
| 6196 | /* May set global value for local option. */ |
| 6197 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
| 6198 | *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; |
| 6199 | |
| 6200 | /* |
| 6201 | * Handle side effects of changing a bool option. |
| 6202 | */ |
| 6203 | |
| 6204 | /* 'compatible' */ |
| 6205 | if ((int *)varp == &p_cp) |
| 6206 | { |
| 6207 | compatible_set(); |
| 6208 | } |
| 6209 | |
| 6210 | /* when 'readonly' is reset globally, also reset readonlymode */ |
| 6211 | else if ((int *)varp == &curbuf->b_p_ro) |
| 6212 | { |
| 6213 | if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
| 6214 | readonlymode = FALSE; |
| 6215 | #ifdef FEAT_TITLE |
| 6216 | need_maketitle = TRUE; |
| 6217 | #endif |
| 6218 | } |
| 6219 | |
| 6220 | #ifdef FEAT_TITLE |
| 6221 | /* when 'modifiable' is changed, redraw the window title */ |
| 6222 | else if ((int *)varp == &curbuf->b_p_ma) |
| 6223 | need_maketitle = TRUE; |
| 6224 | /* when 'endofline' is changed, redraw the window title */ |
| 6225 | else if ((int *)varp == &curbuf->b_p_eol) |
| 6226 | need_maketitle = TRUE; |
| 6227 | #endif |
| 6228 | |
| 6229 | /* when 'bin' is set also set some other options */ |
| 6230 | else if ((int *)varp == &curbuf->b_p_bin) |
| 6231 | { |
| 6232 | set_options_bin(old_value, curbuf->b_p_bin, opt_flags); |
| 6233 | #ifdef FEAT_TITLE |
| 6234 | need_maketitle = TRUE; |
| 6235 | #endif |
| 6236 | } |
| 6237 | |
| 6238 | #ifdef FEAT_AUTOCMD |
| 6239 | /* when 'buflisted' changes, trigger autocommands */ |
| 6240 | else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
| 6241 | { |
| 6242 | apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, |
| 6243 | NULL, NULL, TRUE, curbuf); |
| 6244 | } |
| 6245 | #endif |
| 6246 | |
| 6247 | /* when 'swf' is set, create swapfile, when reset remove swapfile */ |
| 6248 | else if ((int *)varp == &curbuf->b_p_swf) |
| 6249 | { |
| 6250 | if (curbuf->b_p_swf && p_uc) |
| 6251 | ml_open_file(curbuf); /* create the swap file */ |
| 6252 | else |
| 6253 | mf_close_file(curbuf, TRUE); /* remove the swap file */ |
| 6254 | } |
| 6255 | |
| 6256 | /* when 'terse' is set change 'shortmess' */ |
| 6257 | else if ((int *)varp == &p_terse) |
| 6258 | { |
| 6259 | char_u *p; |
| 6260 | |
| 6261 | p = vim_strchr(p_shm, SHM_SEARCH); |
| 6262 | |
| 6263 | /* insert 's' in p_shm */ |
| 6264 | if (p_terse && p == NULL) |
| 6265 | { |
| 6266 | STRCPY(IObuff, p_shm); |
| 6267 | STRCAT(IObuff, "s"); |
| 6268 | set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE); |
| 6269 | } |
| 6270 | /* remove 's' from p_shm */ |
| 6271 | else if (!p_terse && p != NULL) |
| 6272 | mch_memmove(p, p + 1, STRLEN(p)); |
| 6273 | } |
| 6274 | |
| 6275 | /* when 'paste' is set or reset also change other options */ |
| 6276 | else if ((int *)varp == &p_paste) |
| 6277 | { |
| 6278 | paste_option_changed(); |
| 6279 | } |
| 6280 | |
| 6281 | /* when 'insertmode' is set from an autocommand need to do work here */ |
| 6282 | else if ((int *)varp == &p_im) |
| 6283 | { |
| 6284 | if (p_im) |
| 6285 | { |
| 6286 | if ((State & INSERT) == 0) |
| 6287 | need_start_insertmode = TRUE; |
| 6288 | stop_insert_mode = FALSE; |
| 6289 | } |
| 6290 | else |
| 6291 | { |
| 6292 | need_start_insertmode = FALSE; |
| 6293 | stop_insert_mode = TRUE; |
| 6294 | if (p_smd && restart_edit != 0) |
| 6295 | clear_cmdline = TRUE; /* remove "(insert)" */ |
| 6296 | restart_edit = 0; |
| 6297 | } |
| 6298 | } |
| 6299 | |
| 6300 | /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ |
| 6301 | else if ((int *)varp == &p_ic && p_hls) |
| 6302 | { |
| 6303 | redraw_all_later(NOT_VALID); |
| 6304 | } |
| 6305 | |
| 6306 | #ifdef FEAT_SEARCH_EXTRA |
| 6307 | /* when 'hlsearch' is set or reset: reset no_hlsearch */ |
| 6308 | else if ((int *)varp == &p_hls) |
| 6309 | { |
| 6310 | no_hlsearch = FALSE; |
| 6311 | } |
| 6312 | #endif |
| 6313 | |
| 6314 | #ifdef FEAT_SCROLLBIND |
| 6315 | /* when 'scrollbind' is set: snapshot the current position to avoid a jump |
| 6316 | * at the end of normal_cmd() */ |
| 6317 | else if ((int *)varp == &curwin->w_p_scb) |
| 6318 | { |
| 6319 | if (curwin->w_p_scb) |
| 6320 | do_check_scrollbind(FALSE); |
| 6321 | } |
| 6322 | #endif |
| 6323 | |
| 6324 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 6325 | /* There can be only one window with 'previewwindow' set. */ |
| 6326 | else if ((int *)varp == &curwin->w_p_pvw) |
| 6327 | { |
| 6328 | if (curwin->w_p_pvw) |
| 6329 | { |
| 6330 | win_T *win; |
| 6331 | |
| 6332 | for (win = firstwin; win != NULL; win = win->w_next) |
| 6333 | if (win->w_p_pvw && win != curwin) |
| 6334 | { |
| 6335 | curwin->w_p_pvw = FALSE; |
| 6336 | return (char_u *)N_("E590: A preview window already exists"); |
| 6337 | } |
| 6338 | } |
| 6339 | } |
| 6340 | #endif |
| 6341 | |
| 6342 | /* when 'textmode' is set or reset also change 'fileformat' */ |
| 6343 | else if ((int *)varp == &curbuf->b_p_tx) |
| 6344 | { |
| 6345 | set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); |
| 6346 | } |
| 6347 | |
| 6348 | /* when 'textauto' is set or reset also change 'fileformats' */ |
| 6349 | else if ((int *)varp == &p_ta) |
| 6350 | { |
| 6351 | set_string_option_direct((char_u *)"ffs", -1, |
| 6352 | p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", |
| 6353 | OPT_FREE | opt_flags); |
| 6354 | } |
| 6355 | |
| 6356 | /* |
| 6357 | * When 'lisp' option changes include/exclude '-' in |
| 6358 | * keyword characters. |
| 6359 | */ |
| 6360 | #ifdef FEAT_LISP |
| 6361 | else if (varp == (char_u *)&(curbuf->b_p_lisp)) |
| 6362 | { |
| 6363 | (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ |
| 6364 | } |
| 6365 | #endif |
| 6366 | |
| 6367 | #ifdef FEAT_TITLE |
| 6368 | /* when 'title' changed, may need to change the title; same for 'icon' */ |
| 6369 | else if ((int *)varp == &p_title) |
| 6370 | { |
| 6371 | did_set_title(FALSE); |
| 6372 | } |
| 6373 | |
| 6374 | else if ((int *)varp == &p_icon) |
| 6375 | { |
| 6376 | did_set_title(TRUE); |
| 6377 | } |
| 6378 | #endif |
| 6379 | |
| 6380 | else if ((int *)varp == &curbuf->b_changed) |
| 6381 | { |
| 6382 | if (!value) |
| 6383 | save_file_ff(curbuf); /* Buffer is unchanged */ |
| 6384 | #ifdef FEAT_TITLE |
| 6385 | need_maketitle = TRUE; |
| 6386 | #endif |
| 6387 | #ifdef FEAT_AUTOCMD |
| 6388 | modified_was_set = value; |
| 6389 | #endif |
| 6390 | } |
| 6391 | |
| 6392 | #ifdef BACKSLASH_IN_FILENAME |
| 6393 | else if ((int *)varp == &p_ssl) |
| 6394 | { |
| 6395 | if (p_ssl) |
| 6396 | { |
| 6397 | psepc = '/'; |
| 6398 | psepcN = '\\'; |
| 6399 | pseps[0] = '/'; |
| 6400 | psepsN[0] = '\\'; |
| 6401 | } |
| 6402 | else |
| 6403 | { |
| 6404 | psepc = '\\'; |
| 6405 | psepcN = '/'; |
| 6406 | pseps[0] = '\\'; |
| 6407 | psepsN[0] = '/'; |
| 6408 | } |
| 6409 | |
| 6410 | /* need to adjust the file name arguments and buffer names. */ |
| 6411 | buflist_slash_adjust(); |
| 6412 | alist_slash_adjust(); |
| 6413 | # ifdef FEAT_EVAL |
| 6414 | scriptnames_slash_adjust(); |
| 6415 | # endif |
| 6416 | } |
| 6417 | #endif |
| 6418 | |
| 6419 | /* If 'wrap' is set, set w_leftcol to zero. */ |
| 6420 | else if ((int *)varp == &curwin->w_p_wrap) |
| 6421 | { |
| 6422 | if (curwin->w_p_wrap) |
| 6423 | curwin->w_leftcol = 0; |
| 6424 | } |
| 6425 | |
| 6426 | #ifdef FEAT_WINDOWS |
| 6427 | else if ((int *)varp == &p_ea) |
| 6428 | { |
| 6429 | if (p_ea && !old_value) |
| 6430 | win_equal(curwin, FALSE, 0); |
| 6431 | } |
| 6432 | #endif |
| 6433 | |
| 6434 | else if ((int *)varp == &p_wiv) |
| 6435 | { |
| 6436 | /* |
| 6437 | * When 'weirdinvert' changed, set/reset 't_xs'. |
| 6438 | * Then set 'weirdinvert' according to value of 't_xs'. |
| 6439 | */ |
| 6440 | if (p_wiv && !old_value) |
| 6441 | T_XS = (char_u *)"y"; |
| 6442 | else if (!p_wiv && old_value) |
| 6443 | T_XS = empty_option; |
| 6444 | p_wiv = (*T_XS != NUL); |
| 6445 | } |
| 6446 | |
| 6447 | #if defined(FEAT_BEVAL) && (defined(FEAT_SUN_WORKSHOP) \ |
| 6448 | || defined(FEAT_NETBEANS_INTG)) |
| 6449 | else if ((int *)varp == &p_beval) |
| 6450 | { |
| 6451 | extern BalloonEval *balloonEval; |
| 6452 | |
| 6453 | if (p_beval == TRUE) |
| 6454 | gui_mch_enable_beval_area(balloonEval); |
| 6455 | else |
| 6456 | gui_mch_disable_beval_area(balloonEval); |
| 6457 | } |
| 6458 | |
| 6459 | else if ((int *)varp == &p_acd) |
| 6460 | { |
| 6461 | if (p_acd && curbuf->b_ffname != NULL |
| 6462 | && vim_chdirfile(curbuf->b_ffname) == OK) |
| 6463 | shorten_fnames(TRUE); |
| 6464 | } |
| 6465 | #endif |
| 6466 | |
| 6467 | #ifdef FEAT_DIFF |
| 6468 | /* 'diff' */ |
| 6469 | else if ((int *)varp == &curwin->w_p_diff) |
| 6470 | { |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6471 | /* May add or remove the buffer from the list of diff buffers. */ |
| 6472 | diff_buf_adjust(curwin); |
| 6473 | # ifdef FEAT_FOLDING |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6474 | if (foldmethodIsDiff(curwin)) |
| 6475 | foldUpdateAll(curwin); |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6476 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6477 | } |
| 6478 | #endif |
| 6479 | |
| 6480 | #ifdef USE_IM_CONTROL |
| 6481 | /* 'imdisable' */ |
| 6482 | else if ((int *)varp == &p_imdisable) |
| 6483 | { |
| 6484 | /* Only de-activate it here, it will be enabled when changing mode. */ |
| 6485 | if (p_imdisable) |
| 6486 | im_set_active(FALSE); |
| 6487 | } |
| 6488 | #endif |
| 6489 | |
| 6490 | #ifdef FEAT_FKMAP |
| 6491 | else if ((int *)varp == &p_altkeymap) |
| 6492 | { |
| 6493 | if (old_value != p_altkeymap) |
| 6494 | { |
| 6495 | if (!p_altkeymap) |
| 6496 | { |
| 6497 | p_hkmap = p_fkmap; |
| 6498 | p_fkmap = 0; |
| 6499 | } |
| 6500 | else |
| 6501 | { |
| 6502 | p_fkmap = p_hkmap; |
| 6503 | p_hkmap = 0; |
| 6504 | } |
| 6505 | (void)init_chartab(); |
| 6506 | } |
| 6507 | } |
| 6508 | |
| 6509 | /* |
| 6510 | * In case some second language keymapping options have changed, check |
| 6511 | * and correct the setting in a consistent way. |
| 6512 | */ |
| 6513 | |
| 6514 | /* |
| 6515 | * If hkmap or fkmap are set, reset Arabic keymapping. |
| 6516 | */ |
| 6517 | if ((p_hkmap || p_fkmap) && p_altkeymap) |
| 6518 | { |
| 6519 | p_altkeymap = p_fkmap; |
| 6520 | # ifdef FEAT_ARABIC |
| 6521 | curwin->w_p_arab = FALSE; |
| 6522 | # endif |
| 6523 | (void)init_chartab(); |
| 6524 | } |
| 6525 | |
| 6526 | /* |
| 6527 | * If hkmap set, reset Farsi keymapping. |
| 6528 | */ |
| 6529 | if (p_hkmap && p_altkeymap) |
| 6530 | { |
| 6531 | p_altkeymap = 0; |
| 6532 | p_fkmap = 0; |
| 6533 | # ifdef FEAT_ARABIC |
| 6534 | curwin->w_p_arab = FALSE; |
| 6535 | # endif |
| 6536 | (void)init_chartab(); |
| 6537 | } |
| 6538 | |
| 6539 | /* |
| 6540 | * If fkmap set, reset Hebrew keymapping. |
| 6541 | */ |
| 6542 | if (p_fkmap && !p_altkeymap) |
| 6543 | { |
| 6544 | p_altkeymap = 1; |
| 6545 | p_hkmap = 0; |
| 6546 | # ifdef FEAT_ARABIC |
| 6547 | curwin->w_p_arab = FALSE; |
| 6548 | # endif |
| 6549 | (void)init_chartab(); |
| 6550 | } |
| 6551 | #endif |
| 6552 | |
| 6553 | #ifdef FEAT_ARABIC |
| 6554 | if ((int *)varp == &curwin->w_p_arab) |
| 6555 | { |
| 6556 | if (curwin->w_p_arab) |
| 6557 | { |
| 6558 | /* |
| 6559 | * 'arabic' is set, handle various sub-settings. |
| 6560 | */ |
| 6561 | if (!p_tbidi) |
| 6562 | { |
| 6563 | /* set rightleft mode */ |
| 6564 | if (!curwin->w_p_rl) |
| 6565 | { |
| 6566 | curwin->w_p_rl = TRUE; |
| 6567 | changed_window_setting(); |
| 6568 | } |
| 6569 | |
| 6570 | /* Enable Arabic shaping (major part of what Arabic requires) */ |
| 6571 | if (!p_arshape) |
| 6572 | { |
| 6573 | p_arshape = TRUE; |
| 6574 | redraw_later_clear(); |
| 6575 | } |
| 6576 | } |
| 6577 | |
| 6578 | /* Arabic requires a utf-8 encoding, inform the user if its not |
| 6579 | * set. */ |
| 6580 | if (STRCMP(p_enc, "utf-8") != 0) |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6581 | { |
| 6582 | msg_source(hl_attr(HLF_W)); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6583 | MSG_ATTR(_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"), |
| 6584 | hl_attr(HLF_W)); |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6585 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6586 | |
| 6587 | # ifdef FEAT_MBYTE |
| 6588 | /* set 'delcombine' */ |
| 6589 | p_deco = TRUE; |
| 6590 | # endif |
| 6591 | |
| 6592 | # ifdef FEAT_KEYMAP |
| 6593 | /* Force-set the necessary keymap for arabic */ |
| 6594 | set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
| 6595 | OPT_LOCAL); |
| 6596 | # endif |
| 6597 | # ifdef FEAT_FKMAP |
| 6598 | p_altkeymap = 0; |
| 6599 | p_hkmap = 0; |
| 6600 | p_fkmap = 0; |
| 6601 | (void)init_chartab(); |
| 6602 | # endif |
| 6603 | } |
| 6604 | else |
| 6605 | { |
| 6606 | /* |
| 6607 | * 'arabic' is reset, handle various sub-settings. |
| 6608 | */ |
| 6609 | if (!p_tbidi) |
| 6610 | { |
| 6611 | /* reset rightleft mode */ |
| 6612 | if (curwin->w_p_rl) |
| 6613 | { |
| 6614 | curwin->w_p_rl = FALSE; |
| 6615 | changed_window_setting(); |
| 6616 | } |
| 6617 | |
| 6618 | /* 'arabicshape' isn't reset, it is a global option and |
| 6619 | * another window may still need it "on". */ |
| 6620 | } |
| 6621 | |
| 6622 | /* 'delcombine' isn't reset, it is a global option and another |
| 6623 | * window may still want it "on". */ |
| 6624 | |
| 6625 | # ifdef FEAT_KEYMAP |
| 6626 | /* Revert to the default keymap */ |
| 6627 | curbuf->b_p_iminsert = B_IMODE_NONE; |
| 6628 | curbuf->b_p_imsearch = B_IMODE_USE_INSERT; |
| 6629 | # endif |
| 6630 | } |
| 6631 | } |
| 6632 | #endif |
| 6633 | |
| 6634 | /* |
| 6635 | * End of handling side effects for bool options. |
| 6636 | */ |
| 6637 | |
| 6638 | options[opt_idx].flags |= P_WAS_SET; |
| 6639 | |
| 6640 | comp_col(); /* in case 'ruler' or 'showcmd' changed */ |
| 6641 | if (curwin->w_curswant != MAXCOL) |
| 6642 | curwin->w_set_curswant = TRUE; /* in case 'list' changed */ |
| 6643 | check_redraw(options[opt_idx].flags); |
| 6644 | |
| 6645 | return NULL; |
| 6646 | } |
| 6647 | |
| 6648 | /* |
| 6649 | * Set the value of a number option, and take care of side effects. |
| 6650 | * Returns NULL for success, or an error message for an error. |
| 6651 | */ |
| 6652 | static char_u * |
| 6653 | set_num_option(opt_idx, varp, value, errbuf, opt_flags) |
| 6654 | int opt_idx; /* index in options[] table */ |
| 6655 | char_u *varp; /* pointer to the option variable */ |
| 6656 | long value; /* new value */ |
| 6657 | char_u *errbuf; /* buffer for error messages */ |
| 6658 | int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and |
| 6659 | OPT_MODELINE */ |
| 6660 | { |
| 6661 | char_u *errmsg = NULL; |
| 6662 | long old_value = *(long *)varp; |
| 6663 | long old_Rows = Rows; /* remember old Rows */ |
| 6664 | long old_Columns = Columns; /* remember old Columns */ |
| 6665 | long *pp = (long *)varp; |
| 6666 | |
| 6667 | #ifdef FEAT_GUI |
| 6668 | need_mouse_correct = TRUE; |
| 6669 | #endif |
| 6670 | |
| 6671 | *pp = value; |
| 6672 | #ifdef FEAT_EVAL |
| 6673 | /* Remember where the option was set. */ |
| 6674 | options[opt_idx].scriptID = current_SID; |
| 6675 | #endif |
| 6676 | |
| 6677 | if (curbuf->b_p_sw <= 0) |
| 6678 | { |
| 6679 | errmsg = e_positive; |
| 6680 | curbuf->b_p_sw = curbuf->b_p_ts; |
| 6681 | } |
| 6682 | |
| 6683 | /* |
| 6684 | * Number options that need some action when changed |
| 6685 | */ |
| 6686 | #ifdef FEAT_WINDOWS |
| 6687 | if (pp == &p_wh || pp == &p_hh) |
| 6688 | { |
| 6689 | if (p_wh < 1) |
| 6690 | { |
| 6691 | errmsg = e_positive; |
| 6692 | p_wh = 1; |
| 6693 | } |
| 6694 | if (p_wmh > p_wh) |
| 6695 | { |
| 6696 | errmsg = e_winheight; |
| 6697 | p_wh = p_wmh; |
| 6698 | } |
| 6699 | if (p_hh < 0) |
| 6700 | { |
| 6701 | errmsg = e_positive; |
| 6702 | p_hh = 0; |
| 6703 | } |
| 6704 | |
| 6705 | /* Change window height NOW */ |
| 6706 | if (lastwin != firstwin) |
| 6707 | { |
| 6708 | if (pp == &p_wh && curwin->w_height < p_wh) |
| 6709 | win_setheight((int)p_wh); |
| 6710 | if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) |
| 6711 | win_setheight((int)p_hh); |
| 6712 | } |
| 6713 | } |
| 6714 | |
| 6715 | /* 'winminheight' */ |
| 6716 | else if (pp == &p_wmh) |
| 6717 | { |
| 6718 | if (p_wmh < 0) |
| 6719 | { |
| 6720 | errmsg = e_positive; |
| 6721 | p_wmh = 0; |
| 6722 | } |
| 6723 | if (p_wmh > p_wh) |
| 6724 | { |
| 6725 | errmsg = e_winheight; |
| 6726 | p_wmh = p_wh; |
| 6727 | } |
| 6728 | win_setminheight(); |
| 6729 | } |
| 6730 | |
| 6731 | # ifdef FEAT_VERTSPLIT |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 6732 | else if (pp == &p_wiw) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6733 | { |
| 6734 | if (p_wiw < 1) |
| 6735 | { |
| 6736 | errmsg = e_positive; |
| 6737 | p_wiw = 1; |
| 6738 | } |
| 6739 | if (p_wmw > p_wiw) |
| 6740 | { |
| 6741 | errmsg = e_winwidth; |
| 6742 | p_wiw = p_wmw; |
| 6743 | } |
| 6744 | |
| 6745 | /* Change window width NOW */ |
| 6746 | if (lastwin != firstwin && curwin->w_width < p_wiw) |
| 6747 | win_setwidth((int)p_wiw); |
| 6748 | } |
| 6749 | |
| 6750 | /* 'winminwidth' */ |
| 6751 | else if (pp == &p_wmw) |
| 6752 | { |
| 6753 | if (p_wmw < 0) |
| 6754 | { |
| 6755 | errmsg = e_positive; |
| 6756 | p_wmw = 0; |
| 6757 | } |
| 6758 | if (p_wmw > p_wiw) |
| 6759 | { |
| 6760 | errmsg = e_winwidth; |
| 6761 | p_wmw = p_wiw; |
| 6762 | } |
| 6763 | win_setminheight(); |
| 6764 | } |
| 6765 | # endif |
| 6766 | |
| 6767 | #endif |
| 6768 | |
| 6769 | #ifdef FEAT_WINDOWS |
| 6770 | /* (re)set last window status line */ |
| 6771 | else if (pp == &p_ls) |
| 6772 | { |
| 6773 | last_status(FALSE); |
| 6774 | } |
| 6775 | #endif |
| 6776 | |
| 6777 | #ifdef FEAT_GUI |
| 6778 | else if (pp == &p_linespace) |
| 6779 | { |
| 6780 | if (gui.in_use && gui_mch_adjust_charsize() == OK) |
| 6781 | gui_set_shellsize(FALSE, FALSE); |
| 6782 | } |
| 6783 | #endif |
| 6784 | |
| 6785 | #ifdef FEAT_FOLDING |
| 6786 | /* 'foldlevel' */ |
| 6787 | else if (pp == &curwin->w_p_fdl) |
| 6788 | { |
| 6789 | if (curwin->w_p_fdl < 0) |
| 6790 | curwin->w_p_fdl = 0; |
| 6791 | newFoldLevel(); |
| 6792 | } |
| 6793 | |
| 6794 | /* 'foldminlevel' */ |
| 6795 | else if (pp == &curwin->w_p_fml) |
| 6796 | { |
| 6797 | foldUpdateAll(curwin); |
| 6798 | } |
| 6799 | |
| 6800 | /* 'foldnestmax' */ |
| 6801 | else if (pp == &curwin->w_p_fdn) |
| 6802 | { |
| 6803 | if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) |
| 6804 | foldUpdateAll(curwin); |
| 6805 | } |
| 6806 | |
| 6807 | /* 'foldcolumn' */ |
| 6808 | else if (pp == &curwin->w_p_fdc) |
| 6809 | { |
| 6810 | if (curwin->w_p_fdc < 0) |
| 6811 | { |
| 6812 | errmsg = e_positive; |
| 6813 | curwin->w_p_fdc = 0; |
| 6814 | } |
| 6815 | else if (curwin->w_p_fdc > 12) |
| 6816 | { |
| 6817 | errmsg = e_invarg; |
| 6818 | curwin->w_p_fdc = 12; |
| 6819 | } |
| 6820 | } |
| 6821 | |
| 6822 | /* 'shiftwidth' or 'tabstop' */ |
| 6823 | else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
| 6824 | { |
| 6825 | if (foldmethodIsIndent(curwin)) |
| 6826 | foldUpdateAll(curwin); |
| 6827 | } |
| 6828 | #endif /* FEAT_FOLDING */ |
| 6829 | |
| 6830 | else if (pp == &curbuf->b_p_iminsert) |
| 6831 | { |
| 6832 | if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) |
| 6833 | { |
| 6834 | errmsg = e_invarg; |
| 6835 | curbuf->b_p_iminsert = B_IMODE_NONE; |
| 6836 | } |
| 6837 | p_iminsert = curbuf->b_p_iminsert; |
| 6838 | if (termcap_active) /* don't do this in the alternate screen */ |
| 6839 | showmode(); |
| 6840 | #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP) |
| 6841 | /* Show/unshow value of 'keymap' in status lines. */ |
| 6842 | status_redraw_curbuf(); |
| 6843 | #endif |
| 6844 | } |
| 6845 | |
| 6846 | else if (pp == &curbuf->b_p_imsearch) |
| 6847 | { |
| 6848 | if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) |
| 6849 | { |
| 6850 | errmsg = e_invarg; |
| 6851 | curbuf->b_p_imsearch = B_IMODE_NONE; |
| 6852 | } |
| 6853 | p_imsearch = curbuf->b_p_imsearch; |
| 6854 | } |
| 6855 | |
| 6856 | #ifdef FEAT_TITLE |
| 6857 | /* if 'titlelen' has changed, redraw the title */ |
| 6858 | else if (pp == &p_titlelen) |
| 6859 | { |
| 6860 | if (p_titlelen < 0) |
| 6861 | { |
| 6862 | errmsg = e_positive; |
| 6863 | p_titlelen = 85; |
| 6864 | } |
| 6865 | if (starting != NO_SCREEN && old_value != p_titlelen) |
| 6866 | need_maketitle = TRUE; |
| 6867 | } |
| 6868 | #endif |
| 6869 | |
| 6870 | /* if p_ch changed value, change the command line height */ |
| 6871 | else if (pp == &p_ch) |
| 6872 | { |
| 6873 | if (p_ch < 1) |
| 6874 | { |
| 6875 | errmsg = e_positive; |
| 6876 | p_ch = 1; |
| 6877 | } |
| 6878 | |
| 6879 | /* Only compute the new window layout when startup has been |
| 6880 | * completed. Otherwise the frame sizes may be wrong. */ |
| 6881 | if (p_ch != old_value && full_screen |
| 6882 | #ifdef FEAT_GUI |
| 6883 | && !gui.starting |
| 6884 | #endif |
| 6885 | ) |
| 6886 | command_height(old_value); |
| 6887 | } |
| 6888 | |
| 6889 | /* when 'updatecount' changes from zero to non-zero, open swap files */ |
| 6890 | else if (pp == &p_uc) |
| 6891 | { |
| 6892 | if (p_uc < 0) |
| 6893 | { |
| 6894 | errmsg = e_positive; |
| 6895 | p_uc = 100; |
| 6896 | } |
| 6897 | if (p_uc && !old_value) |
| 6898 | ml_open_files(); |
| 6899 | } |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6900 | #ifdef MZSCHEME_GUI_THREADS |
Bram Moolenaar | 325b7a2 | 2004-07-05 15:58:32 +0000 | [diff] [blame] | 6901 | else if (pp == &p_mzq) |
| 6902 | mzvim_reset_timer(); |
| 6903 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6904 | |
| 6905 | /* sync undo before 'undolevels' changes */ |
| 6906 | else if (pp == &p_ul) |
| 6907 | { |
| 6908 | /* use the old value, otherwise u_sync() may not work properly */ |
| 6909 | p_ul = old_value; |
| 6910 | u_sync(); |
| 6911 | p_ul = value; |
| 6912 | } |
| 6913 | |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 6914 | #ifdef FEAT_LINEBREAK |
| 6915 | /* 'numberwidth' must be positive */ |
| 6916 | else if (pp == &curwin->w_p_nuw) |
| 6917 | { |
| 6918 | if (curwin->w_p_nuw < 1) |
| 6919 | { |
| 6920 | errmsg = e_positive; |
| 6921 | curwin->w_p_nuw = 1; |
| 6922 | } |
| 6923 | if (curwin->w_p_nuw > 10) |
| 6924 | { |
| 6925 | errmsg = e_invarg; |
| 6926 | curwin->w_p_nuw = 10; |
| 6927 | } |
| 6928 | curwin->w_nrwidth_line_count = 0; |
| 6929 | } |
| 6930 | #endif |
| 6931 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6932 | /* |
| 6933 | * Check the bounds for numeric options here |
| 6934 | */ |
| 6935 | if (Rows < min_rows() && full_screen) |
| 6936 | { |
| 6937 | if (errbuf != NULL) |
| 6938 | { |
| 6939 | sprintf((char *)errbuf, _("E593: Need at least %d lines"), |
| 6940 | min_rows()); |
| 6941 | errmsg = errbuf; |
| 6942 | } |
| 6943 | Rows = min_rows(); |
| 6944 | } |
| 6945 | if (Columns < MIN_COLUMNS && full_screen) |
| 6946 | { |
| 6947 | if (errbuf != NULL) |
| 6948 | { |
| 6949 | sprintf((char *)errbuf, _("E594: Need at least %d columns"), |
| 6950 | MIN_COLUMNS); |
| 6951 | errmsg = errbuf; |
| 6952 | } |
| 6953 | Columns = MIN_COLUMNS; |
| 6954 | } |
| 6955 | |
| 6956 | #ifdef DJGPP |
| 6957 | /* avoid a crash by checking for a too large value of 'columns' */ |
| 6958 | if (old_Columns != Columns && full_screen && term_console) |
| 6959 | mch_check_columns(); |
| 6960 | #endif |
| 6961 | |
| 6962 | /* |
| 6963 | * If the screen (shell) height has been changed, assume it is the |
| 6964 | * physical screenheight. |
| 6965 | */ |
| 6966 | if (old_Rows != Rows || old_Columns != Columns) |
| 6967 | { |
| 6968 | /* Changing the screen size is not allowed while updating the screen. */ |
| 6969 | if (updating_screen) |
| 6970 | *pp = old_value; |
| 6971 | else if (full_screen |
| 6972 | #ifdef FEAT_GUI |
| 6973 | && !gui.starting |
| 6974 | #endif |
| 6975 | ) |
| 6976 | set_shellsize((int)Columns, (int)Rows, TRUE); |
| 6977 | else |
| 6978 | { |
| 6979 | /* Postpone the resizing; check the size and cmdline position for |
| 6980 | * messages. */ |
| 6981 | check_shellsize(); |
| 6982 | if (cmdline_row > Rows - p_ch && Rows > p_ch) |
| 6983 | cmdline_row = Rows - p_ch; |
| 6984 | } |
| 6985 | } |
| 6986 | |
| 6987 | if (curbuf->b_p_sts < 0) |
| 6988 | { |
| 6989 | errmsg = e_positive; |
| 6990 | curbuf->b_p_sts = 0; |
| 6991 | } |
| 6992 | if (curbuf->b_p_ts <= 0) |
| 6993 | { |
| 6994 | errmsg = e_positive; |
| 6995 | curbuf->b_p_ts = 8; |
| 6996 | } |
| 6997 | if (curbuf->b_p_tw < 0) |
| 6998 | { |
| 6999 | errmsg = e_positive; |
| 7000 | curbuf->b_p_tw = 0; |
| 7001 | } |
| 7002 | if (p_tm < 0) |
| 7003 | { |
| 7004 | errmsg = e_positive; |
| 7005 | p_tm = 0; |
| 7006 | } |
| 7007 | if ((curwin->w_p_scr <= 0 |
| 7008 | || (curwin->w_p_scr > curwin->w_height |
| 7009 | && curwin->w_height > 0)) |
| 7010 | && full_screen) |
| 7011 | { |
| 7012 | if (pp == &(curwin->w_p_scr)) |
| 7013 | { |
| 7014 | if (curwin->w_p_scr != 0) |
| 7015 | errmsg = e_scroll; |
| 7016 | win_comp_scroll(curwin); |
| 7017 | } |
| 7018 | /* If 'scroll' became invalid because of a side effect silently adjust |
| 7019 | * it. */ |
| 7020 | else if (curwin->w_p_scr <= 0) |
| 7021 | curwin->w_p_scr = 1; |
| 7022 | else /* curwin->w_p_scr > curwin->w_height */ |
| 7023 | curwin->w_p_scr = curwin->w_height; |
| 7024 | } |
| 7025 | if (p_report < 0) |
| 7026 | { |
| 7027 | errmsg = e_positive; |
| 7028 | p_report = 1; |
| 7029 | } |
| 7030 | if ((p_sj < 0 || p_sj >= Rows) && full_screen) |
| 7031 | { |
| 7032 | if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ |
| 7033 | p_sj = Rows / 2; |
| 7034 | else |
| 7035 | { |
| 7036 | errmsg = e_scroll; |
| 7037 | p_sj = 1; |
| 7038 | } |
| 7039 | } |
| 7040 | if (p_so < 0 && full_screen) |
| 7041 | { |
| 7042 | errmsg = e_scroll; |
| 7043 | p_so = 0; |
| 7044 | } |
| 7045 | if (p_siso < 0 && full_screen) |
| 7046 | { |
| 7047 | errmsg = e_positive; |
| 7048 | p_siso = 0; |
| 7049 | } |
| 7050 | #ifdef FEAT_CMDWIN |
| 7051 | if (p_cwh < 1) |
| 7052 | { |
| 7053 | errmsg = e_positive; |
| 7054 | p_cwh = 1; |
| 7055 | } |
| 7056 | #endif |
| 7057 | if (p_ut < 0) |
| 7058 | { |
| 7059 | errmsg = e_positive; |
| 7060 | p_ut = 2000; |
| 7061 | } |
| 7062 | if (p_ss < 0) |
| 7063 | { |
| 7064 | errmsg = e_positive; |
| 7065 | p_ss = 0; |
| 7066 | } |
| 7067 | |
| 7068 | /* May set global value for local option. */ |
| 7069 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
| 7070 | *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; |
| 7071 | |
| 7072 | options[opt_idx].flags |= P_WAS_SET; |
| 7073 | |
| 7074 | comp_col(); /* in case 'columns' or 'ls' changed */ |
| 7075 | if (curwin->w_curswant != MAXCOL) |
| 7076 | curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */ |
| 7077 | check_redraw(options[opt_idx].flags); |
| 7078 | |
| 7079 | return errmsg; |
| 7080 | } |
| 7081 | |
| 7082 | /* |
| 7083 | * Called after an option changed: check if something needs to be redrawn. |
| 7084 | */ |
| 7085 | static void |
| 7086 | check_redraw(flags) |
| 7087 | long_u flags; |
| 7088 | { |
| 7089 | /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ |
| 7090 | int clear = (flags & P_RCLR) == P_RCLR; |
| 7091 | int all = ((flags & P_RALL) == P_RALL || clear); |
| 7092 | |
| 7093 | #ifdef FEAT_WINDOWS |
| 7094 | if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ |
| 7095 | status_redraw_all(); |
| 7096 | #endif |
| 7097 | |
| 7098 | if ((flags & P_RBUF) || (flags & P_RWIN) || all) |
| 7099 | changed_window_setting(); |
| 7100 | if (flags & P_RBUF) |
| 7101 | redraw_curbuf_later(NOT_VALID); |
| 7102 | if (clear) |
| 7103 | redraw_all_later(CLEAR); |
| 7104 | else if (all) |
| 7105 | redraw_all_later(NOT_VALID); |
| 7106 | } |
| 7107 | |
| 7108 | /* |
| 7109 | * Find index for option 'arg'. |
| 7110 | * Return -1 if not found. |
| 7111 | */ |
| 7112 | static int |
| 7113 | findoption(arg) |
| 7114 | char_u *arg; |
| 7115 | { |
| 7116 | int opt_idx; |
| 7117 | char *s, *p; |
| 7118 | static short quick_tab[27] = {0, 0}; /* quick access table */ |
| 7119 | int is_term_opt; |
| 7120 | |
| 7121 | /* |
| 7122 | * For first call: Initialize the quick-access table. |
| 7123 | * It contains the index for the first option that starts with a certain |
| 7124 | * letter. There are 26 letters, plus the first "t_" option. |
| 7125 | */ |
| 7126 | if (quick_tab[1] == 0) |
| 7127 | { |
| 7128 | p = options[0].fullname; |
| 7129 | for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) |
| 7130 | { |
| 7131 | if (s[0] != p[0]) |
| 7132 | { |
| 7133 | if (s[0] == 't' && s[1] == '_') |
| 7134 | quick_tab[26] = opt_idx; |
| 7135 | else |
| 7136 | quick_tab[CharOrdLow(s[0])] = opt_idx; |
| 7137 | } |
| 7138 | p = s; |
| 7139 | } |
| 7140 | } |
| 7141 | |
| 7142 | /* |
| 7143 | * Check for name starting with an illegal character. |
| 7144 | */ |
| 7145 | #ifdef EBCDIC |
| 7146 | if (!islower(arg[0])) |
| 7147 | #else |
| 7148 | if (arg[0] < 'a' || arg[0] > 'z') |
| 7149 | #endif |
| 7150 | return -1; |
| 7151 | |
| 7152 | is_term_opt = (arg[0] == 't' && arg[1] == '_'); |
| 7153 | if (is_term_opt) |
| 7154 | opt_idx = quick_tab[26]; |
| 7155 | else |
| 7156 | opt_idx = quick_tab[CharOrdLow(arg[0])]; |
| 7157 | for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) |
| 7158 | { |
| 7159 | if (STRCMP(arg, s) == 0) /* match full name */ |
| 7160 | break; |
| 7161 | } |
| 7162 | if (s == NULL && !is_term_opt) |
| 7163 | { |
| 7164 | opt_idx = quick_tab[CharOrdLow(arg[0])]; |
| 7165 | for ( ; options[opt_idx].fullname != NULL; opt_idx++) |
| 7166 | { |
| 7167 | s = options[opt_idx].shortname; |
| 7168 | if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ |
| 7169 | break; |
| 7170 | s = NULL; |
| 7171 | } |
| 7172 | } |
| 7173 | if (s == NULL) |
| 7174 | opt_idx = -1; |
| 7175 | return opt_idx; |
| 7176 | } |
| 7177 | |
Bram Moolenaar | 325b7a2 | 2004-07-05 15:58:32 +0000 | [diff] [blame] | 7178 | #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7179 | /* |
| 7180 | * Get the value for an option. |
| 7181 | * |
| 7182 | * Returns: |
| 7183 | * Number or Toggle option: 1, *numval gets value. |
| 7184 | * String option: 0, *stringval gets allocated string. |
| 7185 | * Hidden Number or Toggle option: -1. |
| 7186 | * hidden String option: -2. |
| 7187 | * unknown option: -3. |
| 7188 | */ |
| 7189 | int |
| 7190 | get_option_value(name, numval, stringval, opt_flags) |
| 7191 | char_u *name; |
| 7192 | long *numval; |
| 7193 | char_u **stringval; /* NULL when only checking existance */ |
| 7194 | int opt_flags; |
| 7195 | { |
| 7196 | int opt_idx; |
| 7197 | char_u *varp; |
| 7198 | |
| 7199 | opt_idx = findoption(name); |
| 7200 | if (opt_idx < 0) /* unknown option */ |
| 7201 | return -3; |
| 7202 | |
| 7203 | varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
| 7204 | |
| 7205 | if (options[opt_idx].flags & P_STRING) |
| 7206 | { |
| 7207 | if (varp == NULL) /* hidden option */ |
| 7208 | return -2; |
| 7209 | if (stringval != NULL) |
| 7210 | { |
| 7211 | #ifdef FEAT_CRYPT |
| 7212 | /* never return the value of the crypt key */ |
| 7213 | if ((char_u **)varp == &curbuf->b_p_key) |
| 7214 | *stringval = vim_strsave((char_u *)"*****"); |
| 7215 | else |
| 7216 | #endif |
| 7217 | *stringval = vim_strsave(*(char_u **)(varp)); |
| 7218 | } |
| 7219 | return 0; |
| 7220 | } |
| 7221 | |
| 7222 | if (varp == NULL) /* hidden option */ |
| 7223 | return -1; |
| 7224 | if (options[opt_idx].flags & P_NUM) |
| 7225 | *numval = *(long *)varp; |
| 7226 | else |
| 7227 | { |
| 7228 | /* Special case: 'modified' is b_changed, but we also want to consider |
| 7229 | * it set when 'ff' or 'fenc' changed. */ |
| 7230 | if ((int *)varp == &curbuf->b_changed) |
| 7231 | *numval = curbufIsChanged(); |
| 7232 | else |
| 7233 | *numval = *(int *)varp; |
| 7234 | } |
| 7235 | return 1; |
| 7236 | } |
| 7237 | #endif |
| 7238 | |
| 7239 | /* |
| 7240 | * Set the value of option "name". |
| 7241 | * Use "string" for string options, use "number" for other options. |
| 7242 | */ |
| 7243 | void |
| 7244 | set_option_value(name, number, string, opt_flags) |
| 7245 | char_u *name; |
| 7246 | long number; |
| 7247 | char_u *string; |
| 7248 | int opt_flags; /* OPT_LOCAL or 0 (both) */ |
| 7249 | { |
| 7250 | int opt_idx; |
| 7251 | char_u *varp; |
| 7252 | int flags; |
| 7253 | |
| 7254 | opt_idx = findoption(name); |
| 7255 | if (opt_idx == -1) |
| 7256 | EMSG2(_("E355: Unknown option: %s"), name); |
| 7257 | else |
| 7258 | { |
| 7259 | flags = options[opt_idx].flags; |
| 7260 | #ifdef HAVE_SANDBOX |
| 7261 | /* Disallow changing some options in the sandbox */ |
| 7262 | if (sandbox > 0 && (flags & P_SECURE)) |
| 7263 | EMSG(_(e_sandbox)); |
| 7264 | else |
| 7265 | #endif |
| 7266 | if (flags & P_STRING) |
| 7267 | set_string_option(opt_idx, string, opt_flags); |
| 7268 | else |
| 7269 | { |
| 7270 | varp = get_varp(&options[opt_idx]); |
| 7271 | if (varp != NULL) /* hidden option is not changed */ |
| 7272 | { |
| 7273 | if (flags & P_NUM) |
| 7274 | (void)set_num_option(opt_idx, varp, number, NULL, opt_flags); |
| 7275 | else |
| 7276 | (void)set_bool_option(opt_idx, varp, (int)number, opt_flags); |
| 7277 | } |
| 7278 | } |
| 7279 | } |
| 7280 | } |
| 7281 | |
| 7282 | /* |
| 7283 | * Get the terminal code for a terminal option. |
| 7284 | * Returns NULL when not found. |
| 7285 | */ |
| 7286 | char_u * |
| 7287 | get_term_code(tname) |
| 7288 | char_u *tname; |
| 7289 | { |
| 7290 | int opt_idx; |
| 7291 | char_u *varp; |
| 7292 | |
| 7293 | if (tname[0] != 't' || tname[1] != '_' || |
| 7294 | tname[2] == NUL || tname[3] == NUL) |
| 7295 | return NULL; |
| 7296 | if ((opt_idx = findoption(tname)) >= 0) |
| 7297 | { |
| 7298 | varp = get_varp(&(options[opt_idx])); |
| 7299 | if (varp != NULL) |
| 7300 | varp = *(char_u **)(varp); |
| 7301 | return varp; |
| 7302 | } |
| 7303 | return find_termcode(tname + 2); |
| 7304 | } |
| 7305 | |
| 7306 | char_u * |
| 7307 | get_highlight_default() |
| 7308 | { |
| 7309 | int i; |
| 7310 | |
| 7311 | i = findoption((char_u *)"hl"); |
| 7312 | if (i >= 0) |
| 7313 | return options[i].def_val[VI_DEFAULT]; |
| 7314 | return (char_u *)NULL; |
| 7315 | } |
| 7316 | |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 7317 | #if defined(FEAT_MBYTE) || defined(PROTO) |
| 7318 | char_u * |
| 7319 | get_encoding_default() |
| 7320 | { |
| 7321 | int i; |
| 7322 | |
| 7323 | i = findoption((char_u *)"enc"); |
| 7324 | if (i >= 0) |
| 7325 | return options[i].def_val[VI_DEFAULT]; |
| 7326 | return (char_u *)NULL; |
| 7327 | } |
| 7328 | #endif |
| 7329 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7330 | /* |
| 7331 | * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. |
| 7332 | */ |
| 7333 | static int |
| 7334 | find_key_option(arg) |
| 7335 | char_u *arg; |
| 7336 | { |
| 7337 | int key; |
| 7338 | int modifiers; |
| 7339 | |
| 7340 | /* |
| 7341 | * Don't use get_special_key_code() for t_xx, we don't want it to call |
| 7342 | * add_termcap_entry(). |
| 7343 | */ |
| 7344 | if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
| 7345 | key = TERMCAP2KEY(arg[2], arg[3]); |
| 7346 | else |
| 7347 | { |
| 7348 | --arg; /* put arg at the '<' */ |
| 7349 | modifiers = 0; |
| 7350 | key = find_special_key(&arg, &modifiers, TRUE); |
| 7351 | if (modifiers) /* can't handle modifiers here */ |
| 7352 | key = 0; |
| 7353 | } |
| 7354 | return key; |
| 7355 | } |
| 7356 | |
| 7357 | /* |
| 7358 | * if 'all' == 0: show changed options |
| 7359 | * if 'all' == 1: show all normal options |
| 7360 | * if 'all' == 2: show all terminal options |
| 7361 | */ |
| 7362 | static void |
| 7363 | showoptions(all, opt_flags) |
| 7364 | int all; |
| 7365 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 7366 | { |
| 7367 | struct vimoption *p; |
| 7368 | int col; |
| 7369 | int isterm; |
| 7370 | char_u *varp; |
| 7371 | struct vimoption **items; |
| 7372 | int item_count; |
| 7373 | int run; |
| 7374 | int row, rows; |
| 7375 | int cols; |
| 7376 | int i; |
| 7377 | int len; |
| 7378 | |
| 7379 | #define INC 20 |
| 7380 | #define GAP 3 |
| 7381 | |
| 7382 | items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) * |
| 7383 | PARAM_COUNT)); |
| 7384 | if (items == NULL) |
| 7385 | return; |
| 7386 | |
| 7387 | /* Highlight title */ |
| 7388 | if (all == 2) |
| 7389 | MSG_PUTS_TITLE(_("\n--- Terminal codes ---")); |
| 7390 | else if (opt_flags & OPT_GLOBAL) |
| 7391 | MSG_PUTS_TITLE(_("\n--- Global option values ---")); |
| 7392 | else if (opt_flags & OPT_LOCAL) |
| 7393 | MSG_PUTS_TITLE(_("\n--- Local option values ---")); |
| 7394 | else |
| 7395 | MSG_PUTS_TITLE(_("\n--- Options ---")); |
| 7396 | |
| 7397 | /* |
| 7398 | * do the loop two times: |
| 7399 | * 1. display the short items |
| 7400 | * 2. display the long items (only strings and numbers) |
| 7401 | */ |
| 7402 | for (run = 1; run <= 2 && !got_int; ++run) |
| 7403 | { |
| 7404 | /* |
| 7405 | * collect the items in items[] |
| 7406 | */ |
| 7407 | item_count = 0; |
| 7408 | for (p = &options[0]; p->fullname != NULL; p++) |
| 7409 | { |
| 7410 | varp = NULL; |
| 7411 | isterm = istermoption(p); |
| 7412 | if (opt_flags != 0) |
| 7413 | { |
| 7414 | if (p->indir != PV_NONE && !isterm) |
| 7415 | varp = get_varp_scope(p, opt_flags); |
| 7416 | } |
| 7417 | else |
| 7418 | varp = get_varp(p); |
| 7419 | if (varp != NULL |
| 7420 | && ((all == 2 && isterm) |
| 7421 | || (all == 1 && !isterm) |
| 7422 | || (all == 0 && !optval_default(p, varp)))) |
| 7423 | { |
| 7424 | if (p->flags & P_BOOL) |
| 7425 | len = 1; /* a toggle option fits always */ |
| 7426 | else |
| 7427 | { |
| 7428 | option_value2string(p, opt_flags); |
| 7429 | len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; |
| 7430 | } |
| 7431 | if ((len <= INC - GAP && run == 1) || |
| 7432 | (len > INC - GAP && run == 2)) |
| 7433 | items[item_count++] = p; |
| 7434 | } |
| 7435 | } |
| 7436 | |
| 7437 | /* |
| 7438 | * display the items |
| 7439 | */ |
| 7440 | if (run == 1) |
| 7441 | { |
| 7442 | cols = (Columns + GAP - 3) / INC; |
| 7443 | if (cols == 0) |
| 7444 | cols = 1; |
| 7445 | rows = (item_count + cols - 1) / cols; |
| 7446 | } |
| 7447 | else /* run == 2 */ |
| 7448 | rows = item_count; |
| 7449 | for (row = 0; row < rows && !got_int; ++row) |
| 7450 | { |
| 7451 | msg_putchar('\n'); /* go to next line */ |
| 7452 | if (got_int) /* 'q' typed in more */ |
| 7453 | break; |
| 7454 | col = 0; |
| 7455 | for (i = row; i < item_count; i += rows) |
| 7456 | { |
| 7457 | msg_col = col; /* make columns */ |
| 7458 | showoneopt(items[i], opt_flags); |
| 7459 | col += INC; |
| 7460 | } |
| 7461 | out_flush(); |
| 7462 | ui_breakcheck(); |
| 7463 | } |
| 7464 | } |
| 7465 | vim_free(items); |
| 7466 | } |
| 7467 | |
| 7468 | /* |
| 7469 | * Return TRUE if option "p" has its default value. |
| 7470 | */ |
| 7471 | static int |
| 7472 | optval_default(p, varp) |
| 7473 | struct vimoption *p; |
| 7474 | char_u *varp; |
| 7475 | { |
| 7476 | int dvi; |
| 7477 | |
| 7478 | if (varp == NULL) |
| 7479 | return TRUE; /* hidden option is always at default */ |
| 7480 | dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT; |
| 7481 | if (p->flags & P_NUM) |
| 7482 | return (*(long *)varp == (long)p->def_val[dvi]); |
| 7483 | if (p->flags & P_BOOL) |
| 7484 | /* the cast to long is required for Manx C */ |
| 7485 | return (*(int *)varp == (int)(long)p->def_val[dvi]); |
| 7486 | /* P_STRING */ |
| 7487 | return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
| 7488 | } |
| 7489 | |
| 7490 | /* |
| 7491 | * showoneopt: show the value of one option |
| 7492 | * must not be called with a hidden option! |
| 7493 | */ |
| 7494 | static void |
| 7495 | showoneopt(p, opt_flags) |
| 7496 | struct vimoption *p; |
| 7497 | int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */ |
| 7498 | { |
| 7499 | char_u *varp; |
| 7500 | |
| 7501 | varp = get_varp_scope(p, opt_flags); |
| 7502 | |
| 7503 | /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ |
| 7504 | if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
| 7505 | ? !curbufIsChanged() : !*(int *)varp)) |
| 7506 | MSG_PUTS("no"); |
| 7507 | else if ((p->flags & P_BOOL) && *(int *)varp < 0) |
| 7508 | MSG_PUTS("--"); |
| 7509 | else |
| 7510 | MSG_PUTS(" "); |
| 7511 | MSG_PUTS(p->fullname); |
| 7512 | if (!(p->flags & P_BOOL)) |
| 7513 | { |
| 7514 | msg_putchar('='); |
| 7515 | /* put value string in NameBuff */ |
| 7516 | option_value2string(p, opt_flags); |
| 7517 | msg_outtrans(NameBuff); |
| 7518 | } |
| 7519 | } |
| 7520 | |
| 7521 | /* |
| 7522 | * Write modified options as ":set" commands to a file. |
| 7523 | * |
| 7524 | * There are three values for "opt_flags": |
| 7525 | * OPT_GLOBAL: Write global option values and fresh values of |
| 7526 | * buffer-local options (used for start of a session |
| 7527 | * file). |
| 7528 | * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for |
| 7529 | * curwin (used for a vimrc file). |
| 7530 | * OPT_LOCAL: Write buffer-local option values for curbuf, fresh |
| 7531 | * and local values for window-local options of |
| 7532 | * curwin. Local values are also written when at the |
| 7533 | * default value, because a modeline or autocommand |
| 7534 | * may have set them when doing ":edit file" and the |
| 7535 | * user has set them back at the default or fresh |
| 7536 | * value. |
| 7537 | * When "local_only" is TRUE, don't write fresh |
| 7538 | * values, only local values (for ":mkview"). |
| 7539 | * (fresh value = value used for a new buffer or window for a local option). |
| 7540 | * |
| 7541 | * Return FAIL on error, OK otherwise. |
| 7542 | */ |
| 7543 | int |
| 7544 | makeset(fd, opt_flags, local_only) |
| 7545 | FILE *fd; |
| 7546 | int opt_flags; |
| 7547 | int local_only; |
| 7548 | { |
| 7549 | struct vimoption *p; |
| 7550 | char_u *varp; /* currently used value */ |
| 7551 | char_u *varp_fresh; /* local value */ |
| 7552 | char_u *varp_local = NULL; /* fresh value */ |
| 7553 | char *cmd; |
| 7554 | int round; |
| 7555 | |
| 7556 | /* |
| 7557 | * The options that don't have a default (terminal name, columns, lines) |
| 7558 | * are never written. Terminal options are also not written. |
| 7559 | */ |
| 7560 | for (p = &options[0]; !istermoption(p); p++) |
| 7561 | if (!(p->flags & P_NO_MKRC) && !istermoption(p)) |
| 7562 | { |
| 7563 | /* skip global option when only doing locals */ |
| 7564 | if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
| 7565 | continue; |
| 7566 | |
| 7567 | /* Do not store options like 'bufhidden' and 'syntax' in a vimrc |
| 7568 | * file, they are always buffer-specific. */ |
| 7569 | if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
| 7570 | continue; |
| 7571 | |
| 7572 | /* Global values are only written when not at the default value. */ |
| 7573 | varp = get_varp_scope(p, opt_flags); |
| 7574 | if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp)) |
| 7575 | continue; |
| 7576 | |
| 7577 | round = 2; |
| 7578 | if (p->indir != PV_NONE) |
| 7579 | { |
| 7580 | if (p->var == VAR_WIN) |
| 7581 | { |
| 7582 | /* skip window-local option when only doing globals */ |
| 7583 | if (!(opt_flags & OPT_LOCAL)) |
| 7584 | continue; |
| 7585 | /* When fresh value of window-local option is not at the |
| 7586 | * default, need to write it too. */ |
| 7587 | if (!(opt_flags & OPT_GLOBAL) && !local_only) |
| 7588 | { |
| 7589 | varp_fresh = get_varp_scope(p, OPT_GLOBAL); |
| 7590 | if (!optval_default(p, varp_fresh)) |
| 7591 | { |
| 7592 | round = 1; |
| 7593 | varp_local = varp; |
| 7594 | varp = varp_fresh; |
| 7595 | } |
| 7596 | } |
| 7597 | } |
| 7598 | } |
| 7599 | |
| 7600 | /* Round 1: fresh value for window-local options. |
| 7601 | * Round 2: other values */ |
| 7602 | for ( ; round <= 2; varp = varp_local, ++round) |
| 7603 | { |
| 7604 | if (round == 1 || (opt_flags & OPT_GLOBAL)) |
| 7605 | cmd = "set"; |
| 7606 | else |
| 7607 | cmd = "setlocal"; |
| 7608 | |
| 7609 | if (p->flags & P_BOOL) |
| 7610 | { |
| 7611 | if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) |
| 7612 | return FAIL; |
| 7613 | } |
| 7614 | else if (p->flags & P_NUM) |
| 7615 | { |
| 7616 | if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) |
| 7617 | return FAIL; |
| 7618 | } |
| 7619 | else /* P_STRING */ |
| 7620 | { |
| 7621 | /* Don't set 'syntax' and 'filetype' again if the value is |
| 7622 | * already right, avoids reloading the syntax file. */ |
| 7623 | if (p->indir == PV_SYN || p->indir == PV_FT) |
| 7624 | { |
| 7625 | if (fprintf(fd, "if &%s != '%s'", p->fullname, |
| 7626 | *(char_u **)(varp)) < 0 |
| 7627 | || put_eol(fd) < 0) |
| 7628 | return FAIL; |
| 7629 | } |
| 7630 | if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, |
| 7631 | (p->flags & P_EXPAND) != 0) == FAIL) |
| 7632 | return FAIL; |
| 7633 | if (p->indir == PV_SYN || p->indir == PV_FT) |
| 7634 | { |
| 7635 | if (put_line(fd, "endif") == FAIL) |
| 7636 | return FAIL; |
| 7637 | } |
| 7638 | } |
| 7639 | } |
| 7640 | } |
| 7641 | return OK; |
| 7642 | } |
| 7643 | |
| 7644 | #if defined(FEAT_FOLDING) || defined(PROTO) |
| 7645 | /* |
| 7646 | * Generate set commands for the local fold options only. Used when |
| 7647 | * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". |
| 7648 | */ |
| 7649 | int |
| 7650 | makefoldset(fd) |
| 7651 | FILE *fd; |
| 7652 | { |
| 7653 | if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL |
| 7654 | # ifdef FEAT_EVAL |
| 7655 | || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE) |
| 7656 | == FAIL |
| 7657 | # endif |
| 7658 | || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE) |
| 7659 | == FAIL |
| 7660 | || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE) |
| 7661 | == FAIL |
| 7662 | || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL |
| 7663 | || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL |
| 7664 | || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL |
| 7665 | || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL |
| 7666 | ) |
| 7667 | return FAIL; |
| 7668 | |
| 7669 | return OK; |
| 7670 | } |
| 7671 | #endif |
| 7672 | |
| 7673 | static int |
| 7674 | put_setstring(fd, cmd, name, valuep, expand) |
| 7675 | FILE *fd; |
| 7676 | char *cmd; |
| 7677 | char *name; |
| 7678 | char_u **valuep; |
| 7679 | int expand; |
| 7680 | { |
| 7681 | char_u *s; |
| 7682 | char_u buf[MAXPATHL]; |
| 7683 | |
| 7684 | if (fprintf(fd, "%s %s=", cmd, name) < 0) |
| 7685 | return FAIL; |
| 7686 | if (*valuep != NULL) |
| 7687 | { |
| 7688 | /* Output 'pastetoggle' as key names. For other |
| 7689 | * options some characters have to be escaped with |
| 7690 | * CTRL-V or backslash */ |
| 7691 | if (valuep == &p_pt) |
| 7692 | { |
| 7693 | s = *valuep; |
| 7694 | while (*s != NUL) |
| 7695 | if (fputs((char *)str2special(&s, FALSE), fd) < 0) |
| 7696 | return FAIL; |
| 7697 | } |
| 7698 | else if (expand) |
| 7699 | { |
| 7700 | home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); |
| 7701 | if (put_escstr(fd, buf, 2) == FAIL) |
| 7702 | return FAIL; |
| 7703 | } |
| 7704 | else if (put_escstr(fd, *valuep, 2) == FAIL) |
| 7705 | return FAIL; |
| 7706 | } |
| 7707 | if (put_eol(fd) < 0) |
| 7708 | return FAIL; |
| 7709 | return OK; |
| 7710 | } |
| 7711 | |
| 7712 | static int |
| 7713 | put_setnum(fd, cmd, name, valuep) |
| 7714 | FILE *fd; |
| 7715 | char *cmd; |
| 7716 | char *name; |
| 7717 | long *valuep; |
| 7718 | { |
| 7719 | long wc; |
| 7720 | |
| 7721 | if (fprintf(fd, "%s %s=", cmd, name) < 0) |
| 7722 | return FAIL; |
| 7723 | if (wc_use_keyname((char_u *)valuep, &wc)) |
| 7724 | { |
| 7725 | /* print 'wildchar' and 'wildcharm' as a key name */ |
| 7726 | if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
| 7727 | return FAIL; |
| 7728 | } |
| 7729 | else if (fprintf(fd, "%ld", *valuep) < 0) |
| 7730 | return FAIL; |
| 7731 | if (put_eol(fd) < 0) |
| 7732 | return FAIL; |
| 7733 | return OK; |
| 7734 | } |
| 7735 | |
| 7736 | static int |
| 7737 | put_setbool(fd, cmd, name, value) |
| 7738 | FILE *fd; |
| 7739 | char *cmd; |
| 7740 | char *name; |
| 7741 | int value; |
| 7742 | { |
| 7743 | if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
| 7744 | || put_eol(fd) < 0) |
| 7745 | return FAIL; |
| 7746 | return OK; |
| 7747 | } |
| 7748 | |
| 7749 | /* |
| 7750 | * Clear all the terminal options. |
| 7751 | * If the option has been allocated, free the memory. |
| 7752 | * Terminal options are never hidden or indirect. |
| 7753 | */ |
| 7754 | void |
| 7755 | clear_termoptions() |
| 7756 | { |
| 7757 | struct vimoption *p; |
| 7758 | |
| 7759 | /* |
| 7760 | * Reset a few things before clearing the old options. This may cause |
| 7761 | * outputting a few things that the terminal doesn't understand, but the |
| 7762 | * screen will be cleared later, so this is OK. |
| 7763 | */ |
| 7764 | #ifdef FEAT_MOUSE_TTY |
| 7765 | mch_setmouse(FALSE); /* switch mouse off */ |
| 7766 | #endif |
| 7767 | #ifdef FEAT_TITLE |
| 7768 | mch_restore_title(3); /* restore window titles */ |
| 7769 | #endif |
| 7770 | #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) |
| 7771 | /* When starting the GUI close the display opened for the clipboard. |
| 7772 | * After restoring the title, because that will need the display. */ |
| 7773 | if (gui.starting) |
| 7774 | clear_xterm_clip(); |
| 7775 | #endif |
| 7776 | #ifdef WIN3264 |
| 7777 | /* |
| 7778 | * Check if this is allowed now. |
| 7779 | */ |
| 7780 | if (can_end_termcap_mode(FALSE) == TRUE) |
| 7781 | #endif |
| 7782 | stoptermcap(); /* stop termcap mode */ |
| 7783 | |
| 7784 | for (p = &options[0]; p->fullname != NULL; p++) |
| 7785 | if (istermoption(p)) |
| 7786 | { |
| 7787 | if (p->flags & P_ALLOCED) |
| 7788 | free_string_option(*(char_u **)(p->var)); |
| 7789 | if (p->flags & P_DEF_ALLOCED) |
| 7790 | free_string_option(p->def_val[VI_DEFAULT]); |
| 7791 | *(char_u **)(p->var) = empty_option; |
| 7792 | p->def_val[VI_DEFAULT] = empty_option; |
| 7793 | p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); |
| 7794 | } |
| 7795 | clear_termcodes(); |
| 7796 | } |
| 7797 | |
| 7798 | /* |
| 7799 | * Set the terminal option defaults to the current value. |
| 7800 | * Used after setting the terminal name. |
| 7801 | */ |
| 7802 | void |
| 7803 | set_term_defaults() |
| 7804 | { |
| 7805 | struct vimoption *p; |
| 7806 | |
| 7807 | for (p = &options[0]; p->fullname != NULL; p++) |
| 7808 | { |
| 7809 | if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) |
| 7810 | { |
| 7811 | if (p->flags & P_DEF_ALLOCED) |
| 7812 | { |
| 7813 | free_string_option(p->def_val[VI_DEFAULT]); |
| 7814 | p->flags &= ~P_DEF_ALLOCED; |
| 7815 | } |
| 7816 | p->def_val[VI_DEFAULT] = *(char_u **)(p->var); |
| 7817 | if (p->flags & P_ALLOCED) |
| 7818 | { |
| 7819 | p->flags |= P_DEF_ALLOCED; |
| 7820 | p->flags &= ~P_ALLOCED; /* don't free the value now */ |
| 7821 | } |
| 7822 | } |
| 7823 | } |
| 7824 | } |
| 7825 | |
| 7826 | /* |
| 7827 | * return TRUE if 'p' starts with 't_' |
| 7828 | */ |
| 7829 | static int |
| 7830 | istermoption(p) |
| 7831 | struct vimoption *p; |
| 7832 | { |
| 7833 | return (p->fullname[0] == 't' && p->fullname[1] == '_'); |
| 7834 | } |
| 7835 | |
| 7836 | /* |
| 7837 | * Compute columns for ruler and shown command. 'sc_col' is also used to |
| 7838 | * decide what the maximum length of a message on the status line can be. |
| 7839 | * If there is a status line for the last window, 'sc_col' is independent |
| 7840 | * of 'ru_col'. |
| 7841 | */ |
| 7842 | |
| 7843 | #define COL_RULER 17 /* columns needed by standard ruler */ |
| 7844 | |
| 7845 | void |
| 7846 | comp_col() |
| 7847 | { |
| 7848 | #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS) |
| 7849 | int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); |
| 7850 | |
| 7851 | sc_col = 0; |
| 7852 | ru_col = 0; |
| 7853 | if (p_ru) |
| 7854 | { |
| 7855 | #ifdef FEAT_STL_OPT |
| 7856 | ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; |
| 7857 | #else |
| 7858 | ru_col = COL_RULER + 1; |
| 7859 | #endif |
| 7860 | /* no last status line, adjust sc_col */ |
| 7861 | if (!last_has_status) |
| 7862 | sc_col = ru_col; |
| 7863 | } |
| 7864 | if (p_sc) |
| 7865 | { |
| 7866 | sc_col += SHOWCMD_COLS; |
| 7867 | if (!p_ru || last_has_status) /* no need for separating space */ |
| 7868 | ++sc_col; |
| 7869 | } |
| 7870 | sc_col = Columns - sc_col; |
| 7871 | ru_col = Columns - ru_col; |
| 7872 | if (sc_col <= 0) /* screen too narrow, will become a mess */ |
| 7873 | sc_col = 1; |
| 7874 | if (ru_col <= 0) |
| 7875 | ru_col = 1; |
| 7876 | #else |
| 7877 | sc_col = Columns; |
| 7878 | ru_col = Columns; |
| 7879 | #endif |
| 7880 | } |
| 7881 | |
| 7882 | /* |
| 7883 | * Get pointer to option variable, depending on local or global scope. |
| 7884 | */ |
| 7885 | static char_u * |
| 7886 | get_varp_scope(p, opt_flags) |
| 7887 | struct vimoption *p; |
| 7888 | int opt_flags; |
| 7889 | { |
| 7890 | if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) |
| 7891 | { |
| 7892 | if (p->var == VAR_WIN) |
| 7893 | return (char_u *)GLOBAL_WO(get_varp(p)); |
| 7894 | return p->var; |
| 7895 | } |
| 7896 | if ((opt_flags & OPT_LOCAL) && (int)p->indir >= PV_BOTH) |
| 7897 | { |
| 7898 | switch ((int)p->indir) |
| 7899 | { |
| 7900 | #ifdef FEAT_QUICKFIX |
| 7901 | case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp); |
| 7902 | case OPT_BOTH(PV_MP): return (char_u *)&(curbuf->b_p_mp); |
| 7903 | case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm); |
| 7904 | #endif |
| 7905 | case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep); |
| 7906 | case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp); |
| 7907 | case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path); |
| 7908 | case OPT_BOTH(PV_AR): return (char_u *)&(curbuf->b_p_ar); |
| 7909 | case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags); |
| 7910 | #ifdef FEAT_FIND_ID |
| 7911 | case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def); |
| 7912 | case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc); |
| 7913 | #endif |
| 7914 | #ifdef FEAT_INS_EXPAND |
| 7915 | case OPT_BOTH(PV_DICT): return (char_u *)&(curbuf->b_p_dict); |
| 7916 | case OPT_BOTH(PV_TSR): return (char_u *)&(curbuf->b_p_tsr); |
| 7917 | #endif |
| 7918 | } |
| 7919 | return NULL; /* "cannot happen" */ |
| 7920 | } |
| 7921 | return get_varp(p); |
| 7922 | } |
| 7923 | |
| 7924 | /* |
| 7925 | * Get pointer to option variable. |
| 7926 | */ |
| 7927 | static char_u * |
| 7928 | get_varp(p) |
| 7929 | struct vimoption *p; |
| 7930 | { |
| 7931 | /* hidden option, always return NULL */ |
| 7932 | if (p->var == NULL) |
| 7933 | return NULL; |
| 7934 | |
| 7935 | switch ((int)p->indir) |
| 7936 | { |
| 7937 | case PV_NONE: return p->var; |
| 7938 | |
| 7939 | /* global option with local value: use local value if it's been set */ |
| 7940 | case OPT_BOTH(PV_EP): return *curbuf->b_p_ep != NUL |
| 7941 | ? (char_u *)&curbuf->b_p_ep : p->var; |
| 7942 | case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL |
| 7943 | ? (char_u *)&curbuf->b_p_kp : p->var; |
| 7944 | case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL |
| 7945 | ? (char_u *)&(curbuf->b_p_path) : p->var; |
| 7946 | case OPT_BOTH(PV_AR): return curbuf->b_p_ar >= 0 |
| 7947 | ? (char_u *)&(curbuf->b_p_ar) : p->var; |
| 7948 | case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL |
| 7949 | ? (char_u *)&(curbuf->b_p_tags) : p->var; |
| 7950 | #ifdef FEAT_FIND_ID |
| 7951 | case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL |
| 7952 | ? (char_u *)&(curbuf->b_p_def) : p->var; |
| 7953 | case OPT_BOTH(PV_INC): return *curbuf->b_p_inc != NUL |
| 7954 | ? (char_u *)&(curbuf->b_p_inc) : p->var; |
| 7955 | #endif |
| 7956 | #ifdef FEAT_INS_EXPAND |
| 7957 | case OPT_BOTH(PV_DICT): return *curbuf->b_p_dict != NUL |
| 7958 | ? (char_u *)&(curbuf->b_p_dict) : p->var; |
| 7959 | case OPT_BOTH(PV_TSR): return *curbuf->b_p_tsr != NUL |
| 7960 | ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
| 7961 | #endif |
| 7962 | #ifdef FEAT_QUICKFIX |
| 7963 | case OPT_BOTH(PV_GP): return *curbuf->b_p_gp != NUL |
| 7964 | ? (char_u *)&(curbuf->b_p_gp) : p->var; |
| 7965 | case OPT_BOTH(PV_MP): return *curbuf->b_p_mp != NUL |
| 7966 | ? (char_u *)&(curbuf->b_p_mp) : p->var; |
| 7967 | case OPT_BOTH(PV_EFM): return *curbuf->b_p_efm != NUL |
| 7968 | ? (char_u *)&(curbuf->b_p_efm) : p->var; |
| 7969 | #endif |
| 7970 | |
| 7971 | #ifdef FEAT_ARABIC |
| 7972 | case PV_ARAB: return (char_u *)&(curwin->w_p_arab); |
| 7973 | #endif |
| 7974 | case PV_LIST: return (char_u *)&(curwin->w_p_list); |
| 7975 | #ifdef FEAT_DIFF |
| 7976 | case PV_DIFF: return (char_u *)&(curwin->w_p_diff); |
| 7977 | #endif |
| 7978 | #ifdef FEAT_FOLDING |
| 7979 | case PV_FDC: return (char_u *)&(curwin->w_p_fdc); |
| 7980 | case PV_FEN: return (char_u *)&(curwin->w_p_fen); |
| 7981 | case PV_FDI: return (char_u *)&(curwin->w_p_fdi); |
| 7982 | case PV_FDL: return (char_u *)&(curwin->w_p_fdl); |
| 7983 | case PV_FDM: return (char_u *)&(curwin->w_p_fdm); |
| 7984 | case PV_FML: return (char_u *)&(curwin->w_p_fml); |
| 7985 | case PV_FDN: return (char_u *)&(curwin->w_p_fdn); |
| 7986 | # ifdef FEAT_EVAL |
| 7987 | case PV_FDE: return (char_u *)&(curwin->w_p_fde); |
| 7988 | case PV_FDT: return (char_u *)&(curwin->w_p_fdt); |
| 7989 | # endif |
| 7990 | case PV_FMR: return (char_u *)&(curwin->w_p_fmr); |
| 7991 | #endif |
| 7992 | case PV_NU: return (char_u *)&(curwin->w_p_nu); |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 7993 | #ifdef FEAT_LINEBREAK |
| 7994 | case PV_NUW: return (char_u *)&(curwin->w_p_nuw); |
| 7995 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7996 | #if defined(FEAT_WINDOWS) |
| 7997 | case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
| 7998 | #endif |
| 7999 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 8000 | case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
| 8001 | #endif |
| 8002 | #ifdef FEAT_RIGHTLEFT |
| 8003 | case PV_RL: return (char_u *)&(curwin->w_p_rl); |
| 8004 | case PV_RLC: return (char_u *)&(curwin->w_p_rlc); |
| 8005 | #endif |
| 8006 | case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); |
| 8007 | case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); |
| 8008 | #ifdef FEAT_LINEBREAK |
| 8009 | case PV_LBR: return (char_u *)&(curwin->w_p_lbr); |
| 8010 | #endif |
| 8011 | #ifdef FEAT_SCROLLBIND |
| 8012 | case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); |
| 8013 | #endif |
| 8014 | |
| 8015 | case PV_AI: return (char_u *)&(curbuf->b_p_ai); |
| 8016 | case PV_BIN: return (char_u *)&(curbuf->b_p_bin); |
| 8017 | #ifdef FEAT_MBYTE |
| 8018 | case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); |
| 8019 | #endif |
| 8020 | #if defined(FEAT_QUICKFIX) |
| 8021 | case PV_BH: return (char_u *)&(curbuf->b_p_bh); |
| 8022 | case PV_BT: return (char_u *)&(curbuf->b_p_bt); |
| 8023 | #endif |
| 8024 | case PV_BL: return (char_u *)&(curbuf->b_p_bl); |
| 8025 | case PV_CI: return (char_u *)&(curbuf->b_p_ci); |
| 8026 | #ifdef FEAT_CINDENT |
| 8027 | case PV_CIN: return (char_u *)&(curbuf->b_p_cin); |
| 8028 | case PV_CINK: return (char_u *)&(curbuf->b_p_cink); |
| 8029 | case PV_CINO: return (char_u *)&(curbuf->b_p_cino); |
| 8030 | #endif |
| 8031 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 8032 | case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); |
| 8033 | #endif |
| 8034 | #ifdef FEAT_COMMENTS |
| 8035 | case PV_COM: return (char_u *)&(curbuf->b_p_com); |
| 8036 | #endif |
| 8037 | #ifdef FEAT_FOLDING |
| 8038 | case PV_CMS: return (char_u *)&(curbuf->b_p_cms); |
| 8039 | #endif |
| 8040 | #ifdef FEAT_INS_EXPAND |
| 8041 | case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); |
| 8042 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8043 | #ifdef FEAT_COMPL_FUNC |
| 8044 | case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); |
| 8045 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8046 | case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
| 8047 | case PV_ET: return (char_u *)&(curbuf->b_p_et); |
| 8048 | #ifdef FEAT_MBYTE |
| 8049 | case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); |
| 8050 | #endif |
| 8051 | case PV_FF: return (char_u *)&(curbuf->b_p_ff); |
| 8052 | #ifdef FEAT_AUTOCMD |
| 8053 | case PV_FT: return (char_u *)&(curbuf->b_p_ft); |
| 8054 | #endif |
| 8055 | case PV_FO: return (char_u *)&(curbuf->b_p_fo); |
| 8056 | case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
| 8057 | case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); |
| 8058 | case PV_INF: return (char_u *)&(curbuf->b_p_inf); |
| 8059 | case PV_ISK: return (char_u *)&(curbuf->b_p_isk); |
| 8060 | #ifdef FEAT_FIND_ID |
| 8061 | # ifdef FEAT_EVAL |
| 8062 | case PV_INEX: return (char_u *)&(curbuf->b_p_inex); |
| 8063 | # endif |
| 8064 | #endif |
| 8065 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 8066 | case PV_INDE: return (char_u *)&(curbuf->b_p_inde); |
| 8067 | case PV_INDK: return (char_u *)&(curbuf->b_p_indk); |
| 8068 | #endif |
| 8069 | #ifdef FEAT_CRYPT |
| 8070 | case PV_KEY: return (char_u *)&(curbuf->b_p_key); |
| 8071 | #endif |
| 8072 | #ifdef FEAT_LISP |
| 8073 | case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); |
| 8074 | #endif |
| 8075 | case PV_ML: return (char_u *)&(curbuf->b_p_ml); |
| 8076 | case PV_MPS: return (char_u *)&(curbuf->b_p_mps); |
| 8077 | case PV_MA: return (char_u *)&(curbuf->b_p_ma); |
| 8078 | case PV_MOD: return (char_u *)&(curbuf->b_changed); |
| 8079 | case PV_NF: return (char_u *)&(curbuf->b_p_nf); |
| 8080 | #ifdef FEAT_OSFILETYPE |
| 8081 | case PV_OFT: return (char_u *)&(curbuf->b_p_oft); |
| 8082 | #endif |
| 8083 | case PV_PI: return (char_u *)&(curbuf->b_p_pi); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8084 | #ifdef FEAT_TEXTOBJ |
| 8085 | case PV_QE: return (char_u *)&(curbuf->b_p_qe); |
| 8086 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8087 | case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
| 8088 | #ifdef FEAT_SMARTINDENT |
| 8089 | case PV_SI: return (char_u *)&(curbuf->b_p_si); |
| 8090 | #endif |
| 8091 | #ifndef SHORT_FNAME |
| 8092 | case PV_SN: return (char_u *)&(curbuf->b_p_sn); |
| 8093 | #endif |
| 8094 | case PV_STS: return (char_u *)&(curbuf->b_p_sts); |
| 8095 | #ifdef FEAT_SEARCHPATH |
| 8096 | case PV_SUA: return (char_u *)&(curbuf->b_p_sua); |
| 8097 | #endif |
| 8098 | case PV_SWF: return (char_u *)&(curbuf->b_p_swf); |
| 8099 | #ifdef FEAT_SYN_HL |
| 8100 | case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
| 8101 | #endif |
| 8102 | case PV_SW: return (char_u *)&(curbuf->b_p_sw); |
| 8103 | case PV_TS: return (char_u *)&(curbuf->b_p_ts); |
| 8104 | case PV_TW: return (char_u *)&(curbuf->b_p_tw); |
| 8105 | case PV_TX: return (char_u *)&(curbuf->b_p_tx); |
| 8106 | case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
| 8107 | #ifdef FEAT_KEYMAP |
| 8108 | case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); |
| 8109 | #endif |
| 8110 | default: EMSG(_("E356: get_varp ERROR")); |
| 8111 | } |
| 8112 | /* always return a valid pointer to avoid a crash! */ |
| 8113 | return (char_u *)&(curbuf->b_p_wm); |
| 8114 | } |
| 8115 | |
| 8116 | /* |
| 8117 | * Get the value of 'equalprg', either the buffer-local one or the global one. |
| 8118 | */ |
| 8119 | char_u * |
| 8120 | get_equalprg() |
| 8121 | { |
| 8122 | if (*curbuf->b_p_ep == NUL) |
| 8123 | return p_ep; |
| 8124 | return curbuf->b_p_ep; |
| 8125 | } |
| 8126 | |
| 8127 | #if defined(FEAT_WINDOWS) || defined(PROTO) |
| 8128 | /* |
| 8129 | * Copy options from one window to another. |
| 8130 | * Used when splitting a window. |
| 8131 | */ |
| 8132 | void |
| 8133 | win_copy_options(wp_from, wp_to) |
| 8134 | win_T *wp_from; |
| 8135 | win_T *wp_to; |
| 8136 | { |
| 8137 | copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); |
| 8138 | copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); |
| 8139 | # ifdef FEAT_RIGHTLEFT |
| 8140 | # ifdef FEAT_FKMAP |
| 8141 | /* Is this right? */ |
| 8142 | wp_to->w_farsi = wp_from->w_farsi; |
| 8143 | # endif |
| 8144 | # endif |
| 8145 | } |
| 8146 | #endif |
| 8147 | |
| 8148 | /* |
| 8149 | * Copy the options from one winopt_T to another. |
| 8150 | * Doesn't free the old option values in "to", use clear_winopt() for that. |
| 8151 | * The 'scroll' option is not copied, because it depends on the window height. |
| 8152 | * The 'previewwindow' option is reset, there can be only one preview window. |
| 8153 | */ |
| 8154 | void |
| 8155 | copy_winopt(from, to) |
| 8156 | winopt_T *from; |
| 8157 | winopt_T *to; |
| 8158 | { |
| 8159 | #ifdef FEAT_ARABIC |
| 8160 | to->wo_arab = from->wo_arab; |
| 8161 | #endif |
| 8162 | to->wo_list = from->wo_list; |
| 8163 | to->wo_nu = from->wo_nu; |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 8164 | #ifdef FEAT_LINEBREAK |
| 8165 | to->wo_nuw = from->wo_nuw; |
| 8166 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8167 | #ifdef FEAT_RIGHTLEFT |
| 8168 | to->wo_rl = from->wo_rl; |
| 8169 | to->wo_rlc = vim_strsave(from->wo_rlc); |
| 8170 | #endif |
| 8171 | to->wo_wrap = from->wo_wrap; |
| 8172 | #ifdef FEAT_LINEBREAK |
| 8173 | to->wo_lbr = from->wo_lbr; |
| 8174 | #endif |
| 8175 | #ifdef FEAT_SCROLLBIND |
| 8176 | to->wo_scb = from->wo_scb; |
| 8177 | #endif |
| 8178 | #ifdef FEAT_DIFF |
| 8179 | to->wo_diff = from->wo_diff; |
| 8180 | #endif |
| 8181 | #ifdef FEAT_FOLDING |
| 8182 | to->wo_fdc = from->wo_fdc; |
| 8183 | to->wo_fen = from->wo_fen; |
| 8184 | to->wo_fdi = vim_strsave(from->wo_fdi); |
| 8185 | to->wo_fml = from->wo_fml; |
| 8186 | to->wo_fdl = from->wo_fdl; |
| 8187 | to->wo_fdm = vim_strsave(from->wo_fdm); |
| 8188 | to->wo_fdn = from->wo_fdn; |
| 8189 | # ifdef FEAT_EVAL |
| 8190 | to->wo_fde = vim_strsave(from->wo_fde); |
| 8191 | to->wo_fdt = vim_strsave(from->wo_fdt); |
| 8192 | # endif |
| 8193 | to->wo_fmr = vim_strsave(from->wo_fmr); |
| 8194 | #endif |
| 8195 | check_winopt(to); /* don't want NULL pointers */ |
| 8196 | } |
| 8197 | |
| 8198 | /* |
| 8199 | * Check string options in a window for a NULL value. |
| 8200 | */ |
| 8201 | void |
| 8202 | check_win_options(win) |
| 8203 | win_T *win; |
| 8204 | { |
| 8205 | check_winopt(&win->w_onebuf_opt); |
| 8206 | check_winopt(&win->w_allbuf_opt); |
| 8207 | } |
| 8208 | |
| 8209 | /* |
| 8210 | * Check for NULL pointers in a winopt_T and replace them with empty_option. |
| 8211 | */ |
| 8212 | /*ARGSUSED*/ |
| 8213 | void |
| 8214 | check_winopt(wop) |
| 8215 | winopt_T *wop; |
| 8216 | { |
| 8217 | #ifdef FEAT_FOLDING |
| 8218 | check_string_option(&wop->wo_fdi); |
| 8219 | check_string_option(&wop->wo_fdm); |
| 8220 | # ifdef FEAT_EVAL |
| 8221 | check_string_option(&wop->wo_fde); |
| 8222 | check_string_option(&wop->wo_fdt); |
| 8223 | # endif |
| 8224 | check_string_option(&wop->wo_fmr); |
| 8225 | #endif |
| 8226 | #ifdef FEAT_RIGHTLEFT |
| 8227 | check_string_option(&wop->wo_rlc); |
| 8228 | #endif |
| 8229 | } |
| 8230 | |
| 8231 | /* |
| 8232 | * Free the allocated memory inside a winopt_T. |
| 8233 | */ |
| 8234 | /*ARGSUSED*/ |
| 8235 | void |
| 8236 | clear_winopt(wop) |
| 8237 | winopt_T *wop; |
| 8238 | { |
| 8239 | #ifdef FEAT_FOLDING |
| 8240 | clear_string_option(&wop->wo_fdi); |
| 8241 | clear_string_option(&wop->wo_fdm); |
| 8242 | # ifdef FEAT_EVAL |
| 8243 | clear_string_option(&wop->wo_fde); |
| 8244 | clear_string_option(&wop->wo_fdt); |
| 8245 | # endif |
| 8246 | clear_string_option(&wop->wo_fmr); |
| 8247 | #endif |
| 8248 | #ifdef FEAT_RIGHTLEFT |
| 8249 | clear_string_option(&wop->wo_rlc); |
| 8250 | #endif |
| 8251 | } |
| 8252 | |
| 8253 | /* |
| 8254 | * Copy global option values to local options for one buffer. |
| 8255 | * Used when creating a new buffer and sometimes when entering a buffer. |
| 8256 | * flags: |
| 8257 | * BCO_ENTER We will enter the buf buffer. |
| 8258 | * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
| 8259 | * appropriate. |
| 8260 | * BCO_NOHELP Don't copy the values to a help buffer. |
| 8261 | */ |
| 8262 | void |
| 8263 | buf_copy_options(buf, flags) |
| 8264 | buf_T *buf; |
| 8265 | int flags; |
| 8266 | { |
| 8267 | int should_copy = TRUE; |
| 8268 | char_u *save_p_isk = NULL; /* init for GCC */ |
| 8269 | int dont_do_help; |
| 8270 | int did_isk = FALSE; |
| 8271 | |
| 8272 | /* |
| 8273 | * Don't do anything of the buffer is invalid. |
| 8274 | */ |
| 8275 | if (buf == NULL || !buf_valid(buf)) |
| 8276 | return; |
| 8277 | |
| 8278 | /* |
| 8279 | * Skip this when the option defaults have not been set yet. Happens when |
| 8280 | * main() allocates the first buffer. |
| 8281 | */ |
| 8282 | if (p_cpo != NULL) |
| 8283 | { |
| 8284 | /* |
| 8285 | * Always copy when entering and 'cpo' contains 'S'. |
| 8286 | * Don't copy when already initialized. |
| 8287 | * Don't copy when 'cpo' contains 's' and not entering. |
| 8288 | * 'S' BCO_ENTER initialized 's' should_copy |
| 8289 | * yes yes X X TRUE |
| 8290 | * yes no yes X FALSE |
| 8291 | * no X yes X FALSE |
| 8292 | * X no no yes FALSE |
| 8293 | * X no no no TRUE |
| 8294 | * no yes no X TRUE |
| 8295 | */ |
| 8296 | if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) |
| 8297 | && (buf->b_p_initialized |
| 8298 | || (!(flags & BCO_ENTER) |
| 8299 | && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) |
| 8300 | should_copy = FALSE; |
| 8301 | |
| 8302 | if (should_copy || (flags & BCO_ALWAYS)) |
| 8303 | { |
| 8304 | /* Don't copy the options specific to a help buffer when |
| 8305 | * BCO_NOHELP is given or the options were initialized already |
| 8306 | * (jumping back to a help file with CTRL-T or CTRL-O) */ |
| 8307 | dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
| 8308 | || buf->b_p_initialized; |
| 8309 | if (dont_do_help) /* don't free b_p_isk */ |
| 8310 | { |
| 8311 | save_p_isk = buf->b_p_isk; |
| 8312 | buf->b_p_isk = NULL; |
| 8313 | } |
| 8314 | /* |
| 8315 | * Always free the allocated strings. |
| 8316 | * If not already initialized, set 'readonly' and copy 'fileformat'. |
| 8317 | */ |
| 8318 | if (!buf->b_p_initialized) |
| 8319 | { |
| 8320 | free_buf_options(buf, TRUE); |
| 8321 | buf->b_p_ro = FALSE; /* don't copy readonly */ |
| 8322 | buf->b_p_tx = p_tx; |
| 8323 | #ifdef FEAT_MBYTE |
| 8324 | buf->b_p_fenc = vim_strsave(p_fenc); |
| 8325 | #endif |
| 8326 | buf->b_p_ff = vim_strsave(p_ff); |
| 8327 | #if defined(FEAT_QUICKFIX) |
| 8328 | buf->b_p_bh = empty_option; |
| 8329 | buf->b_p_bt = empty_option; |
| 8330 | #endif |
| 8331 | } |
| 8332 | else |
| 8333 | free_buf_options(buf, FALSE); |
| 8334 | |
| 8335 | buf->b_p_ai = p_ai; |
| 8336 | buf->b_p_ai_nopaste = p_ai_nopaste; |
| 8337 | buf->b_p_sw = p_sw; |
| 8338 | buf->b_p_tw = p_tw; |
| 8339 | buf->b_p_tw_nopaste = p_tw_nopaste; |
| 8340 | buf->b_p_tw_nobin = p_tw_nobin; |
| 8341 | buf->b_p_wm = p_wm; |
| 8342 | buf->b_p_wm_nopaste = p_wm_nopaste; |
| 8343 | buf->b_p_wm_nobin = p_wm_nobin; |
| 8344 | buf->b_p_bin = p_bin; |
| 8345 | buf->b_p_et = p_et; |
| 8346 | buf->b_p_et_nobin = p_et_nobin; |
| 8347 | buf->b_p_ml = p_ml; |
| 8348 | buf->b_p_ml_nobin = p_ml_nobin; |
| 8349 | buf->b_p_inf = p_inf; |
| 8350 | buf->b_p_swf = p_swf; |
| 8351 | #ifdef FEAT_INS_EXPAND |
| 8352 | buf->b_p_cpt = vim_strsave(p_cpt); |
| 8353 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8354 | #ifdef FEAT_COMPL_FUNC |
| 8355 | buf->b_p_cfu = vim_strsave(p_cfu); |
| 8356 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8357 | buf->b_p_sts = p_sts; |
| 8358 | buf->b_p_sts_nopaste = p_sts_nopaste; |
| 8359 | #ifndef SHORT_FNAME |
| 8360 | buf->b_p_sn = p_sn; |
| 8361 | #endif |
| 8362 | #ifdef FEAT_COMMENTS |
| 8363 | buf->b_p_com = vim_strsave(p_com); |
| 8364 | #endif |
| 8365 | #ifdef FEAT_FOLDING |
| 8366 | buf->b_p_cms = vim_strsave(p_cms); |
| 8367 | #endif |
| 8368 | buf->b_p_fo = vim_strsave(p_fo); |
| 8369 | buf->b_p_nf = vim_strsave(p_nf); |
| 8370 | buf->b_p_mps = vim_strsave(p_mps); |
| 8371 | #ifdef FEAT_SMARTINDENT |
| 8372 | buf->b_p_si = p_si; |
| 8373 | #endif |
| 8374 | buf->b_p_ci = p_ci; |
| 8375 | #ifdef FEAT_CINDENT |
| 8376 | buf->b_p_cin = p_cin; |
| 8377 | buf->b_p_cink = vim_strsave(p_cink); |
| 8378 | buf->b_p_cino = vim_strsave(p_cino); |
| 8379 | #endif |
| 8380 | #ifdef FEAT_AUTOCMD |
| 8381 | /* Don't copy 'filetype', it must be detected */ |
| 8382 | buf->b_p_ft = empty_option; |
| 8383 | #endif |
| 8384 | #ifdef FEAT_OSFILETYPE |
| 8385 | buf->b_p_oft = vim_strsave(p_oft); |
| 8386 | #endif |
| 8387 | buf->b_p_pi = p_pi; |
| 8388 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 8389 | buf->b_p_cinw = vim_strsave(p_cinw); |
| 8390 | #endif |
| 8391 | #ifdef FEAT_LISP |
| 8392 | buf->b_p_lisp = p_lisp; |
| 8393 | #endif |
| 8394 | #ifdef FEAT_SYN_HL |
| 8395 | /* Don't copy 'syntax', it must be set */ |
| 8396 | buf->b_p_syn = empty_option; |
| 8397 | #endif |
| 8398 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 8399 | buf->b_p_inde = vim_strsave(p_inde); |
| 8400 | buf->b_p_indk = vim_strsave(p_indk); |
| 8401 | #endif |
| 8402 | #ifdef FEAT_CRYPT |
| 8403 | buf->b_p_key = vim_strsave(p_key); |
| 8404 | #endif |
| 8405 | #ifdef FEAT_SEARCHPATH |
| 8406 | buf->b_p_sua = vim_strsave(p_sua); |
| 8407 | #endif |
| 8408 | #ifdef FEAT_KEYMAP |
| 8409 | buf->b_p_keymap = vim_strsave(p_keymap); |
| 8410 | buf->b_kmap_state |= KEYMAP_INIT; |
| 8411 | #endif |
| 8412 | /* This isn't really an option, but copying the langmap and IME |
| 8413 | * state from the current buffer is better than resetting it. */ |
| 8414 | buf->b_p_iminsert = p_iminsert; |
| 8415 | buf->b_p_imsearch = p_imsearch; |
| 8416 | |
| 8417 | /* options that are normally global but also have a local value |
| 8418 | * are not copied, start using the global value */ |
| 8419 | buf->b_p_ar = -1; |
| 8420 | #ifdef FEAT_QUICKFIX |
| 8421 | buf->b_p_gp = empty_option; |
| 8422 | buf->b_p_mp = empty_option; |
| 8423 | buf->b_p_efm = empty_option; |
| 8424 | #endif |
| 8425 | buf->b_p_ep = empty_option; |
| 8426 | buf->b_p_kp = empty_option; |
| 8427 | buf->b_p_path = empty_option; |
| 8428 | buf->b_p_tags = empty_option; |
| 8429 | #ifdef FEAT_FIND_ID |
| 8430 | buf->b_p_def = empty_option; |
| 8431 | buf->b_p_inc = empty_option; |
| 8432 | # ifdef FEAT_EVAL |
| 8433 | buf->b_p_inex = vim_strsave(p_inex); |
| 8434 | # endif |
| 8435 | #endif |
| 8436 | #ifdef FEAT_INS_EXPAND |
| 8437 | buf->b_p_dict = empty_option; |
| 8438 | buf->b_p_tsr = empty_option; |
| 8439 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8440 | #ifdef FEAT_TEXTOBJ |
| 8441 | buf->b_p_qe = vim_strsave(p_qe); |
| 8442 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8443 | |
| 8444 | /* |
| 8445 | * Don't copy the options set by ex_help(), use the saved values, |
| 8446 | * when going from a help buffer to a non-help buffer. |
| 8447 | * Don't touch these at all when BCO_NOHELP is used and going from |
| 8448 | * or to a help buffer. |
| 8449 | */ |
| 8450 | if (dont_do_help) |
| 8451 | buf->b_p_isk = save_p_isk; |
| 8452 | else |
| 8453 | { |
| 8454 | buf->b_p_isk = vim_strsave(p_isk); |
| 8455 | did_isk = TRUE; |
| 8456 | buf->b_p_ts = p_ts; |
| 8457 | buf->b_help = FALSE; |
| 8458 | #ifdef FEAT_QUICKFIX |
| 8459 | if (buf->b_p_bt[0] == 'h') |
| 8460 | clear_string_option(&buf->b_p_bt); |
| 8461 | #endif |
| 8462 | buf->b_p_ma = p_ma; |
| 8463 | } |
| 8464 | } |
| 8465 | |
| 8466 | /* |
| 8467 | * When the options should be copied (ignoring BCO_ALWAYS), set the |
| 8468 | * flag that indicates that the options have been initialized. |
| 8469 | */ |
| 8470 | if (should_copy) |
| 8471 | buf->b_p_initialized = TRUE; |
| 8472 | } |
| 8473 | |
| 8474 | check_buf_options(buf); /* make sure we don't have NULLs */ |
| 8475 | if (did_isk) |
| 8476 | (void)buf_init_chartab(buf, FALSE); |
| 8477 | } |
| 8478 | |
| 8479 | /* |
| 8480 | * Reset the 'modifiable' option and its default value. |
| 8481 | */ |
| 8482 | void |
| 8483 | reset_modifiable() |
| 8484 | { |
| 8485 | int opt_idx; |
| 8486 | |
| 8487 | curbuf->b_p_ma = FALSE; |
| 8488 | p_ma = FALSE; |
| 8489 | opt_idx = findoption((char_u *)"ma"); |
| 8490 | options[opt_idx].def_val[VI_DEFAULT] = FALSE; |
| 8491 | } |
| 8492 | |
| 8493 | /* |
| 8494 | * Set the global value for 'iminsert' to the local value. |
| 8495 | */ |
| 8496 | void |
| 8497 | set_iminsert_global() |
| 8498 | { |
| 8499 | p_iminsert = curbuf->b_p_iminsert; |
| 8500 | } |
| 8501 | |
| 8502 | /* |
| 8503 | * Set the global value for 'imsearch' to the local value. |
| 8504 | */ |
| 8505 | void |
| 8506 | set_imsearch_global() |
| 8507 | { |
| 8508 | p_imsearch = curbuf->b_p_imsearch; |
| 8509 | } |
| 8510 | |
| 8511 | #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
| 8512 | static int expand_option_idx = -1; |
| 8513 | static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; |
| 8514 | static int expand_option_flags = 0; |
| 8515 | |
| 8516 | void |
| 8517 | set_context_in_set_cmd(xp, arg, opt_flags) |
| 8518 | expand_T *xp; |
| 8519 | char_u *arg; |
| 8520 | int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ |
| 8521 | { |
| 8522 | int nextchar; |
| 8523 | long_u flags = 0; /* init for GCC */ |
| 8524 | int opt_idx = 0; /* init for GCC */ |
| 8525 | char_u *p; |
| 8526 | char_u *s; |
| 8527 | int is_term_option = FALSE; |
| 8528 | int key; |
| 8529 | |
| 8530 | expand_option_flags = opt_flags; |
| 8531 | |
| 8532 | xp->xp_context = EXPAND_SETTINGS; |
| 8533 | if (*arg == NUL) |
| 8534 | { |
| 8535 | xp->xp_pattern = arg; |
| 8536 | return; |
| 8537 | } |
| 8538 | p = arg + STRLEN(arg) - 1; |
| 8539 | if (*p == ' ' && *(p - 1) != '\\') |
| 8540 | { |
| 8541 | xp->xp_pattern = p + 1; |
| 8542 | return; |
| 8543 | } |
| 8544 | while (p > arg) |
| 8545 | { |
| 8546 | s = p; |
| 8547 | /* count number of backslashes before ' ' or ',' */ |
| 8548 | if (*p == ' ' || *p == ',') |
| 8549 | { |
| 8550 | while (s > arg && *(s - 1) == '\\') |
| 8551 | --s; |
| 8552 | } |
| 8553 | /* break at a space with an even number of backslashes */ |
| 8554 | if (*p == ' ' && ((p - s) & 1) == 0) |
| 8555 | { |
| 8556 | ++p; |
| 8557 | break; |
| 8558 | } |
| 8559 | --p; |
| 8560 | } |
| 8561 | if (STRNCMP(p, "no", 2) == 0) |
| 8562 | { |
| 8563 | xp->xp_context = EXPAND_BOOL_SETTINGS; |
| 8564 | p += 2; |
| 8565 | } |
| 8566 | if (STRNCMP(p, "inv", 3) == 0) |
| 8567 | { |
| 8568 | xp->xp_context = EXPAND_BOOL_SETTINGS; |
| 8569 | p += 3; |
| 8570 | } |
| 8571 | xp->xp_pattern = arg = p; |
| 8572 | if (*arg == '<') |
| 8573 | { |
| 8574 | while (*p != '>') |
| 8575 | if (*p++ == NUL) /* expand terminal option name */ |
| 8576 | return; |
| 8577 | key = get_special_key_code(arg + 1); |
| 8578 | if (key == 0) /* unknown name */ |
| 8579 | { |
| 8580 | xp->xp_context = EXPAND_NOTHING; |
| 8581 | return; |
| 8582 | } |
| 8583 | nextchar = *++p; |
| 8584 | is_term_option = TRUE; |
| 8585 | expand_option_name[2] = KEY2TERMCAP0(key); |
| 8586 | expand_option_name[3] = KEY2TERMCAP1(key); |
| 8587 | } |
| 8588 | else |
| 8589 | { |
| 8590 | if (p[0] == 't' && p[1] == '_') |
| 8591 | { |
| 8592 | p += 2; |
| 8593 | if (*p != NUL) |
| 8594 | ++p; |
| 8595 | if (*p == NUL) |
| 8596 | return; /* expand option name */ |
| 8597 | nextchar = *++p; |
| 8598 | is_term_option = TRUE; |
| 8599 | expand_option_name[2] = p[-2]; |
| 8600 | expand_option_name[3] = p[-1]; |
| 8601 | } |
| 8602 | else |
| 8603 | { |
| 8604 | /* Allow * wildcard */ |
| 8605 | while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
| 8606 | p++; |
| 8607 | if (*p == NUL) |
| 8608 | return; |
| 8609 | nextchar = *p; |
| 8610 | *p = NUL; |
| 8611 | opt_idx = findoption(arg); |
| 8612 | *p = nextchar; |
| 8613 | if (opt_idx == -1 || options[opt_idx].var == NULL) |
| 8614 | { |
| 8615 | xp->xp_context = EXPAND_NOTHING; |
| 8616 | return; |
| 8617 | } |
| 8618 | flags = options[opt_idx].flags; |
| 8619 | if (flags & P_BOOL) |
| 8620 | { |
| 8621 | xp->xp_context = EXPAND_NOTHING; |
| 8622 | return; |
| 8623 | } |
| 8624 | } |
| 8625 | } |
| 8626 | /* handle "-=" and "+=" */ |
| 8627 | if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
| 8628 | { |
| 8629 | ++p; |
| 8630 | nextchar = '='; |
| 8631 | } |
| 8632 | if ((nextchar != '=' && nextchar != ':') |
| 8633 | || xp->xp_context == EXPAND_BOOL_SETTINGS) |
| 8634 | { |
| 8635 | xp->xp_context = EXPAND_UNSUCCESSFUL; |
| 8636 | return; |
| 8637 | } |
| 8638 | if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) |
| 8639 | { |
| 8640 | xp->xp_context = EXPAND_OLD_SETTING; |
| 8641 | if (is_term_option) |
| 8642 | expand_option_idx = -1; |
| 8643 | else |
| 8644 | expand_option_idx = opt_idx; |
| 8645 | xp->xp_pattern = p + 1; |
| 8646 | return; |
| 8647 | } |
| 8648 | xp->xp_context = EXPAND_NOTHING; |
| 8649 | if (is_term_option || (flags & P_NUM)) |
| 8650 | return; |
| 8651 | |
| 8652 | xp->xp_pattern = p + 1; |
| 8653 | |
| 8654 | if (flags & P_EXPAND) |
| 8655 | { |
| 8656 | p = options[opt_idx].var; |
| 8657 | if (p == (char_u *)&p_bdir |
| 8658 | || p == (char_u *)&p_dir |
| 8659 | || p == (char_u *)&p_path |
| 8660 | || p == (char_u *)&p_rtp |
| 8661 | #ifdef FEAT_SEARCHPATH |
| 8662 | || p == (char_u *)&p_cdpath |
| 8663 | #endif |
| 8664 | #ifdef FEAT_SESSION |
| 8665 | || p == (char_u *)&p_vdir |
| 8666 | #endif |
| 8667 | ) |
| 8668 | { |
| 8669 | xp->xp_context = EXPAND_DIRECTORIES; |
| 8670 | if (p == (char_u *)&p_path |
| 8671 | #ifdef FEAT_SEARCHPATH |
| 8672 | || p == (char_u *)&p_cdpath |
| 8673 | #endif |
| 8674 | ) |
| 8675 | xp->xp_backslash = XP_BS_THREE; |
| 8676 | else |
| 8677 | xp->xp_backslash = XP_BS_ONE; |
| 8678 | } |
| 8679 | else |
| 8680 | { |
| 8681 | xp->xp_context = EXPAND_FILES; |
| 8682 | /* for 'tags' need three backslashes for a space */ |
| 8683 | if (p == (char_u *)&p_tags) |
| 8684 | xp->xp_backslash = XP_BS_THREE; |
| 8685 | else |
| 8686 | xp->xp_backslash = XP_BS_ONE; |
| 8687 | } |
| 8688 | } |
| 8689 | |
| 8690 | /* For an option that is a list of file names, find the start of the |
| 8691 | * last file name. */ |
| 8692 | for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
| 8693 | { |
| 8694 | /* count number of backslashes before ' ' or ',' */ |
| 8695 | if (*p == ' ' || *p == ',') |
| 8696 | { |
| 8697 | s = p; |
| 8698 | while (s > xp->xp_pattern && *(s - 1) == '\\') |
| 8699 | --s; |
| 8700 | if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) |
| 8701 | || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) |
| 8702 | { |
| 8703 | xp->xp_pattern = p + 1; |
| 8704 | break; |
| 8705 | } |
| 8706 | } |
| 8707 | } |
| 8708 | |
| 8709 | return; |
| 8710 | } |
| 8711 | |
| 8712 | int |
| 8713 | ExpandSettings(xp, regmatch, num_file, file) |
| 8714 | expand_T *xp; |
| 8715 | regmatch_T *regmatch; |
| 8716 | int *num_file; |
| 8717 | char_u ***file; |
| 8718 | { |
| 8719 | int num_normal = 0; /* Nr of matching non-term-code settings */ |
| 8720 | int num_term = 0; /* Nr of matching terminal code settings */ |
| 8721 | int opt_idx; |
| 8722 | int match; |
| 8723 | int count = 0; |
| 8724 | char_u *str; |
| 8725 | int loop; |
| 8726 | int is_term_opt; |
| 8727 | char_u name_buf[MAX_KEY_NAME_LEN]; |
| 8728 | static char *(names[]) = {"all", "termcap"}; |
| 8729 | int ic = regmatch->rm_ic; /* remember the ignore-case flag */ |
| 8730 | |
| 8731 | /* do this loop twice: |
| 8732 | * loop == 0: count the number of matching options |
| 8733 | * loop == 1: copy the matching options into allocated memory |
| 8734 | */ |
| 8735 | for (loop = 0; loop <= 1; ++loop) |
| 8736 | { |
| 8737 | regmatch->rm_ic = ic; |
| 8738 | if (xp->xp_context != EXPAND_BOOL_SETTINGS) |
| 8739 | { |
| 8740 | for (match = 0; match < sizeof(names) / sizeof(char *); ++match) |
| 8741 | if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
| 8742 | { |
| 8743 | if (loop == 0) |
| 8744 | num_normal++; |
| 8745 | else |
| 8746 | (*file)[count++] = vim_strsave((char_u *)names[match]); |
| 8747 | } |
| 8748 | } |
| 8749 | for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; |
| 8750 | opt_idx++) |
| 8751 | { |
| 8752 | if (options[opt_idx].var == NULL) |
| 8753 | continue; |
| 8754 | if (xp->xp_context == EXPAND_BOOL_SETTINGS |
| 8755 | && !(options[opt_idx].flags & P_BOOL)) |
| 8756 | continue; |
| 8757 | is_term_opt = istermoption(&options[opt_idx]); |
| 8758 | if (is_term_opt && num_normal > 0) |
| 8759 | continue; |
| 8760 | match = FALSE; |
| 8761 | if (vim_regexec(regmatch, str, (colnr_T)0) |
| 8762 | || (options[opt_idx].shortname != NULL |
| 8763 | && vim_regexec(regmatch, |
| 8764 | (char_u *)options[opt_idx].shortname, (colnr_T)0))) |
| 8765 | match = TRUE; |
| 8766 | else if (is_term_opt) |
| 8767 | { |
| 8768 | name_buf[0] = '<'; |
| 8769 | name_buf[1] = 't'; |
| 8770 | name_buf[2] = '_'; |
| 8771 | name_buf[3] = str[2]; |
| 8772 | name_buf[4] = str[3]; |
| 8773 | name_buf[5] = '>'; |
| 8774 | name_buf[6] = NUL; |
| 8775 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 8776 | { |
| 8777 | match = TRUE; |
| 8778 | str = name_buf; |
| 8779 | } |
| 8780 | } |
| 8781 | if (match) |
| 8782 | { |
| 8783 | if (loop == 0) |
| 8784 | { |
| 8785 | if (is_term_opt) |
| 8786 | num_term++; |
| 8787 | else |
| 8788 | num_normal++; |
| 8789 | } |
| 8790 | else |
| 8791 | (*file)[count++] = vim_strsave(str); |
| 8792 | } |
| 8793 | } |
| 8794 | /* |
| 8795 | * Check terminal key codes, these are not in the option table |
| 8796 | */ |
| 8797 | if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) |
| 8798 | { |
| 8799 | for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) |
| 8800 | { |
| 8801 | if (!isprint(str[0]) || !isprint(str[1])) |
| 8802 | continue; |
| 8803 | |
| 8804 | name_buf[0] = 't'; |
| 8805 | name_buf[1] = '_'; |
| 8806 | name_buf[2] = str[0]; |
| 8807 | name_buf[3] = str[1]; |
| 8808 | name_buf[4] = NUL; |
| 8809 | |
| 8810 | match = FALSE; |
| 8811 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 8812 | match = TRUE; |
| 8813 | else |
| 8814 | { |
| 8815 | name_buf[0] = '<'; |
| 8816 | name_buf[1] = 't'; |
| 8817 | name_buf[2] = '_'; |
| 8818 | name_buf[3] = str[0]; |
| 8819 | name_buf[4] = str[1]; |
| 8820 | name_buf[5] = '>'; |
| 8821 | name_buf[6] = NUL; |
| 8822 | |
| 8823 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 8824 | match = TRUE; |
| 8825 | } |
| 8826 | if (match) |
| 8827 | { |
| 8828 | if (loop == 0) |
| 8829 | num_term++; |
| 8830 | else |
| 8831 | (*file)[count++] = vim_strsave(name_buf); |
| 8832 | } |
| 8833 | } |
| 8834 | |
| 8835 | /* |
| 8836 | * Check special key names. |
| 8837 | */ |
| 8838 | regmatch->rm_ic = TRUE; /* ignore case here */ |
| 8839 | for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
| 8840 | { |
| 8841 | name_buf[0] = '<'; |
| 8842 | STRCPY(name_buf + 1, str); |
| 8843 | STRCAT(name_buf, ">"); |
| 8844 | |
| 8845 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 8846 | { |
| 8847 | if (loop == 0) |
| 8848 | num_term++; |
| 8849 | else |
| 8850 | (*file)[count++] = vim_strsave(name_buf); |
| 8851 | } |
| 8852 | } |
| 8853 | } |
| 8854 | if (loop == 0) |
| 8855 | { |
| 8856 | if (num_normal > 0) |
| 8857 | *num_file = num_normal; |
| 8858 | else if (num_term > 0) |
| 8859 | *num_file = num_term; |
| 8860 | else |
| 8861 | return OK; |
| 8862 | *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *))); |
| 8863 | if (*file == NULL) |
| 8864 | { |
| 8865 | *file = (char_u **)""; |
| 8866 | return FAIL; |
| 8867 | } |
| 8868 | } |
| 8869 | } |
| 8870 | return OK; |
| 8871 | } |
| 8872 | |
| 8873 | int |
| 8874 | ExpandOldSetting(num_file, file) |
| 8875 | int *num_file; |
| 8876 | char_u ***file; |
| 8877 | { |
| 8878 | char_u *var = NULL; /* init for GCC */ |
| 8879 | char_u *buf; |
| 8880 | |
| 8881 | *num_file = 0; |
| 8882 | *file = (char_u **)alloc((unsigned)sizeof(char_u *)); |
| 8883 | if (*file == NULL) |
| 8884 | return FAIL; |
| 8885 | |
| 8886 | /* |
| 8887 | * For a terminal key code expand_option_idx is < 0. |
| 8888 | */ |
| 8889 | if (expand_option_idx < 0) |
| 8890 | { |
| 8891 | var = find_termcode(expand_option_name + 2); |
| 8892 | if (var == NULL) |
| 8893 | expand_option_idx = findoption(expand_option_name); |
| 8894 | } |
| 8895 | |
| 8896 | if (expand_option_idx >= 0) |
| 8897 | { |
| 8898 | /* put string of option value in NameBuff */ |
| 8899 | option_value2string(&options[expand_option_idx], expand_option_flags); |
| 8900 | var = NameBuff; |
| 8901 | } |
| 8902 | else if (var == NULL) |
| 8903 | var = (char_u *)""; |
| 8904 | |
| 8905 | /* A backslash is required before some characters. This is the reverse of |
| 8906 | * what happens in do_set(). */ |
| 8907 | buf = vim_strsave_escaped(var, escape_chars); |
| 8908 | |
| 8909 | if (buf == NULL) |
| 8910 | { |
| 8911 | vim_free(*file); |
| 8912 | *file = NULL; |
| 8913 | return FAIL; |
| 8914 | } |
| 8915 | |
| 8916 | #ifdef BACKSLASH_IN_FILENAME |
| 8917 | /* For MS-Windows et al. we don't double backslashes at the start and |
| 8918 | * before a file name character. */ |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 8919 | for (var = buf; *var != NUL; mb_ptr_adv(var)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8920 | if (var[0] == '\\' && var[1] == '\\' |
| 8921 | && expand_option_idx >= 0 |
| 8922 | && (options[expand_option_idx].flags & P_EXPAND) |
| 8923 | && vim_isfilec(var[2]) |
| 8924 | && (var[2] != '\\' || (var == buf && var[4] != '\\'))) |
| 8925 | mch_memmove(var, var + 1, STRLEN(var)); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8926 | #endif |
| 8927 | |
| 8928 | *file[0] = buf; |
| 8929 | *num_file = 1; |
| 8930 | return OK; |
| 8931 | } |
| 8932 | #endif |
| 8933 | |
| 8934 | /* |
| 8935 | * Get the value for the numeric or string option *opp in a nice format into |
| 8936 | * NameBuff[]. Must not be called with a hidden option! |
| 8937 | */ |
| 8938 | static void |
| 8939 | option_value2string(opp, opt_flags) |
| 8940 | struct vimoption *opp; |
| 8941 | int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ |
| 8942 | { |
| 8943 | char_u *varp; |
| 8944 | |
| 8945 | varp = get_varp_scope(opp, opt_flags); |
| 8946 | |
| 8947 | if (opp->flags & P_NUM) |
| 8948 | { |
| 8949 | long wc = 0; |
| 8950 | |
| 8951 | if (wc_use_keyname(varp, &wc)) |
| 8952 | STRCPY(NameBuff, get_special_key_name((int)wc, 0)); |
| 8953 | else if (wc != 0) |
| 8954 | STRCPY(NameBuff, transchar((int)wc)); |
| 8955 | else |
| 8956 | sprintf((char *)NameBuff, "%ld", *(long *)varp); |
| 8957 | } |
| 8958 | else /* P_STRING */ |
| 8959 | { |
| 8960 | varp = *(char_u **)(varp); |
| 8961 | if (varp == NULL) /* just in case */ |
| 8962 | NameBuff[0] = NUL; |
| 8963 | #ifdef FEAT_CRYPT |
| 8964 | /* don't show the actual value of 'key', only that it's set */ |
| 8965 | if (opp->var == (char_u *)&p_key && *varp) |
| 8966 | STRCPY(NameBuff, "*****"); |
| 8967 | #endif |
| 8968 | else if (opp->flags & P_EXPAND) |
| 8969 | home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); |
| 8970 | /* Translate 'pastetoggle' into special key names */ |
| 8971 | else if ((char_u **)opp->var == &p_pt) |
| 8972 | str2specialbuf(p_pt, NameBuff, MAXPATHL); |
| 8973 | else |
| 8974 | STRNCPY(NameBuff, varp, MAXPATHL); |
| 8975 | } |
| 8976 | } |
| 8977 | |
| 8978 | /* |
| 8979 | * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be |
| 8980 | * printed as a keyname. |
| 8981 | * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. |
| 8982 | */ |
| 8983 | static int |
| 8984 | wc_use_keyname(varp, wcp) |
| 8985 | char_u *varp; |
| 8986 | long *wcp; |
| 8987 | { |
| 8988 | if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) |
| 8989 | { |
| 8990 | *wcp = *(long *)varp; |
| 8991 | if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) |
| 8992 | return TRUE; |
| 8993 | } |
| 8994 | return FALSE; |
| 8995 | } |
| 8996 | |
| 8997 | #ifdef FEAT_LANGMAP |
| 8998 | /* |
| 8999 | * Any character has an equivalent character. This is used for keyboards that |
| 9000 | * have a special language mode that sends characters above 128 (although |
| 9001 | * other characters can be translated too). |
| 9002 | */ |
| 9003 | |
| 9004 | /* |
| 9005 | * char_u langmap_mapchar[256]; |
| 9006 | * Normally maps each of the 128 upper chars to an <128 ascii char; used to |
| 9007 | * "translate" native lang chars in normal mode or some cases of |
| 9008 | * insert mode without having to tediously switch lang mode back&forth. |
| 9009 | */ |
| 9010 | |
| 9011 | static void |
| 9012 | langmap_init() |
| 9013 | { |
| 9014 | int i; |
| 9015 | |
| 9016 | for (i = 0; i < 256; i++) /* we init with a-one-to one map */ |
| 9017 | langmap_mapchar[i] = i; |
| 9018 | } |
| 9019 | |
| 9020 | /* |
| 9021 | * Called when langmap option is set; the language map can be |
| 9022 | * changed at any time! |
| 9023 | */ |
| 9024 | static void |
| 9025 | langmap_set() |
| 9026 | { |
| 9027 | char_u *p; |
| 9028 | char_u *p2; |
| 9029 | int from, to; |
| 9030 | |
| 9031 | langmap_init(); /* back to one-to-one map first */ |
| 9032 | |
| 9033 | for (p = p_langmap; p[0] != NUL; ) |
| 9034 | { |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 9035 | for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; |
| 9036 | mb_ptr_adv(p2)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9037 | { |
| 9038 | if (p2[0] == '\\' && p2[1] != NUL) |
| 9039 | ++p2; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9040 | } |
| 9041 | if (p2[0] == ';') |
| 9042 | ++p2; /* abcd;ABCD form, p2 points to A */ |
| 9043 | else |
| 9044 | p2 = NULL; /* aAbBcCdD form, p2 is NULL */ |
| 9045 | while (p[0]) |
| 9046 | { |
| 9047 | if (p[0] == '\\' && p[1] != NUL) |
| 9048 | ++p; |
| 9049 | #ifdef FEAT_MBYTE |
| 9050 | from = (*mb_ptr2char)(p); |
| 9051 | #else |
| 9052 | from = p[0]; |
| 9053 | #endif |
| 9054 | if (p2 == NULL) |
| 9055 | { |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 9056 | mb_ptr_adv(p); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9057 | if (p[0] == '\\') |
| 9058 | ++p; |
| 9059 | #ifdef FEAT_MBYTE |
| 9060 | to = (*mb_ptr2char)(p); |
| 9061 | #else |
| 9062 | to = p[0]; |
| 9063 | #endif |
| 9064 | } |
| 9065 | else |
| 9066 | { |
| 9067 | if (p2[0] == '\\') |
| 9068 | ++p2; |
| 9069 | #ifdef FEAT_MBYTE |
| 9070 | to = (*mb_ptr2char)(p2); |
| 9071 | #else |
| 9072 | to = p2[0]; |
| 9073 | #endif |
| 9074 | } |
| 9075 | if (to == NUL) |
| 9076 | { |
| 9077 | EMSG2(_("E357: 'langmap': Matching character missing for %s"), |
| 9078 | transchar(from)); |
| 9079 | return; |
| 9080 | } |
| 9081 | langmap_mapchar[from & 255] = to; |
| 9082 | |
| 9083 | /* Advance to next pair */ |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 9084 | mb_ptr_adv(p); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9085 | if (p2 == NULL) |
| 9086 | { |
| 9087 | if (p[0] == ',') |
| 9088 | { |
| 9089 | ++p; |
| 9090 | break; |
| 9091 | } |
| 9092 | } |
| 9093 | else |
| 9094 | { |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame^] | 9095 | mb_ptr_adv(p2); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9096 | if (*p == ';') |
| 9097 | { |
| 9098 | p = p2; |
| 9099 | if (p[0] != NUL) |
| 9100 | { |
| 9101 | if (p[0] != ',') |
| 9102 | { |
| 9103 | EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p); |
| 9104 | return; |
| 9105 | } |
| 9106 | ++p; |
| 9107 | } |
| 9108 | break; |
| 9109 | } |
| 9110 | } |
| 9111 | } |
| 9112 | } |
| 9113 | } |
| 9114 | #endif |
| 9115 | |
| 9116 | /* |
| 9117 | * Return TRUE if format option 'x' is in effect. |
| 9118 | * Take care of no formatting when 'paste' is set. |
| 9119 | */ |
| 9120 | int |
| 9121 | has_format_option(x) |
| 9122 | int x; |
| 9123 | { |
| 9124 | if (p_paste) |
| 9125 | return FALSE; |
| 9126 | return (vim_strchr(curbuf->b_p_fo, x) != NULL); |
| 9127 | } |
| 9128 | |
| 9129 | /* |
| 9130 | * Return TRUE if "x" is present in 'shortmess' option, or |
| 9131 | * 'shortmess' contains 'a' and "x" is present in SHM_A. |
| 9132 | */ |
| 9133 | int |
| 9134 | shortmess(x) |
| 9135 | int x; |
| 9136 | { |
| 9137 | return ( vim_strchr(p_shm, x) != NULL |
| 9138 | || (vim_strchr(p_shm, 'a') != NULL |
| 9139 | && vim_strchr((char_u *)SHM_A, x) != NULL)); |
| 9140 | } |
| 9141 | |
| 9142 | /* |
| 9143 | * paste_option_changed() - Called after p_paste was set or reset. |
| 9144 | */ |
| 9145 | static void |
| 9146 | paste_option_changed() |
| 9147 | { |
| 9148 | static int old_p_paste = FALSE; |
| 9149 | static int save_sm = 0; |
| 9150 | #ifdef FEAT_CMDL_INFO |
| 9151 | static int save_ru = 0; |
| 9152 | #endif |
| 9153 | #ifdef FEAT_RIGHTLEFT |
| 9154 | static int save_ri = 0; |
| 9155 | static int save_hkmap = 0; |
| 9156 | #endif |
| 9157 | buf_T *buf; |
| 9158 | |
| 9159 | if (p_paste) |
| 9160 | { |
| 9161 | /* |
| 9162 | * Paste switched from off to on. |
| 9163 | * Save the current values, so they can be restored later. |
| 9164 | */ |
| 9165 | if (!old_p_paste) |
| 9166 | { |
| 9167 | /* save options for each buffer */ |
| 9168 | for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
| 9169 | { |
| 9170 | buf->b_p_tw_nopaste = buf->b_p_tw; |
| 9171 | buf->b_p_wm_nopaste = buf->b_p_wm; |
| 9172 | buf->b_p_sts_nopaste = buf->b_p_sts; |
| 9173 | buf->b_p_ai_nopaste = buf->b_p_ai; |
| 9174 | } |
| 9175 | |
| 9176 | /* save global options */ |
| 9177 | save_sm = p_sm; |
| 9178 | #ifdef FEAT_CMDL_INFO |
| 9179 | save_ru = p_ru; |
| 9180 | #endif |
| 9181 | #ifdef FEAT_RIGHTLEFT |
| 9182 | save_ri = p_ri; |
| 9183 | save_hkmap = p_hkmap; |
| 9184 | #endif |
| 9185 | /* save global values for local buffer options */ |
| 9186 | p_tw_nopaste = p_tw; |
| 9187 | p_wm_nopaste = p_wm; |
| 9188 | p_sts_nopaste = p_sts; |
| 9189 | p_ai_nopaste = p_ai; |
| 9190 | } |
| 9191 | |
| 9192 | /* |
| 9193 | * Always set the option values, also when 'paste' is set when it is |
| 9194 | * already on. |
| 9195 | */ |
| 9196 | /* set options for each buffer */ |
| 9197 | for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
| 9198 | { |
| 9199 | buf->b_p_tw = 0; /* textwidth is 0 */ |
| 9200 | buf->b_p_wm = 0; /* wrapmargin is 0 */ |
| 9201 | buf->b_p_sts = 0; /* softtabstop is 0 */ |
| 9202 | buf->b_p_ai = 0; /* no auto-indent */ |
| 9203 | } |
| 9204 | |
| 9205 | /* set global options */ |
| 9206 | p_sm = 0; /* no showmatch */ |
| 9207 | #ifdef FEAT_CMDL_INFO |
| 9208 | # ifdef FEAT_WINDOWS |
| 9209 | if (p_ru) |
| 9210 | status_redraw_all(); /* redraw to remove the ruler */ |
| 9211 | # endif |
| 9212 | p_ru = 0; /* no ruler */ |
| 9213 | #endif |
| 9214 | #ifdef FEAT_RIGHTLEFT |
| 9215 | p_ri = 0; /* no reverse insert */ |
| 9216 | p_hkmap = 0; /* no Hebrew keyboard */ |
| 9217 | #endif |
| 9218 | /* set global values for local buffer options */ |
| 9219 | p_tw = 0; |
| 9220 | p_wm = 0; |
| 9221 | p_sts = 0; |
| 9222 | p_ai = 0; |
| 9223 | } |
| 9224 | |
| 9225 | /* |
| 9226 | * Paste switched from on to off: Restore saved values. |
| 9227 | */ |
| 9228 | else if (old_p_paste) |
| 9229 | { |
| 9230 | /* restore options for each buffer */ |
| 9231 | for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
| 9232 | { |
| 9233 | buf->b_p_tw = buf->b_p_tw_nopaste; |
| 9234 | buf->b_p_wm = buf->b_p_wm_nopaste; |
| 9235 | buf->b_p_sts = buf->b_p_sts_nopaste; |
| 9236 | buf->b_p_ai = buf->b_p_ai_nopaste; |
| 9237 | } |
| 9238 | |
| 9239 | /* restore global options */ |
| 9240 | p_sm = save_sm; |
| 9241 | #ifdef FEAT_CMDL_INFO |
| 9242 | # ifdef FEAT_WINDOWS |
| 9243 | if (p_ru != save_ru) |
| 9244 | status_redraw_all(); /* redraw to draw the ruler */ |
| 9245 | # endif |
| 9246 | p_ru = save_ru; |
| 9247 | #endif |
| 9248 | #ifdef FEAT_RIGHTLEFT |
| 9249 | p_ri = save_ri; |
| 9250 | p_hkmap = save_hkmap; |
| 9251 | #endif |
| 9252 | /* set global values for local buffer options */ |
| 9253 | p_tw = p_tw_nopaste; |
| 9254 | p_wm = p_wm_nopaste; |
| 9255 | p_sts = p_sts_nopaste; |
| 9256 | p_ai = p_ai_nopaste; |
| 9257 | } |
| 9258 | |
| 9259 | old_p_paste = p_paste; |
| 9260 | } |
| 9261 | |
| 9262 | /* |
| 9263 | * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. |
| 9264 | * |
| 9265 | * Reset 'compatible' and set the values for options that didn't get set yet |
| 9266 | * to the Vim defaults. |
| 9267 | * Don't do this if the 'compatible' option has been set or reset before. |
| 9268 | */ |
| 9269 | void |
| 9270 | vimrc_found() |
| 9271 | { |
| 9272 | int opt_idx; |
| 9273 | |
| 9274 | if (!option_was_set((char_u *)"cp")) |
| 9275 | { |
| 9276 | p_cp = FALSE; |
| 9277 | for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
| 9278 | if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
| 9279 | set_option_default(opt_idx, OPT_FREE, FALSE); |
| 9280 | didset_options(); |
| 9281 | } |
| 9282 | } |
| 9283 | |
| 9284 | /* |
| 9285 | * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. |
| 9286 | */ |
| 9287 | void |
| 9288 | change_compatible(on) |
| 9289 | int on; |
| 9290 | { |
| 9291 | if (p_cp != on) |
| 9292 | { |
| 9293 | p_cp = on; |
| 9294 | compatible_set(); |
| 9295 | } |
| 9296 | options[findoption((char_u *)"cp")].flags |= P_WAS_SET; |
| 9297 | } |
| 9298 | |
| 9299 | /* |
| 9300 | * Return TRUE when option "name" has been set. |
| 9301 | */ |
| 9302 | int |
| 9303 | option_was_set(name) |
| 9304 | char_u *name; |
| 9305 | { |
| 9306 | int idx; |
| 9307 | |
| 9308 | idx = findoption(name); |
| 9309 | if (idx < 0) /* unknown option */ |
| 9310 | return FALSE; |
| 9311 | if (options[idx].flags & P_WAS_SET) |
| 9312 | return TRUE; |
| 9313 | return FALSE; |
| 9314 | } |
| 9315 | |
| 9316 | /* |
| 9317 | * compatible_set() - Called when 'compatible' has been set or unset. |
| 9318 | * |
| 9319 | * When 'compatible' set: Set all relevant options (those that have the P_VIM) |
| 9320 | * flag) to a Vi compatible value. |
| 9321 | * When 'compatible' is unset: Set all options that have a different default |
| 9322 | * for Vim (without the P_VI_DEF flag) to that default. |
| 9323 | */ |
| 9324 | static void |
| 9325 | compatible_set() |
| 9326 | { |
| 9327 | int opt_idx; |
| 9328 | |
| 9329 | for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
| 9330 | if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
| 9331 | || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) |
| 9332 | set_option_default(opt_idx, OPT_FREE, p_cp); |
| 9333 | didset_options(); |
| 9334 | } |
| 9335 | |
| 9336 | #ifdef FEAT_LINEBREAK |
| 9337 | |
| 9338 | # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) |
| 9339 | /* Borland C++ screws up loop optimisation here (negri) */ |
| 9340 | # pragma option -O-l |
| 9341 | # endif |
| 9342 | |
| 9343 | /* |
| 9344 | * fill_breakat_flags() -- called when 'breakat' changes value. |
| 9345 | */ |
| 9346 | static void |
| 9347 | fill_breakat_flags() |
| 9348 | { |
| 9349 | char_u *c; |
| 9350 | int i; |
| 9351 | |
| 9352 | for (i = 0; i < 256; i++) |
| 9353 | breakat_flags[i] = FALSE; |
| 9354 | |
| 9355 | if (p_breakat != NULL) |
| 9356 | for (c = p_breakat; *c; c++) |
| 9357 | breakat_flags[*c] = TRUE; |
| 9358 | } |
| 9359 | |
| 9360 | # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) |
| 9361 | # pragma option -O.l |
| 9362 | # endif |
| 9363 | |
| 9364 | #endif |
| 9365 | |
| 9366 | /* |
| 9367 | * Check an option that can be a range of string values. |
| 9368 | * |
| 9369 | * Return OK for correct value, FAIL otherwise. |
| 9370 | * Empty is always OK. |
| 9371 | */ |
| 9372 | static int |
| 9373 | check_opt_strings(val, values, list) |
| 9374 | char_u *val; |
| 9375 | char **values; |
| 9376 | int list; /* when TRUE: accept a list of values */ |
| 9377 | { |
| 9378 | return opt_strings_flags(val, values, NULL, list); |
| 9379 | } |
| 9380 | |
| 9381 | /* |
| 9382 | * Handle an option that can be a range of string values. |
| 9383 | * Set a flag in "*flagp" for each string present. |
| 9384 | * |
| 9385 | * Return OK for correct value, FAIL otherwise. |
| 9386 | * Empty is always OK. |
| 9387 | */ |
| 9388 | static int |
| 9389 | opt_strings_flags(val, values, flagp, list) |
| 9390 | char_u *val; /* new value */ |
| 9391 | char **values; /* array of valid string values */ |
| 9392 | unsigned *flagp; |
| 9393 | int list; /* when TRUE: accept a list of values */ |
| 9394 | { |
| 9395 | int i; |
| 9396 | int len; |
| 9397 | unsigned new_flags = 0; |
| 9398 | |
| 9399 | while (*val) |
| 9400 | { |
| 9401 | for (i = 0; ; ++i) |
| 9402 | { |
| 9403 | if (values[i] == NULL) /* val not found in values[] */ |
| 9404 | return FAIL; |
| 9405 | |
| 9406 | len = (int)STRLEN(values[i]); |
| 9407 | if (STRNCMP(values[i], val, len) == 0 |
| 9408 | && ((list && val[len] == ',') || val[len] == NUL)) |
| 9409 | { |
| 9410 | val += len + (val[len] == ','); |
| 9411 | new_flags |= (1 << i); |
| 9412 | break; /* check next item in val list */ |
| 9413 | } |
| 9414 | } |
| 9415 | } |
| 9416 | if (flagp != NULL) |
| 9417 | *flagp = new_flags; |
| 9418 | |
| 9419 | return OK; |
| 9420 | } |
| 9421 | |
| 9422 | /* |
| 9423 | * Read the 'wildmode' option, fill wim_flags[]. |
| 9424 | */ |
| 9425 | static int |
| 9426 | check_opt_wim() |
| 9427 | { |
| 9428 | char_u new_wim_flags[4]; |
| 9429 | char_u *p; |
| 9430 | int i; |
| 9431 | int idx = 0; |
| 9432 | |
| 9433 | for (i = 0; i < 4; ++i) |
| 9434 | new_wim_flags[i] = 0; |
| 9435 | |
| 9436 | for (p = p_wim; *p; ++p) |
| 9437 | { |
| 9438 | for (i = 0; ASCII_ISALPHA(p[i]); ++i) |
| 9439 | ; |
| 9440 | if (p[i] != NUL && p[i] != ',' && p[i] != ':') |
| 9441 | return FAIL; |
| 9442 | if (i == 7 && STRNCMP(p, "longest", 7) == 0) |
| 9443 | new_wim_flags[idx] |= WIM_LONGEST; |
| 9444 | else if (i == 4 && STRNCMP(p, "full", 4) == 0) |
| 9445 | new_wim_flags[idx] |= WIM_FULL; |
| 9446 | else if (i == 4 && STRNCMP(p, "list", 4) == 0) |
| 9447 | new_wim_flags[idx] |= WIM_LIST; |
| 9448 | else |
| 9449 | return FAIL; |
| 9450 | p += i; |
| 9451 | if (*p == NUL) |
| 9452 | break; |
| 9453 | if (*p == ',') |
| 9454 | { |
| 9455 | if (idx == 3) |
| 9456 | return FAIL; |
| 9457 | ++idx; |
| 9458 | } |
| 9459 | } |
| 9460 | |
| 9461 | /* fill remaining entries with last flag */ |
| 9462 | while (idx < 3) |
| 9463 | { |
| 9464 | new_wim_flags[idx + 1] = new_wim_flags[idx]; |
| 9465 | ++idx; |
| 9466 | } |
| 9467 | |
| 9468 | /* only when there are no errors, wim_flags[] is changed */ |
| 9469 | for (i = 0; i < 4; ++i) |
| 9470 | wim_flags[i] = new_wim_flags[i]; |
| 9471 | return OK; |
| 9472 | } |
| 9473 | |
| 9474 | /* |
| 9475 | * Check if backspacing over something is allowed. |
| 9476 | */ |
| 9477 | int |
| 9478 | can_bs(what) |
| 9479 | int what; /* BS_INDENT, BS_EOL or BS_START */ |
| 9480 | { |
| 9481 | switch (*p_bs) |
| 9482 | { |
| 9483 | case '2': return TRUE; |
| 9484 | case '1': return (what != BS_START); |
| 9485 | case '0': return FALSE; |
| 9486 | } |
| 9487 | return vim_strchr(p_bs, what) != NULL; |
| 9488 | } |
| 9489 | |
| 9490 | /* |
| 9491 | * Save the current values of 'fileformat' and 'fileencoding', so that we know |
| 9492 | * the file must be considered changed when the value is different. |
| 9493 | */ |
| 9494 | void |
| 9495 | save_file_ff(buf) |
| 9496 | buf_T *buf; |
| 9497 | { |
| 9498 | buf->b_start_ffc = *buf->b_p_ff; |
| 9499 | buf->b_start_eol = buf->b_p_eol; |
| 9500 | #ifdef FEAT_MBYTE |
| 9501 | /* Only use free/alloc when necessary, they take time. */ |
| 9502 | if (buf->b_start_fenc == NULL |
| 9503 | || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) |
| 9504 | { |
| 9505 | vim_free(buf->b_start_fenc); |
| 9506 | buf->b_start_fenc = vim_strsave(buf->b_p_fenc); |
| 9507 | } |
| 9508 | #endif |
| 9509 | } |
| 9510 | |
| 9511 | /* |
| 9512 | * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value |
| 9513 | * from when editing started (save_file_ff() called). |
| 9514 | * Also when 'endofline' was changed and 'binary' is set. |
| 9515 | * Don't consider a new, empty buffer to be changed. |
| 9516 | */ |
| 9517 | int |
| 9518 | file_ff_differs(buf) |
| 9519 | buf_T *buf; |
| 9520 | { |
| 9521 | if ((buf->b_flags & BF_NEW) |
| 9522 | && buf->b_ml.ml_line_count == 1 |
| 9523 | && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) |
| 9524 | return FALSE; |
| 9525 | if (buf->b_start_ffc != *buf->b_p_ff) |
| 9526 | return TRUE; |
| 9527 | if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol) |
| 9528 | return TRUE; |
| 9529 | #ifdef FEAT_MBYTE |
| 9530 | if (buf->b_start_fenc == NULL) |
| 9531 | return (*buf->b_p_fenc != NUL); |
| 9532 | return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); |
| 9533 | #else |
| 9534 | return FALSE; |
| 9535 | #endif |
| 9536 | } |
| 9537 | |
| 9538 | /* |
| 9539 | * return OK if "p" is a valid fileformat name, FAIL otherwise. |
| 9540 | */ |
| 9541 | int |
| 9542 | check_ff_value(p) |
| 9543 | char_u *p; |
| 9544 | { |
| 9545 | return check_opt_strings(p, p_ff_values, FALSE); |
| 9546 | } |